check_services_nodemanagement.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include "check.h"
  8. #include "server/ua_services.h"
  9. #include "ua_client.h"
  10. #include "ua_types.h"
  11. #include "ua_config_default.h"
  12. #include "server/ua_server_internal.h"
  13. static UA_Server *server = NULL;
  14. static UA_ServerConfig *config = NULL;
  15. static UA_Int32 handleCalled = 0;
  16. static UA_StatusCode
  17. globalInstantiationMethod(UA_Server *server_,
  18. const UA_NodeId *sessionId, void *sessionContext,
  19. const UA_NodeId *nodeId, void **nodeContext) {
  20. handleCalled++;
  21. return UA_STATUSCODE_GOOD;
  22. }
  23. static void setup(void) {
  24. config = UA_ServerConfig_new_default();
  25. UA_GlobalNodeLifecycle lifecycle;
  26. lifecycle.constructor = globalInstantiationMethod;
  27. lifecycle.destructor = NULL;
  28. config->nodeLifecycle = lifecycle;
  29. server = UA_Server_new(config);
  30. }
  31. static void teardown(void) {
  32. UA_Server_delete(server);
  33. UA_ServerConfig_delete(config);
  34. }
  35. START_TEST(AddVariableNode) {
  36. /* add a variable node to the address space */
  37. UA_VariableAttributes attr = UA_VariableAttributes_default;
  38. UA_Int32 myInteger = 42;
  39. UA_Variant_setScalar(&attr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  40. attr.description = UA_LOCALIZEDTEXT("en-US","the answer");
  41. attr.displayName = UA_LOCALIZEDTEXT("en-US","the answer");
  42. UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  43. UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  44. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  45. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  46. UA_StatusCode res =
  47. UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  48. parentReferenceNodeId, myIntegerName,
  49. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  50. attr, NULL, NULL);
  51. ck_assert_int_eq(UA_STATUSCODE_GOOD, res);
  52. } END_TEST
  53. START_TEST(InstantiateVariableTypeNode) {
  54. UA_VariableTypeAttributes vtAttr = UA_VariableTypeAttributes_default;
  55. vtAttr.dataType = UA_TYPES[UA_TYPES_DOUBLE].typeId;
  56. vtAttr.valueRank = 1; /* array with one dimension */
  57. UA_UInt32 arrayDims[1] = {2};
  58. vtAttr.arrayDimensions = arrayDims;
  59. vtAttr.arrayDimensionsSize = 1;
  60. vtAttr.displayName = UA_LOCALIZEDTEXT("en-US", "2DPoint Type");
  61. /* a matching default value is required */
  62. UA_Double zero[2] = {0.0, 0.0};
  63. UA_Variant_setArray(&vtAttr.value, zero, 2, &UA_TYPES[UA_TYPES_DOUBLE]);
  64. UA_NodeId pointTypeId;
  65. UA_StatusCode res =
  66. UA_Server_addVariableTypeNode(server, UA_NODEID_NULL,
  67. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  68. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  69. UA_QUALIFIEDNAME(1, "2DPoint Type"), UA_NODEID_NULL,
  70. vtAttr, NULL, &pointTypeId);
  71. ck_assert_int_eq(UA_STATUSCODE_GOOD, res);
  72. /* Prepare the node attributes */
  73. UA_VariableAttributes vAttr = UA_VariableAttributes_default;
  74. vAttr.dataType = UA_TYPES[UA_TYPES_DOUBLE].typeId;
  75. vAttr.valueRank = 1; /* array with one dimension */
  76. vAttr.arrayDimensions = arrayDims;
  77. vAttr.arrayDimensionsSize = 1;
  78. vAttr.displayName = UA_LOCALIZEDTEXT("en-US", "2DPoint Variable");
  79. vAttr.accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;
  80. /* vAttr.value is left empty, the server instantiates with the default value */
  81. /* Add the node */
  82. UA_NodeId pointVariableId;
  83. res = UA_Server_addVariableNode(server, UA_NODEID_NULL,
  84. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  85. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  86. UA_QUALIFIEDNAME(1, "2DPoint Type"), pointTypeId,
  87. vAttr, NULL, &pointVariableId);
  88. ck_assert_int_eq(UA_STATUSCODE_GOOD, res);
  89. /* Was the value instantiated? */
  90. UA_Variant val;
  91. UA_Server_readValue(server, pointVariableId, &val);
  92. ck_assert(val.type != NULL);
  93. UA_Variant_deleteMembers(&val);
  94. } END_TEST
  95. START_TEST(AddComplexTypeWithInheritance) {
  96. /* add a variable node to the address space */
  97. UA_ObjectAttributes attr = UA_ObjectAttributes_default;
  98. attr.description = UA_LOCALIZEDTEXT("en-US","fakeServerStruct");
  99. attr.displayName = UA_LOCALIZEDTEXT("en-US","fakeServerStruct");
  100. UA_NodeId myObjectNodeId = UA_NODEID_STRING(1, "the.fake.Server.Struct");
  101. UA_QualifiedName myObjectName = UA_QUALIFIEDNAME(1, "the.fake.Server.Struct");
  102. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  103. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  104. UA_StatusCode res =
  105. UA_Server_addObjectNode(server, myObjectNodeId, parentNodeId,
  106. parentReferenceNodeId, myObjectName,
  107. UA_NODEID_NUMERIC(0, 2004), attr,
  108. &handleCalled, NULL);
  109. ck_assert_int_eq(UA_STATUSCODE_GOOD, res);
  110. ck_assert_int_gt(handleCalled, 0); // Should be 58, but may depend on NS0 XML detail
  111. } END_TEST
  112. START_TEST(AddNodeTwiceGivesError) {
  113. /* add a variable node to the address space */
  114. UA_VariableAttributes attr = UA_VariableAttributes_default;
  115. UA_Int32 myInteger = 42;
  116. UA_Variant_setScalar(&attr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  117. attr.description = UA_LOCALIZEDTEXT("en-US","the answer");
  118. attr.displayName = UA_LOCALIZEDTEXT("en-US","the answer");
  119. UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  120. UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  121. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  122. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  123. UA_StatusCode res =
  124. UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  125. parentReferenceNodeId, myIntegerName,
  126. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  127. attr, NULL, NULL);
  128. ck_assert_int_eq(UA_STATUSCODE_GOOD, res);
  129. res = UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  130. parentReferenceNodeId, myIntegerName,
  131. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  132. attr, NULL, NULL);
  133. ck_assert_int_eq(res, UA_STATUSCODE_BADNODEIDEXISTS);
  134. } END_TEST
  135. static UA_Boolean constructorCalled = false;
  136. static UA_StatusCode
  137. objectConstructor(UA_Server *server_,
  138. const UA_NodeId *sessionId, void *sessionContext,
  139. const UA_NodeId *typeId, void *typeContext,
  140. const UA_NodeId *nodeId, void **nodeContext) {
  141. constructorCalled = true;
  142. return UA_STATUSCODE_GOOD;
  143. }
  144. START_TEST(AddObjectWithConstructor) {
  145. /* Add an object type */
  146. UA_NodeId objecttypeid = UA_NODEID_NUMERIC(0, 13371337);
  147. UA_ObjectTypeAttributes attr = UA_ObjectTypeAttributes_default;
  148. attr.displayName = UA_LOCALIZEDTEXT("en-US","my objecttype");
  149. UA_StatusCode res =
  150. UA_Server_addObjectTypeNode(server, objecttypeid,
  151. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEOBJECTTYPE),
  152. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  153. UA_QUALIFIEDNAME(0, "myobjecttype"), attr,
  154. NULL, NULL);
  155. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  156. /* Add a constructor to the object type */
  157. UA_NodeTypeLifecycle lifecycle;
  158. lifecycle.constructor = objectConstructor;
  159. lifecycle.destructor = NULL;
  160. res = UA_Server_setNodeTypeLifecycle(server, objecttypeid, lifecycle);
  161. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  162. /* Add an object of the type */
  163. UA_ObjectAttributes attr2 = UA_ObjectAttributes_default;
  164. attr2.displayName = UA_LOCALIZEDTEXT("en-US","my object");
  165. res = UA_Server_addObjectNode(server, UA_NODEID_NULL,
  166. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  167. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  168. UA_QUALIFIEDNAME(0, ""), objecttypeid,
  169. attr2, NULL, NULL);
  170. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  171. /* Verify that the constructor was called */
  172. ck_assert_int_eq(constructorCalled, true);
  173. } END_TEST
  174. static UA_Boolean destructorCalled = false;
  175. static void
  176. objectDestructor(UA_Server *server_,
  177. const UA_NodeId *sessionId, void *sessionContext,
  178. const UA_NodeId *typeId, void *typeContext,
  179. const UA_NodeId *nodeId, void **nodeContext) {
  180. destructorCalled = true;
  181. }
  182. START_TEST(DeleteObjectWithDestructor) {
  183. /* Add an object type */
  184. UA_NodeId objecttypeid = UA_NODEID_NUMERIC(0, 13371337);
  185. UA_ObjectTypeAttributes attr = UA_ObjectTypeAttributes_default;
  186. attr.displayName = UA_LOCALIZEDTEXT("en-US","my objecttype");
  187. UA_StatusCode res =
  188. UA_Server_addObjectTypeNode(server, objecttypeid,
  189. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEOBJECTTYPE),
  190. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  191. UA_QUALIFIEDNAME(0, "myobjecttype"), attr, NULL, NULL);
  192. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  193. /* Add a constructor to the object type */
  194. UA_NodeTypeLifecycle lifecycle;
  195. lifecycle.constructor = NULL;
  196. lifecycle.destructor = objectDestructor;
  197. res = UA_Server_setNodeTypeLifecycle(server, objecttypeid, lifecycle);
  198. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  199. /* Add an object of the type */
  200. UA_NodeId objectid = UA_NODEID_NUMERIC(0, 23372337);
  201. UA_ObjectAttributes attr2 = UA_ObjectAttributes_default;
  202. attr2.displayName = UA_LOCALIZEDTEXT("en-US","my object");
  203. res = UA_Server_addObjectNode(server, objectid,
  204. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  205. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  206. UA_QUALIFIEDNAME(0, ""), objecttypeid,
  207. attr2, NULL, NULL);
  208. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  209. /* Delete the object */
  210. UA_Server_deleteNode(server, objectid, true);
  211. /* Verify that the destructor was called */
  212. ck_assert_int_eq(destructorCalled, true);
  213. } END_TEST
  214. START_TEST(DeleteObjectAndReferences) {
  215. /* Add an object of the type */
  216. UA_ObjectAttributes attr = UA_ObjectAttributes_default;
  217. attr.displayName = UA_LOCALIZEDTEXT("en-US","my object");
  218. UA_NodeId objectid = UA_NODEID_NUMERIC(0, 23372337);
  219. UA_StatusCode res;
  220. res = UA_Server_addObjectNode(server, objectid,
  221. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  222. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  223. UA_QUALIFIEDNAME(0, ""),
  224. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEOBJECTTYPE),
  225. attr, NULL, NULL);
  226. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  227. /* Verify that we have a reference to the node from the objects folder */
  228. UA_BrowseDescription bd;
  229. UA_BrowseDescription_init(&bd);
  230. bd.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  231. bd.referenceTypeId = UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT);
  232. bd.browseDirection = UA_BROWSEDIRECTION_FORWARD;
  233. UA_BrowseResult br = UA_Server_browse(server, 0, &bd);
  234. ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
  235. size_t refCount = 0;
  236. for(size_t i = 0; i < br.referencesSize; ++i) {
  237. if(UA_NodeId_equal(&br.references[i].nodeId.nodeId, &objectid))
  238. refCount++;
  239. }
  240. ck_assert_int_eq(refCount, 1);
  241. UA_BrowseResult_deleteMembers(&br);
  242. /* Delete the object */
  243. UA_Server_deleteNode(server, objectid, true);
  244. /* Browse again, this time we expect that no reference is found */
  245. br = UA_Server_browse(server, 0, &bd);
  246. ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
  247. refCount = 0;
  248. for(size_t i = 0; i < br.referencesSize; ++i) {
  249. if(UA_NodeId_equal(&br.references[i].nodeId.nodeId, &objectid))
  250. refCount++;
  251. }
  252. ck_assert_int_eq(refCount, 0);
  253. UA_BrowseResult_deleteMembers(&br);
  254. /* Add an object the second time */
  255. attr = UA_ObjectAttributes_default;
  256. attr.displayName = UA_LOCALIZEDTEXT("en-US","my object");
  257. objectid = UA_NODEID_NUMERIC(0, 23372337);
  258. res = UA_Server_addObjectNode(server, objectid,
  259. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  260. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  261. UA_QUALIFIEDNAME(0, ""),
  262. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEOBJECTTYPE),
  263. attr, NULL, NULL);
  264. ck_assert_int_eq(res, UA_STATUSCODE_GOOD);
  265. /* Browse again, this time we expect that a single reference to the node is found */
  266. refCount = 0;
  267. br = UA_Server_browse(server, 0, &bd);
  268. ck_assert_int_eq(br.statusCode, UA_STATUSCODE_GOOD);
  269. for(size_t i = 0; i < br.referencesSize; ++i) {
  270. if(UA_NodeId_equal(&br.references[i].nodeId.nodeId, &objectid))
  271. refCount++;
  272. }
  273. ck_assert_int_eq(refCount, 1);
  274. UA_BrowseResult_deleteMembers(&br);
  275. } END_TEST
  276. /* Example taken from tutorial_server_object.c */
  277. START_TEST(InstantiateObjectType) {
  278. /* Define the object type */
  279. UA_NodeId pumpTypeId = {1, UA_NODEIDTYPE_NUMERIC, {1001}};
  280. UA_StatusCode retval;
  281. /* Define the object type for "Device" */
  282. UA_NodeId deviceTypeId; /* get the nodeid assigned by the server */
  283. UA_ObjectTypeAttributes dtAttr = UA_ObjectTypeAttributes_default;
  284. dtAttr.displayName = UA_LOCALIZEDTEXT("en-US", "DeviceType");
  285. retval = UA_Server_addObjectTypeNode(server, UA_NODEID_NULL,
  286. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEOBJECTTYPE),
  287. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  288. UA_QUALIFIEDNAME(1, "DeviceType"), dtAttr,
  289. NULL, &deviceTypeId);
  290. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  291. UA_VariableAttributes mnAttr = UA_VariableAttributes_default;
  292. mnAttr.displayName = UA_LOCALIZEDTEXT("en-US", "ManufacturerName");
  293. UA_NodeId manufacturerNameId;
  294. retval = UA_Server_addVariableNode(server, UA_NODEID_NULL, deviceTypeId,
  295. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  296. UA_QUALIFIEDNAME(1, "ManufacturerName"),
  297. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  298. mnAttr, NULL, &manufacturerNameId);
  299. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  300. /* Make the manufacturer name mandatory */
  301. retval = UA_Server_addReference(server, manufacturerNameId,
  302. UA_NODEID_NUMERIC(0, UA_NS0ID_HASMODELLINGRULE),
  303. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_MODELLINGRULE_MANDATORY), true);
  304. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  305. UA_VariableAttributes modelAttr = UA_VariableAttributes_default;
  306. modelAttr.displayName = UA_LOCALIZEDTEXT("en-US", "ModelName");
  307. retval = UA_Server_addVariableNode(server, UA_NODEID_NULL, deviceTypeId,
  308. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  309. UA_QUALIFIEDNAME(1, "ModelName"),
  310. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  311. modelAttr, NULL, NULL);
  312. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  313. /* Define the object type for "Pump" */
  314. UA_ObjectTypeAttributes ptAttr = UA_ObjectTypeAttributes_default;
  315. ptAttr.displayName = UA_LOCALIZEDTEXT("en-US", "PumpType");
  316. retval = UA_Server_addObjectTypeNode(server, pumpTypeId, deviceTypeId,
  317. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  318. UA_QUALIFIEDNAME(1, "PumpType"), ptAttr,
  319. NULL, NULL);
  320. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  321. UA_VariableAttributes statusAttr = UA_VariableAttributes_default;
  322. statusAttr.displayName = UA_LOCALIZEDTEXT("en-US", "Status");
  323. statusAttr.valueRank = -1;
  324. UA_NodeId statusId;
  325. retval = UA_Server_addVariableNode(server, UA_NODEID_NULL, pumpTypeId,
  326. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  327. UA_QUALIFIEDNAME(1, "Status"),
  328. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  329. statusAttr, NULL, &statusId);
  330. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  331. /* Make the status variable mandatory */
  332. retval = UA_Server_addReference(server, statusId,
  333. UA_NODEID_NUMERIC(0, UA_NS0ID_HASMODELLINGRULE),
  334. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_MODELLINGRULE_MANDATORY), true);
  335. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  336. UA_VariableAttributes rpmAttr = UA_VariableAttributes_default;
  337. rpmAttr.displayName = UA_LOCALIZEDTEXT("en-US", "MotorRPM");
  338. rpmAttr.valueRank = -1;
  339. retval = UA_Server_addVariableNode(server, UA_NODEID_NULL, pumpTypeId,
  340. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  341. UA_QUALIFIEDNAME(1, "MotorRPMs"),
  342. UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE),
  343. rpmAttr, NULL, NULL);
  344. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  345. /* Instantiate the variable */
  346. UA_ObjectAttributes oAttr = UA_ObjectAttributes_default;
  347. oAttr.displayName = UA_LOCALIZEDTEXT("en-US", "MyPump");
  348. retval = UA_Server_addObjectNode(server, UA_NODEID_NULL,
  349. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  350. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  351. UA_QUALIFIEDNAME(1, "MyPump"),
  352. pumpTypeId, /* this refers to the object type
  353. identifier */
  354. oAttr, NULL, NULL);
  355. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  356. } END_TEST
  357. int main(void) {
  358. Suite *s = suite_create("services_nodemanagement");
  359. TCase *tc_addnodes = tcase_create("addnodes");
  360. tcase_add_checked_fixture(tc_addnodes, setup, teardown);
  361. tcase_add_test(tc_addnodes, AddVariableNode);
  362. tcase_add_test(tc_addnodes, InstantiateVariableTypeNode);
  363. tcase_add_test(tc_addnodes, AddComplexTypeWithInheritance);
  364. tcase_add_test(tc_addnodes, AddNodeTwiceGivesError);
  365. tcase_add_test(tc_addnodes, AddObjectWithConstructor);
  366. tcase_add_test(tc_addnodes, InstantiateObjectType);
  367. suite_add_tcase(s, tc_addnodes);
  368. TCase *tc_deletenodes = tcase_create("deletenodes");
  369. tcase_add_checked_fixture(tc_deletenodes, setup, teardown);
  370. tcase_add_test(tc_deletenodes, DeleteObjectWithDestructor);
  371. tcase_add_test(tc_deletenodes, DeleteObjectAndReferences);
  372. suite_add_tcase(s, tc_deletenodes);
  373. SRunner *sr = srunner_create(s);
  374. srunner_set_fork_status(sr, CK_NOFORK);
  375. srunner_run_all(sr, CK_NORMAL);
  376. int number_failed = srunner_ntests_failed(sr);
  377. srunner_free(sr);
  378. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  379. }