check_services_attributes.c 50 KB

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