選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dns_test.c 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /*
  2. * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. FILE_LICENCE ( GPL2_OR_LATER );
  20. /** @file
  21. *
  22. * DNS self-tests
  23. *
  24. */
  25. /* Forcibly enable assertions */
  26. #undef NDEBUG
  27. #include <string.h>
  28. #include <assert.h>
  29. #include <ipxe/dns.h>
  30. #include <ipxe/test.h>
  31. /** Define inline data */
  32. #define DATA(...) { __VA_ARGS__ }
  33. /** A DNS encoding test */
  34. struct dns_encode_test {
  35. /** String */
  36. const char *string;
  37. /** Encoded string */
  38. const void *data;
  39. /** Length of encoded string */
  40. int len;
  41. };
  42. /**
  43. * Define a DNS encoding test
  44. *
  45. * @v _name Test name
  46. * @v _string Test string
  47. * @v _data Expected encoded data
  48. * @ret test DNS encoding test
  49. */
  50. #define DNS_ENCODE( _name, _string, _data ) \
  51. static const uint8_t _name ## __data[] = _data; \
  52. static struct dns_encode_test _name = { \
  53. .string = _string, \
  54. .data = _name ## __data, \
  55. .len = sizeof ( _name ## __data ), \
  56. }
  57. /**
  58. * Report DNS encoding test result
  59. *
  60. * @v test DNS encoding test
  61. * @v file Test code file
  62. * @v line Test code line
  63. */
  64. static void dns_encode_okx ( struct dns_encode_test *test, const char *file,
  65. unsigned int line ) {
  66. uint8_t data[ test->len ];
  67. struct dns_name name;
  68. int len;
  69. /* Check ability to determine length with no buffer */
  70. memset ( &name, 0, sizeof ( name ) );
  71. len = dns_encode ( test->string, &name );
  72. okx ( len >= 0, file, line );
  73. okx ( len == test->len, file, line );
  74. /* Check encoded name */
  75. name.data = data;
  76. name.len = sizeof ( data );
  77. len = dns_encode ( test->string, &name );
  78. okx ( len >= 0, file, line );
  79. if ( len >= 0 ) {
  80. okx ( len == test->len, file, line );
  81. okx ( memcmp ( data, test->data, test->len ) == 0, file, line );
  82. DBGC ( test, "DNS encoded \"%s\" to:\n", test->string );
  83. DBGC_HDA ( test, 0, data, len );
  84. }
  85. }
  86. #define dns_encode_ok( test ) dns_encode_okx ( test, __FILE__, __LINE__ )
  87. /**
  88. * Report DNS encoding failure test result
  89. *
  90. * @v test DNS encoding test
  91. * @v file Test code file
  92. * @v line Test code line
  93. */
  94. static void dns_encode_fail_okx ( struct dns_encode_test *test,
  95. const char *file, unsigned int line ) {
  96. struct dns_name name = { .data = NULL, .len = 0 };
  97. int len;
  98. len = dns_encode ( test->string, &name );
  99. okx ( len < 0, file, line );
  100. }
  101. #define dns_encode_fail_ok( test ) \
  102. dns_encode_fail_okx ( test, __FILE__, __LINE__ )
  103. /** A DNS decoding test */
  104. struct dns_decode_test {
  105. /** Name */
  106. struct dns_name name;
  107. /** Expected string */
  108. const char *string;
  109. };
  110. /**
  111. * Define a DNS decoding test
  112. *
  113. * @v _name Test name
  114. * @v _data RFC1035-encoded data
  115. * @v _offset Starting offset within encoded data
  116. * @v _string Expected decoded string
  117. * @ret test DNS decoding test
  118. */
  119. #define DNS_DECODE( _name, _data, _offset, _string ) \
  120. static uint8_t _name ## __data[] = _data; \
  121. static struct dns_decode_test _name = { \
  122. .name = { \
  123. .data = _name ## __data, \
  124. .offset = _offset, \
  125. .len = sizeof ( _name ## __data ), \
  126. }, \
  127. .string = _string, \
  128. }
  129. /**
  130. * Report DNS decoding test result
  131. *
  132. * @v test DNS decoding test
  133. * @v file Test code file
  134. * @v line Test code line
  135. */
  136. static void dns_decode_okx ( struct dns_decode_test *test, const char *file,
  137. unsigned int line ) {
  138. char string[ strlen ( test->string ) + 1 /* NUL */ ];
  139. int len;
  140. /* Check ability to determine length with no buffer */
  141. len = dns_decode ( &test->name, NULL, 0 );
  142. okx ( len >= 0, file, line );
  143. okx ( len == ( ( int ) strlen ( test->string ) ), file, line );
  144. /* Check decoded string */
  145. len = dns_decode ( &test->name, string, sizeof ( string ) );
  146. okx ( len >= 0, file, line );
  147. if ( len >= 0 ) {
  148. okx ( strcmp ( string, test->string ) == 0, file, line );
  149. DBGC ( test, "DNS decoded \"%s\" from offset %#zx in:\n",
  150. string, test->name.offset );
  151. DBGC_HDA ( test, 0, test->name.data, test->name.len );
  152. }
  153. }
  154. #define dns_decode_ok( test ) dns_decode_okx ( test, __FILE__, __LINE__ )
  155. /**
  156. * Report DNS decoding failure test result
  157. *
  158. * @v test DNS decoding test
  159. * @v file Test code file
  160. * @v line Test code line
  161. */
  162. static void dns_decode_fail_okx ( struct dns_decode_test *test,
  163. const char *file, unsigned int line ) {
  164. int len;
  165. len = dns_decode ( &test->name, NULL, 0 );
  166. okx ( len < 0, file, line );
  167. }
  168. #define dns_decode_fail_ok( test ) \
  169. dns_decode_fail_okx ( test, __FILE__, __LINE__ )
  170. /** A DNS comparison test */
  171. struct dns_compare_test {
  172. /** First name */
  173. struct dns_name first;
  174. /** Second name */
  175. struct dns_name second;
  176. };
  177. /**
  178. * Define a DNS comparison test
  179. *
  180. * @v _name Test name
  181. * @v _first_data First RFC1035-encoded data
  182. * @v _first_offset Starting offset within first encoded data
  183. * @v _second_data Second RFC1035-encoded data
  184. * @v _second_offset Starting offset within second encoded data
  185. * @ret test DNS comparison test
  186. */
  187. #define DNS_COMPARE( _name, _first_data, _first_offset, _second_data, \
  188. _second_offset ) \
  189. static uint8_t _name ## __first_data[] = _first_data; \
  190. static uint8_t _name ## __second_data[] = _second_data; \
  191. static struct dns_compare_test _name = { \
  192. .first = { \
  193. .data = _name ## __first_data, \
  194. .offset = _first_offset, \
  195. .len = sizeof ( _name ## __first_data ), \
  196. }, \
  197. .second = { \
  198. .data = _name ## __second_data, \
  199. .offset = _second_offset, \
  200. .len = sizeof ( _name ## __second_data ), \
  201. }, \
  202. }
  203. /**
  204. * Report DNS comparison test result
  205. *
  206. * @v test DNS comparison test
  207. * @v file Test code file
  208. * @v line Test code line
  209. */
  210. static void dns_compare_okx ( struct dns_compare_test *test, const char *file,
  211. unsigned int line ) {
  212. okx ( dns_compare ( &test->first, &test->second ) == 0, file, line );
  213. }
  214. #define dns_compare_ok( test ) dns_compare_okx ( test, __FILE__, __LINE__ )
  215. /**
  216. * Report DNS comparison test failure result
  217. *
  218. * @v test DNS comparison test
  219. * @v file Test code file
  220. * @v line Test code line
  221. */
  222. static void dns_compare_fail_okx ( struct dns_compare_test *test,
  223. const char *file, unsigned int line ) {
  224. okx ( dns_compare ( &test->first, &test->second ) != 0, file, line );
  225. }
  226. #define dns_compare_fail_ok( test ) \
  227. dns_compare_fail_okx ( test, __FILE__, __LINE__ )
  228. /** A DNS copying test */
  229. struct dns_copy_test {
  230. /** Source name */
  231. struct dns_name src;
  232. /** Expected copied name */
  233. struct dns_name dst;
  234. };
  235. /**
  236. * Define a DNS copying test
  237. *
  238. * @v _name Test name
  239. * @v _src_data Source RFC1035-encoded data
  240. * @v _src_offset Starting offset within source encoded data
  241. * @v _dst_data Expected copied RFC1035-encoded data
  242. * @v _dst_offset Starting offset withint copied encoded data
  243. * @ret test DNS copying test
  244. */
  245. #define DNS_COPY( _name, _src_data, _src_offset, _dst_data, \
  246. _dst_offset ) \
  247. static uint8_t _name ## __src_data[] = _src_data; \
  248. static uint8_t _name ## __dst_data[] = _dst_data; \
  249. static struct dns_copy_test _name = { \
  250. .src = { \
  251. .data = _name ## __src_data, \
  252. .offset = _src_offset, \
  253. .len = sizeof ( _name ## __src_data ), \
  254. }, \
  255. .dst = { \
  256. .data = _name ## __dst_data, \
  257. .offset = _dst_offset, \
  258. .len = sizeof ( _name ## __dst_data ), \
  259. }, \
  260. }
  261. /**
  262. * Report a DNS copying test result
  263. *
  264. * @v test DNS copying test
  265. * @v file Test code file
  266. * @v line Test code line
  267. */
  268. static void dns_copy_okx ( struct dns_copy_test *test,
  269. const char *file, unsigned int line ) {
  270. uint8_t data[ test->dst.len ];
  271. struct dns_name dst;
  272. int len;
  273. /* Check ability to determine length with no buffer */
  274. memset ( &dst, 0, sizeof ( dst ) );
  275. len = dns_copy ( &test->src, &dst );
  276. okx ( len >= 0, file, line );
  277. okx ( len == ( ( int ) ( test->dst.len - test->dst.offset ) ),
  278. file, line );
  279. /* Check copied name */
  280. dst.data = data;
  281. dst.offset = test->dst.offset;
  282. dst.len = sizeof ( data );
  283. memcpy ( dst.data, test->dst.data, test->dst.offset );
  284. len = dns_copy ( &test->src, &dst );
  285. okx ( len >= 0, file, line );
  286. okx ( len == ( ( int ) ( test->dst.len - test->dst.offset ) ),
  287. file, line );
  288. okx ( memcmp ( data, test->dst.data, sizeof ( data ) ) == 0,
  289. file, line );
  290. DBGC ( test, "DNS copied:\n" );
  291. DBGC_HDA ( test, 0, test->src.data, test->src.len );
  292. DBGC_HDA ( test, 0, data, ( test->dst.offset + len ) );
  293. }
  294. #define dns_copy_ok( test ) dns_copy_okx ( test, __FILE__, __LINE__ )
  295. /**
  296. * Report a DNS copying failure test result
  297. *
  298. * @v test DNS copying test
  299. * @v file Test code file
  300. * @v line Test code line
  301. */
  302. static void dns_copy_fail_okx ( struct dns_copy_test *test,
  303. const char *file, unsigned int line ) {
  304. struct dns_name dst;
  305. int len;
  306. memset ( &dst, 0, sizeof ( dst ) );
  307. len = dns_copy ( &test->src, &dst );
  308. okx ( len < 0, file, line );
  309. }
  310. #define dns_copy_fail_ok( test ) dns_copy_fail_okx ( test, __FILE__, __LINE__ )
  311. /** A DNS search list test */
  312. struct dns_list_test {
  313. /** Search list */
  314. struct dns_name list;
  315. /** Expected decoded search list */
  316. const char **strings;
  317. /** Number of expected decoded string */
  318. unsigned int count;
  319. };
  320. /**
  321. * Define a DNS search list test
  322. *
  323. * @v _name Test name
  324. * @v _list RFC1035-encoded data
  325. * @v _strings Expected decoded strings
  326. * @ret test DNS search list test
  327. */
  328. #define DNS_LIST( _name, _list, _strings ) \
  329. static uint8_t _name ## __list[] = _list; \
  330. static const char * _name ## __strings[] = _strings; \
  331. static struct dns_list_test _name = { \
  332. .list = { \
  333. .data = _name ## __list, \
  334. .offset = 0, \
  335. .len = sizeof ( _name ## __list ), \
  336. }, \
  337. .strings = _name ## __strings, \
  338. .count = ( sizeof ( _name ## __strings ) / \
  339. sizeof ( _name ## __strings[0] ) ), \
  340. }
  341. /**
  342. * Report DNS search list test result
  343. *
  344. * @v test DNS search list test
  345. * @v file Test code file
  346. * @v line Test code line
  347. */
  348. static void dns_list_okx ( struct dns_list_test *test, const char *file,
  349. unsigned int line ) {
  350. struct dns_name name;
  351. unsigned int i;
  352. DBGC ( test, "DNS search list:\n" );
  353. DBGC_HDA ( test, 0, test->list.data, test->list.len );
  354. memcpy ( &name, &test->list, sizeof ( name ) );
  355. for ( i = 0 ; i < test->count ; i++ ) {
  356. char buf[ strlen ( test->strings[i] ) + 1 /* NUL */ ];
  357. int len;
  358. int offset;
  359. /* Decode this name */
  360. len = dns_decode ( &name, buf, sizeof ( buf ) );
  361. okx ( len >= 0, file, line );
  362. if ( len >= 0 ) {
  363. okx ( len == ( ( int ) strlen ( test->strings[i] ) ),
  364. file, line );
  365. okx ( strcmp ( buf, test->strings[i] ) == 0,
  366. file, line );
  367. DBGC ( test, "DNS search list found \"%s\" at offset "
  368. "%#zx\n", buf, name.offset );
  369. }
  370. /* Skip to next name */
  371. offset = dns_skip ( &name );
  372. okx ( offset >= 0, file, line );
  373. name.offset = offset;
  374. }
  375. /* Check that we have consumed the whole search list */
  376. okx ( name.offset == name.len, file, line );
  377. }
  378. #define dns_list_ok( test ) dns_list_okx ( test, __FILE__, __LINE__ )
  379. /* Simple encoding test */
  380. DNS_ENCODE ( encode_simple, "ipxe.org",
  381. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ) );
  382. /* Single-word encoding test */
  383. DNS_ENCODE ( encode_single, "foo", DATA ( 3, 'f', 'o', 'o', 0 ) );
  384. /* Absolute encoding test */
  385. DNS_ENCODE ( encode_absolute, "git.ipxe.org.",
  386. DATA ( 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g',
  387. 0 ) );
  388. /* Empty string encoding test */
  389. DNS_ENCODE ( encode_empty, "", DATA ( 0 ) );
  390. /* Root domain encoding test */
  391. DNS_ENCODE ( encode_root, ".", DATA ( 0 ) );
  392. /* Invalid initial dot encoding test */
  393. DNS_ENCODE ( encode_initial_dot, ".foo", DATA() );
  394. /* Invalid double dot encoding test */
  395. DNS_ENCODE ( encode_double_dot, "ipxe..org", DATA() );
  396. /* Invalid solo double dot encoding test */
  397. DNS_ENCODE ( encode_solo_double_dot, "..", DATA() );
  398. /* Invalid trailing double dot encoding test */
  399. DNS_ENCODE ( encode_trailing_double_dot, "ipxe.org..", DATA() );
  400. /* Invalid overlength label encoding test */
  401. DNS_ENCODE ( encode_overlength,
  402. "this-label-is-maliciously-long-in-an-attempt-to-overflow-the-"
  403. "length-field-and-generate-a-length-which-looks-like-a-"
  404. "compression-pointer", DATA() );
  405. /* Simple decoding test */
  406. DNS_DECODE ( decode_simple,
  407. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0,
  408. "ipxe.org" );
  409. /* Compression pointer decoding test */
  410. DNS_DECODE ( decode_ptr,
  411. DATA ( 3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x',
  412. 'e', 0xc0, 0x00 ), 5,
  413. "git.ipxe.org" );
  414. /* Root decoding test */
  415. DNS_DECODE ( decode_root,
  416. DATA ( 0 ), 0, "" );
  417. /* Incomplete name decoding test */
  418. DNS_DECODE ( decode_incomplete_name,
  419. DATA ( 4, 'i', 'p', 'x', 'e' ), 0, NULL );
  420. /* Incomplete label decoding test */
  421. DNS_DECODE ( decode_incomplete_label,
  422. DATA ( 4, 'i', 'p', 'x' ), 0, NULL );
  423. /* Incomplete compression pointer decoding test */
  424. DNS_DECODE ( decode_incomplete_ptr,
  425. DATA ( 3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e', 0xc0 ), 5,
  426. NULL );
  427. /* Forward reference decoding test */
  428. DNS_DECODE ( decode_forward,
  429. DATA ( 0xc0, 0x02, 3, 'f', 'o', 'o', 0 ), 0, NULL );
  430. /* Infinite loop decoding test */
  431. DNS_DECODE ( decode_infinite,
  432. DATA ( 4, 'i', 'p', 'x', 'e', 0xc0, 0x00 ), 0, NULL );
  433. /* Empty decoding test */
  434. DNS_DECODE ( decode_empty,
  435. DATA (), 0, NULL );
  436. /* Simple comparison test */
  437. DNS_COMPARE ( compare_simple,
  438. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0,
  439. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0 );
  440. /* Compression pointer comparison test */
  441. DNS_COMPARE ( compare_ptr,
  442. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0,
  443. DATA ( 3, 'o', 'r', 'g', 0, 4, 'i', 'p', 'x', 'e',
  444. 0xc0, 0x00 ), 5 );
  445. /* Case insensitive comparison test */
  446. DNS_COMPARE ( compare_case,
  447. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0,
  448. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'O', 'R', 'G', 0 ), 0 );
  449. /* Mismatch comparison test */
  450. DNS_COMPARE ( compare_mismatch,
  451. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0,
  452. DATA ( 4, 'g', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0 );
  453. /* Infinite loop comparison test */
  454. DNS_COMPARE ( compare_infinite,
  455. DATA ( 3, 'f', 'o', 'o', 0xc0, 0x00 ), 0,
  456. DATA ( 3, 'f', 'o', 'o', 0xc0, 0x00 ), 0 );
  457. /* Simple copying test */
  458. DNS_COPY ( copy_simple,
  459. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0,
  460. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0 );
  461. /* Simple copying test with offset */
  462. DNS_COPY ( copy_offset,
  463. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0 ), 0,
  464. DATA ( 'f', 'o', 'o', 0, 4, 'i', 'p', 'x', 'e',
  465. 3, 'o', 'r', 'g', 0 ), 4 );
  466. /* Compression pointer copying test */
  467. DNS_COPY ( copy_ptr,
  468. DATA ( 3, 'o', 'r', 'g', 0, 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e',
  469. 0xc0, 0x00 ), 5,
  470. DATA ( 3, 'g', 'i', 't', 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g',
  471. 0 ), 0 );
  472. /* Infinite loop copying test */
  473. DNS_COPY ( copy_infinite,
  474. DATA ( 4, 'l', 'o', 'o', 'p', 7, 'f', 'o', 'r', 'e', 'v', 'e', 'r',
  475. 0xc0, 0x05 ), 0,
  476. DATA (), 0 );
  477. /* DNS search list test */
  478. DNS_LIST ( search,
  479. DATA ( 4, 'i', 'p', 'x', 'e', 3, 'o', 'r', 'g', 0,
  480. 4, 'b', 'o', 'o', 't', 0xc0, 0x00,
  481. 3, 'd', 'e', 'v', 0xc0, 0x0a,
  482. 11, 'n', 'e', 't', 'w', 'o', 'r', 'k', 'b', 'o', 'o', 't',
  483. 0xc0, 0x05 ),
  484. DATA ( "ipxe.org", "boot.ipxe.org", "dev.boot.ipxe.org",
  485. "networkboot.org" ) );
  486. /**
  487. * Perform DNS self-test
  488. *
  489. */
  490. static void dns_test_exec ( void ) {
  491. /* Encoding tests */
  492. dns_encode_ok ( &encode_simple );
  493. dns_encode_ok ( &encode_single );
  494. dns_encode_ok ( &encode_absolute );
  495. dns_encode_ok ( &encode_empty );
  496. dns_encode_ok ( &encode_root );
  497. dns_encode_fail_ok ( &encode_initial_dot );
  498. dns_encode_fail_ok ( &encode_double_dot );
  499. dns_encode_fail_ok ( &encode_solo_double_dot );
  500. dns_encode_fail_ok ( &encode_trailing_double_dot );
  501. dns_encode_fail_ok ( &encode_overlength );
  502. /* Decoding tests */
  503. dns_decode_ok ( &decode_simple );
  504. dns_decode_ok ( &decode_ptr );
  505. dns_decode_ok ( &decode_root );
  506. dns_decode_fail_ok ( &decode_incomplete_name );
  507. dns_decode_fail_ok ( &decode_incomplete_label );
  508. dns_decode_fail_ok ( &decode_incomplete_ptr );
  509. dns_decode_fail_ok ( &decode_forward );
  510. dns_decode_fail_ok ( &decode_infinite );
  511. dns_decode_fail_ok ( &decode_empty );
  512. /* Comparison tests */
  513. dns_compare_ok ( &compare_simple );
  514. dns_compare_ok ( &compare_ptr );
  515. dns_compare_ok ( &compare_case );
  516. dns_compare_fail_ok ( &compare_mismatch );
  517. dns_compare_fail_ok ( &compare_infinite );
  518. /* Copying tests */
  519. dns_copy_ok ( &copy_simple );
  520. dns_copy_ok ( &copy_offset );
  521. dns_copy_ok ( &copy_ptr );
  522. dns_copy_fail_ok ( &copy_infinite );
  523. /* Search list tets */
  524. dns_list_ok ( &search );
  525. }
  526. /** DNS self-test */
  527. struct self_test dns_test __self_test = {
  528. .name = "dns",
  529. .exec = dns_test_exec,
  530. };