bind9/lib/isc/tests/Makefile.am
Ondřej Surý 42e4e3b843 Improve reliability of the netmgr unit tests
The netmgr unit tests were designed to push the system limits to maximum
by sending as many queries as possible in the busy loop from multiple
threads.  This mostly works with UDP, but in the stateful protocol where
establishing the connection takes more time, it failed quite often in
the CI.  On FreeBSD, this happened more often, because the socket() call
would fail spuriosly making the problem even worse.

This commit does several things to improve reliability:

* return value of isc_nm_<proto>connect() is always checked and retried
  when scheduling the connection fails

* The busy while loop has been slowed down with usleep(1000); so the
  netmgr threads could schedule the work and get executed.

* The isc_thread_yield() was replaced with usleep(1000); also to allow
  the other threads to do any work.

* Instead of waiting on just one variable, we wait for multiple
  variables to reach the final value

* We are wrapping the netmgr operations (connects, reads, writes,
  accepts) with reference counting and waiting for all the callbacks to
  be accounted for.

  This has two effects:

  a) the isc_nm_t is always clean of active sockets and handles when
     destroyed, so it will prevent the spurious INSIST(references == 1)
     from isc_nm_destroy()

  b) the unit test now ensures that all the callbacks are always called
     when they should be called, so any stuck test means that there was
     a missing callback call and it is always a real bug

These changes allows us to remove the workaround that would not run
certain tests on systems without port load-balancing.
2021-03-19 16:25:28 +01:00

98 lines
1.4 KiB
Makefile

include $(top_srcdir)/Makefile.top
include $(top_srcdir)/Makefile.tests
AM_CPPFLAGS += \
$(LIBISC_CFLAGS)
LDADD += \
libisctest.la \
$(LIBISC_LIBS)
check_LTLIBRARIES = libisctest.la
libisctest_la_SOURCES = \
../unix/socket_p.h \
isctest.c \
isctest.h \
uv_wrap.h
TESTS = \
aes_test \
buffer_test \
counter_test \
crc64_test \
doh_test \
errno_test \
file_test \
hash_test \
heap_test \
hmac_test \
ht_test \
lex_test \
md_test \
mem_test \
netaddr_test \
netmgr_test \
parse_test \
pool_test \
quota_test \
radix_test \
random_test \
regex_test \
result_test \
safe_test \
siphash_test \
sockaddr_test \
socket_test \
symtab_test \
task_test \
taskpool_test \
time_test \
timer_test
check_PROGRAMS = \
$(TESTS)
doh_test_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(LIBUV_CFLAGS) \
$(OPENSSL_CFLAGS)
doh_test_LDADD = \
$(LDADD) \
$(LIBUV_LIBS) \
$(OPENSSL_LIBS)
hmac_test_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(OPENSSL_CFLAGS)
hmac_test_LDADD = \
$(LDADD) \
$(OPENSSL_LIBS)
md_test_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(OPENSSL_CFLAGS)
md_test_LDADD = \
$(LDADD) \
$(OPENSSL_LIBS)
random_test_LDADD = \
$(LDADD) \
-lm
netmgr_test_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(LIBUV_CFLAGS) \
$(OPENSSL_CFLAGS)
netmgr_test_LDADD = \
$(LDADD) \
$(LIBUV_LIBS)
unit-local: check
EXTRA_DIST = testdata
LOG_COMPILER = $(builddir)/../../unit-test-driver.sh