check_services_nodemanagement.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include "check.h"
  5. #include "server/ua_nodestore.h"
  6. #include "server/ua_services.h"
  7. #include "ua_client.h"
  8. #include "ua_nodeids.h"
  9. #include "ua_statuscodes.h"
  10. #include "ua_types.h"
  11. #include "ua_util.h"
  12. #include "server/ua_server_internal.h"
  13. #ifdef UA_MULTITHREADING
  14. #include <pthread.h>
  15. #include <urcu.h>
  16. #endif
  17. START_TEST(AddVariableNode) {
  18. UA_Server *server = UA_Server_new(UA_ServerConfig_standard);
  19. /* add a variable node to the address space */
  20. UA_VariableAttributes attr;
  21. UA_VariableAttributes_init(&attr);
  22. UA_Int32 myInteger = 42;
  23. UA_Variant_setScalar(&attr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  24. attr.description = UA_LOCALIZEDTEXT("en_US","the answer");
  25. attr.displayName = UA_LOCALIZEDTEXT("en_US","the answer");
  26. UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  27. UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  28. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  29. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  30. UA_AddNodesResult res = UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  31. parentReferenceNodeId, myIntegerName,
  32. UA_NODEID_NULL, attr);
  33. ck_assert_int_eq(UA_STATUSCODE_GOOD, res.statusCode);
  34. UA_AddNodesResult_deleteMembers(&res);
  35. UA_Server_delete(server);
  36. } END_TEST
  37. static Suite * testSuite_services_nodemanagement(void) {
  38. Suite *s = suite_create("services_nodemanagement");
  39. TCase *tc_addnodes = tcase_create("addnodes");
  40. tcase_add_test(tc_addnodes, AddVariableNode);
  41. suite_add_tcase(s, tc_addnodes);
  42. return s;
  43. }
  44. int main(void) {
  45. int number_failed = 0;
  46. Suite *s;
  47. s = testSuite_services_nodemanagement();
  48. SRunner *sr = srunner_create(s);
  49. // srunner_set_fork_status(sr, CK_NOFORK);
  50. srunner_run_all(sr, CK_NORMAL);
  51. number_failed += srunner_ntests_failed(sr);
  52. srunner_free(sr);
  53. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  54. }