diff options
Diffstat (limited to 'testcode')
-rw-r--r-- | testcode/petal.c | 2 | ||||
-rw-r--r-- | testcode/replay.h | 20 | ||||
-rw-r--r-- | testcode/unitdname.c | 29 |
3 files changed, 41 insertions, 10 deletions
diff --git a/testcode/petal.c b/testcode/petal.c index dcc31fdc5d99a..123684aab52da 100644 --- a/testcode/petal.c +++ b/testcode/petal.c @@ -234,7 +234,9 @@ setup_ctx(char* key, char* cert) { SSL_CTX* ctx = SSL_CTX_new(SSLv23_server_method()); if(!ctx) print_exit("out of memory"); +#if SSL_OP_NO_SSLv2 != 0 (void)SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2); +#endif (void)SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv3); if(!SSL_CTX_use_certificate_chain_file(ctx, cert)) print_exit("cannot read cert"); diff --git a/testcode/replay.h b/testcode/replay.h index 0cce0b4901057..5132cdacbd473 100644 --- a/testcode/replay.h +++ b/testcode/replay.h @@ -74,18 +74,18 @@ * o CHECK_ANSWER - followed by entry * o CHECK_OUT_QUERY - followed by entry (if copy-id it is also reply). * o REPLY - followed by entry - * o TIMEOUT - * o TIME_PASSES ELAPSE [seconds] - increase 'now' time counter, can be - * a floating point number. - * TIME_PASSES EVAL [macro] - expanded for seconds to move time. - * o TRAFFIC - like CHECK_ANSWER, causes traffic to flow. + * o TIMEOUT + * o TIME_PASSES ELAPSE [seconds] - increase 'now' time counter, can be + * a floating point number. + * TIME_PASSES EVAL [macro] - expanded for seconds to move time. + * o TRAFFIC - like CHECK_ANSWER, causes traffic to flow. * actually the traffic flows before this step is taken. * the step waits for traffic to stop. - * o CHECK_AUTOTRUST [id] - followed by FILE_BEGIN [to match] FILE_END. - * The file contents is macro expanded before match. - * o CHECK_TEMPFILE [fname] - followed by FILE_BEGIN [to match] FILE_END - * o INFRA_RTT [ip] [dp] [rtt] - update infra cache entry with rtt. - * o ERROR + * o CHECK_AUTOTRUST [id] - followed by FILE_BEGIN [to match] FILE_END. + * The file contents is macro expanded before match. + * o CHECK_TEMPFILE [fname] - followed by FILE_BEGIN [to match] FILE_END + * o INFRA_RTT [ip] [dp] [rtt] - update infra cache entry with rtt. + * o ERROR * ; following entry starts on the next line, ENTRY_BEGIN. * ; more STEP items * SCENARIO_END diff --git a/testcode/unitdname.c b/testcode/unitdname.c index 238c3edf7ade1..6769127b93495 100644 --- a/testcode/unitdname.c +++ b/testcode/unitdname.c @@ -794,6 +794,34 @@ dname_test_valid(void) , 4096) == 0); } +/** Test dname_has_label */ +static void +dname_test_has_label(void) +{ + unit_show_func("util/data/dname.c", "dname_has_label"); + /* label past root label */ + unit_assert(dname_has_label((uint8_t*)"\01a\0\01c", 5, (uint8_t*)"\01c") == 0); + /* label not found */ + unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 6, (uint8_t*)"\01e") == 0); + /* buffer too short */ + unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 5, (uint8_t*)"\0") == 0); + unit_assert(dname_has_label((uint8_t*)"\1a\0", 2, (uint8_t*)"\0") == 0); + unit_assert(dname_has_label((uint8_t*)"\0", 0, (uint8_t*)"\0") == 0); + unit_assert(dname_has_label((uint8_t*)"\02ab\01c", 4, (uint8_t*)"\01c") == 0); + unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 19, (uint8_t*)"\01c") == 0); + + /* positive cases */ + unit_assert(dname_has_label((uint8_t*)"\0", 1, (uint8_t*)"\0") == 1); + unit_assert(dname_has_label((uint8_t*)"\1a\0", 3, (uint8_t*)"\0") == 1); + unit_assert(dname_has_label((uint8_t*)"\01a\0\01c", 5, (uint8_t*)"\0") == 1); + unit_assert(dname_has_label((uint8_t*)"\02ab\01c", 5, (uint8_t*)"\01c") == 1); + unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 10, (uint8_t*)"\0") == 1); + unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 7, (uint8_t*)"\0") == 1); + unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 22, (uint8_t*)"\03def") == 1); + unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 22, (uint8_t*)"\02ab") == 1); + unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 22, (uint8_t*)"\01c") == 1); +} + /** test pkt_dname_tolower */ static void dname_test_pdtl(sldns_buffer* loopbuf, sldns_buffer* boundbuf) @@ -855,6 +883,7 @@ void dname_test(void) dname_test_canoncmp(); dname_test_topdomain(); dname_test_valid(); + dname_test_has_label(); sldns_buffer_free(buff); sldns_buffer_free(loopbuf); sldns_buffer_free(boundbuf); |