diff --git a/backends/open62541/tests/CMakeLists.txt b/backends/open62541/tests/CMakeLists.txt index 0bdd204..1ad4664 100644 --- a/backends/open62541/tests/CMakeLists.txt +++ b/backends/open62541/tests/CMakeLists.txt @@ -139,6 +139,20 @@ add_test(NAME conversion_Test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND conversion) +add_executable(issue_246 issue_246.c) +target_include_directories(issue_246 PRIVATE ${CHECK_INCLUDE_DIR}) +target_link_libraries(issue_246 PRIVATE NodesetLoader open62541::open62541 ${CHECK_LIBRARIES} ${PTHREAD_LIB}) +add_test(NAME issue_246_Test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND issue_246 ${CMAKE_CURRENT_SOURCE_DIR}/issue_246.xml) + +add_executable(issue_246_2 issue_246_2.c) +target_include_directories(issue_246_2 PRIVATE ${CHECK_INCLUDE_DIR}) +target_link_libraries(issue_246_2 PRIVATE NodesetLoader open62541::open62541 ${CHECK_LIBRARIES} ${PTHREAD_LIB}) +add_test(NAME issue_246_2_Test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND issue_246_2 ${CMAKE_CURRENT_SOURCE_DIR}/issue_246_2.xml) + if(${ENABLE_DATATYPEIMPORT_TEST}) add_subdirectory(dataTypeImport) endif() diff --git a/backends/open62541/tests/issue_246.c b/backends/open62541/tests/issue_246.c new file mode 100644 index 0000000..24b9422 --- /dev/null +++ b/backends/open62541/tests/issue_246.c @@ -0,0 +1,72 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "check.h" +#include +#include +#include +#include + +UA_Server *server; +char *nodesetPath = NULL; + +static void setup(void) +{ + printf("path to testnodesets %s\n", nodesetPath); + server = UA_Server_new(); + UA_ServerConfig *config = UA_Server_getConfig(server); + UA_ServerConfig_setDefault(config); +} + +static void teardown(void) +{ + UA_Server_run_shutdown(server); +#ifdef USE_CLEANUP_CUSTOM_DATATYPES + const UA_DataTypeArray *customTypes = + UA_Server_getConfig(server)->customDataTypes; +#endif + UA_Server_delete(server); +#ifdef USE_CLEANUP_CUSTOM_DATATYPES + NodesetLoader_cleanupCustomDataTypes(customTypes); +#endif +} + +START_TEST(Server_Issue_246) +{ + ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + + UA_Variant var; + UA_Variant_init(&var); + // Check if the last node in the chain exists. It should be. + UA_StatusCode retval = UA_Server_readValue( + server, UA_NODEID_STRING(2, "Test.Var4"), &var); + ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD); + UA_Variant_clear(&var); +} +END_TEST + +static Suite *testSuite_Client(void) +{ + Suite *s = suite_create("server nodeset import"); + TCase *tc_server = tcase_create("server nodeset import"); + tcase_add_unchecked_fixture(tc_server, setup, teardown); + tcase_add_test(tc_server, Server_Issue_246); + suite_add_tcase(s, tc_server); + return s; +} + +int main(int argc, char *argv[]) +{ + printf("%s", argv[0]); + if (!(argc > 1)) + return 1; + nodesetPath = argv[1]; + Suite *s = testSuite_Client(); + SRunner *sr = srunner_create(s); + srunner_set_fork_status(sr, CK_NOFORK); + srunner_run_all(sr, CK_NORMAL); + int number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/backends/open62541/tests/issue_246.xml b/backends/open62541/tests/issue_246.xml new file mode 100644 index 0000000..c130c7a --- /dev/null +++ b/backends/open62541/tests/issue_246.xml @@ -0,0 +1,68 @@ + + + + http://test/object_node/to/variable_node/parent/connection + + + i=3 + i=47 + i=46 + i=40 + i=35 + + + Test.Var1 + + i=63 + i=85 + ns=2;s=Test.Obj1 + + + + Test.Obj1 + + i=61 + ns=2;s=Test.Var2 + ns=2;s=Test.Var1 + + + + Test.Var2 + + i=63 + ns=2;s=Test.Obj1 + ns=2;s=Test.Obj2 + + + + Test.Obj2 + + i=61 + ns=2;s=Test.Var3 + ns=2;s=Test.Var2 + + + + Test.Var3 + + i=63 + ns=2;s=Test.Obj2 + ns=2;s=Test.Obj3 + + + + Test.Obj3 + + i=61 + ns=2;s=Test.Var4 + ns=2;s=Test.Var3 + + + + Test.Var4 + + i=63 + ns=2;s=Test.Obj3 + + + diff --git a/backends/open62541/tests/issue_246_2.c b/backends/open62541/tests/issue_246_2.c new file mode 100644 index 0000000..8fb7752 --- /dev/null +++ b/backends/open62541/tests/issue_246_2.c @@ -0,0 +1,97 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "check.h" +#include +#include +#include +#include + +UA_Server *server; +char *nodesetPath = NULL; + +static void setup(void) +{ + printf("path to testnodesets %s\n", nodesetPath); + server = UA_Server_new(); + UA_ServerConfig *config = UA_Server_getConfig(server); + UA_ServerConfig_setDefault(config); +} + +static void teardown(void) +{ + UA_Server_run_shutdown(server); +#ifdef USE_CLEANUP_CUSTOM_DATATYPES + const UA_DataTypeArray *customTypes = + UA_Server_getConfig(server)->customDataTypes; +#endif + UA_Server_delete(server); +#ifdef USE_CLEANUP_CUSTOM_DATATYPES + NodesetLoader_cleanupCustomDataTypes(customTypes); +#endif +} + +START_TEST(Server_Issue_246) +{ + ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + // Check if [Object Type] nodes exist with a HasHistoricalConfiguration type inverse reference to the Variable nodes. + UA_NodeClass node_class; + UA_NodeClass_init(&node_class); + UA_StatusCode retval = UA_Server_readNodeClass( + server, UA_NODEID_STRING(2, "History1.HistoricalDataConfiguration"), &node_class); + ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD); + ck_assert_uint_eq(node_class, UA_NODECLASS_OBJECT); + UA_NodeClass_clear(&node_class); + + ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + UA_NodeClass_init(&node_class); + retval = UA_Server_readNodeClass( + server, UA_NODEID_STRING(2, "History2.HistoricalDataConfiguration"), &node_class); + ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD); + ck_assert_uint_eq(node_class, UA_NODECLASS_OBJECT); + UA_NodeClass_clear(&node_class); + + ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + UA_NodeClass_init(&node_class); + retval = UA_Server_readNodeClass( + server, UA_NODEID_STRING(2, "History3.HistoricalDataConfiguration"), &node_class); + ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD); + ck_assert_uint_eq(node_class, UA_NODECLASS_OBJECT); + UA_NodeClass_clear(&node_class); + + + ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); + UA_NodeClass_init(&node_class); + retval = UA_Server_readNodeClass( + server, UA_NODEID_STRING(2, "History4.HistoricalDataConfiguration"), &node_class); + ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD); + ck_assert_uint_eq(node_class, UA_NODECLASS_OBJECT); + UA_NodeClass_clear(&node_class); +} +END_TEST + +static Suite *testSuite_Client(void) +{ + Suite *s = suite_create("server nodeset import"); + TCase *tc_server = tcase_create("server nodeset import"); + tcase_add_unchecked_fixture(tc_server, setup, teardown); + tcase_add_test(tc_server, Server_Issue_246); + suite_add_tcase(s, tc_server); + return s; +} + +int main(int argc, char *argv[]) +{ + printf("%s", argv[0]); + if (!(argc > 1)) + return 1; + nodesetPath = argv[1]; + Suite *s = testSuite_Client(); + SRunner *sr = srunner_create(s); + srunner_set_fork_status(sr, CK_NOFORK); + srunner_run_all(sr, CK_NORMAL); + int number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/backends/open62541/tests/issue_246_2.xml b/backends/open62541/tests/issue_246_2.xml new file mode 100644 index 0000000..1d5ee45 --- /dev/null +++ b/backends/open62541/tests/issue_246_2.xml @@ -0,0 +1,307 @@ + + + + http://test/object_node/to/variable_node/parent/connection + + + i=1 + i=3 + i=11 + i=47 + i=56 + i=46 + i=40 + i=35 + + + 002_History + + i=85 + i=61 + ns=2;s=Demo.History.ByteWithHistory + ns=2;s=Demo.History.DataLoggerActive + ns=2;s=Demo.History.DoubleWithHistory + ns=2;s=Demo.History.Historian_1 + ns=2;s=Demo.History.Historian_2 + ns=2;s=Demo.History.Historian_3 + ns=2;s=Demo.History.Historian_4 + + + + ByteWithHistory + + i=63 + ns=2;s=Demo.History + + + + DataLoggerActive + + i=63 + ns=2;s=Demo.History + + + + DoubleWithHistory + + i=63 + ns=2;s=Demo.History + + + + Historian_1 + Holds sample data to test aggregates as described in OPC UA Specification Part 13. + + i=63 + ns=2;s=History1.HistoricalDataConfiguration + ns=2;s=Demo.History + + + + Historian_2 + Holds sample data to test aggregates as described in OPC UA Specification Part 13. + + i=63 + ns=2;s=History2.HistoricalDataConfiguration + ns=2;s=Demo.History + + + + Historian_3 + Holds sample data to test aggregates as described in OPC UA Specification Part 13. + + i=63 + ns=2;s=History3.HistoricalDataConfiguration + ns=2;s=Demo.History + + + + Historian_4 + Holds sample data to test aggregates as described in OPC UA Specification Part 13. + + i=63 + ns=2;s=History4.HistoricalDataConfiguration + ns=2;s=Demo.History + + + + HA Configuration + + i=2318 + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration + ns=2;s=History1.HistoricalDataConfiguration.Stepped + ns=2;s=Demo.History.Historian_1 + + + + HA Configuration + + i=2318 + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration + ns=2;s=History2.HistoricalDataConfiguration.Stepped + ns=2;s=Demo.History.Historian_2 + + + + HA Configuration + + i=2318 + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration + ns=2;s=History3.HistoricalDataConfiguration.Stepped + ns=2;s=Demo.History.Historian_3 + + + + HA Configuration + + i=2318 + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration + ns=2;s=History4.HistoricalDataConfiguration.Stepped + ns=2;s=Demo.History.Historian_4 + + + + AggregateConfiguration + + i=11187 + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration.PercentDataBad + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration.PercentDataGood + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration.TreatUncertainAsBad + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration.UseSlopedExtrapolation + ns=2;s=History1.HistoricalDataConfiguration + + + + Stepped + + i=68 + ns=2;s=History1.HistoricalDataConfiguration + + + + AggregateConfiguration + + i=11187 + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration.PercentDataBad + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration.PercentDataGood + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration.TreatUncertainAsBad + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration.UseSlopedExtrapolation + ns=2;s=History2.HistoricalDataConfiguration + + + + Stepped + + i=68 + ns=2;s=History2.HistoricalDataConfiguration + + + + AggregateConfiguration + + i=11187 + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration.PercentDataBad + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration.PercentDataGood + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration.TreatUncertainAsBad + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration.UseSlopedExtrapolation + ns=2;s=History3.HistoricalDataConfiguration + + + + Stepped + + i=68 + ns=2;s=History3.HistoricalDataConfiguration + + + + AggregateConfiguration + + i=11187 + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration.PercentDataBad + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration.PercentDataGood + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration.TreatUncertainAsBad + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration.UseSlopedExtrapolation + ns=2;s=History4.HistoricalDataConfiguration + + + + Stepped + + i=68 + ns=2;s=History4.HistoricalDataConfiguration + + + + PercentDataBad + + i=68 + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration + + + + PercentDataGood + + i=68 + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration + + + + TreatUncertainAsBad + + i=68 + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration + + + + UseSlopedExtrapolation + + i=68 + ns=2;s=History1.HistoricalDataConfiguration.AggregateConfiguration + + + + PercentDataBad + + i=68 + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration + + + + PercentDataGood + + i=68 + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration + + + + TreatUncertainAsBad + + i=68 + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration + + + + UseSlopedExtrapolation + + i=68 + ns=2;s=History2.HistoricalDataConfiguration.AggregateConfiguration + + + + PercentDataBad + + i=68 + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration + + + + PercentDataGood + + i=68 + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration + + + + TreatUncertainAsBad + + i=68 + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration + + + + UseSlopedExtrapolation + + i=68 + ns=2;s=History3.HistoricalDataConfiguration.AggregateConfiguration + + + + PercentDataBad + + i=68 + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration + + + + PercentDataGood + + i=68 + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration + + + + TreatUncertainAsBad + + i=68 + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration + + + + UseSlopedExtrapolation + + i=68 + ns=2;s=History4.HistoricalDataConfiguration.AggregateConfiguration + + +