check_services_attributes.c 50 KB

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