check_services_attributes.c 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  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. static UA_StatusCode
  17. readCPUTemperature(void *handle, const UA_NodeId nodeid, UA_Boolean sourceTimeStamp,
  18. const UA_NumericRange *range, UA_DataValue *dataValue) {
  19. UA_Float temp = 20.5f;
  20. UA_Variant_setScalarCopy(&dataValue->value, &temp, &UA_TYPES[UA_TYPES_FLOAT]);
  21. dataValue->hasValue = true;
  22. return UA_STATUSCODE_GOOD;
  23. }
  24. static UA_Server *
  25. makeTestSequence(void) {
  26. UA_Server * server = UA_Server_new(UA_ServerConfig_standard);
  27. UA_StatusCode retval = UA_STATUSCODE_GOOD;
  28. /* VariableNode */
  29. UA_VariableAttributes vattr;
  30. UA_VariableAttributes_init(&vattr);
  31. UA_Int32 myInteger = 42;
  32. UA_Variant_setScalar(&vattr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  33. vattr.description = UA_LOCALIZEDTEXT("locale","the answer");
  34. vattr.displayName = UA_LOCALIZEDTEXT("locale","the answer");
  35. vattr.valueRank = -2;
  36. UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
  37. UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
  38. UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  39. UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  40. retval = UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  41. parentReferenceNodeId, myIntegerName,
  42. UA_NODEID_NULL, vattr, NULL, NULL);
  43. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  44. /* DataSource VariableNode */
  45. UA_VariableAttributes_init(&vattr);
  46. UA_DataSource temperatureDataSource =
  47. (UA_DataSource) {.handle = NULL, .read = readCPUTemperature, .write = NULL};
  48. vattr.description = UA_LOCALIZEDTEXT("en_US","temperature");
  49. vattr.displayName = UA_LOCALIZEDTEXT("en_US","temperature");
  50. retval = UA_Server_addDataSourceVariableNode(server, UA_NODEID_STRING(1, "cpu.temperature"),
  51. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  52. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  53. UA_QUALIFIEDNAME(1, "cpu temperature"),
  54. UA_NODEID_NULL, vattr, temperatureDataSource, NULL);
  55. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  56. /* VariableNode with array */
  57. UA_VariableAttributes_init(&vattr);
  58. UA_Int32 myIntegerArray[9] = {1,2,3,4,5,6,7,8,9};
  59. UA_Variant_setArray(&vattr.value, &myIntegerArray, 9, &UA_TYPES[UA_TYPES_INT32]);
  60. vattr.valueRank = -2;
  61. UA_UInt32 myIntegerDimensions[2] = {3,3};
  62. vattr.value.arrayDimensions = myIntegerDimensions;
  63. vattr.value.arrayDimensionsSize = 2;
  64. vattr.displayName = UA_LOCALIZEDTEXT("locale","myarray");
  65. myIntegerName = UA_QUALIFIEDNAME(1, "myarray");
  66. myIntegerNodeId = UA_NODEID_STRING(1, "myarray");
  67. parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
  68. parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
  69. retval = UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
  70. parentReferenceNodeId, myIntegerName,
  71. UA_NODEID_NULL, vattr, NULL, NULL);
  72. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  73. /* ObjectNode */
  74. UA_ObjectAttributes obj_attr;
  75. UA_ObjectAttributes_init(&obj_attr);
  76. obj_attr.description = UA_LOCALIZEDTEXT("en_US","Demo");
  77. obj_attr.displayName = UA_LOCALIZEDTEXT("en_US","Demo");
  78. retval = UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, 50),
  79. UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  80. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  81. UA_QUALIFIEDNAME(1, "Demo"),
  82. UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE),
  83. obj_attr, NULL, NULL);
  84. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  85. /* ViewNode */
  86. UA_ViewAttributes view_attr;
  87. UA_ViewAttributes_init(&view_attr);
  88. view_attr.description = UA_LOCALIZEDTEXT("en_US", "Viewtest");
  89. view_attr.displayName = UA_LOCALIZEDTEXT("en_US", "Viewtest");
  90. retval = UA_Server_addViewNode(server, UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWNODE),
  91. UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWSFOLDER),
  92. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  93. UA_QUALIFIEDNAME(0, "Viewtest"), view_attr, NULL, NULL);
  94. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  95. #ifdef UA_ENABLE_METHODCALLS
  96. /* MethodNode */
  97. UA_MethodAttributes ma;
  98. UA_MethodAttributes_init(&ma);
  99. ma.description = UA_LOCALIZEDTEXT("en_US", "Methodtest");
  100. ma.displayName = UA_LOCALIZEDTEXT("en_US", "Methodtest");
  101. retval = UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(0, UA_NS0ID_METHODNODE),
  102. UA_NODEID_NUMERIC(0, 3),
  103. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  104. UA_QUALIFIEDNAME(0, "Methodtest"), ma,
  105. NULL, NULL, 0, NULL, 0, NULL, NULL);
  106. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  107. #endif
  108. return server;
  109. }
  110. static UA_VariableNode* makeCompareSequence(void) {
  111. UA_VariableNode *node = UA_NodeStore_newVariableNode();
  112. UA_Int32 myInteger = 42;
  113. UA_Variant_setScalarCopy(&node->value.data.value.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  114. node->value.data.value.hasValue = true;
  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(resp.status, UA_STATUSCODE_GOOD);
  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_NODECLASS],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==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==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==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. ck_assert_int_eq(0, resp.value.arrayLength);
  410. ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
  411. ck_assert_int_eq(true, resp.hasValue);
  412. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_NODEID], resp.value.type);
  413. UA_NodeId* respval = (UA_NodeId*)resp.value.data;
  414. ck_assert_int_eq(respval->namespaceIndex,0);
  415. ck_assert_int_eq(respval->identifier.numeric, UA_NS0ID_BASEDATATYPE);
  416. UA_ReadRequest_deleteMembers(&rReq);
  417. UA_DataValue_deleteMembers(&resp);
  418. UA_Server_delete(server);
  419. } END_TEST
  420. START_TEST(ReadSingleAttributeValueRankWithoutTimestamp) {
  421. UA_Server *server = makeTestSequence();
  422. UA_DataValue resp;
  423. UA_DataValue_init(&resp);
  424. UA_ReadRequest rReq;
  425. UA_ReadRequest_init(&rReq);
  426. rReq.nodesToRead = UA_ReadValueId_new();
  427. rReq.nodesToReadSize = 1;
  428. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  429. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUERANK;
  430. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  431. ck_assert_int_eq(0, resp.value.arrayLength);
  432. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  433. ck_assert_int_eq(-2, *(UA_Int32* )resp.value.data);
  434. UA_ReadRequest_deleteMembers(&rReq);
  435. UA_DataValue_deleteMembers(&resp);
  436. UA_Server_delete(server);
  437. } END_TEST
  438. START_TEST(ReadSingleAttributeArrayDimensionsWithoutTimestamp) {
  439. UA_Server *server = makeTestSequence();
  440. UA_DataValue resp;
  441. UA_DataValue_init(&resp);
  442. UA_ReadRequest rReq;
  443. UA_ReadRequest_init(&rReq);
  444. rReq.nodesToRead = UA_ReadValueId_new();
  445. rReq.nodesToReadSize = 1;
  446. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  447. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
  448. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  449. ck_assert_int_eq(0, resp.value.arrayLength);
  450. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
  451. ck_assert_ptr_eq((UA_Int32*)resp.value.data,0);
  452. UA_DataValue_deleteMembers(&resp);
  453. UA_ReadRequest_deleteMembers(&rReq);
  454. UA_Server_delete(server);
  455. } END_TEST
  456. START_TEST(ReadSingleAttributeAccessLevelWithoutTimestamp) {
  457. UA_Server *server = makeTestSequence();
  458. UA_DataValue resp;
  459. UA_DataValue_init(&resp);
  460. UA_ReadRequest rReq;
  461. UA_ReadRequest_init(&rReq);
  462. rReq.nodesToRead = UA_ReadValueId_new();
  463. rReq.nodesToReadSize = 1;
  464. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  465. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ACCESSLEVEL;
  466. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  467. ck_assert_int_eq(0, resp.value.arrayLength);
  468. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type);
  469. ck_assert_int_eq(*(UA_Byte*)resp.value.data, 0);
  470. UA_DataValue_deleteMembers(&resp);
  471. UA_ReadRequest_deleteMembers(&rReq);
  472. UA_Server_delete(server);
  473. } END_TEST
  474. START_TEST(ReadSingleAttributeUserAccessLevelWithoutTimestamp) {
  475. UA_Server *server = makeTestSequence();
  476. UA_DataValue resp;
  477. UA_DataValue_init(&resp);
  478. UA_ReadRequest rReq;
  479. UA_ReadRequest_init(&rReq);
  480. rReq.nodesToRead = UA_ReadValueId_new();
  481. rReq.nodesToReadSize = 1;
  482. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  483. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USERACCESSLEVEL;
  484. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  485. const UA_VariableNode* compNode =
  486. (const UA_VariableNode*)UA_NodeStore_get(server->nodestore, &rReq.nodesToRead[0].nodeId);
  487. ck_assert_int_eq(0, resp.value.arrayLength);
  488. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type);
  489. ck_assert_int_eq(*(UA_Byte*)resp.value.data, compNode->userAccessLevel);
  490. UA_Server_delete(server);
  491. UA_DataValue_deleteMembers(&resp);
  492. UA_ReadRequest_deleteMembers(&rReq);
  493. } END_TEST
  494. START_TEST(ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp) {
  495. UA_Server *server = makeTestSequence();
  496. UA_DataValue resp;
  497. UA_DataValue_init(&resp);
  498. UA_ReadRequest rReq;
  499. UA_ReadRequest_init(&rReq);
  500. rReq.nodesToRead = UA_ReadValueId_new();
  501. rReq.nodesToReadSize = 1;
  502. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  503. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL;
  504. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  505. UA_Double* respval = (UA_Double*) resp.value.data;
  506. UA_VariableNode *compNode = makeCompareSequence();
  507. UA_Double comp = (UA_Double) compNode->minimumSamplingInterval;
  508. ck_assert_int_eq(0, resp.value.arrayLength);
  509. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_DOUBLE], resp.value.type);
  510. ck_assert(*respval == comp);
  511. UA_DataValue_deleteMembers(&resp);
  512. UA_ReadRequest_deleteMembers(&rReq);
  513. UA_NodeStore_deleteNode((UA_Node*)compNode);
  514. UA_Server_delete(server);
  515. } END_TEST
  516. START_TEST(ReadSingleAttributeHistorizingWithoutTimestamp) {
  517. UA_Server *server = makeTestSequence();
  518. UA_DataValue resp;
  519. UA_DataValue_init(&resp);
  520. UA_ReadRequest rReq;
  521. UA_ReadRequest_init(&rReq);
  522. rReq.nodesToRead = UA_ReadValueId_new();
  523. rReq.nodesToReadSize = 1;
  524. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.answer");
  525. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_HISTORIZING;
  526. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  527. ck_assert_int_eq(0, resp.value.arrayLength);
  528. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  529. ck_assert(*(UA_Boolean*)resp.value.data==false);
  530. UA_ReadRequest_deleteMembers(&rReq);
  531. UA_DataValue_deleteMembers(&resp);
  532. UA_Server_delete(server);
  533. } END_TEST
  534. START_TEST(ReadSingleAttributeExecutableWithoutTimestamp) {
  535. #ifdef UA_ENABLE_METHODCALLS
  536. UA_Server *server = makeTestSequence();
  537. UA_DataValue resp;
  538. UA_DataValue_init(&resp);
  539. UA_ReadRequest rReq;
  540. UA_ReadRequest_init(&rReq);
  541. rReq.nodesToRead = UA_ReadValueId_new();
  542. rReq.nodesToReadSize = 1;
  543. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_METHODNODE;
  544. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_EXECUTABLE;
  545. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  546. ck_assert_int_eq(0, resp.value.arrayLength);
  547. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  548. ck_assert(*(UA_Boolean*)resp.value.data==false);
  549. UA_DataValue_deleteMembers(&resp);
  550. UA_ReadRequest_deleteMembers(&rReq);
  551. UA_Server_delete(server);
  552. #endif
  553. } END_TEST
  554. START_TEST(ReadSingleAttributeUserExecutableWithoutTimestamp) {
  555. #ifdef UA_ENABLE_METHODCALLS
  556. UA_Server *server = makeTestSequence();
  557. UA_DataValue resp;
  558. UA_DataValue_init(&resp);
  559. UA_ReadRequest rReq;
  560. UA_ReadRequest_init(&rReq);
  561. rReq.nodesToRead = UA_ReadValueId_new();
  562. rReq.nodesToReadSize = 1;
  563. rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_METHODNODE;
  564. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USEREXECUTABLE;
  565. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  566. ck_assert_int_eq(0, resp.value.arrayLength);
  567. ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
  568. ck_assert(*(UA_Boolean*)resp.value.data==false);
  569. UA_DataValue_deleteMembers(&resp);
  570. UA_ReadRequest_deleteMembers(&rReq);
  571. UA_Server_delete(server);
  572. #endif
  573. } END_TEST
  574. START_TEST(ReadSingleDataSourceAttributeValueWithoutTimestamp) {
  575. UA_Server *server = makeTestSequence();
  576. UA_DataValue resp;
  577. UA_DataValue_init(&resp);
  578. UA_ReadRequest rReq;
  579. UA_ReadRequest_init(&rReq);
  580. rReq.nodesToRead = UA_ReadValueId_new();
  581. rReq.nodesToReadSize = 1;
  582. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "cpu.temperature");
  583. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
  584. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  585. ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
  586. UA_Server_delete(server);
  587. UA_ReadRequest_deleteMembers(&rReq);
  588. UA_DataValue_deleteMembers(&resp);
  589. } END_TEST
  590. START_TEST(ReadSingleDataSourceAttributeDataTypeWithoutTimestamp) {
  591. UA_Server *server = makeTestSequence();
  592. UA_DataValue resp;
  593. UA_DataValue_init(&resp);
  594. UA_ReadRequest rReq;
  595. UA_ReadRequest_init(&rReq);
  596. rReq.nodesToRead = UA_ReadValueId_new();
  597. rReq.nodesToReadSize = 1;
  598. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "cpu.temperature");
  599. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_DATATYPE;
  600. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  601. ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
  602. ck_assert_int_eq(resp.hasServerTimestamp, false);
  603. UA_Server_delete(server);
  604. UA_ReadRequest_deleteMembers(&rReq);
  605. UA_DataValue_deleteMembers(&resp);
  606. } END_TEST
  607. START_TEST (ReadSingleDataSourceAttributeArrayDimensionsWithoutTimestamp) {
  608. UA_Server *server = makeTestSequence();
  609. UA_DataValue resp;
  610. UA_DataValue_init(&resp);
  611. UA_ReadRequest rReq;
  612. UA_ReadRequest_init(&rReq);
  613. rReq.nodesToRead = UA_ReadValueId_new();
  614. rReq.nodesToReadSize = 1;
  615. rReq.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "cpu.temperature");
  616. rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
  617. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp);
  618. ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
  619. UA_Server_delete(server);
  620. UA_ReadRequest_deleteMembers(&rReq);
  621. UA_DataValue_deleteMembers(&resp);
  622. } END_TEST
  623. /* Tests for writeValue method */
  624. START_TEST(WriteSingleAttributeNodeId) {
  625. UA_Server *server = makeTestSequence();
  626. UA_WriteValue wValue;
  627. UA_WriteValue_init(&wValue);
  628. UA_NodeId id;
  629. UA_NodeId_init(&id);
  630. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  631. wValue.attributeId = UA_ATTRIBUTEID_NODEID;
  632. wValue.value.hasValue = true;
  633. UA_Variant_setScalar(&wValue.value.value, &id, &UA_TYPES[UA_TYPES_NODEID]);
  634. UA_StatusCode retval = UA_Server_write(server, &wValue);
  635. ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
  636. UA_Server_delete(server);
  637. } END_TEST
  638. START_TEST(WriteSingleAttributeNodeclass) {
  639. UA_Server *server = makeTestSequence();
  640. UA_WriteValue wValue;
  641. UA_WriteValue_init(&wValue);
  642. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  643. UA_NodeClass class;
  644. UA_NodeClass_init(&class);
  645. wValue.attributeId = UA_ATTRIBUTEID_NODECLASS;
  646. wValue.value.hasValue = true;
  647. UA_Variant_setScalar(&wValue.value.value, &class, &UA_TYPES[UA_TYPES_NODECLASS]);
  648. UA_StatusCode retval = UA_Server_write(server, &wValue);
  649. ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
  650. UA_Server_delete(server);
  651. } END_TEST
  652. START_TEST(WriteSingleAttributeBrowseName) {
  653. UA_Server *server = makeTestSequence();
  654. UA_WriteValue wValue;
  655. UA_WriteValue_init(&wValue);
  656. UA_QualifiedName testValue = UA_QUALIFIEDNAME(1, "the.answer");
  657. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
  658. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  659. wValue.attributeId = UA_ATTRIBUTEID_BROWSENAME;
  660. wValue.value.hasValue = true;
  661. UA_StatusCode retval = UA_Server_write(server, &wValue);
  662. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  663. UA_Server_delete(server);
  664. } END_TEST
  665. START_TEST(WriteSingleAttributeDisplayName) {
  666. UA_Server *server = makeTestSequence();
  667. UA_WriteValue wValue;
  668. UA_WriteValue_init(&wValue);
  669. UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_EN", "the.answer");
  670. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  671. wValue.value.hasValue = true;
  672. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  673. wValue.attributeId = UA_ATTRIBUTEID_DISPLAYNAME;
  674. UA_StatusCode retval = UA_Server_write(server, &wValue);
  675. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  676. UA_Server_delete(server);
  677. } END_TEST
  678. START_TEST(WriteSingleAttributeDescription) {
  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 = true;
  685. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  686. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  687. wValue.attributeId = UA_ATTRIBUTEID_DESCRIPTION;
  688. wValue.value.hasValue = true;
  689. UA_StatusCode retval = UA_Server_write(server, &wValue);
  690. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  691. UA_Server_delete(server);
  692. } END_TEST
  693. START_TEST(WriteSingleAttributeWriteMask) {
  694. UA_Server *server = makeTestSequence();
  695. UA_WriteValue wValue;
  696. UA_WriteValue_init(&wValue);
  697. UA_Int32 testValue = 0;
  698. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_UINT32]);
  699. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  700. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  701. wValue.attributeId = UA_ATTRIBUTEID_WRITEMASK;
  702. wValue.value.hasValue = true;
  703. UA_StatusCode retval = UA_Server_write(server, &wValue);
  704. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  705. UA_Server_delete(server);
  706. } END_TEST
  707. START_TEST(WriteSingleAttributeUserWriteMask) {
  708. UA_Server *server = makeTestSequence();
  709. UA_WriteValue wValue;
  710. UA_WriteValue_init(&wValue);
  711. UA_Int32 testValue = 0;
  712. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_UINT32]);
  713. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  714. wValue.attributeId = UA_ATTRIBUTEID_USERWRITEMASK;
  715. wValue.value.hasValue = true;
  716. UA_StatusCode retval = UA_Server_write(server, &wValue);
  717. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  718. UA_Server_delete(server);
  719. } END_TEST
  720. START_TEST(WriteSingleAttributeIsAbstract) {
  721. UA_Server *server = makeTestSequence();
  722. UA_WriteValue wValue;
  723. UA_WriteValue_init(&wValue);
  724. UA_Boolean testValue = true;
  725. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  726. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  727. wValue.attributeId = UA_ATTRIBUTEID_ISABSTRACT;
  728. wValue.value.hasValue = true;
  729. UA_StatusCode retval = UA_Server_write(server, &wValue);
  730. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  731. UA_Server_delete(server);
  732. } END_TEST
  733. START_TEST(WriteSingleAttributeSymmetric) {
  734. UA_Server *server = makeTestSequence();
  735. UA_WriteValue wValue;
  736. UA_WriteValue_init(&wValue);
  737. UA_Boolean testValue = 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_SYMMETRIC;
  741. wValue.value.hasValue = true;
  742. UA_StatusCode retval = UA_Server_write(server, &wValue);
  743. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  744. UA_Server_delete(server);
  745. } END_TEST
  746. START_TEST(WriteSingleAttributeInverseName) {
  747. UA_Server *server = makeTestSequence();
  748. UA_WriteValue wValue;
  749. UA_WriteValue_init(&wValue);
  750. UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_US", "not.the.answer");
  751. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
  752. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  753. wValue.attributeId = UA_ATTRIBUTEID_INVERSENAME;
  754. wValue.value.hasValue = true;
  755. UA_StatusCode retval = UA_Server_write(server, &wValue);
  756. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  757. UA_Server_delete(server);
  758. } END_TEST
  759. START_TEST(WriteSingleAttributeContainsNoLoops) {
  760. UA_Server *server = makeTestSequence();
  761. UA_WriteValue wValue;
  762. UA_WriteValue_init(&wValue);
  763. UA_Boolean testValue = true;
  764. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  765. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  766. wValue.attributeId = UA_ATTRIBUTEID_CONTAINSNOLOOPS;
  767. wValue.value.hasValue = true;
  768. UA_StatusCode retval = UA_Server_write(server, &wValue);
  769. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  770. UA_Server_delete(server);
  771. } END_TEST
  772. START_TEST(WriteSingleAttributeEventNotifier) {
  773. UA_Server *server = makeTestSequence();
  774. UA_WriteValue wValue;
  775. UA_WriteValue_init(&wValue);
  776. UA_Byte testValue = 0;
  777. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
  778. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  779. wValue.attributeId = UA_ATTRIBUTEID_EVENTNOTIFIER;
  780. wValue.value.hasValue = true;
  781. UA_StatusCode retval = UA_Server_write(server, &wValue);
  782. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  783. UA_Server_delete(server);
  784. } END_TEST
  785. START_TEST(WriteSingleAttributeValue) {
  786. UA_Server *server = makeTestSequence();
  787. UA_WriteValue wValue;
  788. UA_WriteValue_init(&wValue);
  789. UA_Int32 myInteger = 20;
  790. UA_Variant_setScalar(&wValue.value.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  791. wValue.value.hasValue = true;
  792. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  793. wValue.attributeId = UA_ATTRIBUTEID_VALUE;
  794. UA_StatusCode retval = UA_Server_write(server, &wValue);
  795. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  796. UA_DataValue resp;
  797. UA_DataValue_init(&resp);
  798. UA_ReadValueId id;
  799. UA_ReadValueId_init(&id);
  800. id.nodeId = UA_NODEID_STRING(1, "the.answer");
  801. id.attributeId = UA_ATTRIBUTEID_VALUE;
  802. Service_Read_single(server, &adminSession, UA_TIMESTAMPSTORETURN_NEITHER, &id, &resp);
  803. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  804. ck_assert(resp.hasValue);
  805. ck_assert_int_eq(20, *(UA_Int32*)resp.value.data);
  806. UA_DataValue_deleteMembers(&resp);
  807. UA_Server_delete(server);
  808. } END_TEST
  809. START_TEST(WriteSingleAttributeValueRangeFromScalar) {
  810. UA_Server *server = makeTestSequence();
  811. UA_WriteValue wValue;
  812. UA_WriteValue_init(&wValue);
  813. UA_Int32 myInteger = 20;
  814. UA_Variant_setScalar(&wValue.value.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
  815. wValue.value.hasValue = true;
  816. wValue.nodeId = UA_NODEID_STRING(1, "myarray");
  817. wValue.indexRange = UA_STRING("0,0");
  818. wValue.attributeId = UA_ATTRIBUTEID_VALUE;
  819. UA_StatusCode retval = UA_Server_write(server, &wValue);
  820. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  821. UA_Server_delete(server);
  822. } END_TEST
  823. START_TEST(WriteSingleAttributeValueRangeFromArray) {
  824. UA_Server *server = makeTestSequence();
  825. UA_WriteValue wValue;
  826. UA_WriteValue_init(&wValue);
  827. UA_Int32 myInteger = 20;
  828. UA_Variant_setArray(&wValue.value.value, &myInteger, 1, &UA_TYPES[UA_TYPES_INT32]);
  829. wValue.value.hasValue = true;
  830. wValue.nodeId = UA_NODEID_STRING(1, "myarray");
  831. wValue.indexRange = UA_STRING("0,0");
  832. wValue.attributeId = UA_ATTRIBUTEID_VALUE;
  833. UA_StatusCode retval = UA_Server_write(server, &wValue);
  834. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  835. UA_Server_delete(server);
  836. } END_TEST
  837. START_TEST(WriteSingleAttributeDataType) {
  838. UA_Server *server = makeTestSequence();
  839. UA_WriteValue wValue;
  840. UA_WriteValue_init(&wValue);
  841. UA_NodeId typeId;
  842. UA_NodeId_init(&typeId);
  843. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  844. wValue.attributeId = UA_ATTRIBUTEID_DATATYPE;
  845. wValue.value.hasValue = true;
  846. UA_Variant_setScalar(&wValue.value.value, &typeId, &UA_TYPES[UA_TYPES_NODEID]);
  847. UA_StatusCode retval = UA_Server_write(server, &wValue);
  848. ck_assert_int_eq(retval, UA_STATUSCODE_BADTYPEMISMATCH);
  849. UA_Server_delete(server);
  850. } END_TEST
  851. START_TEST(WriteSingleAttributeValueRank) {
  852. UA_Server *server = makeTestSequence();
  853. UA_WriteValue wValue;
  854. UA_WriteValue_init(&wValue);
  855. UA_Int32 testValue = -1;
  856. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_INT32]);
  857. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  858. wValue.attributeId = UA_ATTRIBUTEID_VALUERANK;
  859. wValue.value.hasValue = true;
  860. UA_StatusCode retval = UA_Server_write(server, &wValue);
  861. // Returns attributeInvalid, since variant/value may be writable
  862. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  863. UA_Server_delete(server);
  864. } END_TEST
  865. START_TEST(WriteSingleAttributeArrayDimensions) {
  866. UA_Server *server = makeTestSequence();
  867. UA_WriteValue wValue;
  868. UA_WriteValue_init(&wValue);
  869. UA_UInt32 testValue[] = {1,1,1};
  870. UA_Variant_setArray(&wValue.value.value, &testValue, 3, &UA_TYPES[UA_TYPES_UINT32]);
  871. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  872. wValue.attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
  873. wValue.value.hasValue = true;
  874. UA_StatusCode retval = UA_Server_write(server, &wValue);
  875. // Returns attributeInvalid, since variant/value may be writable
  876. ck_assert_int_eq(retval, UA_STATUSCODE_BADTYPEMISMATCH);
  877. UA_Server_delete(server);
  878. } END_TEST
  879. START_TEST(WriteSingleAttributeAccessLevel) {
  880. UA_Server *server = makeTestSequence();
  881. UA_WriteValue wValue;
  882. UA_WriteValue_init(&wValue);
  883. UA_Byte testValue = 0;
  884. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
  885. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  886. wValue.attributeId = UA_ATTRIBUTEID_ACCESSLEVEL;
  887. wValue.value.hasValue = true;
  888. UA_StatusCode retval = UA_Server_write(server, &wValue);
  889. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  890. UA_Server_delete(server);
  891. } END_TEST
  892. START_TEST(WriteSingleAttributeUserAccessLevel) {
  893. UA_Server *server = makeTestSequence();
  894. UA_WriteValue wValue;
  895. UA_WriteValue_init(&wValue);
  896. UA_Byte testValue = 0;
  897. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
  898. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  899. wValue.attributeId = UA_ATTRIBUTEID_USERACCESSLEVEL;
  900. wValue.value.hasValue = true;
  901. UA_StatusCode retval = UA_Server_write(server, &wValue);
  902. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  903. UA_Server_delete(server);
  904. } END_TEST
  905. START_TEST(WriteSingleAttributeMinimumSamplingInterval) {
  906. UA_Server *server = makeTestSequence();
  907. UA_WriteValue wValue;
  908. UA_WriteValue_init(&wValue);
  909. UA_Double testValue = 0.0;
  910. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_DOUBLE]);
  911. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  912. wValue.attributeId = UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL;
  913. wValue.value.hasValue = true;
  914. UA_StatusCode retval = UA_Server_write(server, &wValue);
  915. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  916. UA_Server_delete(server);
  917. } END_TEST
  918. START_TEST(WriteSingleAttributeHistorizing) {
  919. UA_Server *server = makeTestSequence();
  920. UA_WriteValue wValue;
  921. UA_WriteValue_init(&wValue);
  922. UA_Boolean testValue = true;
  923. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  924. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  925. wValue.attributeId = UA_ATTRIBUTEID_HISTORIZING;
  926. wValue.value.hasValue = true;
  927. UA_StatusCode retval = UA_Server_write(server, &wValue);
  928. ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
  929. UA_Server_delete(server);
  930. } END_TEST
  931. START_TEST(WriteSingleAttributeExecutable) {
  932. UA_Server *server = makeTestSequence();
  933. UA_WriteValue wValue;
  934. UA_WriteValue_init(&wValue);
  935. UA_Boolean testValue = true;
  936. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  937. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  938. wValue.attributeId = UA_ATTRIBUTEID_EXECUTABLE;
  939. wValue.value.hasValue = true;
  940. UA_StatusCode retval = UA_Server_write(server, &wValue);
  941. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  942. UA_Server_delete(server);
  943. } END_TEST
  944. START_TEST(WriteSingleAttributeUserExecutable) {
  945. UA_Server *server = makeTestSequence();
  946. UA_WriteValue wValue;
  947. UA_WriteValue_init(&wValue);
  948. UA_Boolean testValue = true;
  949. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
  950. wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
  951. wValue.attributeId = UA_ATTRIBUTEID_USEREXECUTABLE;
  952. wValue.value.hasValue = true;
  953. UA_StatusCode retval = UA_Server_write(server, &wValue);
  954. ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
  955. UA_Server_delete(server);
  956. } END_TEST
  957. START_TEST(WriteSingleDataSourceAttributeValue) {
  958. UA_Server *server = makeTestSequence();
  959. UA_WriteValue wValue;
  960. UA_WriteValue_init(&wValue);
  961. UA_Int32 testValue = 0;
  962. UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_INT32]);
  963. wValue.nodeId = UA_NODEID_STRING(1, "cpu.temperature");
  964. wValue.attributeId = UA_ATTRIBUTEID_VALUE;
  965. wValue.value.hasValue = true;
  966. UA_StatusCode retval = UA_Server_write(server, &wValue);
  967. ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
  968. UA_Server_delete(server);
  969. } END_TEST
  970. static Suite * testSuite_services_attributes(void) {
  971. Suite *s = suite_create("services_attributes_read");
  972. TCase *tc_readSingleAttributes = tcase_create("readSingleAttributes");
  973. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueWithoutTimestamp);
  974. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueRangeWithoutTimestamp);
  975. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeNodeIdWithoutTimestamp);
  976. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeNodeClassWithoutTimestamp);
  977. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeBrowseNameWithoutTimestamp);
  978. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDisplayNameWithoutTimestamp);
  979. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDescriptionWithoutTimestamp);
  980. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeWriteMaskWithoutTimestamp);
  981. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserWriteMaskWithoutTimestamp);
  982. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeIsAbstractWithoutTimestamp);
  983. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeSymmetricWithoutTimestamp);
  984. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeInverseNameWithoutTimestamp);
  985. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeContainsNoLoopsWithoutTimestamp);
  986. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeEventNotifierWithoutTimestamp);
  987. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDataTypeWithoutTimestamp);
  988. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueRankWithoutTimestamp);
  989. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeArrayDimensionsWithoutTimestamp);
  990. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeAccessLevelWithoutTimestamp);
  991. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserAccessLevelWithoutTimestamp);
  992. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp);
  993. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeHistorizingWithoutTimestamp);
  994. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeExecutableWithoutTimestamp);
  995. tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserExecutableWithoutTimestamp);
  996. tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeValueWithoutTimestamp);
  997. tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeDataTypeWithoutTimestamp);
  998. tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeArrayDimensionsWithoutTimestamp);
  999. suite_add_tcase(s, tc_readSingleAttributes);
  1000. TCase *tc_writeSingleAttributes = tcase_create("writeSingleAttributes");
  1001. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeNodeId);
  1002. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeNodeclass);
  1003. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeBrowseName);
  1004. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDisplayName);
  1005. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDescription);
  1006. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeWriteMask);
  1007. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeUserWriteMask);
  1008. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeIsAbstract);
  1009. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeSymmetric);
  1010. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeInverseName);
  1011. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeContainsNoLoops);
  1012. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeEventNotifier);
  1013. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValue);
  1014. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDataType);
  1015. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValueRangeFromScalar);
  1016. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValueRangeFromArray);
  1017. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValueRank);
  1018. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeArrayDimensions);
  1019. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeAccessLevel);
  1020. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeUserAccessLevel);
  1021. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeMinimumSamplingInterval);
  1022. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeHistorizing);
  1023. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeExecutable);
  1024. tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeUserExecutable);
  1025. tcase_add_test(tc_writeSingleAttributes, WriteSingleDataSourceAttributeValue);
  1026. suite_add_tcase(s, tc_writeSingleAttributes);
  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. }