From 24d420f20bc98b01dd9b66a1543c50b7df5464a2 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Tue, 31 May 2022 20:00:40 +0100 Subject: [PATCH 1/5] Add missing CFLAGS and LDADD to unit tests A number of unit tests needed to be told where to find their libraries and matching headers. --- tests/isc/Makefile.am | 8 ++++++++ tests/isccfg/Makefile.am | 4 +++- tests/ns/Makefile.am | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/isc/Makefile.am b/tests/isc/Makefile.am index 6ce570c882..86983d1fdf 100644 --- a/tests/isc/Makefile.am +++ b/tests/isc/Makefile.am @@ -70,6 +70,14 @@ md_test_LDADD = \ $(LDADD) \ $(OPENSSL_LIBS) +netmgr_test_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(OPENSSL_CFLAGS) + +netmgr_test_LDADD = \ + $(LDADD) \ + $(OPENSSL_LIBS) + random_test_LDADD = \ $(LDADD) \ -lm diff --git a/tests/isccfg/Makefile.am b/tests/isccfg/Makefile.am index 73655a5401..5a6fb03ac4 100644 --- a/tests/isccfg/Makefile.am +++ b/tests/isccfg/Makefile.am @@ -4,12 +4,14 @@ AM_CPPFLAGS += \ $(LIBISC_CFLAGS) \ $(LIBDNS_CFLAGS) \ $(LIBISCCFG_CFLAGS) \ + $(LIBUV_CFLAGS) \ -I$(top_srcdir)/lib/isc LDADD += \ $(LIBISC_LIBS) \ $(LIBDNS_LIBS) \ - $(LIBISCCFG_LIBS) + $(LIBISCCFG_LIBS) \ + $(LIBUV_LIBS) check_PROGRAMS = \ duration_test \ diff --git a/tests/ns/Makefile.am b/tests/ns/Makefile.am index 50f87ca40a..33f91d8c7b 100644 --- a/tests/ns/Makefile.am +++ b/tests/ns/Makefile.am @@ -4,13 +4,15 @@ AM_CPPFLAGS += \ $(LIBISC_CFLAGS) \ $(LIBDNS_CFLAGS) \ $(LIBNS_CFLAGS) \ + $(LIBUV_CFLAGS) \ -I$(top_srcdir)/lib/isc \ -I$(top_srcdir)/lib/dns LDADD += \ $(LIBISC_LIBS) \ $(LIBDNS_LIBS) \ - $(LIBNS_LIBS) + $(LIBNS_LIBS) \ + $(LIBUV_LIBS) check_PROGRAMS = \ listenlist_test \ From dec845017bff9e340f88db95bd2c990b25a3c3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 1 Jun 2022 08:47:00 +0200 Subject: [PATCH 2/5] Add tests/isc/uv_wrap.h to Makefile.am The automake was missing reference to uv_wrap.h, so it was not added to the distribution. Add uv_wrap.h to SOURCES for both doh and netmgr unit tests. --- tests/isc/Makefile.am | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/isc/Makefile.am b/tests/isc/Makefile.am index 86983d1fdf..5cfd90b20d 100644 --- a/tests/isc/Makefile.am +++ b/tests/isc/Makefile.am @@ -52,6 +52,11 @@ doh_test_CPPFLAGS = \ doh_test_LDADD = \ $(LDADD) \ $(LIBNGHTTP2_LIBS) + +doh_test_SOURCES = \ + doh_test.c \ + uv_wrap.h + endif HAVE_LIBNGHTTP2 hmac_test_CPPFLAGS = \ @@ -78,6 +83,10 @@ netmgr_test_LDADD = \ $(LDADD) \ $(OPENSSL_LIBS) +netmgr_test_SOURCES = \ + netmgr_test.c \ + uv_wrap.h + random_test_LDADD = \ $(LDADD) \ -lm From 90f0a765d86c022a9aaf7e54bea2c39435da6da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 1 Jun 2022 08:52:28 +0200 Subject: [PATCH 3/5] Fix the path to tsan files in the tsan unit test job The tsan unit test job still referenced lib/*/tests/tsan.*, change this to the correct tests/*/tsan.*. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index db8f85bb1e..b42d056bcd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -381,7 +381,7 @@ stages: artifacts: expire_in: "1 day" paths: - - lib/*/tests/tsan.* + - tests/*/tsan.* - tsan/ - junit.xml when: always From 714fe2f6173f57cdb45449e8816facf8ea8f868d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 1 Jun 2022 09:02:10 +0200 Subject: [PATCH 4/5] Don't list libtest.la headers in HEADERS variable The libtest.la headers were installed in very weird place, in fact, we don't need to list them in the HEADERS variable, listing them in SOURCES is enough for autotools to figure out how to compile the convenience library. --- tests/libtest/Makefile.am | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 2699f4bfcf..6bd4b80340 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -14,13 +14,10 @@ LDADD += \ check_LTLIBRARIES = libtest.la -noinst_libtest_ladir = .. -noinst_libtest_la_HEADERS = \ +libtest_la_SOURCES = \ ../include/tests/dns.h \ ../include/tests/isc.h \ - ../include/tests/ns.h -libtest_la_SOURCES = \ - $(noinst_libtest_la_HEADERS) \ + ../include/tests/ns.h \ dns.c \ isc.c \ ns.c From 16595cdde0ff7c48f030fd26b6c5e2b19bd00215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 1 Jun 2022 13:10:37 +0200 Subject: [PATCH 5/5] Properly adjust the srcdir vs builddir paths Affected unit tests load testdata from the srcdir. Previously, there was a kludge that chdir()ed to the tests srcdir, but that get removed during refactoring. Instead of introducing the kludge again, the paths were fixed to be properly prefixed with TESTS_DIR as needed. --- tests/dns/Makefile.am | 11 +++++- tests/dns/db_test.c | 14 ++++---- tests/dns/dbdiff_test.c | 12 +++---- tests/dns/dbiterator_test.c | 24 ++++++------- tests/dns/dh_test.c | 4 +-- tests/dns/dnstap_test.c | 15 ++++---- tests/dns/dst_test.c | 32 +++++++++-------- tests/dns/master_test.c | 36 +++++++++---------- tests/dns/nsec3_test.c | 10 +++--- tests/dns/nsec3param_test.c | 6 ++-- tests/dns/rsa_test.c | 2 +- tests/dns/sigs_test.c | 2 +- .../{master18.data => master18.data.in} | 4 +-- tests/dns/zt_test.c | 12 +++---- tests/ns/notify_test.c | 7 ++-- tests/ns/query_test.c | 16 ++++----- 16 files changed, 111 insertions(+), 96 deletions(-) rename tests/dns/testdata/master/{master18.data => master18.data.in} (57%) diff --git a/tests/dns/Makefile.am b/tests/dns/Makefile.am index 0164a4ad87..a467ef0f97 100644 --- a/tests/dns/Makefile.am +++ b/tests/dns/Makefile.am @@ -45,13 +45,15 @@ check_PROGRAMS = \ zonemgr_test \ zt_test +CLEANFILES = + if HAVE_PERL check_PROGRAMS += \ master_test EXTRA_master_test_DEPENDENCIES = testdata/master/master12.data testdata/master/master13.data testdata/master/master14.data -CLEANFILES = $(EXTRA_master_test_DEPENDENCIES) +CLEANFILES += $(EXTRA_master_test_DEPENDENCIES) testdata/master/master12.data: testdata/master/master12.data.in mkdir -p testdata/master @@ -105,6 +107,13 @@ rsa_test_CPPFLAGS = \ $(AM_CPPFLAGS) \ $(OPENSSL_CFLAGS) +EXTRA_sigs_test_DEPENDENCIES = testdata/master/master18.data +CLEANFILES += $(EXTRA_sigs_test_DEPENDENCIES) + +testdata/master/master18.data: testdata/master/master18.data.in + mkdir -p testdata/master + sed -e 's,@TOP_SRCDIR@,$(abs_srcdir),' < $(srcdir)/testdata/master/master18.data.in > $@ + EXTRA_DIST = \ Kdh.+002+18602.key \ Krsa.+005+29235.key \ diff --git a/tests/dns/db_test.c b/tests/dns/db_test.c index 27fcf7deea..786a4a8337 100644 --- a/tests/dns/db_test.c +++ b/tests/dns/db_test.c @@ -253,8 +253,8 @@ ISC_RUN_TEST_IMPL(class) { dns_rdataclass_in, 0, NULL, &db); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/db/data.db", dns_masterformat_text, - 0); + result = dns_db_load(db, TESTS_DIR "/testdata/db/data.db", + dns_masterformat_text, 0); assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(dns_db_class(db), dns_rdataclass_in); @@ -273,8 +273,8 @@ ISC_RUN_TEST_IMPL(dbtype) { result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/db/data.db", dns_masterformat_text, - 0); + result = dns_db_load(db, TESTS_DIR "/testdata/db/data.db", + dns_masterformat_text, 0); assert_int_equal(result, ISC_R_SUCCESS); assert_true(dns_db_iszone(db)); assert_false(dns_db_iscache(db)); @@ -284,8 +284,8 @@ ISC_RUN_TEST_IMPL(dbtype) { result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache, dns_rdataclass_in, 0, NULL, &db); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/db/data.db", dns_masterformat_text, - 0); + result = dns_db_load(db, TESTS_DIR "/testdata/db/data.db", + dns_masterformat_text, 0); assert_int_equal(result, ISC_R_SUCCESS); assert_true(dns_db_iscache(db)); assert_false(dns_db_iszone(db)); @@ -305,7 +305,7 @@ ISC_RUN_TEST_IMPL(version) { UNUSED(state); result = dns_test_loaddb(&db, dns_dbtype_zone, "test.test", - "testdata/db/data.db"); + TESTS_DIR "/testdata/db/data.db"); assert_int_equal(result, ISC_R_SUCCESS); /* Open current version for reading */ diff --git a/tests/dns/dbdiff_test.c b/tests/dns/dbdiff_test.c index 12490a8dca..4857683e4c 100644 --- a/tests/dns/dbdiff_test.c +++ b/tests/dns/dbdiff_test.c @@ -55,8 +55,8 @@ ISC_RUN_TEST_IMPL(diffx_same) { UNUSED(state); - test_create("testdata/diff/zone1.data", &olddb, - "testdata/diff/zone1.data", &newdb); + test_create(TESTS_DIR "/testdata/diff/zone1.data", &olddb, + TESTS_DIR "/testdata/diff/zone1.data", &newdb); dns_diff_init(mctx, &diff); @@ -80,8 +80,8 @@ ISC_RUN_TEST_IMPL(diffx_add) { UNUSED(state); - test_create("testdata/diff/zone1.data", &olddb, - "testdata/diff/zone2.data", &newdb); + test_create(TESTS_DIR "/testdata/diff/zone1.data", &olddb, + TESTS_DIR "/testdata/diff/zone2.data", &newdb); dns_diff_init(mctx, &diff); @@ -112,8 +112,8 @@ ISC_RUN_TEST_IMPL(diffx_remove) { UNUSED(state); - test_create("testdata/diff/zone1.data", &olddb, - "testdata/diff/zone3.data", &newdb); + test_create(TESTS_DIR "/testdata/diff/zone1.data", &olddb, + TESTS_DIR "/testdata/diff/zone3.data", &newdb); dns_diff_init(mctx, &diff); diff --git a/tests/dns/dbiterator_test.c b/tests/dns/dbiterator_test.c index 90e8536fc2..f8f008bd51 100644 --- a/tests/dns/dbiterator_test.c +++ b/tests/dns/dbiterator_test.c @@ -62,13 +62,13 @@ test_create(const char *filename) { ISC_RUN_TEST_IMPL(create) { UNUSED(state); - test_create("testdata/dbiterator/zone1.data"); + test_create(TESTS_DIR "/testdata/dbiterator/zone1.data"); } ISC_RUN_TEST_IMPL(create_nsec3) { UNUSED(state); - test_create("testdata/dbiterator/zone2.data"); + test_create(TESTS_DIR "/testdata/dbiterator/zone2.data"); } /* walk: walk a database */ @@ -111,13 +111,13 @@ test_walk(const char *filename, int nodes) { ISC_RUN_TEST_IMPL(walk) { UNUSED(state); - test_walk("testdata/dbiterator/zone1.data", 12); + test_walk(TESTS_DIR "/testdata/dbiterator/zone1.data", 12); } ISC_RUN_TEST_IMPL(walk_nsec3) { UNUSED(state); - test_walk("testdata/dbiterator/zone2.data", 33); + test_walk(TESTS_DIR "/testdata/dbiterator/zone2.data", 33); } /* reverse: walk database backwards */ @@ -160,13 +160,13 @@ test_reverse(const char *filename) { ISC_RUN_TEST_IMPL(reverse) { UNUSED(state); - test_reverse("testdata/dbiterator/zone1.data"); + test_reverse(TESTS_DIR "/testdata/dbiterator/zone1.data"); } ISC_RUN_TEST_IMPL(reverse_nsec3) { UNUSED(state); - test_reverse("testdata/dbiterator/zone2.data"); + test_reverse(TESTS_DIR "/testdata/dbiterator/zone2.data"); } /* seek: walk database starting at a particular node */ @@ -215,13 +215,13 @@ test_seek_node(const char *filename, int nodes) { ISC_RUN_TEST_IMPL(seek_node) { UNUSED(state); - test_seek_node("testdata/dbiterator/zone1.data", 9); + test_seek_node(TESTS_DIR "/testdata/dbiterator/zone1.data", 9); } ISC_RUN_TEST_IMPL(seek_node_nsec3) { UNUSED(state); - test_seek_node("testdata/dbiterator/zone2.data", 30); + test_seek_node(TESTS_DIR "/testdata/dbiterator/zone2.data", 30); } /* @@ -257,13 +257,13 @@ test_seek_empty(const char *filename) { ISC_RUN_TEST_IMPL(seek_empty) { UNUSED(state); - test_seek_empty("testdata/dbiterator/zone1.data"); + test_seek_empty(TESTS_DIR "/testdata/dbiterator/zone1.data"); } ISC_RUN_TEST_IMPL(seek_empty_nsec3) { UNUSED(state); - test_seek_empty("testdata/dbiterator/zone2.data"); + test_seek_empty(TESTS_DIR "/testdata/dbiterator/zone2.data"); } /* @@ -304,13 +304,13 @@ test_seek_nx(const char *filename) { ISC_RUN_TEST_IMPL(seek_nx) { UNUSED(state); - test_seek_nx("testdata/dbiterator/zone1.data"); + test_seek_nx(TESTS_DIR "/testdata/dbiterator/zone1.data"); } ISC_RUN_TEST_IMPL(seek_nx_nsec3) { UNUSED(state); - test_seek_nx("testdata/dbiterator/zone2.data"); + test_seek_nx(TESTS_DIR "/testdata/dbiterator/zone2.data"); } /* diff --git a/tests/dns/dh_test.c b/tests/dns/dh_test.c index acc7c697fc..246de2197a 100644 --- a/tests/dns/dh_test.c +++ b/tests/dns/dh_test.c @@ -74,8 +74,8 @@ ISC_RUN_TEST_IMPL(dh_computesecret) { assert_int_equal(result, ISC_R_SUCCESS); result = dst_key_fromfile(name, 18602, DST_ALG_DH, - DST_TYPE_PUBLIC | DST_TYPE_KEY, "./", mctx, - &key); + DST_TYPE_PUBLIC | DST_TYPE_KEY, TESTS_DIR, + mctx, &key); assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&buf, array, sizeof(array)); diff --git a/tests/dns/dnstap_test.c b/tests/dns/dnstap_test.c index b338ecbcc9..716f986f4c 100644 --- a/tests/dns/dnstap_test.c +++ b/tests/dns/dnstap_test.c @@ -188,25 +188,26 @@ ISC_RUN_TEST_IMPL(dns_dt_send) { isc_time_set(&p, now - 3600, 0); /* past */ isc_time_set(&f, now + 3600, 0); /* future */ - result = dns_test_getdata("testdata/dnstap/query.auth", qambuffer, - sizeof(qambuffer), &qasize); + result = dns_test_getdata(TESTS_DIR "/testdata/dnstap/query.auth", + qambuffer, sizeof(qambuffer), &qasize); assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&qamsg, qambuffer, qasize); isc_buffer_add(&qamsg, qasize); - result = dns_test_getdata("testdata/dnstap/response.auth", rambuffer, - sizeof(rambuffer), &rasize); + result = dns_test_getdata(TESTS_DIR "/testdata/dnstap/response.auth", + rambuffer, sizeof(rambuffer), &rasize); assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&ramsg, rambuffer, rasize); isc_buffer_add(&ramsg, rasize); - result = dns_test_getdata("testdata/dnstap/query.recursive", qrmbuffer, - sizeof(qrmbuffer), &qrsize); + result = dns_test_getdata(TESTS_DIR "/testdata/dnstap/query.recursive", + qrmbuffer, sizeof(qrmbuffer), &qrsize); assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&qrmsg, qrmbuffer, qrsize); isc_buffer_add(&qrmsg, qrsize); - result = dns_test_getdata("testdata/dnstap/response.recursive", + result = dns_test_getdata(TESTS_DIR + "/testdata/dnstap/response.recursive", rrmbuffer, sizeof(rrmbuffer), &rrsize); assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&rrmsg, rrmbuffer, rrsize); diff --git a/tests/dns/dst_test.c b/tests/dns/dst_test.c index 28bd2ec72e..f18bd2f359 100644 --- a/tests/dns/dst_test.c +++ b/tests/dns/dst_test.c @@ -171,8 +171,8 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname, isc_buffer_add(&b, strlen(keyname)); result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); assert_int_equal(result, ISC_R_SUCCESS); - result = dst_key_fromfile(name, id, alg, type, "testdata/dst", mctx, - &key); + result = dst_key_fromfile(name, id, alg, type, + TESTS_DIR "/testdata/dst", mctx, &key); assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&databuf, data, (unsigned int)size); @@ -256,16 +256,20 @@ ISC_RUN_TEST_IMPL(sig_test) { dns_secalg_t alg; bool expect; } testcases[] = { - { "testdata/dst/test1.data", "testdata/dst/test1.ecdsa256sig", - "test.", 49130, DST_ALG_ECDSA256, true }, - { "testdata/dst/test1.data", "testdata/dst/test1.rsasha256sig", - "test.", 11349, DST_ALG_RSASHA256, true }, + { TESTS_DIR "/testdata/dst/test1.data", + TESTS_DIR "/testdata/dst/test1.ecdsa256sig", "test.", 49130, + DST_ALG_ECDSA256, true }, + { TESTS_DIR "/testdata/dst/test1.data", + TESTS_DIR "/testdata/dst/test1.rsasha256sig", "test.", 11349, + DST_ALG_RSASHA256, true }, { /* wrong sig */ - "testdata/dst/test1.data", "testdata/dst/test1.ecdsa256sig", - "test.", 11349, DST_ALG_RSASHA256, false }, + TESTS_DIR "/testdata/dst/test1.data", + TESTS_DIR "/testdata/dst/test1.ecdsa256sig", "test.", 11349, + DST_ALG_RSASHA256, false }, { /* wrong data */ - "testdata/dst/test2.data", "testdata/dst/test1.ecdsa256sig", - "test.", 49130, DST_ALG_ECDSA256, false }, + TESTS_DIR "/testdata/dst/test2.data", + TESTS_DIR "/testdata/dst/test1.ecdsa256sig", "test.", 49130, + DST_ALG_ECDSA256, false }, }; unsigned int i; @@ -302,8 +306,8 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name, isc_buffer_add(&b1, strlen(key1_name)); result = dns_name_fromtext(name1, &b1, dns_rootname, 0, NULL); assert_int_equal(result, ISC_R_SUCCESS); - result = dst_key_fromfile(name1, key1_id, alg, type, "comparekeys", - mctx, &key1); + result = dst_key_fromfile(name1, key1_id, alg, type, + TESTS_DIR "/comparekeys", mctx, &key1); assert_int_equal(result, ISC_R_SUCCESS); /* @@ -314,8 +318,8 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name, isc_buffer_add(&b2, strlen(key2_name)); result = dns_name_fromtext(name2, &b2, dns_rootname, 0, NULL); assert_int_equal(result, ISC_R_SUCCESS); - result = dst_key_fromfile(name2, key2_id, alg, type, "comparekeys", - mctx, &key2); + result = dst_key_fromfile(name2, key2_id, alg, type, + TESTS_DIR "/comparekeys", mctx, &key2); assert_int_equal(result, ISC_R_SUCCESS); /* diff --git a/tests/dns/master_test.c b/tests/dns/master_test.c index 1642b0d12e..324edea8c5 100644 --- a/tests/dns/master_test.c +++ b/tests/dns/master_test.c @@ -171,7 +171,7 @@ ISC_RUN_TEST_IMPL(load) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master1.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master1.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_SUCCESS); } @@ -185,7 +185,7 @@ ISC_RUN_TEST_IMPL(unexpected) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master2.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master2.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_UNEXPECTEDEND); } @@ -200,7 +200,7 @@ ISC_RUN_TEST_IMPL(noowner) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master3.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master3.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, DNS_R_NOOWNER); } @@ -215,7 +215,7 @@ ISC_RUN_TEST_IMPL(nottl) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master4.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master4.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_SUCCESS); } @@ -230,7 +230,7 @@ ISC_RUN_TEST_IMPL(badclass) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master5.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master5.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, DNS_R_BADCLASS); } @@ -244,7 +244,7 @@ ISC_RUN_TEST_IMPL(toobig) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master15.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master15.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_NOSPACE); } @@ -258,7 +258,7 @@ ISC_RUN_TEST_IMPL(maxrdata) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master16.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master16.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_SUCCESS); } @@ -272,7 +272,7 @@ ISC_RUN_TEST_IMPL(dnskey) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master6.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master6.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_SUCCESS); } @@ -289,7 +289,7 @@ ISC_RUN_TEST_IMPL(dnsnokey) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master7.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master7.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_UNEXPECTEDEND); } @@ -303,7 +303,7 @@ ISC_RUN_TEST_IMPL(include) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master8.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master8.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, DNS_R_SEENINCLUDE); } @@ -325,9 +325,9 @@ ISC_RUN_TEST_IMPL(master_includelist) { assert_int_equal(result, ISC_R_SUCCESS); result = dns_master_loadfile( - "testdata/master/master8.data", &dns_origin, &dns_origin, - dns_rdataclass_in, 0, true, &callbacks, include_callback, - &filename, mctx, dns_masterformat_text, 0); + TESTS_DIR "/testdata/master/master8.data", &dns_origin, + &dns_origin, dns_rdataclass_in, 0, true, &callbacks, + include_callback, &filename, mctx, dns_masterformat_text, 0); assert_int_equal(result, DNS_R_SEENINCLUDE); assert_non_null(filename); if (filename != NULL) { @@ -345,7 +345,7 @@ ISC_RUN_TEST_IMPL(includefail) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master9.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master9.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, DNS_R_BADCLASS); } @@ -359,7 +359,7 @@ ISC_RUN_TEST_IMPL(blanklines) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master10.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master10.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_SUCCESS); } @@ -374,7 +374,7 @@ ISC_RUN_TEST_IMPL(leadingzero) { UNUSED(state); - result = test_master(SRCDIR, "testdata/master/master11.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master11.data", dns_masterformat_text, nullmsg, nullmsg); assert_int_equal(result, ISC_R_SUCCESS); } @@ -479,7 +479,7 @@ ISC_RUN_TEST_IMPL(dumpraw) { result = isc_dir_chdir(SRCDIR); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/master/master1.data", + result = dns_db_load(db, TESTS_DIR "/testdata/master/master1.data", dns_masterformat_text, 0); assert_int_equal(result, ISC_R_SUCCESS); @@ -551,7 +551,7 @@ ISC_RUN_TEST_IMPL(neworigin) { UNUSED(state); warn_expect_value = "record with inherited owner"; - result = test_master(SRCDIR, "testdata/master/master17.data", + result = test_master(SRCDIR, TESTS_DIR "/testdata/master/master17.data", dns_masterformat_text, warn_expect, nullmsg); assert_int_equal(result, ISC_R_SUCCESS); assert_true(warn_expect_result); diff --git a/tests/dns/nsec3_test.c b/tests/dns/nsec3_test.c index 7d6e424705..4cbf6a9324 100644 --- a/tests/dns/nsec3_test.c +++ b/tests/dns/nsec3_test.c @@ -114,11 +114,11 @@ nsec3param_salttotext_test(const nsec3param_salttotext_test_params_t *params) { ISC_RUN_TEST_IMPL(max_iterations) { UNUSED(state); - iteration_test("testdata/nsec3/1024.db", 150); - iteration_test("testdata/nsec3/2048.db", 150); - iteration_test("testdata/nsec3/4096.db", 150); - iteration_test("testdata/nsec3/min-1024.db", 150); - iteration_test("testdata/nsec3/min-2048.db", 150); + iteration_test(TESTS_DIR "/testdata/nsec3/1024.db", 150); + iteration_test(TESTS_DIR "/testdata/nsec3/2048.db", 150); + iteration_test(TESTS_DIR "/testdata/nsec3/4096.db", 150); + iteration_test(TESTS_DIR "/testdata/nsec3/min-1024.db", 150); + iteration_test(TESTS_DIR "/testdata/nsec3/min-2048.db", 150); } /* check dns_nsec3param_salttotext() */ diff --git a/tests/dns/nsec3param_test.c b/tests/dns/nsec3param_test.c index 3bd50e59a4..21879da023 100644 --- a/tests/dns/nsec3param_test.c +++ b/tests/dns/nsec3param_test.c @@ -116,9 +116,9 @@ nsec3param_change_test(const nsec3param_change_test_params_t *test) { result = dns_test_makezone("nsec3", &zone, NULL, false); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_zone_setfile(zone, "testdata/nsec3param/nsec3.db.signed", - dns_masterformat_text, - &dns_master_style_default); + result = dns_zone_setfile( + zone, TESTS_DIR "/testdata/nsec3param/nsec3.db.signed", + dns_masterformat_text, &dns_master_style_default); assert_int_equal(result, ISC_R_SUCCESS); result = dns_zone_load(zone, false); diff --git a/tests/dns/rsa_test.c b/tests/dns/rsa_test.c index 8b2bd89219..bebe68139d 100644 --- a/tests/dns/rsa_test.c +++ b/tests/dns/rsa_test.c @@ -151,7 +151,7 @@ ISC_RUN_TEST_IMPL(isc_rsa_verify) { assert_int_equal(ret, ISC_R_SUCCESS); ret = dst_key_fromfile(name, 29235, DST_ALG_RSASHA1, DST_TYPE_PUBLIC, - "./", mctx, &key); + TESTS_DIR, mctx, &key); assert_int_equal(ret, ISC_R_SUCCESS); /* RSASHA1 */ diff --git a/tests/dns/sigs_test.c b/tests/dns/sigs_test.c index 55183057f1..dbb14ac86e 100644 --- a/tests/dns/sigs_test.c +++ b/tests/dns/sigs_test.c @@ -310,7 +310,7 @@ ISC_RUN_TEST_IMPL(updatesigs_next) { "testdata/master/master18.data"); assert_int_equal(result, DNS_R_SEENINCLUDE); - result = dns_zone_setkeydirectory(zone, "testkeys"); + result = dns_zone_setkeydirectory(zone, TESTS_DIR "/testkeys"); assert_int_equal(result, ISC_R_SUCCESS); isc_stdtime_get(&now); diff --git a/tests/dns/testdata/master/master18.data b/tests/dns/testdata/master/master18.data.in similarity index 57% rename from tests/dns/testdata/master/master18.data rename to tests/dns/testdata/master/master18.data.in index dddf04e3bf..73c17ffd99 100644 --- a/tests/dns/testdata/master/master18.data +++ b/tests/dns/testdata/master/master18.data.in @@ -6,5 +6,5 @@ $TTL 1000 604800 ;expiration 3600 ) ;minimum -$INCLUDE "testkeys/Kexample.+008+20386.key"; -$INCLUDE "testkeys/Kexample.+008+37464.key"; +$INCLUDE "@TOP_SRCDIR@/testkeys/Kexample.+008+20386.key"; +$INCLUDE "@TOP_SRCDIR@/testkeys/Kexample.+008+37464.key"; diff --git a/tests/dns/zt_test.c b/tests/dns/zt_test.c index 74cbe059a2..5b25089982 100644 --- a/tests/dns/zt_test.c +++ b/tests/dns/zt_test.c @@ -180,7 +180,7 @@ ISC_RUN_TEST_IMPL(dns_zt_asyncload_zone) { assert_false(atomic_load(&done)); zonefile = fopen("./zone.data", "wb"); assert_non_null(zonefile); - origfile = fopen("./testdata/zt/zone1.db", "r+b"); + origfile = fopen(TESTS_DIR "/testdata/zt/zone1.db", "r+b"); assert_non_null(origfile); n = fread(buf, 1, 4096, origfile); fclose(origfile); @@ -273,19 +273,19 @@ ISC_RUN_TEST_IMPL(dns_zt_asyncload_zt) { result = dns_test_makezone("foo", &zone1, NULL, true); assert_int_equal(result, ISC_R_SUCCESS); - dns_zone_setfile(zone1, "testdata/zt/zone1.db", dns_masterformat_text, - &dns_master_style_default); + dns_zone_setfile(zone1, TESTS_DIR "/testdata/zt/zone1.db", + dns_masterformat_text, &dns_master_style_default); view = dns_zone_getview(zone1); result = dns_test_makezone("bar", &zone2, view, false); assert_int_equal(result, ISC_R_SUCCESS); - dns_zone_setfile(zone2, "testdata/zt/zone1.db", dns_masterformat_text, - &dns_master_style_default); + dns_zone_setfile(zone2, TESTS_DIR "/testdata/zt/zone1.db", + dns_masterformat_text, &dns_master_style_default); /* This one will fail to load */ result = dns_test_makezone("fake", &zone3, view, false); assert_int_equal(result, ISC_R_SUCCESS); - dns_zone_setfile(zone3, "testdata/zt/nonexistent.db", + dns_zone_setfile(zone3, TESTS_DIR "/testdata/zt/nonexistent.db", dns_masterformat_text, &dns_master_style_default); zt = view->zonetable; diff --git a/tests/ns/notify_test.c b/tests/ns/notify_test.c index c5e3009640..548ad79784 100644 --- a/tests/ns/notify_test.c +++ b/tests/ns/notify_test.c @@ -91,7 +91,8 @@ ISC_RUN_TEST_IMPL(ns_notify_start) { result = dns_test_makeview("view", false, &client->view); assert_int_equal(result, ISC_R_SUCCESS); - result = ns_test_serve_zone("example.com", "testdata/notify/zone1.db", + result = ns_test_serve_zone("example.com", + TESTS_DIR "/testdata/notify/zone1.db", client->view); assert_int_equal(result, ISC_R_SUCCESS); @@ -100,8 +101,8 @@ ISC_RUN_TEST_IMPL(ns_notify_start) { * (XXX: use better message mocking method when available.) */ - result = ns_test_getdata("testdata/notify/notify1.msg", ndata, - sizeof(ndata), &nsize); + result = ns_test_getdata(TESTS_DIR "/testdata/notify/notify1.msg", + ndata, sizeof(ndata), &nsize); assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&nbuf, ndata, nsize); isc_buffer_add(&nbuf, nsize); diff --git a/tests/ns/query_test.c b/tests/ns/query_test.c index c86d98d9ac..dda2c07150 100644 --- a/tests/ns/query_test.c +++ b/tests/ns/query_test.c @@ -473,7 +473,7 @@ ISC_RUN_TEST_IMPL(ns_query_start) { .qflags = DNS_MESSAGEFLAG_RD, .recursive_service = true, .auth_zone_origin = "foo", - .auth_zone_path = "testdata/query/foo.db", + .auth_zone_path = TESTS_DIR "/testdata/query/foo.db", .expected_result = NS__QUERY_START_R_AUTH, }, /* @@ -487,7 +487,7 @@ ISC_RUN_TEST_IMPL(ns_query_start) { .qflags = DNS_MESSAGEFLAG_RD, .recursive_service = false, .auth_zone_origin = "foo", - .auth_zone_path = "testdata/query/foo.db", + .auth_zone_path = TESTS_DIR "/testdata/query/foo.db", .expected_result = NS__QUERY_START_R_REFUSE, }, /* @@ -502,7 +502,7 @@ ISC_RUN_TEST_IMPL(ns_query_start) { .qflags = DNS_MESSAGEFLAG_RD, .recursive_service = true, .auth_zone_origin = "foo", - .auth_zone_path = "testdata/query/foo.db", + .auth_zone_path = TESTS_DIR "/testdata/query/foo.db", .expected_result = NS__QUERY_START_R_CACHE, }, /* @@ -517,7 +517,7 @@ ISC_RUN_TEST_IMPL(ns_query_start) { .qflags = DNS_MESSAGEFLAG_RD, .recursive_service = true, .auth_zone_origin = "foo", - .auth_zone_path = "testdata/query/foo.db", + .auth_zone_path = TESTS_DIR "/testdata/query/foo.db", .expected_result = NS__QUERY_START_R_AUTH, }, /* @@ -532,7 +532,7 @@ ISC_RUN_TEST_IMPL(ns_query_start) { .qflags = 0, .recursive_service = true, .auth_zone_origin = "foo", - .auth_zone_path = "testdata/query/foo.db", + .auth_zone_path = TESTS_DIR "/testdata/query/foo.db", .expected_result = NS__QUERY_START_R_AUTH, }, /* @@ -547,7 +547,7 @@ ISC_RUN_TEST_IMPL(ns_query_start) { .qflags = DNS_MESSAGEFLAG_RD, .recursive_service = true, .auth_zone_origin = "foo", - .auth_zone_path = "testdata/query/foo.db", + .auth_zone_path = TESTS_DIR "/testdata/query/foo.db", .expected_result = NS__QUERY_START_R_CACHE, }, /* @@ -562,7 +562,7 @@ ISC_RUN_TEST_IMPL(ns_query_start) { .qflags = 0, .recursive_service = true, .auth_zone_origin = "foo", - .auth_zone_path = "testdata/query/foo.db", + .auth_zone_path = TESTS_DIR "/testdata/query/foo.db", .expected_result = NS__QUERY_START_R_AUTH, }, /* @@ -1402,7 +1402,7 @@ run_hookasync_e2e_test(const ns__query_hookasync_e2e_test_params_t *test) { qctx->client->sendcb = send_noop; /* Load a zone. it should have ns.foo/A */ - result = ns_test_serve_zone("foo", "testdata/query/foo.db", + result = ns_test_serve_zone("foo", TESTS_DIR "/testdata/query/foo.db", qctx->client->view); INSIST(result == ISC_R_SUCCESS);