check_stack.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. /*
  2. ============================================================================
  3. Name : check_stack.c
  4. Author :
  5. Version :
  6. Copyright : Your copyright notice
  7. Description :
  8. ============================================================================
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include "../src/opcua_transportLayer.h"
  13. #include "../src/opcua_binaryEncDec.h"
  14. #include "../src/opcua_encodingLayer.h"
  15. #include "../src/opcua_advancedDatatypes.h"
  16. //#include "check_stdint.h"
  17. #include "check.h"
  18. START_TEST(test_getPacketType_validParameter)
  19. {
  20. char buf[] = {'C','L','O'};
  21. Int32 pos = 0;
  22. AD_RawMessage rawMessage;
  23. rawMessage.message = buf;
  24. rawMessage.length = 3;
  25. ck_assert_int_eq(TL_getPacketType(&pos,&rawMessage),packetType_CLO);
  26. }
  27. END_TEST
  28. START_TEST(encodeByte_test)
  29. {
  30. AD_RawMessage rawMessage;
  31. Int32 position = 0;
  32. //EncodeByte
  33. char *mem = malloc(sizeof(Byte));
  34. rawMessage.message = mem;
  35. Byte testByte = 0x08;
  36. rawMessage.length = 1;
  37. position = 0;
  38. encodeByte(testByte, &position, rawMessage.message);
  39. ck_assert_int_eq(rawMessage.message[0], 0x08);
  40. ck_assert_int_eq(rawMessage.length, 1);
  41. ck_assert_int_eq(position, 1);
  42. free(mem);
  43. }
  44. END_TEST
  45. /*
  46. START_TEST(decodeRequestHeader_test_validParameter)
  47. {
  48. char testMessage = {0x00,0x00,0x72,0xf1,0xdc,0xc9,0x87,0x0b,
  49. 0xcf,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
  50. 0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,
  51. 0x00,0x00,0x00,0x00,0x00};
  52. AD_RawMessage rawMessage;
  53. rawMessage.message = &testMessage;
  54. rawMessage.length = 29;
  55. Int32 position = 0;
  56. T_RequestHeader requestHeader;
  57. decodeRequestHeader(rawMessage,&position,&requestHeader);
  58. ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
  59. ck_assert_int_eq(requestHeader.returnDiagnostics,0);
  60. ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
  61. }
  62. END_TEST
  63. */
  64. START_TEST(decodeInt16_test)
  65. {
  66. AD_RawMessage rawMessage;
  67. Int32 position = 0;
  68. //EncodeUInt16
  69. char mem[2] = {0x01,0x00};
  70. rawMessage.message = mem;
  71. rawMessage.length = 2;
  72. //encodeUInt16(testUInt16, &position, &rawMessage);
  73. Int32 p = 0;
  74. Int16 val;
  75. decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
  76. ck_assert_int_eq(val,1);
  77. //ck_assert_int_eq(p, 2);
  78. //ck_assert_int_eq(rawMessage.message[0], 0xAB);
  79. }
  80. END_TEST
  81. START_TEST(encodeInt16_test)
  82. {
  83. AD_RawMessage rawMessage;
  84. Int32 position = 0;
  85. //EncodeUInt16
  86. char *mem = malloc(sizeof(UInt16));
  87. rawMessage.message = mem;
  88. UInt16 testUInt16 = 1;
  89. rawMessage.length = 2;
  90. position = 0;
  91. encodeUInt16(testUInt16, &position, rawMessage.message);
  92. //encodeUInt16(testUInt16, &position, &rawMessage);
  93. ck_assert_int_eq(position, 2);
  94. Int32 p = 0;
  95. Int16 val;
  96. decoder_decodeBuiltInDatatype(rawMessage.message, INT16, &p, &val);
  97. ck_assert_int_eq(val,testUInt16);
  98. //ck_assert_int_eq(rawMessage.message[0], 0xAB);
  99. }
  100. END_TEST
  101. START_TEST(decodeUInt16_test)
  102. {
  103. AD_RawMessage rawMessage;
  104. Int32 position = 0;
  105. //EncodeUInt16
  106. char mem[2] = {0x01,0x00};
  107. rawMessage.message = mem;
  108. rawMessage.length = 2;
  109. //encodeUInt16(testUInt16, &position, &rawMessage);
  110. Int32 p = 0;
  111. UInt16 val;
  112. decoder_decodeBuiltInDatatype(rawMessage.message,UINT16,&p,&val);
  113. ck_assert_int_eq(val,1);
  114. //ck_assert_int_eq(p, 2);
  115. //ck_assert_int_eq(rawMessage.message[0], 0xAB);
  116. }
  117. END_TEST
  118. START_TEST(encodeUInt16_test)
  119. {
  120. AD_RawMessage rawMessage;
  121. Int32 position = 0;
  122. //EncodeUInt16
  123. char *mem = malloc(sizeof(UInt16));
  124. rawMessage.message = mem;
  125. UInt16 testUInt16 = 1;
  126. rawMessage.length = 2;
  127. position = 0;
  128. encodeUInt16(testUInt16, &position, rawMessage.message);
  129. //encodeUInt16(testUInt16, &position, &rawMessage);
  130. ck_assert_int_eq(position, 2);
  131. Int32 p = 0;
  132. UInt16 val;
  133. decoder_decodeBuiltInDatatype(rawMessage.message, UINT16, &p, &val);
  134. ck_assert_int_eq(val,testUInt16);
  135. //ck_assert_int_eq(rawMessage.message[0], 0xAB);
  136. }
  137. END_TEST
  138. START_TEST(decodeUInt32_test)
  139. {
  140. AD_RawMessage rawMessage;
  141. Int32 position = 0;
  142. //EncodeUInt16
  143. char mem[4] = {0xFF,0x00,0x00,0x00};
  144. rawMessage.message = mem;
  145. rawMessage.length = 4;
  146. Int32 p = 0;
  147. UInt32 val;
  148. decoder_decodeBuiltInDatatype(rawMessage.message, UINT32, &p, &val);
  149. ck_assert_uint_eq(val,255);
  150. }
  151. END_TEST
  152. START_TEST(encodeUInt32_test)
  153. {
  154. AD_RawMessage rawMessage;
  155. Int32 position = 0;
  156. UInt32 value = 0x0101FF00;
  157. //EncodeUInt16
  158. rawMessage.message = (char*)opcua_malloc(2 * sizeof(UInt32));
  159. rawMessage.length = 8;
  160. Int32 p = 4;
  161. //encodeUInt32(value, &p,rawMessage.message);
  162. encoder_encodeBuiltInDatatype(&value,UINT32,&p,rawMessage.message);
  163. ck_assert_uint_eq((Byte)rawMessage.message[4],0x00);
  164. ck_assert_uint_eq((Byte)rawMessage.message[5],0xFF);
  165. ck_assert_uint_eq((Byte)rawMessage.message[6],0x01);
  166. ck_assert_uint_eq((Byte)rawMessage.message[7],0x01);
  167. ck_assert_int_eq(p,8);
  168. }
  169. END_TEST
  170. START_TEST(decodeInt32_test)
  171. {
  172. AD_RawMessage rawMessage;
  173. Int32 position = 0;
  174. //EncodeUInt16
  175. char mem[4] = {0x00,0xCA,0x9A,0x3B};
  176. rawMessage.message = mem;
  177. rawMessage.length = 4;
  178. Int32 p = 0;
  179. Int32 val;
  180. decoder_decodeBuiltInDatatype(rawMessage.message, INT32, &p, &val);
  181. ck_assert_int_eq(val,1000000000);
  182. }
  183. END_TEST
  184. START_TEST(encodeInt32_test)
  185. {
  186. }
  187. END_TEST
  188. START_TEST(decodeUInt64_test)
  189. {
  190. AD_RawMessage rawMessage;
  191. Int32 position = 0;
  192. UInt64 expectedVal = 0xFF;
  193. expectedVal = expectedVal << 56;
  194. char mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
  195. rawMessage.message = mem;
  196. rawMessage.length = 8;
  197. Int32 p = 0;
  198. UInt64 val;
  199. decoder_decodeBuiltInDatatype(rawMessage.message, UINT64, &p, &val);
  200. ck_assert_uint_eq(val, expectedVal);
  201. }
  202. END_TEST
  203. START_TEST(encodeUInt64_test)
  204. {
  205. AD_RawMessage rawMessage;
  206. Int32 position = 0;
  207. UInt64 value = 0x0101FF00FF00FF00;
  208. //EncodeUInt16
  209. rawMessage.message = (char*)opcua_malloc(sizeof(UInt32));
  210. rawMessage.length = 8;
  211. Int32 p = 0;
  212. encodeUInt64(value, &p,rawMessage.message);
  213. ck_assert_uint_eq((Byte)rawMessage.message[0],0x00);
  214. ck_assert_uint_eq((Byte)rawMessage.message[1],0xFF);
  215. ck_assert_uint_eq((Byte)rawMessage.message[2],0x00);
  216. ck_assert_uint_eq((Byte)rawMessage.message[3],0xFF);
  217. ck_assert_uint_eq((Byte)rawMessage.message[4],0x00);
  218. ck_assert_uint_eq((Byte)rawMessage.message[5],0xFF);
  219. ck_assert_uint_eq((Byte)rawMessage.message[6],0x01);
  220. ck_assert_uint_eq((Byte)rawMessage.message[7],0x01);
  221. }
  222. END_TEST
  223. START_TEST(decodeInt64_test)
  224. {
  225. AD_RawMessage rawMessage;
  226. Int32 position = 0;
  227. Int64 expectedVal = 0xFF;
  228. expectedVal = expectedVal << 56;
  229. char mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
  230. rawMessage.message = mem;
  231. rawMessage.length = 8;
  232. Int32 p = 0;
  233. Int64 val;
  234. decoder_decodeBuiltInDatatype(rawMessage.message, INT64, &p, &val);
  235. ck_assert_uint_eq(val, expectedVal);
  236. }
  237. END_TEST
  238. START_TEST(encodeInt64_test)
  239. {
  240. AD_RawMessage rawMessage;
  241. Int32 position = 0;
  242. UInt64 value = 0x0101FF00FF00FF00;
  243. //EncodeUInt16
  244. rawMessage.message = (char*)opcua_malloc(sizeof(UInt32));
  245. rawMessage.length = 8;
  246. Int32 p = 0;
  247. encodeUInt64(value, &p,rawMessage.message);
  248. ck_assert_uint_eq((Byte)rawMessage.message[0],0x00);
  249. ck_assert_uint_eq((Byte)rawMessage.message[1],0xFF);
  250. ck_assert_uint_eq((Byte)rawMessage.message[2],0x00);
  251. ck_assert_uint_eq((Byte)rawMessage.message[3],0xFF);
  252. ck_assert_uint_eq((Byte)rawMessage.message[4],0x00);
  253. ck_assert_uint_eq((Byte)rawMessage.message[5],0xFF);
  254. ck_assert_uint_eq((Byte)rawMessage.message[6],0x01);
  255. ck_assert_uint_eq((Byte)rawMessage.message[7],0x01);
  256. }
  257. END_TEST
  258. START_TEST(decodeFloat_test)
  259. {
  260. Float expectedValue = -6.5;
  261. Int32 pos = 0;
  262. char buf[4] = {0x00,0x00,0xD0,0xC0};
  263. Float calcVal;
  264. decoder_decodeBuiltInDatatype(buf, FLOAT, &pos, &calcVal);
  265. //val should be -6.5
  266. Int32 val = (calcVal > -6.501 && calcVal < -6.499);
  267. ck_assert_int_gt(val,0);
  268. opcua_free(buf);
  269. }
  270. END_TEST
  271. START_TEST(encodeFloat_test)
  272. {
  273. Float value = -6.5;
  274. Int32 pos = 0;
  275. char *buf = (char*)opcua_malloc(sizeof(Float));
  276. encodeFloat(value,&pos,buf);
  277. ck_assert_uint_eq((Byte)buf[2],0xD0);
  278. ck_assert_uint_eq((Byte)buf[3],0xC0);
  279. opcua_free(buf);
  280. }
  281. END_TEST
  282. START_TEST(decodeDouble_test)
  283. {
  284. }
  285. END_TEST
  286. START_TEST(encodeDouble_test)
  287. {
  288. Float value = -6.5;
  289. Int32 pos = 0;
  290. char *buf = (char*)opcua_malloc(sizeof(Float));
  291. encodeDouble(value,&pos,buf);
  292. ck_assert_uint_eq((Byte)buf[6],0xD0);
  293. ck_assert_uint_eq((Byte)buf[7],0xC0);
  294. opcua_free(buf);
  295. }
  296. END_TEST
  297. START_TEST(encodeUAString_test)
  298. {
  299. Int32 pos = 0;
  300. UA_String string;
  301. Int32 l = 11;
  302. char mem[11] = "ACPLT OPCUA";
  303. char *dstBuf = (char*) malloc(sizeof(Int32)+l);
  304. string.Data = mem;
  305. string.Length = 11;
  306. encodeUAString(&string, &pos, dstBuf);
  307. ck_assert_int_eq(dstBuf[0],11);
  308. ck_assert_int_eq(dstBuf[0+sizeof(Int32)],'A');
  309. }
  310. END_TEST
  311. START_TEST(decodeUAString_test)
  312. {
  313. Int32 pos = 0;
  314. UA_String string;
  315. Int32 l = 11;
  316. char binString[15] = {11,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
  317. char *dstBuf = (char*) malloc(l-sizeof(Int32));
  318. string.Data = dstBuf;
  319. string.Length = 0;
  320. decodeUAString(binString, &pos, &string);
  321. ck_assert_int_eq(string.Length,11);
  322. ck_assert_int_eq(string.Data[3],'L');
  323. }
  324. END_TEST
  325. START_TEST(diagnosticInfo_calcSize_test)
  326. {
  327. Int32 valreal = 0;
  328. Int32 valcalc = 0;
  329. UA_DiagnosticInfo diagnosticInfo;
  330. diagnosticInfo.EncodingMask = 0x01 | 0x02 | 0x04 | 0x08 | 0x10;
  331. diagnosticInfo.SymbolicId = 30;
  332. diagnosticInfo.NamespaceUri = 25;
  333. diagnosticInfo.LocalizedText = 22;
  334. diagnosticInfo.AdditionalInfo.Data = "OPCUA";
  335. diagnosticInfo.AdditionalInfo.Length = 5;
  336. valcalc = diagnosticInfo_calcSize(&diagnosticInfo);
  337. valreal = 26;
  338. ck_assert_int_eq(valcalc,valreal);
  339. }
  340. END_TEST
  341. START_TEST(extensionObject_calcSize_test)
  342. {
  343. Int32 valreal = 0;
  344. Int32 valcalc = 0;
  345. Byte data[3] = {1,2,3};
  346. UA_ExtensionObject extensionObject;
  347. extensionObject.TypeId.EncodingByte = NIEVT_TWO_BYTE;; // Numeric TWO BYTES
  348. extensionObject.TypeId.Identifier.Numeric = 0;
  349. extensionObject.Encoding = 0x00;
  350. extensionObject.Length = 0;
  351. //extensionObject.Body = &data;
  352. valcalc = extensionObject_calcSize(&extensionObject);
  353. valreal = 3;
  354. ck_assert_int_eq(valcalc, valreal);
  355. }
  356. END_TEST
  357. START_TEST(responseHeader_calcSize_test)
  358. {
  359. Int32 valreal = 0;
  360. Int32 valcalc = 0;
  361. T_ResponseHeader responseHeader;
  362. UA_DiagnosticInfo diagnosticInfo;
  363. UA_ExtensionObject extensionObject;
  364. //Should have the size of 16 Bytes
  365. responseHeader.timestamp = 150014;
  366. responseHeader.requestHandle = 514;
  367. responseHeader.serviceResult = 504;
  368. //Should have the size of 26 Bytes
  369. diagnosticInfo.EncodingMask = 0x01 | 0x02 | 0x04 | 0x08 | 0x10;
  370. diagnosticInfo.SymbolicId = 30;
  371. diagnosticInfo.NamespaceUri = 25;
  372. diagnosticInfo.LocalizedText = 22;
  373. diagnosticInfo.AdditionalInfo.Data = "OPCUA";
  374. diagnosticInfo.AdditionalInfo.Length = 5;
  375. responseHeader.serviceDiagnostics = &diagnosticInfo;
  376. //Should have the size of 4 Bytes
  377. responseHeader.noOfStringTable = 0;
  378. //Should have the size of 3 Bytes
  379. extensionObject.TypeId.EncodingByte = NIEVT_TWO_BYTE;
  380. extensionObject.TypeId.Identifier.Numeric = 0;
  381. extensionObject.Encoding = 0x00; //binaryBody = false, xmlBody = false
  382. responseHeader.additionalHeader = extensionObject;
  383. valcalc = responseHeader_calcSize(&responseHeader);
  384. valreal = 49;
  385. ck_assert_int_eq(valcalc,valreal);
  386. }
  387. END_TEST
  388. //ToDo: Function needs to be filled
  389. START_TEST(expandedNodeId_calcSize_test)
  390. {
  391. Int32 valreal = 300;
  392. Int32 valcalc = 0;
  393. ck_assert_int_eq(valcalc,valreal);
  394. }
  395. END_TEST
  396. START_TEST(encodeDataValue_test)
  397. {
  398. UA_DataValue dataValue;
  399. Int32 pos = 0;
  400. char *buf = (char*)opcua_malloc(15);
  401. UA_DateTime dateTime;
  402. dateTime = 80;
  403. dataValue.ServerTimestamp = dateTime;
  404. //--without Variant
  405. dataValue.EncodingMask = 0x08; //Only the SourvePicoseconds
  406. encodeDataValue(&dataValue, &pos, buf);
  407. ck_assert_int_eq(pos, 9);// represents the length
  408. ck_assert_int_eq(buf[0], 0x08);
  409. ck_assert_int_eq(buf[1], 80);
  410. ck_assert_int_eq(buf[2], 0);
  411. ck_assert_int_eq(buf[3], 0);
  412. ck_assert_int_eq(buf[4], 0);
  413. ck_assert_int_eq(buf[5], 0);
  414. ck_assert_int_eq(buf[6], 0);
  415. ck_assert_int_eq(buf[7], 0);
  416. ck_assert_int_eq(buf[8], 0);
  417. //TestCase for a DataValue with a Variant!
  418. //ToDo: Need to be checked after the function for encoding variants has been implemented
  419. pos = 0;
  420. dataValue.EncodingMask = 0x01 || 0x08; //Variant & SourvePicoseconds
  421. UA_Variant variant;
  422. variant.ArrayLength = 0;
  423. variant.EncodingMask = VTEMT_INT32;
  424. UA_VariantUnion variantUnion;
  425. variantUnion.Int32 = 45;
  426. variant.Value = &variantUnion;
  427. dataValue.Value = variant;
  428. encodeDataValue(&dataValue, &pos, buf);
  429. ck_assert_int_eq(pos, 14);// represents the length
  430. ck_assert_int_eq(buf[0], 0x08);
  431. ck_assert_int_eq(buf[1], 0x06);
  432. ck_assert_int_eq(buf[2], 45);
  433. ck_assert_int_eq(buf[3], 0);
  434. ck_assert_int_eq(buf[4], 0);
  435. ck_assert_int_eq(buf[5], 0);
  436. ck_assert_int_eq(buf[6], 80);
  437. ck_assert_int_eq(buf[7], 0);
  438. }
  439. END_TEST
  440. Suite *testSuite_getPacketType(void)
  441. {
  442. Suite *s = suite_create("getPacketType");
  443. TCase *tc_core = tcase_create("Core");
  444. tcase_add_test(tc_core,test_getPacketType_validParameter);
  445. suite_add_tcase(s,tc_core);
  446. return s;
  447. }
  448. Suite *testSuite_encodeByte(void)
  449. {
  450. Suite *s = suite_create("encodeByte_test");
  451. TCase *tc_core = tcase_create("Core");
  452. tcase_add_test(tc_core, encodeByte_test);
  453. suite_add_tcase(s,tc_core);
  454. return s;
  455. }
  456. Suite *testSuite_decodeInt16(void)
  457. {
  458. Suite *s = suite_create("decodeInt16_test");
  459. TCase *tc_core = tcase_create("Core");
  460. tcase_add_test(tc_core, decodeInt16_test);
  461. suite_add_tcase(s,tc_core);
  462. return s;
  463. }
  464. Suite*testSuite_encodeInt16(void)
  465. {
  466. Suite *s = suite_create("encodeInt16_test");
  467. TCase *tc_core = tcase_create("Core");
  468. tcase_add_test(tc_core, encodeInt16_test);
  469. suite_add_tcase(s,tc_core);
  470. return s;
  471. }
  472. Suite *testSuite_decodeUInt16(void)
  473. {
  474. Suite *s = suite_create("decodeUInt16_test");
  475. TCase *tc_core = tcase_create("Core");
  476. tcase_add_test(tc_core, decodeUInt16_test);
  477. suite_add_tcase(s,tc_core);
  478. return s;
  479. }
  480. Suite*testSuite_encodeUInt16(void)
  481. {
  482. Suite *s = suite_create("encodeUInt16_test");
  483. TCase *tc_core = tcase_create("Core");
  484. tcase_add_test(tc_core, encodeUInt16_test);
  485. suite_add_tcase(s,tc_core);
  486. return s;
  487. }
  488. Suite*testSuite_decodeUInt32(void)
  489. {
  490. Suite *s = suite_create("decodeUInt32_test");
  491. TCase *tc_core = tcase_create("Core");
  492. tcase_add_test(tc_core, decodeUInt32_test);
  493. suite_add_tcase(s,tc_core);
  494. return s;
  495. }
  496. Suite*testSuite_encodeUInt32(void)
  497. {
  498. Suite *s = suite_create("encodeUInt32_test");
  499. TCase *tc_core = tcase_create("Core");
  500. tcase_add_test(tc_core, encodeUInt32_test);
  501. suite_add_tcase(s,tc_core);
  502. return s;
  503. }
  504. Suite*testSuite_decodeInt32(void)
  505. {
  506. Suite *s = suite_create("decodeInt32_test");
  507. TCase *tc_core = tcase_create("Core");
  508. tcase_add_test(tc_core, decodeInt32_test);
  509. suite_add_tcase(s,tc_core);
  510. return s;
  511. }
  512. Suite*testSuite_encodeInt32(void)
  513. {
  514. Suite *s = suite_create("encodeInt32_test");
  515. TCase *tc_core = tcase_create("Core");
  516. tcase_add_test(tc_core, encodeInt32_test);
  517. suite_add_tcase(s,tc_core);
  518. return s;
  519. }
  520. Suite*testSuite_decodeUInt64(void)
  521. {
  522. Suite *s = suite_create("decodeUInt64_test");
  523. TCase *tc_core = tcase_create("Core");
  524. tcase_add_test(tc_core, decodeUInt64_test);
  525. suite_add_tcase(s,tc_core);
  526. return s;
  527. }
  528. Suite*testSuite_encodeUInt64(void)
  529. {
  530. Suite *s = suite_create("encodeUInt64_test");
  531. TCase *tc_core = tcase_create("Core");
  532. tcase_add_test(tc_core, encodeUInt64_test);
  533. suite_add_tcase(s,tc_core);
  534. return s;
  535. }
  536. Suite*testSuite_decodeInt64(void)
  537. {
  538. Suite *s = suite_create("decodeInt64_test");
  539. TCase *tc_core = tcase_create("Core");
  540. tcase_add_test(tc_core, decodeInt64_test);
  541. suite_add_tcase(s,tc_core);
  542. return s;
  543. }
  544. Suite*testSuite_encodeInt64(void)
  545. {
  546. Suite *s = suite_create("encodeInt64_test");
  547. TCase *tc_core = tcase_create("Core");
  548. tcase_add_test(tc_core, encodeInt64_test);
  549. suite_add_tcase(s,tc_core);
  550. return s;
  551. }
  552. Suite *testSuite_encodeFloat(void)
  553. {
  554. Suite *s = suite_create("encodeFloat_test");
  555. TCase *tc_core = tcase_create("Core");
  556. tcase_add_test(tc_core, encodeFloat_test);
  557. suite_add_tcase(s,tc_core);
  558. return s;
  559. }
  560. Suite *testSuite_decodeFloat(void)
  561. {
  562. Suite *s = suite_create("decodeFloat_test");
  563. TCase *tc_core = tcase_create("Core");
  564. tcase_add_test(tc_core, decodeFloat_test);
  565. suite_add_tcase(s,tc_core);
  566. return s;
  567. }
  568. Suite *testSuite_encodeDouble(void)
  569. {
  570. Suite *s = suite_create("encodeDouble_test");
  571. TCase *tc_core = tcase_create("Core");
  572. tcase_add_test(tc_core, encodeDouble_test);
  573. suite_add_tcase(s,tc_core);
  574. return s;
  575. }
  576. Suite *testSuite_decodeDouble(void)
  577. {
  578. Suite *s = suite_create("decodeDouble_test");
  579. TCase *tc_core = tcase_create("Core");
  580. tcase_add_test(tc_core, decodeDouble_test);
  581. suite_add_tcase(s,tc_core);
  582. return s;
  583. }
  584. Suite * testSuite_encodeUAString(void)
  585. {
  586. Suite *s = suite_create("encodeUAString_test");
  587. TCase *tc_core = tcase_create("Core");
  588. tcase_add_test(tc_core, encodeUAString_test);
  589. suite_add_tcase(s,tc_core);
  590. return s;
  591. }
  592. Suite * testSuite_decodeUAString(void)
  593. {
  594. Suite *s = suite_create("decodeUAString_test");
  595. TCase *tc_core = tcase_create("Core");
  596. tcase_add_test(tc_core, decodeUAString_test);
  597. suite_add_tcase(s,tc_core);
  598. return s;
  599. }
  600. Suite* testSuite_encodeDataValue()
  601. {
  602. Suite *s = suite_create("encodeDataValue");
  603. TCase *tc_core = tcase_create("Core");
  604. tcase_add_test(tc_core, encodeDataValue_test);
  605. suite_add_tcase(s,tc_core);
  606. return s;
  607. }
  608. Suite* testSuite_expandedNodeId_calcSize(void)
  609. {
  610. Suite *s = suite_create("expandedNodeId_calcSize");
  611. TCase *tc_core = tcase_create("Core");
  612. tcase_add_test(tc_core,expandedNodeId_calcSize_test);
  613. suite_add_tcase(s,tc_core);
  614. return s;
  615. }
  616. /*
  617. Suite* TL_<TESTSUITENAME>(void)
  618. {
  619. Suite *s = suite_create("<TESTSUITENAME>");
  620. TCase *tc_core = tcase_create("Core");
  621. tcase_add_test(tc_core,<TEST_NAME>);
  622. suite_add_tcase(s,tc_core);
  623. return s;
  624. }
  625. */
  626. Suite* testSuite_diagnosticInfo_calcSize()
  627. {
  628. Suite *s = suite_create("diagnosticInfo_calcSize");
  629. TCase *tc_core = tcase_create("Core");
  630. tcase_add_test(tc_core, diagnosticInfo_calcSize_test);
  631. suite_add_tcase(s,tc_core);
  632. return s;
  633. }
  634. Suite* testSuite_extensionObject_calcSize()
  635. {
  636. Suite *s = suite_create("extensionObject_calcSize");
  637. TCase *tc_core = tcase_create("Core");
  638. tcase_add_test(tc_core, extensionObject_calcSize_test);
  639. suite_add_tcase(s,tc_core);
  640. return s;
  641. }
  642. Suite* testSuite_responseHeader_calcSize()
  643. {
  644. Suite *s = suite_create("responseHeader_calcSize");
  645. TCase *tc_core = tcase_create("Core");
  646. tcase_add_test(tc_core, responseHeader_calcSize_test);
  647. suite_add_tcase(s,tc_core);
  648. return s;
  649. }
  650. int main (void)
  651. {
  652. int number_failed = 0;
  653. Suite *s = testSuite_getPacketType();
  654. SRunner *sr = srunner_create(s);
  655. srunner_run_all(sr,CK_NORMAL);
  656. number_failed = srunner_ntests_failed(sr);
  657. srunner_free(sr);
  658. s = testSuite_decodeInt16();
  659. sr = srunner_create(s);
  660. srunner_run_all(sr,CK_NORMAL);
  661. number_failed += srunner_ntests_failed(sr);
  662. srunner_free(sr);
  663. s = testSuite_encodeInt16();
  664. sr = srunner_create(s);
  665. srunner_run_all(sr,CK_NORMAL);
  666. number_failed += srunner_ntests_failed(sr);
  667. srunner_free(sr);
  668. s = testSuite_decodeUInt16();
  669. sr = srunner_create(s);
  670. srunner_run_all(sr,CK_NORMAL);
  671. number_failed += srunner_ntests_failed(sr);
  672. srunner_free(sr);
  673. s = testSuite_encodeUInt16();
  674. sr = srunner_create(s);
  675. srunner_run_all(sr,CK_NORMAL);
  676. number_failed += srunner_ntests_failed(sr);
  677. srunner_free(sr);
  678. s = testSuite_decodeUInt32();
  679. sr = srunner_create(s);
  680. srunner_run_all(sr,CK_NORMAL);
  681. number_failed += srunner_ntests_failed(sr);
  682. srunner_free(sr);
  683. s = testSuite_encodeUInt32();
  684. sr = srunner_create(s);
  685. srunner_run_all(sr,CK_NORMAL);
  686. number_failed += srunner_ntests_failed(sr);
  687. srunner_free(sr);
  688. s = testSuite_decodeInt32();
  689. sr = srunner_create(s);
  690. srunner_run_all(sr,CK_NORMAL);
  691. number_failed += srunner_ntests_failed(sr);
  692. srunner_free(sr);
  693. s = testSuite_encodeInt32();
  694. sr = srunner_create(s);
  695. srunner_run_all(sr,CK_NORMAL);
  696. number_failed += srunner_ntests_failed(sr);
  697. srunner_free(sr);
  698. s = testSuite_decodeUInt64();
  699. sr = srunner_create(s);
  700. srunner_run_all(sr,CK_NORMAL);
  701. number_failed += srunner_ntests_failed(sr);
  702. srunner_free(sr);
  703. s = testSuite_encodeUInt64();
  704. sr = srunner_create(s);
  705. srunner_run_all(sr,CK_NORMAL);
  706. number_failed += srunner_ntests_failed(sr);
  707. srunner_free(sr);
  708. s = testSuite_decodeInt64();
  709. sr = srunner_create(s);
  710. srunner_run_all(sr,CK_NORMAL);
  711. number_failed += srunner_ntests_failed(sr);
  712. srunner_free(sr);
  713. s = testSuite_encodeInt64();
  714. sr = srunner_create(s);
  715. srunner_run_all(sr,CK_NORMAL);
  716. number_failed += srunner_ntests_failed(sr);
  717. srunner_free(sr);
  718. s = testSuite_encodeFloat();
  719. sr = srunner_create(s);
  720. srunner_run_all(sr,CK_NORMAL);
  721. number_failed += srunner_ntests_failed(sr);
  722. srunner_free(sr);
  723. s = testSuite_encodeDouble();
  724. sr = srunner_create(s);
  725. srunner_run_all(sr,CK_NORMAL);
  726. number_failed += srunner_ntests_failed(sr);
  727. srunner_free(sr);
  728. s = testSuite_encodeByte();
  729. sr = srunner_create(s);
  730. srunner_run_all(sr,CK_NORMAL);
  731. number_failed += srunner_ntests_failed(sr);
  732. srunner_free(sr);
  733. s = testSuite_encodeUAString();
  734. sr = srunner_create(s);
  735. srunner_run_all(sr,CK_NORMAL);
  736. number_failed += srunner_ntests_failed(sr);
  737. srunner_free(sr);
  738. s = testSuite_decodeUAString();
  739. sr = srunner_create(s);
  740. srunner_run_all(sr,CK_NORMAL);
  741. number_failed += srunner_ntests_failed(sr);
  742. srunner_free(sr);
  743. s = testSuite_diagnosticInfo_calcSize();
  744. sr = srunner_create(s);
  745. srunner_run_all(sr,CK_NORMAL);
  746. number_failed += srunner_ntests_failed(sr);
  747. srunner_free(sr);
  748. s = testSuite_extensionObject_calcSize();
  749. sr = srunner_create(s);
  750. srunner_run_all(sr,CK_NORMAL);
  751. number_failed += srunner_ntests_failed(sr);
  752. srunner_free(sr);
  753. s = testSuite_responseHeader_calcSize();
  754. sr = srunner_create(s);
  755. srunner_run_all(sr,CK_NORMAL);
  756. number_failed += srunner_ntests_failed(sr);
  757. srunner_free(sr);
  758. s = testSuite_encodeDataValue();
  759. sr = srunner_create(s);
  760. srunner_run_all(sr,CK_NORMAL);
  761. number_failed += srunner_ntests_failed(sr);
  762. srunner_free(sr);
  763. s = testSuite_expandedNodeId_calcSize();
  764. sr = srunner_create(s);
  765. srunner_run_all(sr,CK_NORMAL);
  766. number_failed += srunner_ntests_failed(sr);
  767. srunner_free(sr);
  768. /* <TESTSUITE_TEMPLATE>
  769. s = <TESTSUITENAME>;
  770. sr = srunner_create(s);
  771. srunner_run_all(sr,CK_NORMAL);
  772. number_failed += srunner_ntests_failed(sr);
  773. srunner_free(sr);
  774. */
  775. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  776. }