From e2fc8e037ea6bb5de92b25ec9c12a624737ac5ca Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 18:41:29 +0200 Subject: Merging upstream version 1:9.18.24. Signed-off-by: Daniel Baumann --- tests/Makefile.in | 2 - tests/dns/Makefile.in | 2 - tests/irs/Makefile.in | 2 - tests/isc/Makefile.in | 2 - tests/isc/hmac_test.c | 212 ++++++++++++++++++++++--------------------- tests/isc/ht_test.c | 50 ++++++++++ tests/isc/netmgr_test.c | 178 +++++++++++++++++++++++++++++++++++- tests/isccfg/Makefile.in | 2 - tests/libtest/Makefile.in | 2 - tests/libtest/ns.c | 2 +- tests/ns/Makefile.in | 2 - tests/unit-test-driver.sh.in | 48 +++++----- 12 files changed, 358 insertions(+), 146 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.in b/tests/Makefile.in index 7a21334..277b6be 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -103,11 +103,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ $(top_srcdir)/m4/ax_jemalloc.m4 \ $(top_srcdir)/m4/ax_lib_lmdb.m4 \ - $(top_srcdir)/m4/ax_perl_module.m4 \ $(top_srcdir)/m4/ax_posix_shell.m4 \ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ - $(top_srcdir)/m4/ax_python_module.m4 \ $(top_srcdir)/m4/ax_restore_flags.m4 \ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ diff --git a/tests/dns/Makefile.in b/tests/dns/Makefile.in index 34e27a8..88072f8 100644 --- a/tests/dns/Makefile.in +++ b/tests/dns/Makefile.in @@ -127,11 +127,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ $(top_srcdir)/m4/ax_jemalloc.m4 \ $(top_srcdir)/m4/ax_lib_lmdb.m4 \ - $(top_srcdir)/m4/ax_perl_module.m4 \ $(top_srcdir)/m4/ax_posix_shell.m4 \ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ - $(top_srcdir)/m4/ax_python_module.m4 \ $(top_srcdir)/m4/ax_restore_flags.m4 \ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ diff --git a/tests/irs/Makefile.in b/tests/irs/Makefile.in index e5500c1..eb46005 100644 --- a/tests/irs/Makefile.in +++ b/tests/irs/Makefile.in @@ -106,11 +106,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ $(top_srcdir)/m4/ax_jemalloc.m4 \ $(top_srcdir)/m4/ax_lib_lmdb.m4 \ - $(top_srcdir)/m4/ax_perl_module.m4 \ $(top_srcdir)/m4/ax_posix_shell.m4 \ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ - $(top_srcdir)/m4/ax_python_module.m4 \ $(top_srcdir)/m4/ax_restore_flags.m4 \ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ diff --git a/tests/isc/Makefile.in b/tests/isc/Makefile.in index 1060d23..424a589 100644 --- a/tests/isc/Makefile.in +++ b/tests/isc/Makefile.in @@ -124,11 +124,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ $(top_srcdir)/m4/ax_jemalloc.m4 \ $(top_srcdir)/m4/ax_lib_lmdb.m4 \ - $(top_srcdir)/m4/ax_perl_module.m4 \ $(top_srcdir)/m4/ax_posix_shell.m4 \ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ - $(top_srcdir)/m4/ax_python_module.m4 \ $(top_srcdir)/m4/ax_restore_flags.m4 \ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ diff --git a/tests/isc/hmac_test.c b/tests/isc/hmac_test.c index 093c6b2..a1715b0 100644 --- a/tests/isc/hmac_test.c +++ b/tests/isc/hmac_test.c @@ -45,11 +45,11 @@ static int _setup(void **state) { - isc_hmac_t *hmac = isc_hmac_new(); - if (hmac == NULL) { + isc_hmac_t *hmac_st = isc_hmac_new(); + if (hmac_st == NULL) { return (-1); } - *state = hmac; + *state = hmac_st; return (0); } @@ -76,31 +76,32 @@ _reset(void **state) { ISC_RUN_TEST_IMPL(isc_hmac_new) { UNUSED(state); - isc_hmac_t *hmac = isc_hmac_new(); - assert_non_null(hmac); - isc_hmac_free(hmac); /* Cleanup */ + isc_hmac_t *hmac_st = isc_hmac_new(); + assert_non_null(hmac_st); + isc_hmac_free(hmac_st); /* Cleanup */ } ISC_RUN_TEST_IMPL(isc_hmac_free) { UNUSED(state); - isc_hmac_t *hmac = isc_hmac_new(); - assert_non_null(hmac); - isc_hmac_free(hmac); /* Test freeing valid message digest context */ - isc_hmac_free(NULL); /* Test freeing NULL argument */ + isc_hmac_t *hmac_st = isc_hmac_new(); + assert_non_null(hmac_st); + isc_hmac_free(hmac_st); /* Test freeing valid message digest context */ + isc_hmac_free(NULL); /* Test freeing NULL argument */ } static void -isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen, +isc_hmac_test(isc_hmac_t *hmac_st, const void *key, size_t keylen, const isc_md_type_t *type, const char *buf, size_t buflen, const char *result, const size_t repeats) { isc_result_t res; - assert_non_null(hmac); - assert_int_equal(isc_hmac_init(hmac, key, keylen, type), ISC_R_SUCCESS); + assert_non_null(hmac_st); + assert_int_equal(isc_hmac_init(hmac_st, key, keylen, type), + ISC_R_SUCCESS); for (size_t i = 0; i < repeats; i++) { - assert_int_equal(isc_hmac_update(hmac, + assert_int_equal(isc_hmac_update(hmac_st, (const unsigned char *)buf, buflen), ISC_R_SUCCESS); @@ -108,7 +109,7 @@ isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen, unsigned char digest[ISC_MAX_MD_SIZE]; unsigned int digestlen = sizeof(digest); - assert_int_equal(isc_hmac_final(hmac, digest, &digestlen), + assert_int_equal(isc_hmac_final(hmac_st, digest, &digestlen), ISC_R_SUCCESS); char hexdigest[ISC_MAX_MD_SIZE * 2 + 3]; @@ -121,73 +122,76 @@ isc_hmac_test(isc_hmac_t *hmac, const void *key, size_t keylen, assert_return_code(res, ISC_R_SUCCESS); assert_memory_equal(hexdigest, result, (result ? strlen(result) : 0)); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); } ISC_RUN_TEST_IMPL(isc_hmac_init) { - isc_hmac_t *hmac = *state; - assert_non_null(hmac); + isc_hmac_t *hmac_st = *state; + assert_non_null(hmac_st); expect_assert_failure(isc_hmac_init(NULL, "", 0, ISC_MD_MD5)); - assert_int_equal(isc_hmac_init(hmac, "", 0, NULL), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, NULL), ISC_R_NOTIMPLEMENTED); - expect_assert_failure(isc_hmac_init(hmac, NULL, 0, ISC_MD_MD5)); + expect_assert_failure(isc_hmac_init(hmac_st, NULL, 0, ISC_MD_MD5)); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_MD5), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_MD5), + ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA1), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA1), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA224), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA224), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA256), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA256), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA384), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA384), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA512), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA512), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); } ISC_RUN_TEST_IMPL(isc_hmac_update) { - isc_hmac_t *hmac = *state; - assert_non_null(hmac); + isc_hmac_t *hmac_st = *state; + assert_non_null(hmac_st); /* Uses message digest context initialized in isc_hmac_init_test() */ expect_assert_failure(isc_hmac_update(NULL, NULL, 0)); - assert_int_equal(isc_hmac_update(hmac, NULL, 100), ISC_R_SUCCESS); - assert_int_equal(isc_hmac_update(hmac, (const unsigned char *)"", 0), + assert_int_equal(isc_hmac_update(hmac_st, NULL, 100), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_update(hmac_st, (const unsigned char *)"", 0), ISC_R_SUCCESS); } ISC_RUN_TEST_IMPL(isc_hmac_reset) { - isc_hmac_t *hmac = *state; + isc_hmac_t *hmac_st = *state; #if 0 unsigned char digest[ISC_MAX_MD_SIZE] __attribute((unused)); unsigned int digestlen __attribute((unused)); #endif /* if 0 */ - assert_non_null(hmac); + assert_non_null(hmac_st); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA512), - ISC_R_SUCCESS); - assert_int_equal(isc_hmac_update(hmac, (const unsigned char *)"a", 1), - ISC_R_SUCCESS); - assert_int_equal(isc_hmac_update(hmac, (const unsigned char *)"b", 1), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA512), ISC_R_SUCCESS); + assert_int_equal( + isc_hmac_update(hmac_st, (const unsigned char *)"a", 1), + ISC_R_SUCCESS); + assert_int_equal( + isc_hmac_update(hmac_st, (const unsigned char *)"b", 1), + ISC_R_SUCCESS); - assert_int_equal(isc_hmac_reset(hmac), ISC_R_SUCCESS); + assert_int_equal(isc_hmac_reset(hmac_st), ISC_R_SUCCESS); #if 0 /* @@ -195,13 +199,13 @@ ISC_RUN_TEST_IMPL(isc_hmac_reset) { * so this could be only manually checked that the test will * segfault when called by hand */ - expect_assert_failure(isc_hmac_final(hmac, digest, &digestlen)); + expect_assert_failure(isc_hmac_final(hmac_st, digest, &digestlen)); #endif /* if 0 */ } ISC_RUN_TEST_IMPL(isc_hmac_final) { - isc_hmac_t *hmac = *state; - assert_non_null(hmac); + isc_hmac_t *hmac_st = *state; + assert_non_null(hmac_st); unsigned char digest[ISC_MAX_MD_SIZE]; unsigned int digestlen = sizeof(digest); @@ -209,23 +213,23 @@ ISC_RUN_TEST_IMPL(isc_hmac_final) { /* Fail when message digest context is empty */ expect_assert_failure(isc_hmac_final(NULL, digest, &digestlen)); /* Fail when output buffer is empty */ - expect_assert_failure(isc_hmac_final(hmac, NULL, &digestlen)); + expect_assert_failure(isc_hmac_final(hmac_st, NULL, &digestlen)); - assert_int_equal(isc_hmac_init(hmac, "", 0, ISC_MD_SHA512), + assert_int_equal(isc_hmac_init(hmac_st, "", 0, ISC_MD_SHA512), ISC_R_SUCCESS); /* Fail when the digest length pointer is empty */ - expect_assert_failure(isc_hmac_final(hmac, digest, NULL)); + expect_assert_failure(isc_hmac_final(hmac_st, digest, NULL)); } ISC_RUN_TEST_IMPL(isc_hmac_md5) { - isc_hmac_t *hmac = *state; + isc_hmac_t *hmac_st = *state; /* Test 0 */ - isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_MD5, TEST_INPUT(""), + isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_MD5, TEST_INPUT(""), "74E6F7298A9C2D168935F58C001BAD88", 1); /* Test 1 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" "\x0b\x0b\x0b\x0b\x0b\x0b"), ISC_MD_MD5, @@ -233,14 +237,14 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) { "9294727A3638BB1C13F48EF8158BFC9D", 1); /* Test 2 */ - isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_MD5, + isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_MD5, TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79" "\x61\x20\x77\x61\x6e\x74\x20\x66\x6f" "\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"), "750C783E6AB0B503EAA86E310A5DB738", 1); /* Test 3 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa"), ISC_MD_MD5, @@ -251,7 +255,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"), "56BE34521D144C88DBB8C733F0E8B3F6", 1); /* Test 4 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19"), @@ -264,7 +268,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) { "697EAF0ACA3A3AEA3A75164746FFAA79", 1); #if 0 /* Test 5 -- unimplemented optional functionality */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"), ISC_MD_MD5, @@ -272,7 +276,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) { "4C1A03424B55E07FE7F27BE1", 1); /* Test 6 -- unimplemented optional functionality */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -292,7 +296,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) { "AA4AE5E15272D00E95705637CE8A3B55ED402112", 1); /* Test 7 -- unimplemented optional functionality */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -315,27 +319,27 @@ ISC_RUN_TEST_IMPL(isc_hmac_md5) { } ISC_RUN_TEST_IMPL(isc_hmac_sha1) { - isc_hmac_t *hmac = *state; + isc_hmac_t *hmac_st = *state; /* Test 0 */ - isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA1, TEST_INPUT(""), + isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA1, TEST_INPUT(""), "FBDB1D1B18AA6C08324B7D64B71FB76370690E1D", 1); /* Test 1 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"), ISC_MD_SHA1, TEST_INPUT("\x48\x69\x20\x54\x68\x65\x72\x65"), "B617318655057264E28BC0B6FB378C8EF146BE00", 1); /* Test 2 */ - isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA1, + isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA1, TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61" "\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20" "\x6e\x6f\x74\x68\x69\x6e\x67\x3f"), "EFFCDF6AE5EB2FA2D27416D5F184DF9C259A7C79", 1); /* Test 3 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"), ISC_MD_SHA1, @@ -346,7 +350,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD"), "125D7342B9AC11CD91A39AF48AA17B4F63F175D3", 1); /* Test 4 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19"), @@ -359,7 +363,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) { "4C9007F4026250C6BC8414F9BF50C86C2D7235DA", 1); #if 0 /* Test 5 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"), ISC_MD_SHA1, @@ -368,7 +372,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) { 1); #endif /* if 0 */ /* Test 6 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -382,7 +386,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) { "Hash Key First"), "AA4AE5E15272D00E95705637CE8A3B55ED402112", 1); /* Test 7 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -398,16 +402,16 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha1) { } ISC_RUN_TEST_IMPL(isc_hmac_sha224) { - isc_hmac_t *hmac = *state; + isc_hmac_t *hmac_st = *state; /* Test 0 */ - isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA224, TEST_INPUT(""), + isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA224, TEST_INPUT(""), "5CE14F72894662213E2748D2A6BA234B74263910CEDDE2F5" "A9271524", 1); /* Test 1 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"), ISC_MD_SHA224, @@ -416,7 +420,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) { "4F53684B22", 1); /* Test 2 */ - isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA224, + isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA224, TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61" "\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20" "\x6e\x6f\x74\x68\x69\x6e\x67\x3f"), @@ -424,7 +428,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) { "08FD05E44", 1); /* Test 3 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"), ISC_MD_SHA224, @@ -437,7 +441,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) { "D1EC8333EA", 1); /* Test 4 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19"), @@ -452,7 +456,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) { 1); #if 0 /* Test 5 -- unimplemented optional functionality */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"), ISC_MD_SHA224, @@ -461,7 +465,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) { 1); #endif /* if 0 */ /* Test 6 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -483,7 +487,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) { "273FA6870E", 1); /* Test 7 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -521,16 +525,16 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha224) { } ISC_RUN_TEST_IMPL(isc_hmac_sha256) { - isc_hmac_t *hmac = *state; + isc_hmac_t *hmac_st = *state; /* Test 0 */ - isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA256, TEST_INPUT(""), + isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA256, TEST_INPUT(""), "B613679A0814D9EC772F95D778C35FC5FF1697C493715653" "C6C712144292C5AD", 1); /* Test 1 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"), ISC_MD_SHA256, @@ -539,7 +543,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) { "A726E9376C2E32CFF7", 1); /* Test 2 */ - isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA256, + isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA256, TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61" "\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20" "\x6e\x6f\x74\x68\x69\x6e\x67\x3f"), @@ -547,7 +551,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) { "839DEC58B964EC3843", 1); /* Test 3 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"), ISC_MD_SHA256, @@ -560,7 +564,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) { "22D9635514CED565FE", 1); /* Test 4 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19"), @@ -575,7 +579,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) { 1); #if 0 /* Test 5 -- unimplemented optional functionality */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"), ISC_MD_SHA256, @@ -584,7 +588,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) { 1); #endif /* if 0 */ /* Test 6 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -606,7 +610,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) { "140546040F0EE37F54", 1); /* Test 7 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -644,16 +648,16 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha256) { } ISC_RUN_TEST_IMPL(isc_hmac_sha384) { - isc_hmac_t *hmac = *state; + isc_hmac_t *hmac_st = *state; /* Test 0 */ - isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA384, TEST_INPUT(""), + isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA384, TEST_INPUT(""), "6C1F2EE938FAD2E24BD91298474382CA218C75DB3D83E114" "B3D4367776D14D3551289E75E8209CD4B792302840234ADC", 1); /* Test 1 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"), ISC_MD_SHA384, @@ -663,7 +667,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) { "E8B2FA9CB6", 1); /* Test 2 */ - isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA384, + isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA384, TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61" "\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20" "\x6e\x6f\x74\x68\x69\x6e\x67\x3f"), @@ -672,7 +676,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) { "ECFAB21649", 1); /* Test 3 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"), ISC_MD_SHA384, @@ -686,7 +690,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) { "E101A34F27", 1); /* Test 4 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19"), @@ -702,7 +706,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) { 1); #if 0 /* Test 5 -- unimplemented optional functionality */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"), ISC_MD_SHA384, @@ -711,7 +715,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) { 1); #endif /* if 0 */ /* Test 6 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -734,7 +738,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) { "F163F44952", 1); /* Test 7 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -773,17 +777,17 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha384) { } ISC_RUN_TEST_IMPL(isc_hmac_sha512) { - isc_hmac_t *hmac = *state; + isc_hmac_t *hmac_st = *state; /* Test 0 */ - isc_hmac_test(hmac, TEST_INPUT(""), ISC_MD_SHA512, TEST_INPUT(""), + isc_hmac_test(hmac_st, TEST_INPUT(""), ISC_MD_SHA512, TEST_INPUT(""), "B936CEE86C9F87AA5D3C6F2E84CB5A4239A5FE50480A6EC6" "6B70AB5B1F4AC6730C6C515421B327EC1D69402E53DFB49A" "D7381EB067B338FD7B0CB22247225D47", 1); /* Test 1 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"), ISC_MD_SHA512, @@ -793,7 +797,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) { "4EAEA3F4E4BE9D914EEB61F1702E696C203A126854", 1); /* Test 2 */ - isc_hmac_test(hmac, TEST_INPUT("Jefe"), ISC_MD_SHA512, + isc_hmac_test(hmac_st, TEST_INPUT("Jefe"), ISC_MD_SHA512, TEST_INPUT("\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61" "\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20" "\x6e\x6f\x74\x68\x69\x6e\x67\x3f"), @@ -802,7 +806,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) { "65F8F0E6FDCAEAB1A34D4A6B4B636E070A38BCE737", 1); /* Test 3 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"), ISC_MD_SHA512, @@ -816,7 +820,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) { "A47E67C807B946A337BEE8942674278859E13292FB", 1); /* Test 4 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a" "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19"), @@ -832,7 +836,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) { 1); #if 0 /* Test 5 -- unimplemented optional functionality */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"), ISC_MD_SHA512, @@ -841,7 +845,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) { 1); #endif /* if 0 */ /* Test 6 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -864,7 +868,7 @@ ISC_RUN_TEST_IMPL(isc_hmac_sha512) { "215D6A1E5295E64F73F63F0AEC8B915A985D786598", 1); /* Test 7 */ - isc_hmac_test(hmac, + isc_hmac_test(hmac_st, TEST_INPUT("\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" diff --git a/tests/isc/ht_test.c b/tests/isc/ht_test.c index 89e18f3..64efa9d 100644 --- a/tests/isc/ht_test.c +++ b/tests/isc/ht_test.c @@ -312,7 +312,57 @@ ISC_RUN_TEST_IMPL(isc_ht_iterator) { test_ht_iterator(); } +ISC_RUN_TEST_IMPL(isc_ht_case) { + isc_ht_t *ht = NULL; + void *f = NULL; + isc_result_t result = ISC_R_UNSET; + + unsigned char lower[16] = { "test case" }; + unsigned char same[16] = { "test case" }; + unsigned char upper[16] = { "TEST CASE" }; + unsigned char mixed[16] = { "tEsT CaSe" }; + + isc_ht_init(&ht, mctx, 8, ISC_HT_CASE_SENSITIVE); + assert_non_null(ht); + + result = isc_ht_add(ht, lower, 16, (void *)lower); + assert_int_equal(result, ISC_R_SUCCESS); + + result = isc_ht_add(ht, same, 16, (void *)same); + assert_int_equal(result, ISC_R_EXISTS); + + result = isc_ht_add(ht, upper, 16, (void *)upper); + assert_int_equal(result, ISC_R_SUCCESS); + + result = isc_ht_find(ht, mixed, 16, &f); + assert_int_equal(result, ISC_R_NOTFOUND); + assert_null(f); + + isc_ht_destroy(&ht); + assert_null(ht); + + isc_ht_init(&ht, mctx, 8, ISC_HT_CASE_INSENSITIVE); + assert_non_null(ht); + + result = isc_ht_add(ht, lower, 16, (void *)lower); + assert_int_equal(result, ISC_R_SUCCESS); + + result = isc_ht_add(ht, same, 16, (void *)same); + assert_int_equal(result, ISC_R_EXISTS); + + result = isc_ht_add(ht, upper, 16, (void *)upper); + assert_int_equal(result, ISC_R_EXISTS); + + result = isc_ht_find(ht, mixed, 16, &f); + assert_int_equal(result, ISC_R_SUCCESS); + assert_ptr_equal(f, &lower); + + isc_ht_destroy(&ht); + assert_null(ht); +} + ISC_TEST_LIST_START +ISC_TEST_ENTRY(isc_ht_case) ISC_TEST_ENTRY(isc_ht_20) ISC_TEST_ENTRY(isc_ht_8) ISC_TEST_ENTRY(isc_ht_1) diff --git a/tests/isc/netmgr_test.c b/tests/isc/netmgr_test.c index a20db6b..49e5e01 100644 --- a/tests/isc/netmgr_test.c +++ b/tests/isc/netmgr_test.c @@ -393,8 +393,8 @@ noop_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region, UNUSED(cbarg); } -static unsigned int -noop_accept_cb(isc_nmhandle_t *handle, unsigned int result, void *cbarg) { +static isc_result_t +noop_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) { UNUSED(handle); UNUSED(cbarg); @@ -402,7 +402,7 @@ noop_accept_cb(isc_nmhandle_t *handle, unsigned int result, void *cbarg) { (void)atomic_fetch_add(&saccepts, 1); } - return (0); + return (ISC_R_SUCCESS); } static void @@ -2401,6 +2401,176 @@ ISC_RUN_TEST_IMPL(tlsdns_recv_one) { atomic_assert_int_eq(ssends, 0); } +static void +tlsdns_many_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult, + isc_region_t *region, void *cbarg) { + uint64_t magic = 0; + isc_nmhandle_t *sendhandle = NULL; + isc_buffer_t *send_data = (isc_buffer_t *)cbarg; + isc_region_t send_messages = { 0 }; + + assert_non_null(handle); + assert_non_null(send_data); + + F(); + + if (eresult != ISC_R_SUCCESS) { + goto unref; + } + + atomic_fetch_add(&sreads, 1); + + assert_true(region->length >= sizeof(magic)); + + memmove(&magic, region->base + sizeof(uint16_t), sizeof(magic)); + assert_true(magic == stop_magic || magic == send_magic); + + isc_nmhandle_attach(handle, &sendhandle); + isc_refcount_increment0(&active_ssends); + isc_nmhandle_setwritetimeout(sendhandle, T_IDLE); + /* send multiple DNS messages at once */ + isc_buffer_usedregion(send_data, &send_messages); + isc_nm_send(sendhandle, &send_messages, listen_send_cb, cbarg); +unref: + isc_refcount_decrement(&active_sreads); + isc_nmhandle_detach(&handle); +} + +static isc_result_t +tlsdns_many_listen_accept_cb(isc_nmhandle_t *handle, isc_result_t eresult, + void *cbarg) { + isc_nmhandle_t *readhandle = NULL; + + UNUSED(cbarg); + + F(); + + if (eresult != ISC_R_SUCCESS) { + return (eresult); + } + + atomic_fetch_add(&saccepts, 1); + + isc_refcount_increment0(&active_sreads); + isc_nmhandle_attach(handle, &readhandle); + isc_nm_read(handle, tlsdns_many_listen_read_cb, cbarg); + + return (ISC_R_SUCCESS); +} + +static void +tlsdns_many_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult, + isc_region_t *region, void *cbarg) { + isc_nmhandle_t *sendhandle = NULL; + uint64_t magic = 0; + + UNUSED(cbarg); + + assert_non_null(handle); + + F(); + + if (eresult != ISC_R_SUCCESS) { + goto unref; + } + + assert_true(region->length >= sizeof(magic)); + + atomic_fetch_add(&creads, 1); + + memmove(&magic, region->base, sizeof(magic)); + + assert_true(magic == stop_magic || magic == send_magic); + + isc_refcount_increment0(&active_csends); + isc_nmhandle_attach(handle, &sendhandle); + isc_nmhandle_setwritetimeout(handle, T_IDLE); + /* + * At this point the read is completed, so we should stop that - + * but the sending code will make a cycling through input + * attempt. When not properly handled, this situation will cause + * excessive reads. + */ + isc_nm_send(sendhandle, &send_msg, connect_send_cb, NULL); + +unref: + isc_refcount_decrement(&active_creads); + isc_nmhandle_detach(&handle); +} + +/* + * A unit test *VERY* specific to #4487 - it would crash the unit test + * suite without the related fix due to excessive/unexpected reads. + * + * The intention behind the test is to (needlessly ;-)) prove that the + * author of the fix is not fantasising and excessive reads are + * possible in principle. Also, it proves that there is more than one + * way to do that. + * + * It is *not* reproducing the situation from the bug report 1:1, as + * it is impossible to understand what exactly was going on with this + * custom/proprietary server without having access to it (and even in + * that case the bug was hard to reproduce to the point, where the + * reporters considered it to be fixed for a while). There are far too + * many things a play. + */ +ISC_RUN_TEST_IMPL(tlsdns_server_send_many_recv_one) { + isc_result_t result = ISC_R_SUCCESS; + isc_nmsocket_t *listen_sock = NULL; + uint8_t buf[512]; + isc_buffer_t server_send_buf = { 0 }; + + isc_buffer_init(&server_send_buf, buf, sizeof(buf)); + + /* + * Prepare a buffer with three "DNS" messages which we will send + * at once (our code does not normally do that do that). + */ + isc_buffer_putuint16(&server_send_buf, (uint16_t)send_msg.length); + isc_buffer_putmem(&server_send_buf, send_msg.base, send_msg.length); + isc_buffer_putuint16(&server_send_buf, (uint16_t)send_msg.length); + isc_buffer_putmem(&server_send_buf, send_msg.base, send_msg.length); + isc_buffer_putuint16(&server_send_buf, (uint16_t)send_msg.length); + isc_buffer_putmem(&server_send_buf, send_msg.base, send_msg.length); + + atomic_store(&nsends, 1); + + result = isc_nm_listentls( + listen_nm, &tcp_listen_addr, tlsdns_many_listen_accept_cb, + &server_send_buf, 0, 0, NULL, tcp_listen_tlsctx, &listen_sock); + assert_int_equal(result, ISC_R_SUCCESS); + + connect_readcb = tlsdns_many_connect_read_cb; + isc_refcount_increment0(&active_cconnects); + isc_nm_tlsdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr, + connect_connect_cb, NULL, T_CONNECT, 0, + tcp_connect_tlsctx, tcp_tlsctx_client_sess_cache); + + WAIT_FOR_EQ(cconnects, 1); + WAIT_FOR_LE(nsends, 0); + WAIT_FOR_EQ(csends, 2); + WAIT_FOR_EQ(sreads, 1); + WAIT_FOR_EQ(ssends, 1); + WAIT_FOR_EQ(creads, 1); + + isc_nm_stoplistening(listen_sock); + isc_nmsocket_close(&listen_sock); + assert_null(listen_sock); + isc__netmgr_shutdown(connect_nm); + + X(cconnects); + X(csends); + X(creads); + X(sreads); + X(ssends); + + atomic_assert_int_eq(cconnects, 1); + atomic_assert_int_eq(csends, 2); + atomic_assert_int_eq(creads, 1); + atomic_assert_int_eq(sreads, 1); + atomic_assert_int_eq(ssends, 1); +} + ISC_RUN_TEST_IMPL(tlsdns_recv_two) { isc_result_t result = ISC_R_SUCCESS; isc_nmsocket_t *listen_sock = NULL; @@ -2879,6 +3049,8 @@ ISC_TEST_ENTRY_CUSTOM(tls_half_recv_half_send_quota_sendback, setup_test, /* TLSDNS */ ISC_TEST_ENTRY_CUSTOM(tlsdns_recv_one, setup_test, teardown_test) +ISC_TEST_ENTRY_CUSTOM(tlsdns_server_send_many_recv_one, setup_test, + teardown_test) ISC_TEST_ENTRY_CUSTOM(tlsdns_recv_two, setup_test, teardown_test) ISC_TEST_ENTRY_CUSTOM(tlsdns_noop, setup_test, teardown_test) ISC_TEST_ENTRY_CUSTOM(tlsdns_noresponse, setup_test, teardown_test) diff --git a/tests/isccfg/Makefile.in b/tests/isccfg/Makefile.in index 712138a..305d6bb 100644 --- a/tests/isccfg/Makefile.in +++ b/tests/isccfg/Makefile.in @@ -106,11 +106,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ $(top_srcdir)/m4/ax_jemalloc.m4 \ $(top_srcdir)/m4/ax_lib_lmdb.m4 \ - $(top_srcdir)/m4/ax_perl_module.m4 \ $(top_srcdir)/m4/ax_posix_shell.m4 \ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ - $(top_srcdir)/m4/ax_python_module.m4 \ $(top_srcdir)/m4/ax_restore_flags.m4 \ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ diff --git a/tests/libtest/Makefile.in b/tests/libtest/Makefile.in index 8e89774..578a154 100644 --- a/tests/libtest/Makefile.in +++ b/tests/libtest/Makefile.in @@ -106,11 +106,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ $(top_srcdir)/m4/ax_jemalloc.m4 \ $(top_srcdir)/m4/ax_lib_lmdb.m4 \ - $(top_srcdir)/m4/ax_perl_module.m4 \ $(top_srcdir)/m4/ax_posix_shell.m4 \ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ - $(top_srcdir)/m4/ax_python_module.m4 \ $(top_srcdir)/m4/ax_restore_flags.m4 \ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index 4a53ad8..16eaefc 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -290,7 +290,7 @@ attach_query_msg_to_client(ns_client_t *client, const char *qnamestr, dns_rdatatype_t qtype, unsigned int qflags) { dns_rdataset_t *qrdataset = NULL; dns_message_t *message = NULL; - unsigned char query[65536]; + unsigned char query[65535]; dns_name_t *qname = NULL; isc_buffer_t querybuf; dns_compress_t cctx; diff --git a/tests/ns/Makefile.in b/tests/ns/Makefile.in index efa0cc9..bc9d291 100644 --- a/tests/ns/Makefile.in +++ b/tests/ns/Makefile.in @@ -107,11 +107,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ $(top_srcdir)/m4/ax_jemalloc.m4 \ $(top_srcdir)/m4/ax_lib_lmdb.m4 \ - $(top_srcdir)/m4/ax_perl_module.m4 \ $(top_srcdir)/m4/ax_posix_shell.m4 \ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ - $(top_srcdir)/m4/ax_python_module.m4 \ $(top_srcdir)/m4/ax_restore_flags.m4 \ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ diff --git a/tests/unit-test-driver.sh.in b/tests/unit-test-driver.sh.in index 9a60db1..1d35b0e 100644 --- a/tests/unit-test-driver.sh.in +++ b/tests/unit-test-driver.sh.in @@ -15,8 +15,8 @@ TOP_BUILDDIR=@abs_top_builddir@ TOP_SRCDIR=@abs_top_srcdir@ if [ -z "${1}" ]; then - echo "Usage: ${0} test_program" >&2 - exit 1 + echo "Usage: ${0} test_program" >&2 + exit 1 fi TEST_PROGRAM="${1}" @@ -26,35 +26,35 @@ TIMEOUT=300 TEST_PROGRAM_PID=${!} STATUS=124 while [ ${TIMEOUT} -gt 0 ]; do - if ! kill -0 "${TEST_PROGRAM_PID}" 2>/dev/null; then - wait "${TEST_PROGRAM_PID}" - STATUS=${?} - break - fi - sleep 1 - TIMEOUT=$((TIMEOUT - 1)) + if ! kill -0 "${TEST_PROGRAM_PID}" 2>/dev/null; then + wait "${TEST_PROGRAM_PID}" + STATUS=${?} + break + fi + sleep 1 + TIMEOUT=$((TIMEOUT - 1)) done if [ ${TIMEOUT} -eq 0 ]; then - echo "PID ${TEST_PROGRAM_PID} exceeded run time limit, sending SIGABRT" >&2 - kill -ABRT "${TEST_PROGRAM_PID}" 2>/dev/null + echo "PID ${TEST_PROGRAM_PID} exceeded run time limit, sending SIGABRT" >&2 + kill -ABRT "${TEST_PROGRAM_PID}" 2>/dev/null fi TEST_PROGRAM_NAME=$(basename "${TEST_PROGRAM}") TEST_PROGRAM_WORK_DIR=$(dirname "${TEST_PROGRAM}") find "${TEST_PROGRAM_WORK_DIR}" -name 'core*' -or -name '*.core' | while read -r CORE_DUMP; do - BINARY=$(gdb --batch --core="${CORE_DUMP}" 2>/dev/null | sed -n "s/^Core was generated by \`\(.*\)'\.\$/\1/p") - if ! echo "${BINARY}" | grep -q "${TEST_PROGRAM_NAME}\$"; then - continue - fi - echo "I:${TEST_PROGRAM_NAME}:Core dump found: ${CORE_DUMP}" - echo "D:${TEST_PROGRAM_NAME}:backtrace from ${CORE_DUMP} start" - "${TOP_BUILDDIR}/libtool" --mode=execute gdb \ - --batch \ - --command="${TOP_SRCDIR}/bin/tests/system/run.gdb" \ - --core="${CORE_DUMP}" \ - -- \ - "${BINARY}" - echo "D:${TEST_PROGRAM_NAME}:backtrace from ${CORE_DUMP} end" + BINARY=$(gdb --batch --core="${CORE_DUMP}" 2>/dev/null | sed -n "s/^Core was generated by \`\(.*\)'\.\$/\1/p") + if ! echo "${BINARY}" | grep -q "${TEST_PROGRAM_NAME}\$"; then + continue + fi + echo "I:${TEST_PROGRAM_NAME}:Core dump found: ${CORE_DUMP}" + echo "D:${TEST_PROGRAM_NAME}:backtrace from ${CORE_DUMP} start" + "${TOP_BUILDDIR}/libtool" --mode=execute gdb \ + --batch \ + --command="${TOP_SRCDIR}/bin/tests/system/run.gdb" \ + --core="${CORE_DUMP}" \ + -- \ + "${BINARY}" + echo "D:${TEST_PROGRAM_NAME}:backtrace from ${CORE_DUMP} end" done exit ${STATUS} -- cgit v1.2.3