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

dns_test.c 17KB

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