Skip to content

Commit

Permalink
Merge branch 'master' into issue_241_statuscode
Browse files Browse the repository at this point in the history
  • Loading branch information
matkonnerth committed Nov 25, 2023
2 parents 74daf75 + 83065fa commit 5e839aa
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/GccDebugMemcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@master
with:
repository: open62541/open62541
ref: refs/tags/v1.3.4
ref: 1.4
submodules: recursive
path: ./openRoot

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/GccIntegrationTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- uses: actions/checkout@master
with:
repository: open62541/open62541
ref: refs/tags/v1.3.4
ref: 1.4
submodules: recursive
path: ./openRoot

Expand Down
26 changes: 14 additions & 12 deletions backends/open62541/tests/dataTypeImport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,24 @@ 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/"
FILE_NS "${CMAKE_CURRENT_SOURCE_DIR}/union.xml"
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"
Expand All @@ -126,27 +136,19 @@ 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/"
FILE_NS "${CMAKE_CURRENT_SOURCE_DIR}/optionset.xml"
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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,41 @@ 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);
}
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "check.h"

#include "../testHelper.h"
#include "open62541/types_optionset2_generated.h"
#include "open62541/types_optionsetgen_generated.h"
#include <NodesetLoader/backendOpen62541.h>
#include <NodesetLoader/dataTypes.h>

Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

UA_Server *server;
char *nodeset1 = NULL;
char * nodeset2 = NULL;
char *nodeset2 = NULL;

static void setup(void)
{
Expand Down Expand Up @@ -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);

Expand Down
19 changes: 13 additions & 6 deletions backends/open62541/tests/dataTypeImport/compareStructTypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "check.h"

#include "../testHelper.h"
#include "open62541/types_union2_generated.h"
#include "open62541/types_union_generated.h"
#include <NodesetLoader/backendOpen62541.h>
#include <NodesetLoader/dataTypes.h>

Expand Down Expand Up @@ -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);
}
}
Expand Down
14 changes: 11 additions & 3 deletions backends/open62541/tests/dataTypeImport/optionalStruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
14 changes: 14 additions & 0 deletions backends/open62541/tests/testHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5e839aa

Please sign in to comment.