test_tortures.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. * Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
  4. *
  5. * This file is part of Open Source Doubango Framework.
  6. *
  7. * DOUBANGO is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * DOUBANGO is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with DOUBANGO.
  19. *
  20. */
  21. #ifndef TEST_TINYSIGCOMP_TORTURES_H
  22. #define TEST_TINYSIGCOMP_TORTURES_H
  23. #define COMPARTMENT_ID "urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a473"
  24. #define COMPARTMENT_ID_0 "urn:uuid:0"
  25. #define COMPARTMENT_ID_1 "urn:uuid:1"
  26. #define COMPARTMENT_ID_2 "urn:uuid:2"
  27. #define OUTPUT_BUFFER_SIZE 2000
  28. // Be careful before changing these values as not all tests accept any
  29. #define DMS 16384 //2048//4096//8192//65536
  30. #define SMS 2048 //2048//4096//8192//65536
  31. #define CPB 16 // 16//32//64//128
  32. #define RUN_TEST_LOOP 1
  33. #define RUN_TEST_ALL 1
  34. #define RUN_TEST_NO 68
  35. #define IS_STREAM_YES 1
  36. #define IS_STREAM_NO 0
  37. #define XFAIL_YES 1
  38. #define XFAIL_NO 0
  39. #include "rfc4465_torture_tests.h"
  40. #include <assert.h>
  41. struct_torture_test tests[] = {
  42. {
  43. //*** 0***
  44. "A.1.1. Bit Manipulation",
  45. RFC4465_A_1_1__Bit_Manipulation,
  46. 170,
  47. {8, "\x01\x50\x00\x00\xfe\xbf\x00\x00"},
  48. 22,
  49. IS_STREAM_NO,
  50. XFAIL_NO,
  51. COMPARTMENT_ID
  52. }
  53. ,
  54. {
  55. //*** 1***
  56. "A.1.2(.1) Arithmetic",
  57. RFC4465_A_1_2__Arithmetic_1,
  58. 174,
  59. {8, "\x00\x00\x00\x00\x00\x00\x00\x04"},
  60. 25,
  61. IS_STREAM_NO,
  62. XFAIL_NO,
  63. COMPARTMENT_ID
  64. }
  65. ,
  66. {
  67. //*** 2***
  68. "A.1.2(.2) Arithmetic",
  69. RFC4465_A_1_2__Arithmetic_2,
  70. 174,
  71. {11, "DIV_BY_ZERO"},
  72. 0,
  73. IS_STREAM_NO,
  74. XFAIL_YES,
  75. COMPARTMENT_ID
  76. }
  77. ,
  78. {
  79. //*** 3***
  80. "A.1.2(.3) Arithmetic",
  81. RFC4465_A_1_2__Arithmetic_3,
  82. 174,
  83. {11, "DIV_BY_ZERO"},
  84. 0,
  85. IS_STREAM_NO,
  86. XFAIL_YES,
  87. COMPARTMENT_ID
  88. }
  89. ,
  90. {
  91. //*** 4***
  92. "A.1.3. Sorting",
  93. RFC4465_A_1_3__Sorting,
  94. 223,
  95. {
  96. 45, "\x46\x6f\x72\x64\x2c\x20\x79\x6f\x75\x27\x72\x65\x20\x74\x75\x72\x6e\x69\x6e\x67"
  97. "\x20\x69\x6e\x74\x6f\x20\x61\x20\x70\x65\x6e\x67\x75\x69\x6e\x2e\x20\x53\x74\x6f"
  98. "\x70\x20\x69\x74\x2e"
  99. },
  100. 371,
  101. IS_STREAM_NO,
  102. XFAIL_NO,
  103. COMPARTMENT_ID
  104. }
  105. ,
  106. {
  107. //*** 5**
  108. "A.1.4. SHA-1",
  109. RFC4465_A_1_4__SHA1,
  110. 138,
  111. {
  112. 40, "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e\x25\x71\x78\x50\xc2\x6c\x9c\xd0\xd8\x9d"
  113. "\x84\x98\x3e\x44\x1c\x3b\xd2\x6e\xba\xae\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1"
  114. "\x12\xff\x34\x7b\x4f\x27\xd6\x9e\x1f\x32\x8e\x6f\x4b\x55\x73\xe3\x66\x6e\x12\x2f"
  115. "\x4f\x46\x04\x52\xeb\xb5\x63\x93\x4f\x46\x04\x52\xeb\xb5\x63\x93\x4f\x46\x04\x52"
  116. },
  117. 17176,
  118. IS_STREAM_NO,
  119. XFAIL_NO,
  120. COMPARTMENT_ID
  121. }
  122. ,
  123. {
  124. //*** 6**
  125. "A.1.5.(1) LOAD and MULTILOAD",
  126. RFC4465_A_1_5__LOAD_and_MULTILOAD_1,
  127. 58,
  128. {16, "\x00\x84\x00\x84\x00\x86\x00\x86\x00\x2a\x00\x80\x00\x2a\x00\x2a"},
  129. 36,
  130. IS_STREAM_NO,
  131. XFAIL_NO,
  132. COMPARTMENT_ID
  133. }
  134. ,
  135. {
  136. //*** 7**
  137. "A.1.5.(2) LOAD and MULTILOAD",
  138. RFC4465_A_1_5__LOAD_and_MULTILOAD_2,
  139. 58,
  140. {21, "MULTILOAD_OVERWRITTEN"},
  141. 36,
  142. IS_STREAM_NO,
  143. XFAIL_YES,
  144. COMPARTMENT_ID
  145. }
  146. ,
  147. {
  148. //*** 8**
  149. "A.1.5.(3) LOAD and MULTILOAD",
  150. RFC4465_A_1_5__LOAD_and_MULTILOAD_3,
  151. 58,
  152. {21, "MULTILOAD_OVERWRITTEN"},
  153. 36,
  154. IS_STREAM_NO,
  155. XFAIL_YES,
  156. COMPARTMENT_ID
  157. }
  158. ,
  159. {
  160. //** 9**
  161. "A.1.6. COPY",
  162. RFC4465_A_1_6__COPY,
  163. 60,
  164. {
  165. 125, "\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40"
  166. "\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x41\x41\x41\x41\x41\x41\x41\x41"
  167. "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
  168. "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
  169. "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
  170. "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x55\x41"
  171. "\x42\x43\x44\x43\x44"
  172. },
  173. 365,
  174. IS_STREAM_NO,
  175. XFAIL_NO,
  176. COMPARTMENT_ID
  177. }
  178. ,
  179. {
  180. //** 10**
  181. "A.1.7. COPY-LITERAL and COPY-OFFSET",
  182. RFC4465_A_1_7__COPY_LITERAL_and_COPY_OFFSET,
  183. 100,
  184. {
  185. 34, "\x41\x41\x41\x41\x00\x61\x41\x41\x41\x41\x49\x4a\x41\x42\x43\x44\x49\x4a\x41\x42"
  186. "\x00\x4a\x00\x4e\x47\x48\x48\x45\x46\x47\x47\x48\x45\x46"
  187. },
  188. 216,
  189. IS_STREAM_NO,
  190. XFAIL_NO,
  191. COMPARTMENT_ID
  192. }
  193. ,
  194. {
  195. //** 11**
  196. "A.1.8. MEMSET",
  197. RFC4465_A_1_8__MEMSET,
  198. 27,
  199. {16, "\x80\x40\x4f\x5e\x6d\x7c\x8b\x9a\xa9\xb8\xc7\xd6\xe5\xf4\x03\x12"},
  200. 166,
  201. IS_STREAM_NO,
  202. XFAIL_NO,
  203. COMPARTMENT_ID
  204. }
  205. ,
  206. {
  207. //** 12**
  208. "A.1.9.(1) CRC",
  209. RFC4465_A_1_9__CRC_1,
  210. 29,
  211. {0, ""},
  212. 95,
  213. IS_STREAM_NO,
  214. XFAIL_NO,
  215. COMPARTMENT_ID
  216. }
  217. ,
  218. {
  219. //** 13**
  220. "A.1.9.(2) CRC",
  221. RFC4465_A_1_9__CRC_2,
  222. 29,
  223. {14, "USER_REQUESTED"},
  224. 95,
  225. IS_STREAM_NO,
  226. XFAIL_YES,
  227. COMPARTMENT_ID
  228. }
  229. ,
  230. {
  231. //** 14**
  232. "A.1.10. INPUT-BITS",
  233. RFC4465_A_1_10__INPUT_BITS,
  234. 28,
  235. {16, "\x00\x00\x00\x02\x00\x02\x00\x13\x00\x00\x00\x03\x00\x1a\x00\x38"},
  236. 66,
  237. IS_STREAM_NO,
  238. XFAIL_NO,
  239. COMPARTMENT_ID
  240. }
  241. ,
  242. {
  243. //** 15**
  244. "A.1.11. INPUT-HUFFMAN",
  245. RFC4465_A_1_11__INPUT_HUFFMAN,
  246. 39,
  247. {16, "\x00\x00\x00\x03\x00\x08\x04\xd7\x00\x02\x00\x03\x03\x99\x30\xfe"},
  248. 84,
  249. IS_STREAM_NO,
  250. XFAIL_NO,
  251. COMPARTMENT_ID
  252. }
  253. ,
  254. {
  255. //** 16**
  256. "A.1.12. INPUT-BYTES",
  257. RFC4465_A_1_12__INPUT_BYTES,
  258. 72,
  259. {
  260. 39, "\x00\x00\x93\x2e\x00\x01\xb1\x66\xd8\x6f\xb1\x00\x1a\x2b\x00\x03\x9a\x97\x34\xd8"
  261. "\x00\x07\x00\x01\x33\x87\x4e\x00\x08\xdc\x96\x51\xb5\xdc\x96\x00\x59\x9d\x6a"
  262. },
  263. 130,
  264. IS_STREAM_NO,
  265. XFAIL_NO,
  266. COMPARTMENT_ID
  267. }
  268. ,
  269. {
  270. //** 17**
  271. "A.1.13. Stack Manipulation",
  272. RFC4465_A_1_13__Stack_Manipulation,
  273. 324,
  274. {16, "\x00\x03\x00\x02\x00\x01\x00\x42\x00\x42\x00\x00\x00\x01\x00\x01"},
  275. 40,
  276. IS_STREAM_NO,
  277. XFAIL_NO,
  278. COMPARTMENT_ID
  279. }
  280. ,
  281. {
  282. //** 18**
  283. "A.1.14. Program Flow",
  284. RFC4465_A_1_14__Program_Flow,
  285. 66,
  286. {20, "\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x07\x07\x07\x08\x08\x08\x09\x09"},
  287. 131,
  288. IS_STREAM_NO,
  289. XFAIL_NO,
  290. COMPARTMENT_ID
  291. }
  292. ,
  293. {
  294. //** 19**
  295. "A.1.15.(1) State Creation",
  296. RFC4465_A_1_15__State_Creation_1,
  297. 152,
  298. {0, ""},
  299. 23,
  300. IS_STREAM_NO,
  301. XFAIL_NO,
  302. COMPARTMENT_ID
  303. }
  304. ,
  305. {
  306. //** 20 (requires previsous test)**
  307. "A.1.15.(2) State Creation",
  308. RFC4465_A_1_15__State_Creation_2,
  309. 152,
  310. {0, ""},
  311. 14,
  312. IS_STREAM_NO,
  313. XFAIL_NO,
  314. COMPARTMENT_ID
  315. }
  316. ,
  317. {
  318. //** 21 (requires previsous test)**
  319. "A.1.15.(3) State Creation",
  320. RFC4465_A_1_15__State_Creation_3,
  321. 152,
  322. {0, ""},
  323. 24,
  324. IS_STREAM_NO,
  325. XFAIL_NO,
  326. COMPARTMENT_ID
  327. }
  328. ,
  329. {
  330. //** 22 (requires previsous test)**
  331. "A.1.15.(4) State Creation", // FAIL
  332. RFC4465_A_1_15__State_Creation_4,
  333. 153,
  334. {23, "INVALID_STATE_ID_LENGTH"},
  335. 0,
  336. IS_STREAM_NO,
  337. XFAIL_YES,
  338. COMPARTMENT_ID
  339. }
  340. ,
  341. {
  342. //** 23 (requires previsous test)**
  343. "A.1.15.(5) State Creation", // FAIL
  344. RFC4465_A_1_15__State_Creation_5,
  345. 153,
  346. {23, "INVALID_STATE_ID_LENGTH"},
  347. 0,
  348. IS_STREAM_NO,
  349. XFAIL_YES,
  350. COMPARTMENT_ID
  351. }
  352. ,
  353. {
  354. //** 24 (requires previsous test)**
  355. "A.1.15.(6) State Creation",
  356. RFC4465_A_1_15__State_Creation_6,
  357. 153,
  358. {0, ""},
  359. 23,
  360. IS_STREAM_NO,
  361. XFAIL_NO,
  362. COMPARTMENT_ID
  363. }
  364. ,
  365. {
  366. //** 25 (requires previsous test)**
  367. "A.1.15.(7) State Creation",
  368. RFC4465_A_1_15__State_Creation_7,
  369. 152,
  370. {0, ""},
  371. 34,
  372. IS_STREAM_NO,
  373. XFAIL_NO,
  374. COMPARTMENT_ID
  375. }
  376. ,
  377. {
  378. //** 26 (requires previsous test)**
  379. "A.1.15.(8) State Creation",
  380. RFC4465_A_1_15__State_Creation_8,
  381. 153,
  382. {0, ""},
  383. 46,
  384. IS_STREAM_NO,
  385. XFAIL_NO,
  386. COMPARTMENT_ID
  387. }
  388. ,
  389. {
  390. //** 27 (requires previsous test)**
  391. "A.1.15.(9) State Creation",
  392. RFC4465_A_1_15__State_Creation_9,
  393. 153,
  394. {0, ""},
  395. 47,
  396. IS_STREAM_NO,
  397. XFAIL_NO,
  398. COMPARTMENT_ID
  399. }
  400. #if 0 // FIXME: http://code.google.com/p/doubango/issues/detail?id=181
  401. ,
  402. {
  403. //** 23 (requires previsous test)**
  404. "A.1.15.(10) State Creation",
  405. RFC4465_A_1_15__State_Creation_10,
  406. 153,
  407. {0, ""},
  408. 60,
  409. IS_STREAM_NO,
  410. XFAIL_NO,
  411. COMPARTMENT_ID
  412. }
  413. #endif
  414. ,
  415. {
  416. //** 28**
  417. "A.1.16.(0) STATE-ACCESS {Set up bytecode}",
  418. RFC4465_A_1_16__STATE_ACCESS__SETUP,
  419. 403,
  420. {0, ""},
  421. 17,
  422. IS_STREAM_NO,
  423. XFAIL_NO,
  424. COMPARTMENT_ID
  425. }
  426. ,
  427. {
  428. //** 29 (requires previous test)**
  429. "A.1.16.(1) STATE-ACCESS",
  430. RFC4465_A_1_16__STATE_ACCESS_1,
  431. 408,
  432. {4, "\x74\x65\x73\x74"},
  433. 26,
  434. IS_STREAM_NO,
  435. XFAIL_NO,
  436. COMPARTMENT_ID
  437. }
  438. ,
  439. {
  440. //** 30 (requires previous test)**
  441. "A.1.16.(2) STATE-ACCESS",
  442. RFC4465_A_1_16__STATE_ACCESS_2,
  443. 408,
  444. {4, "\x74\x65\x73\x74"},
  445. 15,
  446. IS_STREAM_NO,
  447. XFAIL_NO,
  448. COMPARTMENT_ID
  449. }
  450. ,
  451. {
  452. //** 31 (requires previous test)**
  453. "A.1.16.(3) STATE-ACCESS",
  454. RFC4465_A_1_16__STATE_ACCESS_3,
  455. 408,
  456. {15, "STATE_NOT_FOUND"},
  457. 0,
  458. IS_STREAM_NO,
  459. XFAIL_YES,
  460. COMPARTMENT_ID
  461. }
  462. ,
  463. {
  464. //** 32 (requires previous test)**
  465. "A.1.16.(4) STATE-ACCESS",
  466. RFC4465_A_1_16__STATE_ACCESS_4,
  467. 408,
  468. {15, "STATE_NOT_FOUND"},
  469. 0,
  470. IS_STREAM_NO,
  471. XFAIL_YES,
  472. COMPARTMENT_ID
  473. }
  474. ,
  475. {
  476. //** 33 (requires previous test)**
  477. "A.1.16.(5) STATE-ACCESS",
  478. RFC4465_A_1_16__STATE_ACCESS_5,
  479. 408,
  480. {15, "STATE_TOO_SHORT"},
  481. 0,
  482. IS_STREAM_NO,
  483. XFAIL_YES,
  484. COMPARTMENT_ID
  485. }
  486. ,
  487. {
  488. //** 34**
  489. "A.2.1.(1) Useful Values",
  490. RFC4465_A_2_1__Useful_Values_1,
  491. 93,
  492. {0, ""},
  493. 966,
  494. IS_STREAM_NO,
  495. XFAIL_NO,
  496. COMPARTMENT_ID
  497. }
  498. ,
  499. {
  500. //** 35 (Requires previous test)**
  501. "A.2.1.(2) Useful Values",
  502. RFC4465_A_2_1__Useful_Values_2,
  503. 9,
  504. {0, ""},
  505. (1072 << 4),
  506. IS_STREAM_NO,
  507. XFAIL_NO,
  508. COMPARTMENT_ID
  509. }
  510. ,
  511. {
  512. //** 36 (Requires previous test)**
  513. "A.2.1.(3) Useful Values",
  514. RFC4465_A_2_1__Useful_Values_3,
  515. 9,
  516. {16, "CYCLES_EXHAUSTED"},
  517. 0,
  518. IS_STREAM_NO,
  519. XFAIL_YES,
  520. COMPARTMENT_ID
  521. }
  522. ,
  523. {
  524. //** 37 (Requires previous test)**
  525. "A.2.1.(4) Useful Values",
  526. RFC4465_A_2_1__Useful_Values_4,
  527. 9,
  528. {8, "SEGFAULT"},
  529. 0,
  530. IS_STREAM_NO,
  531. XFAIL_YES,
  532. COMPARTMENT_ID
  533. }
  534. ,
  535. {
  536. //** 38**
  537. "A.2.2. Cycles Checking",
  538. RFC4465_A_2_2__Cycles_Checking,
  539. 29,
  540. {16, "CYCLES_EXHAUSTED"},
  541. 0,
  542. IS_STREAM_NO,
  543. XFAIL_YES,
  544. COMPARTMENT_ID
  545. }
  546. ,
  547. {
  548. //** 39**
  549. "A.2.3.(1) Message-based Transport",
  550. RFC4465_A_2_3_Message_based_Transport_1,
  551. 1,
  552. {17, "MESSAGE_TOO_SHORT"},
  553. 0,
  554. IS_STREAM_NO,
  555. XFAIL_YES,
  556. COMPARTMENT_ID
  557. }
  558. ,
  559. {
  560. //** 40**
  561. "A.2.3.(2) Message-based Transport",
  562. RFC4465_A_2_3_Message_based_Transport_2,
  563. 2,
  564. {17, "MESSAGE_TOO_SHORT"},
  565. 0,
  566. IS_STREAM_NO,
  567. XFAIL_YES,
  568. COMPARTMENT_ID
  569. }
  570. ,
  571. {
  572. //** 41**
  573. "A.2.3.(3) Message-based Transport",
  574. RFC4465_A_2_3_Message_based_Transport_3,
  575. 17,
  576. {25, "decompression_memory_size"},
  577. 5,
  578. IS_STREAM_NO,
  579. XFAIL_YES,
  580. COMPARTMENT_ID
  581. }
  582. ,
  583. {
  584. //** 42**
  585. "A.2.3.(4) Message-based Transport",
  586. RFC4465_A_2_3_Message_based_Transport_4,
  587. 17,
  588. {17, "MESSAGE_TOO_SHORT"},
  589. 0,
  590. IS_STREAM_NO,
  591. XFAIL_YES,
  592. COMPARTMENT_ID
  593. }
  594. ,
  595. {
  596. //** 43**
  597. "A.2.3.(5) Message-based Transport",
  598. RFC4465_A_2_3_Message_based_Transport_5,
  599. 17,
  600. {21, "INVALID_CODE_LOCATION"},
  601. 0,
  602. IS_STREAM_NO,
  603. XFAIL_YES,
  604. COMPARTMENT_ID
  605. }
  606. ,
  607. {
  608. //** 44**
  609. "A.2.3.(6) Message-based Transport",
  610. RFC4465_A_2_3_Message_based_Transport_6,
  611. 17,
  612. {25, "decompression_memory_size"},
  613. 5,
  614. IS_STREAM_NO,
  615. XFAIL_NO,
  616. COMPARTMENT_ID
  617. }
  618. ,
  619. {
  620. //** 45**
  621. "A.2.4.(1&2) Stream-based Transport",
  622. RFC4465_A_2_4_Stream_based_Transport_1,
  623. 67,
  624. {25, "decompression_memory_size"},
  625. 11,
  626. IS_STREAM_YES,
  627. XFAIL_NO,
  628. COMPARTMENT_ID
  629. }
  630. ,
  631. {
  632. //** 46**
  633. "A.2.4.(3) Stream-based Transport",
  634. RFC4465_A_2_4_Stream_based_Transport_3,
  635. 3,
  636. {17, "MESSAGE_TOO_SHORT"},
  637. 0,
  638. IS_STREAM_YES,
  639. XFAIL_YES,
  640. COMPARTMENT_ID
  641. }
  642. ,
  643. {
  644. //** 47**
  645. "A.2.4.(4) Stream-based Transport",
  646. RFC4465_A_2_4_Stream_based_Transport_4,
  647. 4,
  648. {17, "MESSAGE_TOO_SHORT"},
  649. 0,
  650. IS_STREAM_YES,
  651. XFAIL_YES,
  652. COMPARTMENT_ID
  653. }
  654. ,
  655. {
  656. //** 48**
  657. "A.2.4.(5) Stream-based Transport",
  658. RFC4465_A_2_4_Stream_based_Transport_5,
  659. 30,
  660. {17, "MESSAGE_TOO_SHORT"},
  661. 0,
  662. IS_STREAM_YES,
  663. XFAIL_YES,
  664. COMPARTMENT_ID
  665. }
  666. ,
  667. {
  668. //** 49**
  669. "A.2.4.(5.1) Stream-based Transport (cleanup)",
  670. "\xff\xff",
  671. 2,
  672. {14, "INTERNAL_ERROR"},
  673. 0,
  674. IS_STREAM_YES,
  675. XFAIL_YES,
  676. COMPARTMENT_ID
  677. }
  678. ,
  679. {
  680. //** 50**
  681. "A.2.4.(6) Stream-based Transport",
  682. RFC4465_A_2_4_Stream_based_Transport_6,
  683. 29,
  684. {21, "INVALID_CODE_LOCATION"},
  685. 0,
  686. IS_STREAM_YES,
  687. XFAIL_YES,
  688. COMPARTMENT_ID
  689. }
  690. ,
  691. {
  692. //** 51**
  693. "A.2.4.(6.1) Stream-based Transport (cleanup)",
  694. "\xff\xff",
  695. 2,
  696. {14, "INTERNAL_ERROR"},
  697. 0,
  698. IS_STREAM_YES,
  699. XFAIL_YES,
  700. COMPARTMENT_ID
  701. }
  702. ,
  703. {
  704. //** 52**
  705. "A.2.5.(1) Input Past the End of a Message",
  706. RFC4465_A_2_5__Input_Past_the_End_of_a_Message_1,
  707. 59,
  708. {3, "\x68\x69\x21"},
  709. 23,
  710. IS_STREAM_NO,
  711. XFAIL_NO,
  712. COMPARTMENT_ID
  713. }
  714. ,
  715. {
  716. //** 53**
  717. "A.2.5.(2) Input Past the End of a Message",
  718. RFC4465_A_2_5__Input_Past_the_End_of_a_Message_2,
  719. 58,
  720. {14, "USER_REQUESTED"},
  721. 0,
  722. IS_STREAM_NO,
  723. XFAIL_YES,
  724. COMPARTMENT_ID
  725. }
  726. ,
  727. {
  728. //** 54**
  729. "A.3.1.(1) SigComp Feedback Mechanism",
  730. RFC4465_A_3_1__SigComp_Feedback_Mechanism_1,
  731. 84,
  732. {0, ""},
  733. 52,
  734. IS_STREAM_NO,
  735. XFAIL_NO,
  736. COMPARTMENT_ID
  737. }
  738. ,
  739. {
  740. //** 55**
  741. "A.3.1.(2) SigComp Feedback Mechanism",
  742. RFC4465_A_3_1__SigComp_Feedback_Mechanism_2,
  743. 84,
  744. {0, ""},
  745. 179,
  746. IS_STREAM_NO,
  747. XFAIL_NO,
  748. COMPARTMENT_ID
  749. }
  750. ,
  751. {
  752. //** 56 (SMS MUST be 2048)**
  753. "A.3.2.(1) State Memory Management",
  754. RFC4465_A_3_2__State_Memory_Management_1,
  755. 446,
  756. {0, ""},
  757. 811,
  758. IS_STREAM_NO,
  759. XFAIL_NO,
  760. COMPARTMENT_ID
  761. }
  762. ,
  763. {
  764. //** 57 (Requires previous test)**
  765. "A.3.2.(2) State Memory Management",
  766. RFC4465_A_3_2__State_Memory_Management_2,
  767. 446,
  768. {0, ""},
  769. 2603,
  770. IS_STREAM_NO,
  771. XFAIL_NO,
  772. COMPARTMENT_ID
  773. }
  774. ,
  775. {
  776. //** 58 (Requires previous test)**
  777. "A.3.2.(3) State Memory Management",
  778. RFC4465_A_3_2__State_Memory_Management_3,
  779. 446,
  780. {0, ""},
  781. 811,
  782. IS_STREAM_NO,
  783. XFAIL_NO,
  784. COMPARTMENT_ID
  785. }
  786. ,
  787. {
  788. //** 59 (Requires previous test)**
  789. "A.3.2.(4) State Memory Management",
  790. RFC4465_A_3_2__State_Memory_Management_4,
  791. 446,
  792. {0, ""},
  793. 1805,
  794. IS_STREAM_NO,
  795. XFAIL_NO,
  796. COMPARTMENT_ID
  797. }
  798. ,
  799. {
  800. //** 60 (Requires previous test)**
  801. "A.3.2.(5) State Memory Management",
  802. RFC4465_A_3_2__State_Memory_Management_5,
  803. 446,
  804. {15, "STATE_NOT_FOUND"},
  805. 0,
  806. IS_STREAM_NO,
  807. XFAIL_YES,
  808. COMPARTMENT_ID
  809. }
  810. ,
  811. {
  812. //** 61 (Requires previous test)**
  813. "A.3.2.(6) State Memory Management",
  814. RFC4465_A_3_2__State_Memory_Management_6,
  815. 446,
  816. {0, ""},
  817. 2057,
  818. IS_STREAM_NO,
  819. XFAIL_NO,
  820. COMPARTMENT_ID
  821. }
  822. ,
  823. {
  824. //** 62 (Requires previous test)**
  825. "A.3.2.(7) State Memory Management",
  826. RFC4465_A_3_2__State_Memory_Management_7,
  827. 446,
  828. {0, ""},
  829. 1993,
  830. IS_STREAM_NO,
  831. XFAIL_NO,
  832. COMPARTMENT_ID
  833. }
  834. ,
  835. {
  836. //** 63**
  837. "A.3.3.(1) Multiple Compartments",
  838. RFC4465_A_3_3__Multiple_Compartments_1,
  839. 437,
  840. {0, ""},
  841. 1809,
  842. IS_STREAM_NO,
  843. XFAIL_NO,
  844. COMPARTMENT_ID_0
  845. }
  846. ,
  847. {
  848. //** 64 (requires previsous test)**
  849. "A.3.3.(2) Multiple Compartments",
  850. RFC4465_A_3_3__Multiple_Compartments_2,
  851. 437,
  852. {0, ""},
  853. 1809,
  854. IS_STREAM_NO,
  855. XFAIL_NO,
  856. COMPARTMENT_ID_1
  857. }
  858. ,
  859. {
  860. //** 65 (requires previsous test)**
  861. "A.3.3.(3) Multiple Compartments",
  862. RFC4465_A_3_3__Multiple_Compartments_3,
  863. 437,
  864. {0, ""},
  865. 1809,
  866. IS_STREAM_NO,
  867. XFAIL_NO,
  868. COMPARTMENT_ID_2
  869. }
  870. ,
  871. {
  872. //** 66 (requires previsous test)**
  873. "A.3.3.(4) Multiple Compartments",
  874. RFC4465_A_3_3__Multiple_Compartments_4,
  875. 437,
  876. {0, ""},
  877. 1993,
  878. IS_STREAM_NO,
  879. XFAIL_NO,
  880. COMPARTMENT_ID_0
  881. }
  882. ,
  883. {
  884. //** 67 (requires previsous test)**
  885. "A.3.3.(5) Multiple Compartments",
  886. RFC4465_A_3_3__Multiple_Compartments_5,
  887. 437,
  888. {0, ""},
  889. 1994,
  890. IS_STREAM_NO,
  891. XFAIL_NO,
  892. COMPARTMENT_ID_1
  893. }
  894. ,
  895. {
  896. //** 68 (requires previsous test)**
  897. "A.3.3.(6) Multiple Compartments",
  898. RFC4465_A_3_3__Multiple_Compartments_6,
  899. 437,
  900. {0, ""},
  901. 1804,
  902. IS_STREAM_NO,
  903. XFAIL_NO,
  904. COMPARTMENT_ID_2
  905. }
  906. ,
  907. {
  908. //** 69 (requires previsous test)**
  909. "A.3.3.(7) Multiple Compartments",
  910. RFC4465_A_3_3__Multiple_Compartments_7,
  911. 437,
  912. {15, "STATE_NOT_FOUND"},
  913. 0,
  914. IS_STREAM_NO,
  915. XFAIL_YES,
  916. COMPARTMENT_ID_0
  917. }
  918. ,
  919. {
  920. //** 70 (requires previsous test)**
  921. "A.3.3.(8) Multiple Compartments",
  922. RFC4465_A_3_3__Multiple_Compartments_8,
  923. 437,
  924. {15, "STATE_NOT_FOUND"},
  925. 0,
  926. IS_STREAM_NO,
  927. XFAIL_YES,
  928. COMPARTMENT_ID_1
  929. }
  930. ,
  931. {
  932. //** 71 (requires previsous test)**
  933. "A.3.3.(9) Multiple Compartments",
  934. RFC4465_A_3_3__Multiple_Compartments_9,
  935. 437,
  936. {15, "STATE_NOT_FOUND"},
  937. 0,
  938. IS_STREAM_NO,
  939. XFAIL_YES,
  940. COMPARTMENT_ID_2
  941. }
  942. ,
  943. {
  944. //** 72**
  945. "A.3.4. Accessing RFC 3485 State",
  946. RFC4465_A_3_4__Accessing_RFC_3485_State,
  947. 61,
  948. {3, "\x53\x49\x50"},
  949. 11,
  950. IS_STREAM_NO,
  951. XFAIL_NO,
  952. COMPARTMENT_ID
  953. }
  954. ,
  955. {
  956. //** 73**
  957. "A.3.5.(1) Bytecode State Creation",
  958. RFC4465_A_3_5__Bytecode_State_Creation_1,
  959. 74,
  960. {2, "\x4f\x4b"},
  961. 66,
  962. IS_STREAM_NO,
  963. XFAIL_NO,
  964. "Comp-id:A.3.5. Bytecode State Creation"
  965. }
  966. ,
  967. {
  968. //** 74**
  969. "A.3.5.(2) Bytecode State Creation",
  970. RFC4465_A_3_5__Bytecode_State_Creation_2,
  971. 8,
  972. {3, "\x4f\x4b\x31"},
  973. 7,
  974. IS_STREAM_NO,
  975. XFAIL_NO,
  976. "Comp-id:A.3.5. Bytecode State Creation"
  977. }
  978. ,
  979. {
  980. //** 75**
  981. "A.3.5.(3) Bytecode State Creation",
  982. RFC4465_A_3_5__Bytecode_State_Creation_3,
  983. 13,
  984. {3, "\x4f\x4b\x32"},
  985. 5,
  986. IS_STREAM_NO,
  987. XFAIL_NO,
  988. "Comp-id:A.3.5. Bytecode State Creation"
  989. }
  990. ,
  991. {
  992. //** 76**
  993. "A.3.5.(4) Bytecode State Creation",
  994. RFC4465_A_3_5__Bytecode_State_Creation_4,
  995. 7,
  996. {3, "\x00\x00\x32"},
  997. 5,
  998. IS_STREAM_NO,
  999. XFAIL_NO,
  1000. "Comp-id:A.3.5. Bytecode State Creation"
  1001. }
  1002. ,
  1003. {
  1004. //** 77**
  1005. "A.3.5.(5) Bytecode State Creation",
  1006. RFC4465_A_3_5__Bytecode_State_Creation_5,
  1007. 7,
  1008. {15, "STATE_NOT_FOUND"},
  1009. 0,
  1010. IS_STREAM_NO,
  1011. XFAIL_YES,
  1012. "Comp-id:A.3.5. Bytecode State Creation"
  1013. }
  1014. };
  1015. int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t size2)
  1016. {
  1017. size_t i;
  1018. if(!size2) {
  1019. return 1;
  1020. }
  1021. if(size1 < size2) {
  1022. return 0;
  1023. }
  1024. for(i = 0; i< size2; i++) {
  1025. if(buffer1[i] != buffer2[i]) {
  1026. return 0;
  1027. }
  1028. }
  1029. return 1;
  1030. }
  1031. static const int16_t wordForEndianess = 0x4321;
  1032. static tsk_bool_t isBigEndian;
  1033. static TCOMP_INLINE uint16_t HostToNetworkShort(uint16_t x)
  1034. {
  1035. return isBigEndian ? (x) : ((((uint16_t)(x) & 0xff00) >> 8) |
  1036. (((uint16_t)(x) & 0x00ff) << 8));
  1037. }
  1038. static void checkResult(const struct_torture_test* test, const tcomp_result_t *result, const void* output_ptr, tsk_size_t output_size)
  1039. {
  1040. tsk_bool_t ok_cycles = (result->consumed_cycles == test->xcycles);
  1041. tsk_bool_t ok_output = tsk_true;
  1042. if(tsk_striequals(test->xoutput.ptr, "decompression_memory_size")) {
  1043. printf("xoutput (decompression_memory_size): %s\n", (HostToNetworkShort(DMS) == *((uint16_t*)output_ptr)) ? "YES" : "NO");
  1044. }
  1045. else {
  1046. ok_output = startsWith(output_ptr, output_size, test->xoutput.ptr, test->xoutput.size);
  1047. printf("xoutput: %s\n", ok_output ? "YES" : "NO");
  1048. }
  1049. printf("xcycles: %s\n", ok_cycles ? "YES" : "NO");
  1050. if(!ok_cycles || !ok_output) {
  1051. assert(test->xfail && result->isNack); // failure must be expected and NACK have to be present
  1052. assert(tsk_strequals(test->xoutput.ptr, tcomp_nackinfo_get_description(result->nack_info))); // returned NACK and expected one must be equal
  1053. }
  1054. }
  1055. static int test_tortures()
  1056. {
  1057. size_t i, start, end;
  1058. size_t res_size = 0;
  1059. char buffer[OUTPUT_BUFFER_SIZE];
  1060. #if RUN_TEST_LOOP
  1061. for(;;)
  1062. #endif
  1063. {
  1064. tcomp_manager_handle_t *manager = tcomp_manager_create();
  1065. tcomp_result_t *result = tcomp_result_create();
  1066. isBigEndian = ((*(int8_t *)&wordForEndianess) != 0x21);
  1067. /* Add SIP dictionary. */
  1068. tcomp_manager_addSipSdpDictionary(manager);
  1069. /* Add Presence dictionary. */
  1070. tcomp_manager_addPresenceDictionary(manager);
  1071. /* Set decompression size. */
  1072. tcomp_manager_setDecompression_Memory_Size(manager, DMS);
  1073. /* Set state memory size. */
  1074. tcomp_manager_setState_Memory_Size(manager, SMS);
  1075. /* Set Cycles Per Bit */
  1076. tcomp_manager_setCycles_Per_Bit(manager, CPB);
  1077. #if RUN_TEST_ALL
  1078. start = 0, end = sizeof(tests)/sizeof(tests[0]);
  1079. #else
  1080. start = RUN_TEST_NO, end = RUN_TEST_NO + 1;
  1081. #endif
  1082. for(i = start; i<end; i++) {
  1083. printf("=== Testing %s ===\n\n", tests[i].section_name);
  1084. if(tests[i].stream) {
  1085. tcomp_result_setOutputTCPBuffer(result, buffer, OUTPUT_BUFFER_SIZE, STREAM_ID);
  1086. }
  1087. else {
  1088. tcomp_result_setOutputUDPBuffer(result, buffer, OUTPUT_BUFFER_SIZE);
  1089. }
  1090. /* Performs decompression */
  1091. res_size = tcomp_manager_decompress(manager, tests[i].bytecode, tests[i].bytecode_size, result);
  1092. if(result->isNack) {
  1093. printf("\n==WE GOT A NACK\n\n");
  1094. //sendto(tcomp_buffer_getBuffer(result->nack_info), tcomp_buffer_getSize(result->nack_info));
  1095. }
  1096. else {
  1097. tcomp_result_setCompartmentId(result, tests[i].comp_id, strlen(tests[i].comp_id));
  1098. tcomp_manager_provideCompartmentId(manager, result);
  1099. }
  1100. /* Checks result */
  1101. checkResult(&tests[i], result, buffer, sizeof(buffer));
  1102. /* Get sub-sequent stream messages */
  1103. if(tests[i].stream && (res_size || result->isNack)) {
  1104. uint64_t consumed_cycles = result->consumed_cycles; // save "consumed_cycles" (shared by all sub-sequent messages)
  1105. for(;;) {
  1106. res_size = tcomp_manager_getNextStreamMessage(manager, result);
  1107. if(!res_size && !result->isNack) {
  1108. break;
  1109. }
  1110. else if(res_size) {
  1111. tcomp_result_setCompartmentId(result, tests[i].comp_id, strlen(tests[i].comp_id));
  1112. tcomp_manager_provideCompartmentId(manager, result);
  1113. }
  1114. else {
  1115. printf("\n==WE GOT A NACK\n\n");
  1116. //sendto(tcomp_buffer_getBuffer(result->nack_info), tcomp_buffer_getSize(result->nack_info));
  1117. }
  1118. result->consumed_cycles = consumed_cycles; // restore cycles just for checking. Had been cleared by "tcomp_manager_getNextStreamMessage()"
  1119. checkResult(&tests[i], result, buffer, sizeof(buffer));
  1120. }
  1121. }
  1122. }
  1123. /* Free previously allocated resources. */
  1124. TSK_OBJECT_SAFE_FREE(result);
  1125. TSK_OBJECT_SAFE_FREE(manager);
  1126. }/* LOOP */
  1127. return 0;
  1128. }
  1129. #endif /* TEST_TINYSIGCOMP_TORTURES_H */