check_services_attributes.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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. //#include "server/ua_services_attribute.c"
  14. #ifdef UA_MULTITHREADING
  15. #include <pthread.h>
  16. #include <urcu.h>
  17. #endif
  18. static void copyNames(UA_Node *node, char *name) {
  19. node->browseName = UA_QUALIFIEDNAME_ALLOC(0, name);
  20. node->displayName = UA_LOCALIZEDTEXT_ALLOC("", name);
  21. node->description = UA_LOCALIZEDTEXT_ALLOC("", name);
  22. }
  23. static UA_Server* makeTestSequence(void) {
  24. UA_Server *server = UA_Server_new(UA_ServerConfig_standard);
  25. /* VariableNode */
  26. UA_Variant *myIntegerVariant = UA_Variant_new();
  27. UA_Int32 myInteger = 42;
  28. UA_Variant_setScalarCopy(myIntegerVariant, &myInteger,
  29. &UA_TYPES[UA_TYPES_INT32]);
  30. const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  31. const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  32. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  33. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  34. UA_Server_addVariableNode(server, myIntegerVariant, myIntegerName,
  35. myIntegerNodeId, parentNodeId, parentReferenceNodeId);
  36. /* ObjectNode */
  37. UA_Server_addObjectNode(server,UA_QUALIFIEDNAME(1, "Demo"), UA_NODEID_NUMERIC(1, 50), UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES), UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  38. /* ReferenceTypeNode */
  39. UA_ReferenceTypeNode *hierarchicalreferences = UA_ReferenceTypeNode_new();
  40. copyNames((UA_Node*)hierarchicalreferences, "Hierarchicalreferences");
  41. hierarchicalreferences->nodeId.identifier.numeric = UA_NS0ID_HIERARCHICALREFERENCES;
  42. hierarchicalreferences->isAbstract = UA_TRUE;
  43. hierarchicalreferences->symmetric = UA_FALSE;
  44. hierarchicalreferences->inverseName = UA_LOCALIZEDTEXT("", "test");
  45. UA_Server_addNode(server, (UA_Node*)hierarchicalreferences,
  46. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_REFERENCES),
  47. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  48. /* ViewNode */
  49. UA_ViewNode *viewtest = UA_ViewNode_new();
  50. copyNames((UA_Node*)viewtest, "Viewtest");
  51. viewtest->nodeId.identifier.numeric = UA_NS0ID_VIEWNODE;
  52. UA_Server_addNode(server, (UA_Node*)viewtest,
  53. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_VIEWSFOLDER),
  54. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  55. /* MethodNode */
  56. UA_MethodNode *methodtest = UA_MethodNode_new();
  57. copyNames((UA_Node*)methodtest, "Methodtest");
  58. methodtest->nodeId.identifier.numeric = UA_NS0ID_METHODNODE;
  59. UA_Server_addNode(server, (UA_Node*)methodtest,
  60. UA_EXPANDEDNODEID_NUMERIC(0, 3),
  61. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  62. return server;
  63. }
  64. static UA_VariableNode* makeCompareSequence(void) {
  65. UA_VariableNode *node = UA_VariableNode_new();
  66. UA_Variant *myIntegerVariant = UA_Variant_new();
  67. UA_Int32 myInteger = 42;
  68. UA_Variant_setScalarCopy(myIntegerVariant, &myInteger,
  69. &UA_TYPES[UA_TYPES_INT32]);
  70. const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  71. const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  72. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  73. //UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  74. node->value.variant=*myIntegerVariant;
  75. UA_NodeId_copy(&myIntegerNodeId,&node->nodeId);
  76. UA_QualifiedName_copy(&myIntegerName,&node->browseName);
  77. UA_String_copy(&myIntegerName.name,&node->displayName.text);
  78. UA_ExpandedNodeId parentId;
  79. UA_ExpandedNodeId_init(&parentId);
  80. UA_NodeId_copy(&parentNodeId,&parentId.nodeId);
  81. return node;
  82. }
  83. START_TEST(ReadSingleAttributeValueWithoutTimestamp)
  84. {
  85. UA_Server *server = makeTestSequence();
  86. UA_DataValue resp;
  87. UA_DataValue_init(&resp);
  88. UA_ReadRequest rReq;
  89. UA_ReadRequest_init(&rReq);
  90. rReq.nodesToRead = UA_ReadValueId_new();
  91. rReq.nodesToReadSize = 1;
  92. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  93. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
  94. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  95. &resp);
  96. ck_assert_int_eq(-1, resp.value.arrayLength);
  97. ck_assert_int_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  98. ck_assert_int_eq(42, *(UA_Int32* )resp.value.data);
  99. }END_TEST
  100. START_TEST(ReadSingleAttributeNodeIdWithoutTimestamp)
  101. {
  102. UA_Server *server = makeTestSequence();
  103. UA_DataValue resp;
  104. UA_DataValue_init(&resp);
  105. UA_ReadRequest rReq;
  106. UA_ReadRequest_init(&rReq);
  107. rReq.nodesToRead = UA_ReadValueId_new();
  108. rReq.nodesToReadSize = 1;
  109. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  110. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_NODEID;
  111. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  112. &resp);
  113. UA_NodeId* respval;
  114. respval = (UA_NodeId*) resp.value.data;
  115. const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  116. ck_assert_int_eq(-1, resp.value.arrayLength);
  117. ck_assert_int_eq(&UA_TYPES[UA_TYPES_NODEID], resp.value.type);
  118. ck_assert_int_eq(1, respval->namespaceIndex);
  119. for (int var = 0; var < respval->identifier.string.length; ++var) {
  120. ck_assert_int_eq(myIntegerNodeId.identifier.string.data[var],
  121. respval->identifier.string.data[var]);
  122. }
  123. UA_free(respval);
  124. }END_TEST
  125. START_TEST(ReadSingleAttributeNodeClassWithoutTimestamp)
  126. {
  127. UA_Server *server = makeTestSequence();
  128. UA_DataValue resp;
  129. UA_DataValue_init(&resp);
  130. UA_ReadRequest rReq;
  131. UA_ReadRequest_init(&rReq);
  132. rReq.nodesToRead = UA_ReadValueId_new();
  133. rReq.nodesToReadSize = 1;
  134. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  135. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_NODECLASS;
  136. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  137. &resp);
  138. ck_assert_int_eq(-1, resp.value.arrayLength);
  139. //ck_assert_int_eq(&UA_TYPES[UA_TYPES_NODECLASS],resp.value.type);
  140. }END_TEST
  141. START_TEST(ReadSingleAttributeBrowseNameWithoutTimestamp)
  142. {
  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(1, "the.answer");
  151. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_BROWSENAME;
  152. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  153. &resp);
  154. UA_QualifiedName* respval;
  155. respval = (UA_QualifiedName*) resp.value.data;
  156. const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1,
  157. "the answer");
  158. ck_assert_int_eq(-1, resp.value.arrayLength);
  159. ck_assert_int_eq(&UA_TYPES[UA_TYPES_QUALIFIEDNAME], resp.value.type);
  160. ck_assert_int_eq(1, respval->namespaceIndex);
  161. ck_assert_int_eq(myIntegerName.name.length, respval->name.length);
  162. for (int var = 0; var < respval->name.length - 1; ++var) {
  163. ck_assert_int_eq(myIntegerName.name.data[var],
  164. respval->name.data[var]);
  165. }
  166. UA_free(respval);
  167. }END_TEST
  168. START_TEST(ReadSingleAttributeDisplayNameWithoutTimestamp)
  169. {
  170. UA_Server *server = makeTestSequence();
  171. UA_DataValue resp;
  172. UA_DataValue_init(&resp);
  173. UA_ReadRequest rReq;
  174. UA_ReadRequest_init(&rReq);
  175. rReq.nodesToRead = UA_ReadValueId_new();
  176. rReq.nodesToReadSize = 1;
  177. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  178. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DISPLAYNAME;
  179. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  180. &resp);
  181. UA_LocalizedText* respval;
  182. respval = (UA_LocalizedText*) resp.value.data;
  183. const UA_LocalizedText comp = UA_LOCALIZEDTEXT("locale", "the answer");
  184. UA_VariableNode* compNode = makeCompareSequence();
  185. ck_assert_int_eq(-1, resp.value.arrayLength);
  186. ck_assert_int_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT], resp.value.type);
  187. ck_assert_int_eq(comp.text.length, respval->text.length);
  188. for (int var = 0; var < respval->text.length - 1; ++var) {
  189. ck_assert_int_eq(comp.text.data[var], respval->text.data[var]);
  190. }
  191. ck_assert_int_eq(compNode->displayName.locale.length, respval->locale.length);
  192. for (int var = 0; var < respval->locale.length - 1; ++var) {
  193. ck_assert_int_eq(compNode->displayName.locale.data[var], respval->locale.data[var]);
  194. }
  195. UA_free(respval);
  196. }END_TEST
  197. START_TEST(ReadSingleAttributeDescriptionWithoutTimestamp)
  198. {
  199. UA_Server *server = makeTestSequence();
  200. UA_DataValue resp;
  201. UA_DataValue_init(&resp);
  202. UA_ReadRequest rReq;
  203. UA_ReadRequest_init(&rReq);
  204. rReq.nodesToRead = UA_ReadValueId_new();
  205. rReq.nodesToReadSize = 1;
  206. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  207. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DESCRIPTION;
  208. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  209. &resp);
  210. UA_LocalizedText* respval;
  211. respval = (UA_LocalizedText*) resp.value.data;
  212. UA_VariableNode* compNode = makeCompareSequence();
  213. ck_assert_int_eq(-1, resp.value.arrayLength);
  214. ck_assert_int_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT], resp.value.type);
  215. ck_assert_int_eq(compNode->description.locale.length, respval->locale.length);
  216. for (int var = 0; var < respval->locale.length - 1; ++var) {
  217. ck_assert_int_eq(compNode->description.locale.data[var], respval->locale.data[var]);
  218. }
  219. ck_assert_int_eq(compNode->description.text.length, respval->text.length);
  220. for (int var = 0; var < respval->text.length - 1; ++var) {
  221. ck_assert_int_eq(compNode->description.text.data[var], respval->text.data[var]);
  222. }
  223. UA_free(respval);
  224. }END_TEST
  225. START_TEST(ReadSingleAttributeWriteMaskWithoutTimestamp)
  226. {
  227. UA_Server *server = makeTestSequence();
  228. UA_DataValue resp;
  229. UA_DataValue_init(&resp);
  230. UA_ReadRequest rReq;
  231. UA_ReadRequest_init(&rReq);
  232. rReq.nodesToRead = UA_ReadValueId_new();
  233. rReq.nodesToReadSize = 1;
  234. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  235. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_WRITEMASK;
  236. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  237. &resp);
  238. //UA_UInt32* respval;
  239. //respval = (UA_UInt32*) resp.value.data;
  240. //UA_VariableNode* compNode = makeCompareSequence();
  241. ck_assert_int_eq(-1, resp.value.arrayLength);
  242. ck_assert_int_eq(&UA_TYPES[UA_TYPES_UINT32], resp.value.type);
  243. //ck_assert_int_eq(*(UA_UInt32* )compNode->writeMask,respval);
  244. }END_TEST
  245. START_TEST(ReadSingleAttributeUserWriteMaskWithoutTimestamp)
  246. {
  247. UA_Server *server = makeTestSequence();
  248. UA_DataValue resp;
  249. UA_DataValue_init(&resp);
  250. UA_ReadRequest rReq;
  251. UA_ReadRequest_init(&rReq);
  252. rReq.nodesToRead = UA_ReadValueId_new();
  253. rReq.nodesToReadSize = 1;
  254. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  255. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USERWRITEMASK;
  256. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  257. &resp);
  258. ck_assert_int_eq(-1, resp.value.arrayLength);
  259. ck_assert_int_eq(&UA_TYPES[UA_TYPES_UINT32], resp.value.type);
  260. }END_TEST
  261. START_TEST(ReadSingleAttributeIsAbstractWithoutTimestamp)
  262. {
  263. UA_Server *server = makeTestSequence();
  264. UA_DataValue resp;
  265. UA_DataValue_init(&resp);
  266. UA_ReadRequest rReq;
  267. UA_ReadRequest_init(&rReq);
  268. rReq.nodesToRead = UA_ReadValueId_new();
  269. rReq.nodesToReadSize = 1;
  270. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_HIERARCHICALREFERENCES;
  271. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ISABSTRACT;
  272. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  273. &resp);
  274. ck_assert_int_eq(-1, resp.value.arrayLength);
  275. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  276. ck_assert(*(UA_Boolean* )resp.value.data==UA_TRUE);
  277. }END_TEST
  278. START_TEST(ReadSingleAttributeSymmetricWithoutTimestamp)
  279. {
  280. UA_Server *server = makeTestSequence();
  281. UA_DataValue resp;
  282. UA_DataValue_init(&resp);
  283. UA_ReadRequest rReq;
  284. UA_ReadRequest_init(&rReq);
  285. rReq.nodesToRead = UA_ReadValueId_new();
  286. rReq.nodesToReadSize = 1;
  287. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_HIERARCHICALREFERENCES;
  288. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_SYMMETRIC;
  289. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  290. &resp);
  291. ck_assert_int_eq(-1, resp.value.arrayLength);
  292. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  293. ck_assert(*(UA_Boolean* )resp.value.data==UA_FALSE);
  294. }END_TEST
  295. START_TEST(ReadSingleAttributeInverseNameWithoutTimestamp)
  296. {
  297. UA_Server *server = makeTestSequence();
  298. UA_DataValue resp;
  299. UA_DataValue_init(&resp);
  300. UA_ReadRequest rReq;
  301. UA_ReadRequest_init(&rReq);
  302. rReq.nodesToRead = UA_ReadValueId_new();
  303. rReq.nodesToReadSize = 1;
  304. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_HIERARCHICALREFERENCES;
  305. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_INVERSENAME;
  306. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  307. &resp);
  308. /*UA_LocalizedText* respval;
  309. respval = (UA_LocalizedText*) resp.value.data;
  310. const UA_LocalizedText comp = UA_LOCALIZEDTEXT("", "test");
  311. */
  312. ck_assert_int_eq(-1, resp.value.arrayLength);
  313. ck_assert_int_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT],resp.value.type);
  314. /*ck_assert_int_eq(comp.text.length, respval->text.length);
  315. for (int var = 0; var < respval->text.length - 1; ++var) {
  316. ck_assert_int_eq(comp.text.data[var], respval->text.data[var]);
  317. }
  318. ck_assert_int_eq(comp.locale.length, respval->locale.length);
  319. for (int var = 0; var < respval->locale.length - 1; ++var) {
  320. ck_assert_int_eq(comp.locale.data[var], respval->locale.data[var]);
  321. }
  322. UA_free(respval);*/
  323. }END_TEST
  324. START_TEST(ReadSingleAttributeContainsNoLoopsWithoutTimestamp)
  325. {
  326. UA_Server *server = makeTestSequence();
  327. UA_DataValue resp;
  328. UA_DataValue_init(&resp);
  329. UA_ReadRequest rReq;
  330. UA_ReadRequest_init(&rReq);
  331. rReq.nodesToRead = UA_ReadValueId_new();
  332. rReq.nodesToReadSize = 1;
  333. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_VIEWNODE;
  334. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_CONTAINSNOLOOPS;
  335. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  336. &resp);
  337. ck_assert_int_eq(-1, resp.value.arrayLength);
  338. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  339. ck_assert(*(UA_Boolean* )resp.value.data==UA_FALSE);
  340. }END_TEST
  341. START_TEST(ReadSingleAttributeEventNotifierWithoutTimestamp)
  342. {
  343. UA_Server *server = makeTestSequence();
  344. UA_DataValue resp;
  345. UA_DataValue_init(&resp);
  346. UA_ReadRequest rReq;
  347. UA_ReadRequest_init(&rReq);
  348. rReq.nodesToRead = UA_ReadValueId_new();
  349. rReq.nodesToReadSize = 1;
  350. rReq.nodesToRead[0].nodeId = UA_NODEID_NUMERIC(1, 50);
  351. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_EVENTNOTIFIER;
  352. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  353. &resp);
  354. ck_assert_int_eq(-1, resp.value.arrayLength);
  355. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BYTE],resp.value.type);
  356. ck_assert_int_eq(*(UA_Byte*)resp.value.data, 0);
  357. }END_TEST
  358. START_TEST(ReadSingleAttributeDataTypeWithoutTimestamp)
  359. {
  360. UA_Server *server = makeTestSequence();
  361. UA_DataValue resp;
  362. UA_DataValue_init(&resp);
  363. UA_ReadRequest rReq;
  364. UA_ReadRequest_init(&rReq);
  365. rReq.nodesToRead = UA_ReadValueId_new();
  366. rReq.nodesToReadSize = 1;
  367. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  368. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DATATYPE;
  369. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  370. &resp);
  371. //UA_NodeId* respval;
  372. //respval = (UA_NodeId*) resp.value.data;
  373. //const UA_VariableNode compNode = makeCompareSequence();
  374. //const UA_NodeId comp = compNode;
  375. ck_assert_int_eq(-1, resp.value.arrayLength);
  376. ck_assert_int_eq(&UA_TYPES[UA_TYPES_NODEID], resp.value.type);
  377. }END_TEST
  378. START_TEST(ReadSingleAttributeValueRankWithoutTimestamp)
  379. {
  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_STRING(1, "the.answer");
  388. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUERANK;
  389. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  390. &resp);
  391. ck_assert_int_eq(-1, resp.value.arrayLength);
  392. ck_assert_int_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  393. ck_assert_int_eq(-2, *(UA_Int32* )resp.value.data);
  394. }END_TEST
  395. START_TEST(ReadSingleAttributeArrayDimensionsWithoutTimestamp)
  396. {
  397. UA_Server *server = makeTestSequence();
  398. UA_DataValue resp;
  399. UA_DataValue_init(&resp);
  400. UA_ReadRequest rReq;
  401. UA_ReadRequest_init(&rReq);
  402. rReq.nodesToRead = UA_ReadValueId_new();
  403. rReq.nodesToReadSize = 1;
  404. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  405. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
  406. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  407. &resp);
  408. ck_assert_int_eq(-1, resp.value.arrayLength);
  409. ck_assert_int_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  410. }END_TEST
  411. START_TEST(ReadSingleAttributeAccessLevelWithoutTimestamp)
  412. {
  413. UA_Server *server = makeTestSequence();
  414. UA_DataValue resp;
  415. UA_DataValue_init(&resp);
  416. UA_ReadRequest rReq;
  417. UA_ReadRequest_init(&rReq);
  418. rReq.nodesToRead = UA_ReadValueId_new();
  419. rReq.nodesToReadSize = 1;
  420. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  421. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ACCESSLEVEL;
  422. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  423. &resp);
  424. ck_assert_int_eq(-1, resp.value.arrayLength);
  425. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type);
  426. ck_assert_int_eq(*(UA_Byte*)resp.value.data, 0);
  427. }END_TEST
  428. START_TEST(ReadSingleAttributeUserAccessLevelWithoutTimestamp)
  429. {
  430. UA_Server *server = makeTestSequence();
  431. UA_DataValue resp;
  432. UA_DataValue_init(&resp);
  433. UA_ReadRequest rReq;
  434. UA_ReadRequest_init(&rReq);
  435. rReq.nodesToRead = UA_ReadValueId_new();
  436. rReq.nodesToReadSize = 1;
  437. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  438. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USERACCESSLEVEL;
  439. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  440. &resp);
  441. UA_VariableNode* compNode = makeCompareSequence();
  442. ck_assert_int_eq(-1, resp.value.arrayLength);
  443. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type);
  444. ck_assert_int_eq(*(UA_Byte*)resp.value.data, compNode->userAccessLevel);
  445. }END_TEST
  446. START_TEST(ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp)
  447. {
  448. UA_Server *server = makeTestSequence();
  449. UA_DataValue resp;
  450. UA_DataValue_init(&resp);
  451. UA_ReadRequest rReq;
  452. UA_ReadRequest_init(&rReq);
  453. rReq.nodesToRead = UA_ReadValueId_new();
  454. rReq.nodesToReadSize = 1;
  455. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  456. rReq.nodesToRead[0].attributeId =
  457. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL;
  458. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  459. &resp);
  460. //UA_Double* respval;
  461. //respval = (UA_Double*) resp.value.data;
  462. //UA_VariableNode* compNode = makeCompareSequence();
  463. ck_assert_int_eq(-1, resp.value.arrayLength);
  464. ck_assert_int_eq(&UA_TYPES[UA_TYPES_DOUBLE], resp.value.type);
  465. //ck_assert_int_eq(compNode->minimumSamplingInterval,respval);
  466. }END_TEST
  467. START_TEST(ReadSingleAttributeHistorizingWithoutTimestamp)
  468. {
  469. UA_Server *server = makeTestSequence();
  470. UA_DataValue resp;
  471. UA_DataValue_init(&resp);
  472. UA_ReadRequest rReq;
  473. UA_ReadRequest_init(&rReq);
  474. rReq.nodesToRead = UA_ReadValueId_new();
  475. rReq.nodesToReadSize = 1;
  476. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  477. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_HISTORIZING;
  478. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  479. &resp);
  480. ck_assert_int_eq(-1, resp.value.arrayLength);
  481. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  482. ck_assert(*(UA_Boolean* )resp.value.data==UA_FALSE);
  483. }END_TEST
  484. START_TEST(ReadSingleAttributeExecutableWithoutTimestamp)
  485. {
  486. UA_Server *server = makeTestSequence();
  487. UA_DataValue resp;
  488. UA_DataValue_init(&resp);
  489. UA_ReadRequest rReq;
  490. UA_ReadRequest_init(&rReq);
  491. rReq.nodesToRead = UA_ReadValueId_new();
  492. rReq.nodesToReadSize = 1;
  493. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  494. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_EXECUTABLE;
  495. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  496. ck_assert_int_eq(-1, resp.value.arrayLength);
  497. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  498. }END_TEST
  499. START_TEST(ReadSingleAttributeUserExecutableWithoutTimestamp)
  500. {
  501. UA_Server *server = makeTestSequence();
  502. UA_DataValue resp;
  503. UA_DataValue_init(&resp);
  504. UA_ReadRequest rReq;
  505. UA_ReadRequest_init(&rReq);
  506. rReq.nodesToRead = UA_ReadValueId_new();
  507. rReq.nodesToReadSize = 1;
  508. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer");
  509. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USEREXECUTABLE;
  510. readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0],
  511. &resp);
  512. ck_assert_int_eq(-1, resp.value.arrayLength);
  513. ck_assert_int_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  514. }END_TEST
  515. static Suite * testSuite_services_attributes(void) {
  516. Suite *s = suite_create("services_attributes_read");
  517. TCase *tc_readSingleAttributes = tcase_create("readSingleAttributes");
  518. tcase_add_test(tc_readSingleAttributes,
  519. ReadSingleAttributeValueWithoutTimestamp);
  520. tcase_add_test(tc_readSingleAttributes,
  521. ReadSingleAttributeNodeIdWithoutTimestamp);
  522. tcase_add_test(tc_readSingleAttributes,
  523. ReadSingleAttributeNodeClassWithoutTimestamp);
  524. tcase_add_test(tc_readSingleAttributes,
  525. ReadSingleAttributeBrowseNameWithoutTimestamp);
  526. tcase_add_test(tc_readSingleAttributes,
  527. ReadSingleAttributeDisplayNameWithoutTimestamp);
  528. tcase_add_test(tc_readSingleAttributes,
  529. ReadSingleAttributeDescriptionWithoutTimestamp);
  530. tcase_add_test(tc_readSingleAttributes,
  531. ReadSingleAttributeWriteMaskWithoutTimestamp);
  532. tcase_add_test(tc_readSingleAttributes,
  533. ReadSingleAttributeUserWriteMaskWithoutTimestamp);
  534. tcase_add_test(tc_readSingleAttributes,
  535. ReadSingleAttributeIsAbstractWithoutTimestamp);
  536. tcase_add_test(tc_readSingleAttributes,
  537. ReadSingleAttributeSymmetricWithoutTimestamp);
  538. tcase_add_test(tc_readSingleAttributes,
  539. ReadSingleAttributeInverseNameWithoutTimestamp);
  540. tcase_add_test(tc_readSingleAttributes,
  541. ReadSingleAttributeContainsNoLoopsWithoutTimestamp);
  542. tcase_add_test(tc_readSingleAttributes,
  543. ReadSingleAttributeEventNotifierWithoutTimestamp);
  544. tcase_add_test(tc_readSingleAttributes,
  545. ReadSingleAttributeDataTypeWithoutTimestamp);
  546. tcase_add_test(tc_readSingleAttributes,
  547. ReadSingleAttributeValueRankWithoutTimestamp);
  548. tcase_add_test(tc_readSingleAttributes,
  549. ReadSingleAttributeArrayDimensionsWithoutTimestamp);
  550. tcase_add_test(tc_readSingleAttributes,
  551. ReadSingleAttributeAccessLevelWithoutTimestamp);
  552. tcase_add_test(tc_readSingleAttributes,
  553. ReadSingleAttributeUserAccessLevelWithoutTimestamp);
  554. tcase_add_test(tc_readSingleAttributes,
  555. ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp);
  556. tcase_add_test(tc_readSingleAttributes,
  557. ReadSingleAttributeHistorizingWithoutTimestamp);
  558. tcase_add_test(tc_readSingleAttributes,
  559. ReadSingleAttributeExecutableWithoutTimestamp);
  560. tcase_add_test(tc_readSingleAttributes,
  561. ReadSingleAttributeUserExecutableWithoutTimestamp);
  562. suite_add_tcase(s, tc_readSingleAttributes);
  563. return s;
  564. }
  565. int main(void) {
  566. int number_failed = 0;
  567. Suite *s;
  568. s = testSuite_services_attributes();
  569. SRunner *sr = srunner_create(s);
  570. srunner_set_log(sr, "test.log");
  571. void srunner_set_fork_status(SRunner * sr, enum fork_status CK_NOFORK);
  572. srunner_run_all(sr, CK_NORMAL);
  573. number_failed += srunner_ntests_failed(sr);
  574. srunner_free(sr);
  575. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  576. }