diff --git a/backends/open62541/tests/dataTypeImport/CMakeLists.txt b/backends/open62541/tests/dataTypeImport/CMakeLists.txt index d699d06f..15770822 100644 --- a/backends/open62541/tests/dataTypeImport/CMakeLists.txt +++ b/backends/open62541/tests/dataTypeImport/CMakeLists.txt @@ -99,7 +99,7 @@ add_test(NAME compareOptionalStruct_Test COMMAND compareOptionalStruct "${CMAKE_CURRENT_SOURCE_DIR}/optionalstruct.xml") ua_generate_nodeset_and_datatypes( - NAME "union2" + NAME "union" FILE_CSV "${CMAKE_CURRENT_SOURCE_DIR}/union.csv" FILE_BSD "${CMAKE_CURRENT_SOURCE_DIR}/union.bsd" NAMESPACE_MAP "2:http://yourorganisation.org/union/" @@ -107,6 +107,16 @@ ua_generate_nodeset_and_datatypes( INTERNAL ) +add_executable(compareUnion compareUnion.c ${UA_TYPES_UNION_SOURCES}) +add_dependencies(compareUnion open62541-generator-ns-union) +target_link_libraries(compareUnion PRIVATE NodesetLoader open62541::open62541 ${CHECK_LIBRARIES} ${PTHREAD_LIB}) +target_include_directories(compareUnion PRIVATE ${CMAKE_BINARY_DIR}/src_generated) +target_include_directories(compareUnion PRIVATE ${CHECK_INCLUDE_DIR}) + +add_test(NAME compareUnion_Test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND compareUnion "${CMAKE_CURRENT_SOURCE_DIR}/union.xml") + ua_generate_nodeset_and_datatypes( NAME "abstractdatatypemember" FILE_CSV "${CMAKE_CURRENT_SOURCE_DIR}/abstractdatatypemember.csv" @@ -126,18 +136,10 @@ add_test(NAME compareAbstractDataTypeMember_Test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND compareAbstractDataTypeMember "${CMAKE_CURRENT_SOURCE_DIR}/abstractdatatypemember.xml") -add_executable(compareUnion union2.c ${UA_TYPES_UNION2_SOURCES}) -add_dependencies(compareUnion open62541-generator-ns-union2) -target_link_libraries(compareUnion PRIVATE NodesetLoader open62541::open62541 ${CHECK_LIBRARIES} ${PTHREAD_LIB}) -target_include_directories(compareUnion PRIVATE ${CMAKE_BINARY_DIR}/src_generated) -target_include_directories(compareUnion PRIVATE ${CHECK_INCLUDE_DIR}) -add_test(NAME compareUnion_Test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND compareUnion "${CMAKE_CURRENT_SOURCE_DIR}/union.xml") ua_generate_nodeset_and_datatypes( - NAME "optionset2" + NAME "optionsetgen" FILE_CSV "${CMAKE_CURRENT_SOURCE_DIR}/optionset.csv" FILE_BSD "${CMAKE_CURRENT_SOURCE_DIR}/optionset.bsd" NAMESPACE_MAP "2:http://yourorganisation.org/optionSet/" @@ -145,8 +147,8 @@ ua_generate_nodeset_and_datatypes( INTERNAL ) -add_executable(compareOptionset optionset.c ${UA_TYPES_OPTIONSET2_SOURCES}) -add_dependencies(compareOptionset open62541-generator-ns-optionset2) +add_executable(compareOptionset compareOptionset.c ${UA_TYPES_OPTIONSETGEN_SOURCES}) +add_dependencies(compareOptionset open62541-generator-ns-optionsetgen) target_link_libraries(compareOptionset PRIVATE NodesetLoader open62541::open62541 ${CHECK_LIBRARIES} ${PTHREAD_LIB}) target_include_directories(compareOptionset PRIVATE ${CMAKE_BINARY_DIR}/src_generated) target_include_directories(compareOptionset PRIVATE ${CHECK_INCLUDE_DIR}) diff --git a/backends/open62541/tests/dataTypeImport/compareAbstractDataTypeMember.c b/backends/open62541/tests/dataTypeImport/compareAbstractDataTypeMember.c index 7df89b55..8ab9b701 100644 --- a/backends/open62541/tests/dataTypeImport/compareAbstractDataTypeMember.c +++ b/backends/open62541/tests/dataTypeImport/compareAbstractDataTypeMember.c @@ -38,22 +38,28 @@ static void teardown(void) #endif } -START_TEST(compareDI) +START_TEST(compareAbstractDataTypeMember) { ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); - UA_ServerConfig* config = UA_Server_getConfig(server); + setNamespaceIndexOfGeneratedStruct( + server, "http://yourorganisation.org/AbstractDataTypeMember/", + UA_TYPES_ABSTRACTDATATYPEMEMBER, UA_TYPES_ABSTRACTDATATYPEMEMBER_COUNT); + + UA_ServerConfig *config = UA_Server_getConfig(server); ck_assert(config->customDataTypes); - ck_assert(config->customDataTypes->typesSize == UA_TYPES_ABSTRACTDATATYPEMEMBER_COUNT); + ck_assert(config->customDataTypes->typesSize == + UA_TYPES_ABSTRACTDATATYPEMEMBER_COUNT); for (const UA_DataType *generatedType = UA_TYPES_ABSTRACTDATATYPEMEMBER; generatedType != UA_TYPES_ABSTRACTDATATYPEMEMBER + UA_TYPES_ABSTRACTDATATYPEMEMBER_COUNT; generatedType++) { - const UA_DataType* importedType = NodesetLoader_getCustomDataType(server, &generatedType->typeId); - ck_assert(importedType!=NULL); + const UA_DataType *importedType = + NodesetLoader_getCustomDataType(server, &generatedType->typeId); + ck_assert(importedType != NULL); typesAreMatching(generatedType, importedType, &UA_TYPES_ABSTRACTDATATYPEMEMBER[0], config->customDataTypes->types); @@ -61,13 +67,12 @@ START_TEST(compareDI) } END_TEST - static Suite *testSuite_Client(void) { Suite *s = suite_create("datatype Import"); TCase *tc_server = tcase_create("server nodeset import"); tcase_add_unchecked_fixture(tc_server, setup, teardown); - tcase_add_test(tc_server, compareDI); + tcase_add_test(tc_server, compareAbstractDataTypeMember); suite_add_tcase(s, tc_server); return s; } diff --git a/backends/open62541/tests/dataTypeImport/optionset.c b/backends/open62541/tests/dataTypeImport/compareOptionset.c similarity index 83% rename from backends/open62541/tests/dataTypeImport/optionset.c rename to backends/open62541/tests/dataTypeImport/compareOptionset.c index 98a793be..b764671a 100644 --- a/backends/open62541/tests/dataTypeImport/optionset.c +++ b/backends/open62541/tests/dataTypeImport/compareOptionset.c @@ -9,7 +9,7 @@ #include "check.h" #include "../testHelper.h" -#include "open62541/types_optionset2_generated.h" +#include "open62541/types_optionsetgen_generated.h" #include #include @@ -38,24 +38,28 @@ static void teardown(void) #endif } -START_TEST(compareUnion) +START_TEST(compareOptionSet) { ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + setNamespaceIndexOfGeneratedStruct( + server, "http://yourorganisation.org/optionSet/", + UA_TYPES_OPTIONSETGEN, UA_TYPES_OPTIONSETGEN_COUNT); + UA_ServerConfig *config = UA_Server_getConfig(server); ck_assert(config->customDataTypes); - ck_assert(config->customDataTypes->typesSize == UA_TYPES_OPTIONSET2_COUNT); + ck_assert(config->customDataTypes->typesSize == UA_TYPES_OPTIONSETGEN_COUNT); - for (const UA_DataType *generatedType = UA_TYPES_OPTIONSET2; + for (const UA_DataType *generatedType = UA_TYPES_OPTIONSETGEN; generatedType != - UA_TYPES_OPTIONSET2 + UA_TYPES_OPTIONSET2_COUNT; + UA_TYPES_OPTIONSETGEN + UA_TYPES_OPTIONSETGEN_COUNT; generatedType++) { const UA_DataType *importedType = NodesetLoader_getCustomDataType(server, &generatedType->typeId); ck_assert(importedType != NULL); - typesAreMatching(generatedType, importedType, &UA_TYPES_OPTIONSET2[0], + typesAreMatching(generatedType, importedType, &UA_TYPES_OPTIONSETGEN[0], config->customDataTypes->types); } } @@ -66,7 +70,7 @@ static Suite *testSuite_Client(void) Suite *s = suite_create("datatype Import"); TCase *tc_server = tcase_create("server nodeset import"); tcase_add_unchecked_fixture(tc_server, setup, teardown); - tcase_add_test(tc_server, compareUnion); + tcase_add_test(tc_server, compareOptionSet); suite_add_tcase(s, tc_server); return s; } diff --git a/backends/open62541/tests/dataTypeImport/compareStructExtended.c b/backends/open62541/tests/dataTypeImport/compareStructExtended.c index 39e5c637..b81a892d 100644 --- a/backends/open62541/tests/dataTypeImport/compareStructExtended.c +++ b/backends/open62541/tests/dataTypeImport/compareStructExtended.c @@ -42,6 +42,10 @@ START_TEST(compareDI) { ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + setNamespaceIndexOfGeneratedStruct(server, + "http://yourorganisation.org/struct/", + UA_TYPES_STRUCTEXTENDED, UA_TYPES_STRUCTEXTENDED_COUNT); + UA_ServerConfig* config = UA_Server_getConfig(server); ck_assert(config->customDataTypes); diff --git a/backends/open62541/tests/dataTypeImport/compareStructSpecialized.c b/backends/open62541/tests/dataTypeImport/compareStructSpecialized.c index ea80988b..c3da3f62 100644 --- a/backends/open62541/tests/dataTypeImport/compareStructSpecialized.c +++ b/backends/open62541/tests/dataTypeImport/compareStructSpecialized.c @@ -16,7 +16,7 @@ UA_Server *server; char *nodeset1 = NULL; -char * nodeset2 = NULL; +char *nodeset2 = NULL; static void setup(void) { @@ -46,6 +46,14 @@ START_TEST(compareSpecializedStruct) ck_assert(NodesetLoader_loadFile(server, nodeset1, NULL)); ck_assert(NodesetLoader_loadFile(server, nodeset2, NULL)); + setNamespaceIndexOfGeneratedStruct(server, + "http://yourorganisation.org/struct/", + UA_TYPES_STRUCT, UA_TYPES_STRUCT_COUNT); + + setNamespaceIndexOfGeneratedStruct( + server, "http://yourorganisation.org/specializedStruct/", + UA_TYPES_SPECIALIZEDSTRUCT, UA_TYPES_SPECIALIZEDSTRUCT_COUNT); + UA_ServerConfig *config = UA_Server_getConfig(server); ck_assert(config->customDataTypes); diff --git a/backends/open62541/tests/dataTypeImport/compareStructTypes.c b/backends/open62541/tests/dataTypeImport/compareStructTypes.c index 6ef34d1c..f5e05e9a 100644 --- a/backends/open62541/tests/dataTypeImport/compareStructTypes.c +++ b/backends/open62541/tests/dataTypeImport/compareStructTypes.c @@ -42,21 +42,28 @@ START_TEST(compareDI) { ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); - UA_ServerConfig* config = UA_Server_getConfig(server); + setNamespaceIndexOfGeneratedStruct(server, + "http://yourorganisation.org/struct/", + UA_TYPES_STRUCT, UA_TYPES_STRUCT_COUNT); + + UA_ServerConfig *config = UA_Server_getConfig(server); ck_assert(config->customDataTypes); ck_assert(config->customDataTypes->typesSize == UA_TYPES_STRUCT_COUNT); - for(const UA_DataType* generatedType = UA_TYPES_STRUCT; generatedType!= UA_TYPES_STRUCT + UA_TYPES_STRUCT_COUNT; generatedType++) + for (const UA_DataType *generatedType = UA_TYPES_STRUCT; + generatedType != UA_TYPES_STRUCT + UA_TYPES_STRUCT_COUNT; + generatedType++) { - const UA_DataType* importedType = NodesetLoader_getCustomDataType(server, &generatedType->typeId); - ck_assert(importedType!=NULL); - typesAreMatching(generatedType, importedType, &UA_TYPES_STRUCT[0], config->customDataTypes->types); + const UA_DataType *importedType = + NodesetLoader_getCustomDataType(server, &generatedType->typeId); + ck_assert(importedType != NULL); + typesAreMatching(generatedType, importedType, &UA_TYPES_STRUCT[0], + config->customDataTypes->types); } } END_TEST - static Suite *testSuite_Client(void) { Suite *s = suite_create("datatype Import"); diff --git a/backends/open62541/tests/dataTypeImport/union2.c b/backends/open62541/tests/dataTypeImport/compareUnion.c similarity index 87% rename from backends/open62541/tests/dataTypeImport/union2.c rename to backends/open62541/tests/dataTypeImport/compareUnion.c index f165bf7c..9ce6a649 100644 --- a/backends/open62541/tests/dataTypeImport/union2.c +++ b/backends/open62541/tests/dataTypeImport/compareUnion.c @@ -9,7 +9,7 @@ #include "check.h" #include "../testHelper.h" -#include "open62541/types_union2_generated.h" +#include "open62541/types_union_generated.h" #include #include @@ -41,19 +41,23 @@ START_TEST(compareUnion) { ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + setNamespaceIndexOfGeneratedStruct( + server, "http://yourorganisation.org/union/", + UA_TYPES_UNION, UA_TYPES_UNION_COUNT); + UA_ServerConfig *config = UA_Server_getConfig(server); ck_assert(config->customDataTypes); - ck_assert(config->customDataTypes->typesSize == UA_TYPES_UNION2_COUNT); + ck_assert(config->customDataTypes->typesSize == UA_TYPES_UNION_COUNT); - for (const UA_DataType *generatedType = UA_TYPES_UNION2; - generatedType != UA_TYPES_UNION2 + UA_TYPES_UNION2_COUNT; + for (const UA_DataType *generatedType = UA_TYPES_UNION; + generatedType != UA_TYPES_UNION + UA_TYPES_UNION_COUNT; generatedType++) { const UA_DataType *importedType = NodesetLoader_getCustomDataType(server, &generatedType->typeId); ck_assert(importedType != NULL); - typesAreMatching(generatedType, importedType, &UA_TYPES_UNION2[0], + typesAreMatching(generatedType, importedType, &UA_TYPES_UNION[0], config->customDataTypes->types); } } diff --git a/backends/open62541/tests/dataTypeImport/optionalStruct.c b/backends/open62541/tests/dataTypeImport/optionalStruct.c index f0d015d4..9b0acbc6 100644 --- a/backends/open62541/tests/dataTypeImport/optionalStruct.c +++ b/backends/open62541/tests/dataTypeImport/optionalStruct.c @@ -42,18 +42,26 @@ START_TEST(compareDI) { ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + setNamespaceIndexOfGeneratedStruct( + server, "http://yourorganisation.org/optionalStruct/", + UA_TYPES_OPTIONALSTRUCT, UA_TYPES_OPTIONALSTRUCT_COUNT); + UA_ServerConfig *config = UA_Server_getConfig(server); ck_assert(config->customDataTypes); - ck_assert(config->customDataTypes->typesSize == UA_TYPES_OPTIONALSTRUCT_COUNT); + ck_assert(config->customDataTypes->typesSize == + UA_TYPES_OPTIONALSTRUCT_COUNT); for (const UA_DataType *generatedType = UA_TYPES_OPTIONALSTRUCT; - generatedType != UA_TYPES_OPTIONALSTRUCT + UA_TYPES_OPTIONALSTRUCT_COUNT; generatedType++) + generatedType != + UA_TYPES_OPTIONALSTRUCT + UA_TYPES_OPTIONALSTRUCT_COUNT; + generatedType++) { const UA_DataType *importedType = NodesetLoader_getCustomDataType(server, &generatedType->typeId); ck_assert(importedType != NULL); - typesAreMatching(generatedType, importedType, &UA_TYPES_OPTIONALSTRUCT[0], + typesAreMatching(generatedType, importedType, + &UA_TYPES_OPTIONALSTRUCT[0], config->customDataTypes->types); } } diff --git a/backends/open62541/tests/testHelper.h b/backends/open62541/tests/testHelper.h index 3a95d2eb..1c66c568 100644 --- a/backends/open62541/tests/testHelper.h +++ b/backends/open62541/tests/testHelper.h @@ -92,4 +92,18 @@ UA_NodeId getTypeDefinitionId(UA_Server *s, const UA_NodeId targetId) UA_BrowseResult_clear(&br); return id; } + +static void setNamespaceIndexOfGeneratedStruct(UA_Server *server, + const char *namespaceUri, + UA_DataType *types, + size_t typesSize) +{ + UA_UInt16 nsIdx = UA_Server_addNamespace(server, namespaceUri); + + for (UA_DataType *type = types; type != types + typesSize; type++) + { + type->typeId.namespaceIndex = nsIdx; + type->binaryEncodingId.namespaceIndex = nsIdx; + } +} #endif