check_services_nodemanagement.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_StatusCode res = UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId, parentReferenceNodeId,
  31. myIntegerName, UA_NODEID_NULL, attr, NULL);
  32. ck_assert_int_eq(UA_STATUSCODE_GOOD, res);
  33. UA_Server_delete(server);
  34. } END_TEST
  35. static Suite * testSuite_services_nodemanagement(void) {
  36. Suite *s = suite_create("services_nodemanagement");
  37. TCase *tc_addnodes = tcase_create("addnodes");
  38. tcase_add_test(tc_addnodes, AddVariableNode);
  39. suite_add_tcase(s, tc_addnodes);
  40. return s;
  41. }
  42. int main(void) {
  43. int number_failed = 0;
  44. Suite *s;
  45. s = testSuite_services_nodemanagement();
  46. SRunner *sr = srunner_create(s);
  47. // srunner_set_fork_status(sr, CK_NOFORK);
  48. srunner_run_all(sr, CK_NORMAL);
  49. number_failed += srunner_ntests_failed(sr);
  50. srunner_free(sr);
  51. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  52. }