check_services_attributes.c 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  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_types.h"
  10. #include "ua_config_standard.h"
  11. #include "server/ua_server_internal.h"
  12. #ifdef UA_ENABLE_MULTITHREADING
  13. #include <pthread.h>
  14. #include <urcu.h>
  15. #endif
  16. /* copied definition */
  17. UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range);
  18. static UA_StatusCode
  19. readCPUTemperature_broken(void *handle, const UA_NodeId nodeid, UA_Boolean sourceTimeStamp,
  20. const UA_NumericRange *range, UA_DataValue *dataValue) {
  21. dataValue->hasValue = true;
  22. return UA_STATUSCODE_GOOD;
  23. }
  24. static UA_Server* makeTestSequence(void) {
  25. UA_Server *server = UA_Server_new(UA_ServerConfig_standard);
  26. /* VariableNode */
  27. UA_VariableAttributes vattr;
  28. UA_VariableAttributes_init(&vattr);
  29. UA_Int32 myInteger = 42;
  30. UA_Variant_setScalar(&vattr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  31. vattr.description = UA_LOCALIZEDTEXT("locale","the answer");
  32. vattr.displayName = UA_LOCALIZEDTEXT("locale","the answer");
  33. vattr.valueRank = -2;
  34. UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  35. UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  36. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  37. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  38. UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  39. parentReferenceNodeId, myIntegerName,
  40. UA_NODEID_NULL, vattr, NULL, NULL);
  41. /* DataSource VariableNode */
  42. UA_VariableAttributes_init(&vattr);
  43. UA_DataSource temperatureDataSource = (UA_DataSource) {
  44. .handle = NULL, .read = NULL, .write = NULL};
  45. vattr.description = UA_LOCALIZEDTEXT("en_US","temperature");
  46. vattr.displayName = UA_LOCALIZEDTEXT("en_US","temperature");
  47. UA_Server_addDataSourceVariableNode(server, UA_NODEID_STRING(1, "cpu.temperature"),
  48. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  49. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  50. UA_QUALIFIEDNAME(1, "cpu temperature"),
  51. UA_NODEID_NULL, vattr, temperatureDataSource, NULL);
  52. /* DataSource Variable returning no value */
  53. UA_DataSource temperatureDataSource1 = (UA_DataSource) {
  54. .handle = NULL, .read = readCPUTemperature_broken, .write = NULL};
  55. vattr.description = UA_LOCALIZEDTEXT("en_US","temperature1");
  56. vattr.displayName = UA_LOCALIZEDTEXT("en_US","temperature1");
  57. UA_Server_addDataSourceVariableNode(server, UA_NODEID_STRING(1, "cpu.temperature1"),
  58. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  59. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  60. UA_QUALIFIEDNAME(1, "cpu temperature bogus"),
  61. UA_NODEID_NULL, vattr, temperatureDataSource1, NULL);
  62. /* VariableNode with array */
  63. UA_VariableAttributes_init(&vattr);
  64. UA_Int32 myIntegerArray[9] = {1,2,3,4,5,6,7,8,9};
  65. UA_Variant_setArray(&vattr.value, &myIntegerArray, 9, &UA_TYPES[UA_TYPES_INT32]);
  66. UA_Int32 myIntegerDimensions[2] = {3,3};
  67. vattr.value.arrayDimensions = myIntegerDimensions;
  68. vattr.value.arrayDimensionsSize = 2;
  69. vattr.displayName = UA_LOCALIZEDTEXT("locale","myarray");
  70. myIntegerName = UA_QUALIFIEDNAME(1, "myarray");
  71. myIntegerNodeId = UA_NODEID_STRING(1, "myarray");
  72. parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  73. parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  74. UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  75. parentReferenceNodeId, myIntegerName,
  76. UA_NODEID_NULL, vattr, NULL, NULL);
  77. /* ObjectNode */
  78. UA_ObjectAttributes obj_attr;
  79. UA_ObjectAttributes_init(&obj_attr);
  80. obj_attr.description = UA_LOCALIZEDTEXT("en_US","Demo");
  81. obj_attr.displayName = UA_LOCALIZEDTEXT("en_US","Demo");
  82. UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, 50),
  83. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  84. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  85. UA_QUALIFIEDNAME(1, "Demo"),
  86. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE),
  87. obj_attr, NULL, NULL);
  88. /* ViewNode */
  89. UA_ViewAttributes view_attr;
  90. UA_ViewAttributes_init(&view_attr);
  91. view_attr.description = UA_LOCALIZEDTEXT("en_US", "Viewtest");
  92. view_attr.displayName = UA_LOCALIZEDTEXT("en_US", "Viewtest");
  93. UA_Server_addViewNode(server, UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWNODE),
  94. UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWSFOLDER),
  95. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  96. UA_QUALIFIEDNAME(0, "Viewtest"), view_attr, NULL, NULL);
  97. #ifdef UA_ENABLE_METHODCALLS
  98. /* MethodNode */
  99. UA_MethodAttributes ma;
  100. UA_MethodAttributes_init(&ma);
  101. ma.description = UA_LOCALIZEDTEXT("en_US", "Methodtest");
  102. ma.displayName = UA_LOCALIZEDTEXT("en_US", "Methodtest");
  103. UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(0, UA_NS0ID_METHODNODE),
  104. UA_NODEID_NUMERIC(0, 3),
  105. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  106. UA_QUALIFIEDNAME_ALLOC(0, "Methodtest"), ma,
  107. NULL, NULL, 0, NULL, 0, NULL, NULL);
  108. #endif
  109. return server;
  110. }
  111. static UA_VariableNode* makeCompareSequence(void) {
  112. UA_VariableNode *node = UA_NodeStore_newVariableNode();
  113. UA_Int32 myInteger = 42;
  114. UA_Variant_setScalarCopy(&node->value.variant.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  115. const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  116. UA_QualifiedName_copy(&myIntegerName,&node->browseName);
  117. const UA_LocalizedText myIntegerDisplName = UA_LOCALIZEDTEXT("locale", "the answer");
  118. UA_LocalizedText_copy(&myIntegerDisplName, &node->displayName);
  119. UA_LocalizedText_copy(&myIntegerDisplName, &node->description);
  120. const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  121. UA_NodeId_copy(&myIntegerNodeId,&node->nodeId);
  122. return node;
  123. }
  124. START_TEST(ReadSingleAttributeValueWithoutTimestamp) {
  125. UA_Server *server = makeTestSequence();
  126. UA_DataValue resp;
  127. UA_DataValue_init(&resp);
  128. UA_ReadRequest rReq;
  129. UA_ReadRequest_init(&rReq);
  130. rReq.nodesToRead = UA_ReadValueId_new();
  131. rReq.nodesToReadSize = 1;
  132. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  133. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
  134. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  135. ck_assert_int_eq(0, resp.value.arrayLength);
  136. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  137. ck_assert_int_eq(42, *(UA_Int32* )resp.value.data);
  138. UA_Server_delete(server);
  139. UA_ReadRequest_deleteMembers(&rReq);
  140. UA_DataValue_deleteMembers(&resp);
  141. } END_TEST
  142. START_TEST(ReadSingleAttributeValueRangeWithoutTimestamp) {
  143. UA_Server *server = makeTestSequence();
  144. UA_DataValue resp;
  145. UA_DataValue_init(&resp);
  146. UA_ReadRequest rReq;
  147. UA_ReadRequest_init(&rReq);
  148. rReq.nodesToRead = UA_ReadValueId_new();
  149. rReq.nodesToReadSize = 1;
  150. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "myarray");
  151. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
  152. rReq.nodesToRead[0].indexRange = UA_STRING_ALLOC("1:2,0:1");
  153. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  154. ck_assert_int_eq(4, resp.value.arrayLength);
  155. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  156. UA_Server_delete(server);
  157. UA_ReadRequest_deleteMembers(&rReq);
  158. UA_DataValue_deleteMembers(&resp);
  159. } END_TEST
  160. START_TEST(ReadSingleAttributeNodeIdWithoutTimestamp) {
  161. UA_Server *server = makeTestSequence();
  162. UA_DataValue resp;
  163. UA_DataValue_init(&resp);
  164. UA_ReadRequest rReq;
  165. UA_ReadRequest_init(&rReq);
  166. rReq.nodesToRead = UA_ReadValueId_new();
  167. rReq.nodesToReadSize = 1;
  168. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  169. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_NODEID;
  170. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  171. const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  172. ck_assert_int_eq(0, resp.value.arrayLength);
  173. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_NODEID], resp.value.type);
  174. UA_NodeId* respval = (UA_NodeId*) resp.value.data;
  175. ck_assert_int_eq(1, respval->namespaceIndex);
  176. ck_assert(UA_String_equal(&myIntegerNodeId.identifier.string, &respval->identifier.string));
  177. UA_ReadRequest_deleteMembers(&rReq);
  178. UA_DataValue_deleteMembers(&resp);
  179. UA_Server_delete(server);
  180. } END_TEST
  181. START_TEST(ReadSingleAttributeNodeClassWithoutTimestamp) {
  182. UA_Server *server = makeTestSequence();
  183. UA_DataValue resp;
  184. UA_DataValue_init(&resp);
  185. UA_ReadRequest rReq;
  186. UA_ReadRequest_init(&rReq);
  187. rReq.nodesToRead = UA_ReadValueId_new();
  188. rReq.nodesToReadSize = 1;
  189. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  190. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_NODECLASS;
  191. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  192. ck_assert_int_eq(0, resp.value.arrayLength);
  193. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_NODECLASS],resp.value.type);
  194. ck_assert_int_eq(*(UA_Int32*)resp.value.data,UA_NODECLASS_VARIABLE);
  195. UA_ReadRequest_deleteMembers(&rReq);
  196. UA_DataValue_deleteMembers(&resp);
  197. UA_Server_delete(server);
  198. } END_TEST
  199. START_TEST(ReadSingleAttributeBrowseNameWithoutTimestamp) {
  200. UA_Server *server = makeTestSequence();
  201. UA_DataValue resp;
  202. UA_DataValue_init(&resp);
  203. UA_ReadRequest rReq;
  204. UA_ReadRequest_init(&rReq);
  205. rReq.nodesToRead = UA_ReadValueId_new();
  206. rReq.nodesToReadSize = 1;
  207. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  208. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_BROWSENAME;
  209. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  210. UA_QualifiedName* respval = (UA_QualifiedName*) resp.value.data;
  211. const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  212. ck_assert_int_eq(0, resp.value.arrayLength);
  213. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_QUALIFIEDNAME], resp.value.type);
  214. ck_assert_int_eq(1, respval->namespaceIndex);
  215. ck_assert(UA_String_equal(&myIntegerName.name, &respval->name));
  216. UA_ReadRequest_deleteMembers(&rReq);
  217. UA_DataValue_deleteMembers(&resp);
  218. UA_Server_delete(server);
  219. } END_TEST
  220. START_TEST(ReadSingleAttributeDisplayNameWithoutTimestamp) {
  221. UA_Server *server = makeTestSequence();
  222. UA_DataValue resp;
  223. UA_DataValue_init(&resp);
  224. UA_ReadRequest rReq;
  225. UA_ReadRequest_init(&rReq);
  226. rReq.nodesToRead = UA_ReadValueId_new();
  227. rReq.nodesToReadSize = 1;
  228. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  229. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DISPLAYNAME;
  230. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  231. UA_LocalizedText* respval = (UA_LocalizedText*) resp.value.data;
  232. const UA_LocalizedText comp = UA_LOCALIZEDTEXT("locale", "the answer");
  233. UA_VariableNode* compNode = makeCompareSequence();
  234. ck_assert_int_eq(0, resp.value.arrayLength);
  235. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT], resp.value.type);
  236. ck_assert(UA_String_equal(&comp.text, &respval->text));
  237. ck_assert(UA_String_equal(&compNode->displayName.locale, &respval->locale));
  238. UA_Server_delete(server);
  239. UA_ReadRequest_deleteMembers(&rReq);
  240. UA_DataValue_deleteMembers(&resp);
  241. UA_NodeStore_deleteNode((UA_Node*)compNode);
  242. } END_TEST
  243. START_TEST(ReadSingleAttributeDescriptionWithoutTimestamp) {
  244. UA_Server *server = makeTestSequence();
  245. UA_DataValue resp;
  246. UA_DataValue_init(&resp);
  247. UA_ReadRequest rReq;
  248. UA_ReadRequest_init(&rReq);
  249. rReq.nodesToRead = UA_ReadValueId_new();
  250. rReq.nodesToReadSize = 1;
  251. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  252. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DESCRIPTION;
  253. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  254. UA_LocalizedText* respval = (UA_LocalizedText*) resp.value.data;
  255. UA_VariableNode* compNode = makeCompareSequence();
  256. ck_assert_int_eq(0, resp.value.arrayLength);
  257. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT], resp.value.type);
  258. ck_assert(UA_String_equal(&compNode->description.locale, &respval->locale));
  259. ck_assert(UA_String_equal(&compNode->description.text, &respval->text));
  260. UA_ReadRequest_deleteMembers(&rReq);
  261. UA_DataValue_deleteMembers(&resp);
  262. UA_NodeStore_deleteNode((UA_Node*)compNode);
  263. UA_Server_delete(server);
  264. } END_TEST
  265. START_TEST(ReadSingleAttributeWriteMaskWithoutTimestamp) {
  266. UA_Server *server = makeTestSequence();
  267. UA_DataValue resp;
  268. UA_DataValue_init(&resp);
  269. UA_ReadRequest rReq;
  270. UA_ReadRequest_init(&rReq);
  271. rReq.nodesToRead = UA_ReadValueId_new();
  272. rReq.nodesToReadSize = 1;
  273. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  274. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_WRITEMASK;
  275. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  276. UA_UInt32* respval = (UA_UInt32*) resp.value.data;
  277. ck_assert_int_eq(0, resp.value.arrayLength);
  278. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_UINT32], resp.value.type);
  279. ck_assert_int_eq(0,*respval);
  280. UA_ReadRequest_deleteMembers(&rReq);
  281. UA_DataValue_deleteMembers(&resp);
  282. UA_Server_delete(server);
  283. } END_TEST
  284. START_TEST(ReadSingleAttributeUserWriteMaskWithoutTimestamp) {
  285. UA_Server *server = makeTestSequence();
  286. UA_DataValue resp;
  287. UA_DataValue_init(&resp);
  288. UA_ReadRequest rReq;
  289. UA_ReadRequest_init(&rReq);
  290. rReq.nodesToRead = UA_ReadValueId_new();
  291. rReq.nodesToReadSize = 1;
  292. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  293. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USERWRITEMASK;
  294. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  295. UA_UInt32* respval = (UA_UInt32*) resp.value.data;
  296. ck_assert_int_eq(0, resp.value.arrayLength);
  297. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_UINT32], resp.value.type);
  298. ck_assert_int_eq(0,*respval);
  299. UA_ReadRequest_deleteMembers(&rReq);
  300. UA_DataValue_deleteMembers(&resp);
  301. UA_Server_delete(server);
  302. } END_TEST
  303. START_TEST(ReadSingleAttributeIsAbstractWithoutTimestamp) {
  304. UA_Server *server = makeTestSequence();
  305. UA_DataValue resp;
  306. UA_DataValue_init(&resp);
  307. UA_ReadRequest rReq;
  308. UA_ReadRequest_init(&rReq);
  309. rReq.nodesToRead = UA_ReadValueId_new();
  310. rReq.nodesToReadSize = 1;
  311. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_ORGANIZES;
  312. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ISABSTRACT;
  313. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  314. ck_assert_int_eq(0, resp.value.arrayLength);
  315. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  316. ck_assert(*(UA_Boolean* )resp.value.data==false);
  317. UA_ReadRequest_deleteMembers(&rReq);
  318. UA_DataValue_deleteMembers(&resp);
  319. UA_Server_delete(server);
  320. } END_TEST
  321. START_TEST(ReadSingleAttributeSymmetricWithoutTimestamp) {
  322. UA_Server *server = makeTestSequence();
  323. UA_DataValue resp;
  324. UA_DataValue_init(&resp);
  325. UA_ReadRequest rReq;
  326. UA_ReadRequest_init(&rReq);
  327. rReq.nodesToRead = UA_ReadValueId_new();
  328. rReq.nodesToReadSize = 1;
  329. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_ORGANIZES;
  330. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_SYMMETRIC;
  331. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  332. ck_assert_int_eq(0, resp.value.arrayLength);
  333. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  334. ck_assert(*(UA_Boolean* )resp.value.data==false);
  335. UA_ReadRequest_deleteMembers(&rReq);
  336. UA_DataValue_deleteMembers(&resp);
  337. UA_Server_delete(server);
  338. } END_TEST
  339. START_TEST(ReadSingleAttributeInverseNameWithoutTimestamp) {
  340. UA_Server *server = makeTestSequence();
  341. UA_DataValue resp;
  342. UA_DataValue_init(&resp);
  343. UA_ReadRequest rReq;
  344. UA_ReadRequest_init(&rReq);
  345. rReq.nodesToRead = UA_ReadValueId_new();
  346. rReq.nodesToReadSize = 1;
  347. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_ORGANIZES;
  348. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_INVERSENAME;
  349. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  350. UA_LocalizedText* respval = (UA_LocalizedText*) resp.value.data;
  351. const UA_LocalizedText comp = UA_LOCALIZEDTEXT("en_US", "OrganizedBy");
  352. ck_assert_int_eq(0, resp.value.arrayLength);
  353. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT],resp.value.type);
  354. ck_assert(UA_String_equal(&comp.text, &respval->text));
  355. ck_assert(UA_String_equal(&comp.locale, &respval->locale));
  356. UA_ReadRequest_deleteMembers(&rReq);
  357. UA_DataValue_deleteMembers(&resp);
  358. UA_Server_delete(server);
  359. } END_TEST
  360. START_TEST(ReadSingleAttributeContainsNoLoopsWithoutTimestamp) {
  361. UA_Server *server = makeTestSequence();
  362. UA_DataValue resp;
  363. UA_DataValue_init(&resp);
  364. UA_ReadRequest rReq;
  365. UA_ReadRequest_init(&rReq);
  366. rReq.nodesToRead = UA_ReadValueId_new();
  367. rReq.nodesToReadSize = 1;
  368. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_VIEWNODE;
  369. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_CONTAINSNOLOOPS;
  370. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  371. ck_assert_int_eq(0, resp.value.arrayLength);
  372. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  373. ck_assert(*(UA_Boolean* )resp.value.data==false);
  374. UA_ReadRequest_deleteMembers(&rReq);
  375. UA_DataValue_deleteMembers(&resp);
  376. UA_Server_delete(server);
  377. } END_TEST
  378. START_TEST(ReadSingleAttributeEventNotifierWithoutTimestamp) {
  379. UA_Server *server = makeTestSequence();
  380. UA_DataValue resp;
  381. UA_DataValue_init(&resp);
  382. UA_ReadRequest rReq;
  383. UA_ReadRequest_init(&rReq);
  384. rReq.nodesToRead = UA_ReadValueId_new();
  385. rReq.nodesToReadSize = 1;
  386. rReq.nodesToRead[0].nodeId = UA_NODEID_NUMERIC(1, 50);
  387. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_EVENTNOTIFIER;
  388. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  389. ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
  390. ck_assert_int_eq(0, resp.value.arrayLength);
  391. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE],resp.value.type);
  392. ck_assert_int_eq(*(UA_Byte*)resp.value.data, 0);
  393. UA_ReadRequest_deleteMembers(&rReq);
  394. UA_DataValue_deleteMembers(&resp);
  395. UA_Server_delete(server);
  396. } END_TEST
  397. START_TEST(ReadSingleAttributeDataTypeWithoutTimestamp) {
  398. UA_Server *server = makeTestSequence();
  399. UA_DataValue resp;
  400. UA_DataValue_init(&resp);
  401. UA_ReadRequest rReq;
  402. UA_ReadRequest_init(&rReq);
  403. rReq.nodesToRead = UA_ReadValueId_new();
  404. rReq.nodesToReadSize = 1;
  405. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  406. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DATATYPE;
  407. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  408. UA_NodeId* respval = (UA_NodeId*) resp.value.data;
  409. ck_assert_int_eq(0, resp.value.arrayLength);
  410. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_NODEID], resp.value.type);
  411. ck_assert_int_eq(respval->namespaceIndex,0);
  412. ck_assert_int_eq(respval->identifier.numeric,UA_NS0ID_INT32);
  413. UA_ReadRequest_deleteMembers(&rReq);
  414. UA_DataValue_deleteMembers(&resp);
  415. UA_Server_delete(server);
  416. } END_TEST
  417. START_TEST(ReadSingleAttributeValueRankWithoutTimestamp) {
  418. UA_Server *server = makeTestSequence();
  419. UA_DataValue resp;
  420. UA_DataValue_init(&resp);
  421. UA_ReadRequest rReq;
  422. UA_ReadRequest_init(&rReq);
  423. rReq.nodesToRead = UA_ReadValueId_new();
  424. rReq.nodesToReadSize = 1;
  425. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  426. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUERANK;
  427. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  428. ck_assert_int_eq(0, resp.value.arrayLength);
  429. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  430. ck_assert_int_eq(-2, *(UA_Int32* )resp.value.data);
  431. UA_ReadRequest_deleteMembers(&rReq);
  432. UA_DataValue_deleteMembers(&resp);
  433. UA_Server_delete(server);
  434. } END_TEST
  435. START_TEST(ReadSingleAttributeArrayDimensionsWithoutTimestamp) {
  436. UA_Server *server = makeTestSequence();
  437. UA_DataValue resp;
  438. UA_DataValue_init(&resp);
  439. UA_ReadRequest rReq;
  440. UA_ReadRequest_init(&rReq);
  441. rReq.nodesToRead = UA_ReadValueId_new();
  442. rReq.nodesToReadSize = 1;
  443. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  444. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
  445. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  446. ck_assert_int_eq(0, resp.value.arrayLength);
  447. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  448. ck_assert_ptr_eq((UA_Int32*)resp.value.data,0);
  449. UA_DataValue_deleteMembers(&resp);
  450. UA_ReadRequest_deleteMembers(&rReq);
  451. UA_Server_delete(server);
  452. } END_TEST
  453. START_TEST(ReadSingleAttributeAccessLevelWithoutTimestamp) {
  454. UA_Server *server = makeTestSequence();
  455. UA_DataValue resp;
  456. UA_DataValue_init(&resp);
  457. UA_ReadRequest rReq;
  458. UA_ReadRequest_init(&rReq);
  459. rReq.nodesToRead = UA_ReadValueId_new();
  460. rReq.nodesToReadSize = 1;
  461. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  462. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ACCESSLEVEL;
  463. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  464. ck_assert_int_eq(0, resp.value.arrayLength);
  465. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type);
  466. ck_assert_int_eq(*(UA_Byte*)resp.value.data, 0);
  467. UA_DataValue_deleteMembers(&resp);
  468. UA_ReadRequest_deleteMembers(&rReq);
  469. UA_Server_delete(server);
  470. } END_TEST
  471. START_TEST(ReadSingleAttributeUserAccessLevelWithoutTimestamp) {
  472. UA_Server *server = makeTestSequence();
  473. UA_DataValue resp;
  474. UA_DataValue_init(&resp);
  475. UA_ReadRequest rReq;
  476. UA_ReadRequest_init(&rReq);
  477. rReq.nodesToRead = UA_ReadValueId_new();
  478. rReq.nodesToReadSize = 1;
  479. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  480. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USERACCESSLEVEL;
  481. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  482. const UA_VariableNode* compNode =
  483. (const UA_VariableNode*)UA_NodeStore_get(server->nodestore, &rReq.nodesToRead[0].nodeId);
  484. ck_assert_int_eq(0, resp.value.arrayLength);
  485. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type);
  486. ck_assert_int_eq(*(UA_Byte*)resp.value.data, compNode->userAccessLevel);
  487. UA_Server_delete(server);
  488. UA_DataValue_deleteMembers(&resp);
  489. UA_ReadRequest_deleteMembers(&rReq);
  490. } END_TEST
  491. START_TEST(ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp) {
  492. UA_Server *server = makeTestSequence();
  493. UA_DataValue resp;
  494. UA_DataValue_init(&resp);
  495. UA_ReadRequest rReq;
  496. UA_ReadRequest_init(&rReq);
  497. rReq.nodesToRead = UA_ReadValueId_new();
  498. rReq.nodesToReadSize = 1;
  499. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  500. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL;
  501. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  502. UA_Double* respval = (UA_Double*) resp.value.data;
  503. UA_VariableNode *compNode = makeCompareSequence();
  504. UA_Double comp = (UA_Double) compNode->minimumSamplingInterval;
  505. ck_assert_int_eq(0, resp.value.arrayLength);
  506. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_DOUBLE], resp.value.type);
  507. ck_assert(*respval == comp);
  508. UA_DataValue_deleteMembers(&resp);
  509. UA_ReadRequest_deleteMembers(&rReq);
  510. UA_NodeStore_deleteNode((UA_Node*)compNode);
  511. UA_Server_delete(server);
  512. } END_TEST
  513. START_TEST(ReadSingleAttributeHistorizingWithoutTimestamp) {
  514. UA_Server *server = makeTestSequence();
  515. UA_DataValue resp;
  516. UA_DataValue_init(&resp);
  517. UA_ReadRequest rReq;
  518. UA_ReadRequest_init(&rReq);
  519. rReq.nodesToRead = UA_ReadValueId_new();
  520. rReq.nodesToReadSize = 1;
  521. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  522. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_HISTORIZING;
  523. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  524. ck_assert_int_eq(0, resp.value.arrayLength);
  525. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  526. ck_assert(*(UA_Boolean*)resp.value.data==false);
  527. UA_ReadRequest_deleteMembers(&rReq);
  528. UA_DataValue_deleteMembers(&resp);
  529. UA_Server_delete(server);
  530. } END_TEST
  531. START_TEST(ReadSingleAttributeExecutableWithoutTimestamp) {
  532. #ifdef UA_ENABLE_METHODCALLS
  533. UA_Server *server = makeTestSequence();
  534. UA_DataValue resp;
  535. UA_DataValue_init(&resp);
  536. UA_ReadRequest rReq;
  537. UA_ReadRequest_init(&rReq);
  538. rReq.nodesToRead = UA_ReadValueId_new();
  539. rReq.nodesToReadSize = 1;
  540. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_METHODNODE;
  541. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_EXECUTABLE;
  542. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  543. ck_assert_int_eq(0, resp.value.arrayLength);
  544. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  545. ck_assert(*(UA_Boolean*)resp.value.data==false);
  546. UA_DataValue_deleteMembers(&resp);
  547. UA_ReadRequest_deleteMembers(&rReq);
  548. UA_Server_delete(server);
  549. #endif
  550. } END_TEST
  551. START_TEST(ReadSingleAttributeUserExecutableWithoutTimestamp) {
  552. #ifdef UA_ENABLE_METHODCALLS
  553. UA_Server *server = makeTestSequence();
  554. UA_DataValue resp;
  555. UA_DataValue_init(&resp);
  556. UA_ReadRequest rReq;
  557. UA_ReadRequest_init(&rReq);
  558. rReq.nodesToRead = UA_ReadValueId_new();
  559. rReq.nodesToReadSize = 1;
  560. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_METHODNODE;
  561. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USEREXECUTABLE;
  562. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  563. ck_assert_int_eq(0, resp.value.arrayLength);
  564. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  565. ck_assert(*(UA_Boolean*)resp.value.data==false);
  566. UA_DataValue_deleteMembers(&resp);
  567. UA_ReadRequest_deleteMembers(&rReq);
  568. UA_Server_delete(server);
  569. #endif
  570. } END_TEST
  571. START_TEST(ReadSingleDataSourceAttributeDataTypeWithoutTimestampFromBrokenSource) {
  572. UA_Server *server = makeTestSequence();
  573. UA_DataValue resp;
  574. UA_DataValue_init(&resp);
  575. UA_ReadRequest rReq;
  576. UA_ReadRequest_init(&rReq);
  577. rReq.nodesToRead = UA_ReadValueId_new();
  578. rReq.nodesToReadSize = 1;
  579. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "cpu.temperature1");
  580. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DATATYPE;
  581. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  582. ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
  583. UA_Server_delete(server);
  584. UA_ReadRequest_deleteMembers(&rReq);
  585. UA_DataValue_deleteMembers(&resp);
  586. } END_TEST
  587. START_TEST(ReadSingleDataSourceAttributeValueWithoutTimestamp) {
  588. UA_Server *server = makeTestSequence();
  589. UA_DataValue resp;
  590. UA_DataValue_init(&resp);
  591. UA_ReadRequest rReq;
  592. UA_ReadRequest_init(&rReq);
  593. rReq.nodesToRead = UA_ReadValueId_new();
  594. rReq.nodesToReadSize = 1;
  595. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "cpu.temperature");
  596. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
  597. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  598. ck_assert_int_eq(UA_STATUSCODE_BADINTERNALERROR, resp.status);
  599. UA_Server_delete(server);
  600. UA_ReadRequest_deleteMembers(&rReq);
  601. UA_DataValue_deleteMembers(&resp);
  602. } END_TEST
  603. START_TEST(ReadSingleDataSourceAttributeDataTypeWithoutTimestamp) {
  604. UA_Server *server = makeTestSequence();
  605. UA_DataValue resp;
  606. UA_DataValue_init(&resp);
  607. UA_ReadRequest rReq;
  608. UA_ReadRequest_init(&rReq);
  609. rReq.nodesToRead = UA_ReadValueId_new();
  610. rReq.nodesToReadSize = 1;
  611. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "cpu.temperature");
  612. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DATATYPE;
  613. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  614. ck_assert_int_eq(UA_STATUSCODE_BADINTERNALERROR, resp.status);
  615. UA_Server_delete(server);
  616. UA_ReadRequest_deleteMembers(&rReq);
  617. UA_DataValue_deleteMembers(&resp);
  618. } END_TEST
  619. START_TEST (ReadSingleDataSourceAttributeArrayDimensionsWithoutTimestamp) {
  620. UA_Server *server = makeTestSequence();
  621. UA_DataValue resp;
  622. UA_DataValue_init(&resp);
  623. UA_ReadRequest rReq;
  624. UA_ReadRequest_init(&rReq);
  625. rReq.nodesToRead = UA_ReadValueId_new();
  626. rReq.nodesToReadSize = 1;
  627. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "cpu.temperature");
  628. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
  629. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  630. ck_assert_int_eq(UA_STATUSCODE_BADINTERNALERROR, resp.status);
  631. UA_Server_delete(server);
  632. UA_ReadRequest_deleteMembers(&rReq);
  633. UA_DataValue_deleteMembers(&resp);
  634. } END_TEST
  635. /* Tests for writeValue method */
  636. START_TEST(WriteSingleAttributeNodeId) {
  637. UA_Server *server = makeTestSequence();
  638. UA_WriteValue wValue;
  639. UA_WriteValue_init(&wValue);
  640. UA_NodeId id;
  641. UA_NodeId_init(&id);
  642. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  643. wValue.attributeId = UA_ATTRIBUTEID_NODEID;
  644. wValue.value.hasValue = true;
  645. UA_Variant_setScalar(&wValue.value.value, &id, &UA_TYPES[UA_TYPES_NODEID]);
  646. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  647. ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
  648. UA_Server_delete(server);
  649. } END_TEST
  650. START_TEST(WriteSingleAttributeNodeclass) {
  651. UA_Server *server = makeTestSequence();
  652. UA_WriteValue wValue;
  653. UA_WriteValue_init(&wValue);
  654. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  655. UA_NodeClass class;
  656. UA_NodeClass_init(&class);
  657. wValue.attributeId = UA_ATTRIBUTEID_NODECLASS;
  658. wValue.value.hasValue = true;
  659. UA_Variant_setScalar(&wValue.value.value, &class, &UA_TYPES[UA_TYPES_NODECLASS]);
  660. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  661. ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
  662. UA_Server_delete(server);
  663. } END_TEST
  664. START_TEST(WriteSingleAttributeBrowseName) {
  665. UA_Server *server = makeTestSequence();
  666. UA_WriteValue wValue;
  667. UA_WriteValue_init(&wValue);
  668. UA_QualifiedName testValue = UA_QUALIFIEDNAME(1, "the.answer");
  669. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
  670. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  671. wValue.attributeId = UA_ATTRIBUTEID_BROWSENAME;
  672. wValue.value.hasValue = true;
  673. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  674. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  675. UA_Server_delete(server);
  676. } END_TEST
  677. START_TEST(WriteSingleAttributeDisplayName) {
  678. UA_Server *server = makeTestSequence();
  679. UA_WriteValue wValue;
  680. UA_WriteValue_init(&wValue);
  681. UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_EN", "the.answer");
  682. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  683. wValue.value.hasValue = true;
  684. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  685. wValue.attributeId = UA_ATTRIBUTEID_DISPLAYNAME;
  686. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  687. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  688. UA_Server_delete(server);
  689. } END_TEST
  690. START_TEST(WriteSingleAttributeDescription) {
  691. UA_Server *server = makeTestSequence();
  692. UA_WriteValue wValue;
  693. UA_WriteValue_init(&wValue);
  694. UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_EN", "the.answer");
  695. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  696. wValue.value.hasValue = true;
  697. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  698. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  699. wValue.attributeId = UA_ATTRIBUTEID_DESCRIPTION;
  700. wValue.value.hasValue = true;
  701. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  702. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  703. UA_Server_delete(server);
  704. } END_TEST
  705. START_TEST(WriteSingleAttributeWriteMask) {
  706. UA_Server *server = makeTestSequence();
  707. UA_WriteValue wValue;
  708. UA_WriteValue_init(&wValue);
  709. UA_Int32 testValue = 0;
  710. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_UINT32]);
  711. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  712. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  713. wValue.attributeId = UA_ATTRIBUTEID_WRITEMASK;
  714. wValue.value.hasValue = true;
  715. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  716. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  717. UA_Server_delete(server);
  718. } END_TEST
  719. START_TEST(WriteSingleAttributeUserWriteMask) {
  720. UA_Server *server = makeTestSequence();
  721. UA_WriteValue wValue;
  722. UA_WriteValue_init(&wValue);
  723. UA_Int32 testValue = 0;
  724. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_UINT32]);
  725. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  726. wValue.attributeId = UA_ATTRIBUTEID_USERWRITEMASK;
  727. wValue.value.hasValue = true;
  728. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  729. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  730. UA_Server_delete(server);
  731. } END_TEST
  732. START_TEST(WriteSingleAttributeIsAbstract) {
  733. UA_Server *server = makeTestSequence();
  734. UA_WriteValue wValue;
  735. UA_WriteValue_init(&wValue);
  736. UA_Boolean testValue = true;
  737. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  738. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  739. wValue.attributeId = UA_ATTRIBUTEID_ISABSTRACT;
  740. wValue.value.hasValue = true;
  741. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  742. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  743. UA_Server_delete(server);
  744. } END_TEST
  745. START_TEST(WriteSingleAttributeSymmetric) {
  746. UA_Server *server = makeTestSequence();
  747. UA_WriteValue wValue;
  748. UA_WriteValue_init(&wValue);
  749. UA_Boolean testValue = true;
  750. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  751. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  752. wValue.attributeId = UA_ATTRIBUTEID_SYMMETRIC;
  753. wValue.value.hasValue = true;
  754. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  755. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  756. UA_Server_delete(server);
  757. } END_TEST
  758. START_TEST(WriteSingleAttributeInverseName) {
  759. UA_Server *server = makeTestSequence();
  760. UA_WriteValue wValue;
  761. UA_WriteValue_init(&wValue);
  762. UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_US", "not.the.answer");
  763. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  764. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  765. wValue.attributeId = UA_ATTRIBUTEID_INVERSENAME;
  766. wValue.value.hasValue = true;
  767. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  768. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  769. UA_Server_delete(server);
  770. } END_TEST
  771. START_TEST(WriteSingleAttributeContainsNoLoops) {
  772. UA_Server *server = makeTestSequence();
  773. UA_WriteValue wValue;
  774. UA_WriteValue_init(&wValue);
  775. UA_Boolean testValue = true;
  776. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  777. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  778. wValue.attributeId = UA_ATTRIBUTEID_CONTAINSNOLOOPS;
  779. wValue.value.hasValue = true;
  780. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  781. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  782. UA_Server_delete(server);
  783. } END_TEST
  784. START_TEST(WriteSingleAttributeEventNotifier) {
  785. UA_Server *server = makeTestSequence();
  786. UA_WriteValue wValue;
  787. UA_WriteValue_init(&wValue);
  788. UA_Byte testValue = 0;
  789. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
  790. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  791. wValue.attributeId = UA_ATTRIBUTEID_EVENTNOTIFIER;
  792. wValue.value.hasValue = true;
  793. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  794. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  795. UA_Server_delete(server);
  796. } END_TEST
  797. START_TEST(WriteSingleAttributeValue) {
  798. UA_Server *server = makeTestSequence();
  799. UA_WriteValue wValue;
  800. UA_WriteValue_init(&wValue);
  801. UA_Int32 myInteger = 20;
  802. UA_Variant_setScalar(&wValue.value.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  803. wValue.value.hasValue = true;
  804. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  805. wValue.attributeId = UA_ATTRIBUTEID_VALUE;
  806. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  807. UA_DataValue resp;
  808. UA_DataValue_init(&resp);
  809. UA_ReadValueId id;
  810. UA_ReadValueId_init(&id);
  811. id.nodeId = UA_NODEID_STRING(1, "the.answer");
  812. id.attributeId = UA_ATTRIBUTEID_VALUE;
  813. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &id, &resp);
  814. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  815. ck_assert(wValue.value.hasValue);
  816. ck_assert_int_eq(20, *(UA_Int32*)resp.value.data);
  817. UA_DataValue_deleteMembers(&resp);
  818. UA_Server_delete(server);
  819. } END_TEST
  820. START_TEST(WriteSingleAttributeDataType) {
  821. UA_Server *server = makeTestSequence();
  822. UA_WriteValue wValue;
  823. UA_WriteValue_init(&wValue);
  824. UA_NodeId typeId;
  825. UA_NodeId_init(&typeId);
  826. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  827. wValue.attributeId = UA_ATTRIBUTEID_DATATYPE;
  828. wValue.value.hasValue = true;
  829. UA_Variant_setScalar(&wValue.value.value, &typeId, &UA_TYPES[UA_TYPES_NODEID]);
  830. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  831. ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
  832. UA_Server_delete(server);
  833. } END_TEST
  834. START_TEST(WriteSingleAttributeValueRank) {
  835. UA_Server *server = makeTestSequence();
  836. UA_WriteValue wValue;
  837. UA_WriteValue_init(&wValue);
  838. UA_Int32 testValue = -1;
  839. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_INT32]);
  840. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  841. wValue.attributeId = UA_ATTRIBUTEID_VALUERANK;
  842. wValue.value.hasValue = true;
  843. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  844. // Returns attributeInvalid, since variant/value may be writable
  845. ck_assert_int_eq(retval, UA_STATUSCODE_BADATTRIBUTEIDINVALID);
  846. UA_Server_delete(server);
  847. } END_TEST
  848. START_TEST(WriteSingleAttributeArrayDimensions) {
  849. UA_Server *server = makeTestSequence();
  850. UA_WriteValue wValue;
  851. UA_WriteValue_init(&wValue);
  852. UA_Int32 testValue[] = {-1,-1,-1};
  853. UA_Variant_setArray(&wValue.value.value, &testValue, 3, &UA_TYPES[UA_TYPES_INT32]);
  854. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  855. wValue.attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
  856. wValue.value.hasValue = true;
  857. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  858. // Returns attributeInvalid, since variant/value may be writable
  859. ck_assert_int_eq(retval, UA_STATUSCODE_BADATTRIBUTEIDINVALID);
  860. UA_Server_delete(server);
  861. } END_TEST
  862. START_TEST(WriteSingleAttributeAccessLevel) {
  863. UA_Server *server = makeTestSequence();
  864. UA_WriteValue wValue;
  865. UA_WriteValue_init(&wValue);
  866. UA_Byte testValue = 0;
  867. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
  868. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  869. wValue.attributeId = UA_ATTRIBUTEID_ACCESSLEVEL;
  870. wValue.value.hasValue = true;
  871. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  872. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  873. UA_Server_delete(server);
  874. } END_TEST
  875. START_TEST(WriteSingleAttributeUserAccessLevel) {
  876. UA_Server *server = makeTestSequence();
  877. UA_WriteValue wValue;
  878. UA_WriteValue_init(&wValue);
  879. UA_Byte testValue = 0;
  880. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
  881. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  882. wValue.attributeId = UA_ATTRIBUTEID_USERACCESSLEVEL;
  883. wValue.value.hasValue = true;
  884. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  885. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  886. UA_Server_delete(server);
  887. } END_TEST
  888. START_TEST(WriteSingleAttributeMinimumSamplingInterval) {
  889. UA_Server *server = makeTestSequence();
  890. UA_WriteValue wValue;
  891. UA_WriteValue_init(&wValue);
  892. UA_Double testValue = 0.0;
  893. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_DOUBLE]);
  894. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  895. wValue.attributeId = UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL;
  896. wValue.value.hasValue = true;
  897. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  898. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  899. UA_Server_delete(server);
  900. } END_TEST
  901. START_TEST(WriteSingleAttributeHistorizing) {
  902. UA_Server *server = makeTestSequence();
  903. UA_WriteValue wValue;
  904. UA_WriteValue_init(&wValue);
  905. UA_Boolean testValue = true;
  906. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  907. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  908. wValue.attributeId = UA_ATTRIBUTEID_HISTORIZING;
  909. wValue.value.hasValue = true;
  910. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  911. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  912. UA_Server_delete(server);
  913. } END_TEST
  914. START_TEST(WriteSingleAttributeExecutable) {
  915. UA_Server *server = makeTestSequence();
  916. UA_WriteValue wValue;
  917. UA_WriteValue_init(&wValue);
  918. UA_Boolean testValue = true;
  919. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  920. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  921. wValue.attributeId = UA_ATTRIBUTEID_EXECUTABLE;
  922. wValue.value.hasValue = true;
  923. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  924. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  925. UA_Server_delete(server);
  926. } END_TEST
  927. START_TEST(WriteSingleAttributeUserExecutable) {
  928. UA_Server *server = makeTestSequence();
  929. UA_WriteValue wValue;
  930. UA_WriteValue_init(&wValue);
  931. UA_Boolean testValue = true;
  932. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  933. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  934. wValue.attributeId = UA_ATTRIBUTEID_USEREXECUTABLE;
  935. wValue.value.hasValue = true;
  936. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  937. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  938. UA_Server_delete(server);
  939. } END_TEST
  940. START_TEST(WriteSingleDataSourceAttributeValue) {
  941. UA_Server *server = makeTestSequence();
  942. UA_WriteValue wValue;
  943. UA_WriteValue_init(&wValue);
  944. UA_Int32 testValue = 0;
  945. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_INT32]);
  946. wValue.nodeId = UA_NODEID_STRING(1, "cpu.temperature");
  947. wValue.attributeId = UA_ATTRIBUTEID_VALUE;
  948. wValue.value.hasValue = true;
  949. UA_StatusCode retval = Service_Write_single(server, &adminSession, &wValue);
  950. ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
  951. UA_Server_delete(server);
  952. } END_TEST
  953. START_TEST(numericRange) {
  954. UA_NumericRange range;
  955. const UA_String str = (UA_String){9, (UA_Byte*)"1:2,0:3,5"};
  956. UA_StatusCode retval = parse_numericrange(&str, &range);
  957. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  958. ck_assert_int_eq(range.dimensionsSize,3);
  959. ck_assert_int_eq(range.dimensions[0].min,1);
  960. ck_assert_int_eq(range.dimensions[0].max,2);
  961. ck_assert_int_eq(range.dimensions[1].min,0);
  962. ck_assert_int_eq(range.dimensions[1].max,3);
  963. ck_assert_int_eq(range.dimensions[2].min,5);
  964. ck_assert_int_eq(range.dimensions[2].max,5);
  965. UA_free(range.dimensions);
  966. } END_TEST
  967. static Suite * testSuite_services_attributes(void) {
  968. Suite *s = suite_create("services_attributes_read");
  969. TCase *tc_readSingleAttributes = tcase_create("readSingleAttributes");
  970. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueWithoutTimestamp);
  971. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueRangeWithoutTimestamp);
  972. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeNodeIdWithoutTimestamp);
  973. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeNodeClassWithoutTimestamp);
  974. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeBrowseNameWithoutTimestamp);
  975. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDisplayNameWithoutTimestamp);
  976. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDescriptionWithoutTimestamp);
  977. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeWriteMaskWithoutTimestamp);
  978. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserWriteMaskWithoutTimestamp);
  979. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeIsAbstractWithoutTimestamp);
  980. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeSymmetricWithoutTimestamp);
  981. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeInverseNameWithoutTimestamp);
  982. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeContainsNoLoopsWithoutTimestamp);
  983. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeEventNotifierWithoutTimestamp);
  984. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDataTypeWithoutTimestamp);
  985. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueRankWithoutTimestamp);
  986. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeArrayDimensionsWithoutTimestamp);
  987. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeAccessLevelWithoutTimestamp);
  988. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserAccessLevelWithoutTimestamp);
  989. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp);
  990. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeHistorizingWithoutTimestamp);
  991. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeExecutableWithoutTimestamp);
  992. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserExecutableWithoutTimestamp);
  993. tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeDataTypeWithoutTimestampFromBrokenSource);
  994. tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeValueWithoutTimestamp);
  995. tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeDataTypeWithoutTimestamp);
  996. tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeArrayDimensionsWithoutTimestamp);
  997. suite_add_tcase(s, tc_readSingleAttributes);
  998. TCase *tc_writeSingleAttributes = tcase_create("writeSingleAttributes");
  999. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeNodeId);
  1000. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeNodeclass);
  1001. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeBrowseName);
  1002. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDisplayName);
  1003. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDescription);
  1004. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeWriteMask);
  1005. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeUserWriteMask);
  1006. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeIsAbstract);
  1007. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeSymmetric);
  1008. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeInverseName);
  1009. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeContainsNoLoops);
  1010. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeEventNotifier);
  1011. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValue);
  1012. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDataType);
  1013. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValueRank);
  1014. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeArrayDimensions);
  1015. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeAccessLevel);
  1016. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeUserAccessLevel);
  1017. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeMinimumSamplingInterval);
  1018. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeHistorizing);
  1019. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeExecutable);
  1020. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeUserExecutable);
  1021. tcase_add_test(tc_writeSingleAttributes, WriteSingleDataSourceAttributeValue);
  1022. suite_add_tcase(s, tc_writeSingleAttributes);
  1023. TCase *tc_parseNumericRange = tcase_create("parseNumericRange");
  1024. tcase_add_test(tc_parseNumericRange, numericRange);
  1025. suite_add_tcase(s, tc_parseNumericRange);
  1026. return s;
  1027. }
  1028. int main(void) {
  1029. int number_failed = 0;
  1030. Suite *s;
  1031. s = testSuite_services_attributes();
  1032. SRunner *sr = srunner_create(s);
  1033. srunner_set_fork_status(sr, CK_NOFORK);
  1034. srunner_run_all(sr, CK_NORMAL);
  1035. number_failed += srunner_ntests_failed(sr);
  1036. srunner_free(sr);
  1037. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  1038. }