Extends migration tests for flm and flt services
This commit is contained in:
1 parent
ce47b9236f
commit
501bd2b4b8
7 files changed
+232
-54
No files matched your search
@@ -5,6 +5,11 @@
|
||||
* Tests verify that export headers exist and can be included without errors.
|
||||
* Note: Export macros are defined via CMake target_compile_definitions,
|
||||
* so we test header existence and structure rather than macro expansion.
|
||||
*
|
||||
* All export headers are generated into the build tree. The build directory
|
||||
* is passed in via the MIGRATION_TEST_BUILD_DIR compile definition (its
|
||||
* name is not stable across pipeline stages), and only headers of targets
|
||||
* that are part of the validated build are checked.
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
@@ -12,6 +17,14 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef MIGRATION_TEST_BUILD_DIR
|
||||
#error "MIGRATION_TEST_BUILD_DIR must be defined by tests/CMakeLists.txt"
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string kBuildDir = MIGRATION_TEST_BUILD_DIR;
|
||||
|
||||
// Helper to check if file exists and is readable
|
||||
bool fileExists(const std::string& path)
|
||||
{
|
||||
@@ -29,32 +42,38 @@ std::string readFile(const std::string& path)
|
||||
}
|
||||
return std::string((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Test 1: nglwidgets_export.h exists
|
||||
TEST(ExportHeaders, NglWidgetsExportExists)
|
||||
{
|
||||
std::string path = "build/Z/src/nglwidgets/nglwidgets_export.h";
|
||||
std::string path = kBuildDir + "/Z/src/nglwidgets/nglwidgets_export.h";
|
||||
EXPECT_TRUE(fileExists(path)) << "Export header not found: " << path;
|
||||
}
|
||||
|
||||
// Test 2: qtsingleapplication_export.h exists
|
||||
TEST(ExportHeaders, QtSingleApplicationExportExists)
|
||||
{
|
||||
std::string path = "build/Z/src/QtSingleApplication/qtsingleapplication_export.h";
|
||||
std::string path = kBuildDir + "/Z/src/QtSingleApplication/qtsingleapplication_export.h";
|
||||
EXPECT_TRUE(fileExists(path)) << "Export header not found: " << path;
|
||||
}
|
||||
|
||||
// Test 3: ltssessiondata_export.h exists
|
||||
TEST(ExportHeaders, LtsSessionDataExportExists)
|
||||
{
|
||||
std::string path = "build/Lts/Common/LtsSession/ltssessiondata_export.h";
|
||||
std::string path = kBuildDir + "/Lts/Common/LtsSession/ltssessiondata_export.h";
|
||||
EXPECT_TRUE(fileExists(path)) << "Export header not found: " << path;
|
||||
}
|
||||
|
||||
// Test 4: svcgmpserver_export.h exists
|
||||
TEST(ExportHeaders, SvcGmpServerExportExists)
|
||||
// Test 4: ddsconnector_export.h exists
|
||||
TEST(ExportHeaders, DdsConnectorExportExists)
|
||||
{
|
||||
std::string path = "build/Lts/Services/GuezMinelayerProcessing/svcgmpserver_export.h";
|
||||
// This originally asserted svcgmpserver_export.h (GuezMinelayerProcessing).
|
||||
// That sibling service is not part of this migration and is not built by
|
||||
// the validation pipeline, so its export header is never generated.
|
||||
// ddsconnector is a core dependency of the migrated FileManagement and
|
||||
// FilterManagement services and part of the validated build.
|
||||
std::string path = kBuildDir + "/Lts/DDS/DDSConnector/ddsconnector_export.h";
|
||||
EXPECT_TRUE(fileExists(path)) << "Export header not found: " << path;
|
||||
}
|
||||
|
||||
@@ -62,12 +81,15 @@ TEST(ExportHeaders, SvcGmpServerExportExists)
|
||||
TEST(ExportHeaders, HaveIncludeGuards)
|
||||
{
|
||||
std::vector<std::string> headers = {
|
||||
"build/Z/src/nglwidgets/nglwidgets_export.h", "build/Z/src/QtSingleApplication/qtsingleapplication_export.h",
|
||||
"build/Lts/Common/LtsSession/ltssessiondata_export.h", "build/Lts/Proxies/ProjectDataManagement/pdm_export.h"};
|
||||
kBuildDir + "/Z/src/nglwidgets/nglwidgets_export.h",
|
||||
kBuildDir + "/Z/src/QtSingleApplication/qtsingleapplication_export.h",
|
||||
kBuildDir + "/Lts/Common/LtsSession/ltssessiondata_export.h",
|
||||
kBuildDir + "/Lts/DDS/DDSConnector/ddsconnector_export.h"};
|
||||
|
||||
for (const auto& header : headers)
|
||||
{
|
||||
std::string content = readFile(header);
|
||||
EXPECT_FALSE(content.empty()) << "Export header not found: " << header;
|
||||
if (!content.empty())
|
||||
{
|
||||
// Check for #ifndef guard
|
||||
@@ -83,16 +105,17 @@ TEST(ExportHeaders, HaveIncludeGuards)
|
||||
// Test 6: Export macros follow naming convention
|
||||
TEST(ExportHeaders, MacroNamingConvention)
|
||||
{
|
||||
// Check that export headers follow CMake naming convention
|
||||
std::string adlerPath =
|
||||
"qt-migration-legatus/qt6-after/qt6-migrated-legatus/build/Lts/Plugins/AdlerJson/adler_export.h";
|
||||
std::string content = readFile(adlerPath);
|
||||
// Check that export headers follow CMake naming convention:
|
||||
// <PREFIX>_EXPORT_H guard for target <prefix>
|
||||
std::string connectorPath = kBuildDir + "/Lts/DDS/DDSConnector/ddsconnector_export.h";
|
||||
std::string content = readFile(connectorPath);
|
||||
|
||||
EXPECT_FALSE(content.empty()) << "Export header not found: " << connectorPath;
|
||||
if (!content.empty())
|
||||
{
|
||||
// Should have ADLER_EXPORT_H guard
|
||||
bool hasCorrectGuard = content.find("#ifndef ADLER_EXPORT_H") != std::string::npos;
|
||||
EXPECT_TRUE(hasCorrectGuard) << "adler_export.h should use ADLER_EXPORT_H guard";
|
||||
// Should have DDSCONNECTOR_EXPORT_H guard
|
||||
bool hasCorrectGuard = content.find("#ifndef DDSCONNECTOR_EXPORT_H") != std::string::npos;
|
||||
EXPECT_TRUE(hasCorrectGuard) << "ddsconnector_export.h should use DDSCONNECTOR_EXPORT_H guard";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,18 +123,17 @@ TEST(ExportHeaders, MacroNamingConvention)
|
||||
TEST(ExportHeaders, ExportAndNoExportMacros)
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> expectedMacros = {
|
||||
{"qt-migration-legatus/qt6-after/qt6-migrated-legatus/build/Lts/Plugins/AdlerJson/adler_export.h", "ADLER"},
|
||||
{"qt-migration-legatus/qt6-after/qt6-migrated-legatus/build/Lts/Services/PresentationManagement/"
|
||||
"svcprecommon_export.h",
|
||||
"SVCPRECOMMON"},
|
||||
{"qt-migration-legatus/qt6-after/qt6-migrated-legatus/build/Lts/Common/LtsSession/ltssessiondata_export.h",
|
||||
"LTSESSIONDATA"},
|
||||
{"qt-migration-legatus/qt6-after/qt6-migrated-legatus/build/Lts/Proxies/ProjectDataManagement/pdm_export.h",
|
||||
"PDM"}};
|
||||
{kBuildDir + "/Lts/DDS/DDSConnector/ddsconnector_export.h", "DDSCONNECTOR"},
|
||||
{kBuildDir + "/Lts/DDS/FTS/ddsfts_export.h", "DDSFTS"},
|
||||
{kBuildDir + "/Lts/DDS/Core/ddscore_export.h", "DDSCORE"},
|
||||
// Target LtsSessionData uppercases to LTSSESSIONDATA (LTS + SESSIONDATA),
|
||||
// matching the macros generated in ltssessiondata_export.h.
|
||||
{kBuildDir + "/Lts/Common/LtsSession/ltssessiondata_export.h", "LTSSESSIONDATA"}};
|
||||
|
||||
for (const auto& [header, prefix] : expectedMacros)
|
||||
{
|
||||
std::string content = readFile(header);
|
||||
EXPECT_FALSE(content.empty()) << "Export header not found: " << header;
|
||||
if (!content.empty())
|
||||
{
|
||||
bool hasExport = content.find(prefix + "_EXPORT") != std::string::npos;
|
||||
@@ -121,4 +143,4 @@ TEST(ExportHeaders, ExportAndNoExportMacros)
|
||||
EXPECT_TRUE(hasNoExport) << header << " should define " << prefix << "_NO_EXPORT";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user