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