1
0
mirror of https://gitlab.isc.org/isc-projects/bind9.git synced 2025-04-18 09:44:09 +03:00

Move all the unit tests to /tests/<libname>/

The unit tests are now using a common base, which means that
lib/dns/tests/ code now has to include lib/isc/include/isc/test.h and
link with lib/isc/test.c and lib/ns/tests has to include both libisc and
libdns parts.

Instead of cross-linking code between the directories, move the
/lib/<foo>/test.c to /tests/<foo>.c and /lib/<foo>/include/<foo>test.h
to /tests/include/tests/<foo>.h and create a single libtest.la
convenience library in /tests/.

At the same time, move the /lib/<foo>/tests/ to /tests/<foo>/ (but keep
it symlinked to the old location) and adjust paths accordingly.  In few
places, we are now using absolute paths instead of relative paths,
because the directory level has changed.  By moving the directories
under the /tests/ directory, the test-related code is kept in a single
place and we can avoid referencing files between libns->libdns->libisc
which is unhealthy because they live in a separate Makefile-space.

In the future, the /bin/tests/ should be merged to /tests/ and symlink
kept, and the /fuzz/ directory moved to /tests/fuzz/.
This commit is contained in:
Ondřej Surý 2022-05-03 11:37:31 +02:00 committed by Evan Hunt
parent 63fe9312ff
commit 2c3b2dabe9
206 changed files with 190 additions and 198 deletions

View File

@ -34,12 +34,6 @@ PointerAlignment: Right
PointerBindsToType: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<isc/test.h>$'
Priority: 100
- Regex: '^<dns/test.h>$'
Priority: 101
- Regex: '^<ns/test.h>$'
Priority: 102
- Regex: '^<isc/'
Priority: 5
- Regex: '^<(pk11|pkcs11)/'
@ -64,6 +58,8 @@ IncludeCategories:
Priority: 55
- Regex: '^".*"'
Priority: 99
- Regex: '^<tests/'
Priority: 100
- Regex: '<openssl/'
Priority: 1
- Regex: '<(mysql|protobuf-c)/'

View File

@ -34,12 +34,6 @@ PointerAlignment: Right
PointerBindsToType: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<isc/test.h>$'
Priority: 100
- Regex: '^<dns/test.h>$'
Priority: 101
- Regex: '^<ns/test.h>$'
Priority: 102
- Regex: '^<isc/'
Priority: 2
- Regex: '^<dns/'
@ -54,6 +48,8 @@ IncludeCategories:
Priority: 7
- Regex: '^(<[^/]*)/)'
Priority: 8
- Regex: '^<tests/'
Priority: 10
- Regex: '<[[:alnum:].]+>'
Priority: 1
- Regex: '".*"'

View File

@ -2,6 +2,10 @@ include $(top_srcdir)/Makefile.top
SUBDIRS = . lib doc bin fuzz
if HAVE_CMOCKA
SUBDIRS += tests
endif HAVE_CMOCKA
BUILT_SOURCES = bind.keys.h
CLEANFILES = bind.keys.h
@ -12,7 +16,7 @@ dist_sysconf_DATA = bind.keys
.PHONY: doc
EXTRA_DIST = \
EXTRA_DIST = \
util/bindkeys.pl \
contrib \
CHANGES \

View File

@ -3,18 +3,21 @@
unit-local: check
if HAVE_CMOCKA
TESTS = $(check_PROGRAMS)
endif HAVE_CMOCKA
LOG_COMPILER = $(builddir)/../../unit-test-driver.sh
LOG_COMPILER = $(top_builddir)/tests/unit-test-driver.sh
AM_CFLAGS += \
-I$(top_srcdir)/tests/include \
$(TEST_CFLAGS)
AM_CPPFLAGS += \
$(CMOCKA_CFLAGS) \
-DNAMED_PLUGINDIR=\"$(pkglibdir)\" \
-DSKIPPED_TEST_EXIT_CODE=77 \
-DTESTS_DIR=\"$(abs_srcdir)\"
LDADD += \
$(top_builddir)/tests/libtest.la \
$(CMOCKA_LIBS)

View File

@ -1581,14 +1581,15 @@ AC_CONFIG_FILES([doc/Makefile
# Unit Tests
AC_CONFIG_FILES([lib/isc/tests/Makefile
lib/dns/tests/Makefile
lib/ns/tests/Makefile
lib/irs/tests/Makefile
lib/isccfg/tests/Makefile])
AC_CONFIG_FILES([tests/Makefile
tests/isc/Makefile
tests/dns/Makefile
tests/ns/Makefile
tests/irs/Makefile
tests/isccfg/Makefile])
AC_CONFIG_FILES([lib/unit-test-driver.sh],
[chmod +x lib/unit-test-driver.sh])
AC_CONFIG_FILES([tests/unit-test-driver.sh],
[chmod +x tests/unit-test-driver.sh])
# System Tests

View File

@ -321,7 +321,3 @@ if HAVE_LMDB
libdns_la_CPPFLAGS += $(LMDB_CFLAGS)
libdns_la_LIBADD += $(LMDB_LIBS)
endif
if HAVE_CMOCKA
SUBDIRS = tests
endif

1
lib/dns/tests Symbolic link
View File

@ -0,0 +1 @@
../../tests/dns

View File

@ -25,7 +25,3 @@ libirs_la_LIBADD = \
libirs_la_LDFLAGS = \
$(AM_LDFLAGS) \
-release "$(PACKAGE_VERSION)"
if HAVE_CMOCKA
SUBDIRS = tests
endif

1
lib/irs/tests Symbolic link
View File

@ -0,0 +1 @@
../../tests/irs

View File

@ -251,7 +251,3 @@ libisc_la_CPPFLAGS += \
libisc_la_LIBADD += \
$(LIBXML2_LIBS)
endif HAVE_LIBXML2
if HAVE_CMOCKA
SUBDIRS = tests
endif

1
lib/isc/tests Symbolic link
View File

@ -0,0 +1 @@
../../tests/isc

View File

@ -33,7 +33,3 @@ libisccfg_la_LIBADD = \
libisccfg_la_LDFLAGS = \
$(AM_LDFLAGS) \
-release "$(PACKAGE_VERSION)"
if HAVE_CMOCKA
SUBDIRS = tests
endif

1
lib/isccfg/tests Symbolic link
View File

@ -0,0 +1 @@
../../tests/isccfg

View File

@ -55,7 +55,3 @@ libns_la_LIBADD = \
libns_la_LDFLAGS = \
$(AM_LDFLAGS) \
-release "$(PACKAGE_VERSION)"
if HAVE_CMOCKA
SUBDIRS = tests
endif

1
lib/ns/tests Symbolic link
View File

@ -0,0 +1 @@
../../tests/ns

1
tests/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/unit-test-driver.sh

30
tests/Makefile.am Normal file
View File

@ -0,0 +1,30 @@
include $(top_srcdir)/Makefile.top
AM_CPPFLAGS += \
$(LIBISC_CFLAGS) \
$(LIBDNS_CFLAGS) \
$(LIBNS_CFLAGS) \
$(LIBUV_CFLAGS) \
-I$(top_srcdir)/lib/isc
LDADD += \
$(LIBISC_LIBS) \
$(LIBDNS_LIBS) \
$(LIBNS_LIBS)
SUBDIRS = . isc dns ns isccfg irs
check_LTLIBRARIES = libtest.la
noinst_libtest_ladir = .
noinst_libtest_la_HEADERS = \
include/tests/dns.h \
include/tests/isc.h \
include/tests/ns.h
libtest_la_SOURCES = \
$(noinst_libtest_la_HEADERS) \
dns.c \
isc.c \
ns.c
include $(top_srcdir)/Makefile.tests

View File

@ -53,7 +53,7 @@
#include <dns/view.h>
#include <dns/zone.h>
#include <dns/test.h>
#include <tests/dns.h>
dns_zonemgr_t *zonemgr = NULL;

View File

@ -6,21 +6,15 @@ AM_CPPFLAGS += \
$(LIBUV_CFLAGS) \
$(KRB5_CFLAGS) \
-DSRCDIR=\"$(abs_srcdir)\" \
-DBUILDDIR=\"$(abs_builddir)\"
-DBUILDDIR=\"$(abs_builddir)\" \
-I$(top_srcdir)/lib/isc \
-I$(top_srcdir)/lib/dns
LDADD += \
libdnstest.la \
$(LIBISC_LIBS) \
$(LIBUV_LIBS) \
$(LIBDNS_LIBS)
check_LTLIBRARIES = libdnstest.la
libdnstest_la_SOURCES = \
../../isc/test.c \
../../isc/include/isc/test.h \
../../dns/test.c \
../../dns/include/dns/test.h
check_PROGRAMS = \
acl_test \
db_test \
@ -79,7 +73,8 @@ check_PROGRAMS += \
geoip_test_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(MAXMINDDB_CFLAGS)
$(MAXMINDDB_CFLAGS) \
-DTEST_GEOIP_DATA=\"$(top_srcdir)/bin/tests/system/geoip2/data\"
geoip_test_LDADD = \
$(LDADD) \

View File

@ -29,7 +29,7 @@
#include <dns/acl.h>
#include <dns/test.h>
#include <tests/dns.h>
#define BUFLEN 255
#define BIGBUFLEN (70 * 1024)

View File

@ -27,7 +27,7 @@
#include <dns/name.h>
#include <dns/rdatalist.h>
#include <dns/test.h>
#include <tests/dns.h>
#define BUFLEN 255
#define BIGBUFLEN (64 * 1024)

View File

@ -29,7 +29,7 @@
#include <dns/journal.h>
#include <dns/name.h>
#include <dns/test.h>
#include <tests/dns.h>
#define BUFLEN 255
#define BIGBUFLEN (64 * 1024)

View File

@ -28,7 +28,7 @@
#include <dns/dbiterator.h>
#include <dns/name.h>
#include <dns/test.h>
#include <tests/dns.h>
#define BUFLEN 255
#define BIGBUFLEN (64 * 1024)

View File

@ -35,7 +35,7 @@
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/test.h>
#include <tests/dns.h>
static char tempname[11] = "dtXXXXXXXX";
static dns_db_t *db1 = NULL, *db2 = NULL;

View File

@ -28,9 +28,9 @@
#include <dns/name.h>
#include "../dst_internal.h"
#include "dst_internal.h"
#include <dns/test.h>
#include <tests/dns.h>
static int
setup_test(void **state) {

View File

@ -35,7 +35,7 @@
#include <dns/name.h>
#include <dns/view.h>
#include <dns/test.h>
#include <tests/dns.h>
uv_sem_t sem;

View File

@ -32,7 +32,7 @@
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/test.h>
#include <tests/dns.h>
static void
multiple_prefixes(void) {

View File

@ -36,13 +36,13 @@
#include <dns/dnstap.h>
#include <dns/view.h>
#include <dns/test.h>
#include <tests/dns.h>
#define TAPFILE "testdata/dnstap/dnstap.file"
#define TAPSOCK "testdata/dnstap/dnstap.sock"
#define TAPFILE TESTS_DIR "/testdata/dnstap/dnstap.file"
#define TAPSOCK TESTS_DIR "/testdata/dnstap/dnstap.sock"
#define TAPSAVED "testdata/dnstap/dnstap.saved"
#define TAPTEXT "testdata/dnstap/dnstap.text"
#define TAPSAVED TESTS_DIR "/testdata/dnstap/dnstap.saved"
#define TAPTEXT TESTS_DIR "/testdata/dnstap/dnstap.text"
static int
cleanup(void **state __attribute__((__unused__))) {

View File

@ -31,9 +31,9 @@
#include <dst/dst.h>
#include "../dst_internal.h"
#include "dst_internal.h"
#include <dns/test.h>
#include <tests/dns.h>
static int
setup_test(void **state) {

View File

@ -32,12 +32,9 @@
#include <dns/geoip.h>
#include "../geoip2.c"
#include "geoip2.c"
#include <dns/test.h>
/* Use GeoIP2 databases from the 'geoip2' system test */
#define TEST_GEOIP_DATA "../../../bin/tests/system/geoip2/data"
#include <tests/dns.h>
static dns_geoip_databases_t geoip;

View File

@ -40,7 +40,7 @@
#include <dst/dst.h>
#include <dns/test.h>
#include <tests/dns.h>
dns_keytable_t *keytable = NULL;
dns_ntatable_t *ntatable = NULL;

View File

@ -38,7 +38,7 @@
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/test.h>
#include <tests/dns.h>
static void
nullmsg(dns_rdatacallbacks_t *cb, const char *fmt, ...) {

View File

@ -36,7 +36,7 @@
#include <dns/fixedname.h>
#include <dns/name.h>
#include <dns/test.h>
#include <tests/dns.h>
/* Set to true (or use -v option) for verbose output */
static bool verbose = false;

View File

@ -28,7 +28,7 @@
#include <dns/db.h>
#include <dns/nsec3.h>
#include <dns/test.h>
#include <tests/dns.h>
static void
iteration_test(const char *file, unsigned int expected) {

View File

@ -30,9 +30,9 @@
#include <dns/db.h>
#include <dns/nsec3.h>
#include "../zone_p.h"
#include "zone_p.h"
#include <dns/test.h>
#include <tests/dns.h>
#define HASH 1
#define FLAGS 0

View File

@ -26,7 +26,7 @@
#include <dns/peer.h>
#include <dns/test.h>
#include <tests/dns.h>
/* Test DSCP set/get functions */
ISC_RUN_TEST_IMPL(dscp) {

View File

@ -33,7 +33,7 @@
#include <dst/dst.h>
#include <dns/test.h>
#include <tests/dns.h>
static dns_rdatatype_t privatetype = 65534;

View File

@ -51,7 +51,7 @@
#include <dst/dst.h>
#include <dns/test.h>
#include <tests/dns.h>
typedef struct {
dns_rbt_t *rbt;

View File

@ -27,17 +27,19 @@
#include <dns/rbt.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/test.h>
#define KEEP_BEFORE
/* Include the main file */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#undef CHECK
#include "../rbtdb.c"
#include "rbtdb.c"
#pragma GCC diagnostic pop
#undef CHECK
#include <tests/dns.h>
const char *ownercase_vectors[12][2] = {
{
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",

View File

@ -33,7 +33,7 @@
#include <dns/rdata.h>
#include <dns/test.h>
#include <tests/dns.h>
static bool debug = false;

View File

@ -27,7 +27,7 @@
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/test.h>
#include <tests/dns.h>
/* test trimming of rdataset TTLs */
ISC_RUN_TEST_IMPL(trimttl) {

View File

@ -29,7 +29,7 @@
#include <dns/stats.h>
#include <dns/test.h>
#include <tests/dns.h>
static void
set_typestats(dns_stats_t *stats, dns_rdatatype_t type) {

View File

@ -34,7 +34,7 @@
#include <dns/resolver.h>
#include <dns/view.h>
#include <dns/test.h>
#include <tests/dns.h>
static dns_dispatchmgr_t *dispatchmgr = NULL;
static dns_dispatch_t *dispatch = NULL;

View File

@ -26,9 +26,9 @@
#include <isc/print.h>
#include <isc/util.h>
#include "../dst_internal.h"
#include "dst_internal.h"
#include <dns/test.h>
#include <tests/dns.h>
static int
setup_test(void **state) {

View File

@ -43,9 +43,9 @@
#include <dst/dst.h>
#include "../zone_p.h"
#include "zone_p.h"
#include <dns/test.h>
#include <tests/dns.h>
/*%
* Structure characterizing a single diff tuple in the dns_diff_t structure

Some files were not shown because too many files have changed in this diff Show More