diff --git a/Makefile.in b/Makefile.in index 1e0cd3d1..fadb2f9b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -98,16 +98,16 @@ example: cd spec/example && $(MAKE) $@ test: default - cd src && $(MAKE) $@ + cd src/test && $(MAKE) $@ getdns_query: default - cd src && $(MAKE) $@ + cd src/tools && $(MAKE) $@ stubby: getdns_query - cd src && $(MAKE) $@ + cd src/tools && $(MAKE) $@ scratchpad: default - cd src && $(MAKE) $@ + cd src/test && $(MAKE) $@ pad: scratchpad src/test/scratchpad || ./libtool exec gdb src/test/scratchpad diff --git a/src/test/Makefile.in b/src/test/Makefile.in index 758435c1..9d4dad00 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -148,13 +148,28 @@ nolibcheck: @echo "***" @false -test: $(NOLIBCHECK) all - (cd $(srcdir)/../.. && find . -type f -executable -and \( -name "*.[ch]" -or -name "*.html" -or -name "*.in" -or -name "*.good" -or -name "*.ac" \) | awk 'BEGIN{e=0}{print("ERROR! Executable bit found on", $$0);e=1}END{exit(e)}') +test_noeventloop: $(NOLIBCHECK) all + rm -f $(CHECK_GETDNS).failed + GETDNS_TEST_PORT=43210 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_GETDNS).log" ./$(CHECK_GETDNS) || echo "$(CHECK_GETDNS) failed" >> $(CHECK_GETDNS).failed + +test_libevent: $(NOLIBCHECK) all + rm -f $(CHECK_EVENT_PROG).failed + if test $(have_libevent) = 1 ; then GETDNS_TEST_PORT=44321 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EVENT_PROG).log" ./$(CHECK_EVENT_PROG) || echo "$(CHECK_EVENT_PROG) failed" >> $(CHECK_EVENT_PROG).failed; fi + +test_libev: $(NOLIBCHECK) all + rm -f $(CHECK_EV_PROG).failed + if test $(have_libev) = 1 ; then GETDNS_TEST_PORT=45432 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EV_PROG).log" ./$(CHECK_EV_PROG) || echo "$(CHECK_EV_PROG) failed" >> $(CHECK_EV_PROG).failed; fi + +test_libuv: $(NOLIBCHECK) all + rm -f $(CHECK_UV_PROG).failed + if test $(have_libev) = 1 ; then GETDNS_TEST_PORT=46543 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_UV_PROG).log" ./$(CHECK_UV_PROG) || echo "$(CHECK_UV_PROG) failed" >> $(CHECK_UV_PROG).failed; fi + +test: test_noeventloop test_libevent test_libev test_libuv rm -f fails - CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_GETDNS).log" ./$(CHECK_GETDNS) || echo "$(CHECK_GETDNS) failed" >> fails - if test $(have_libevent) = 1 ; then CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EVENT_PROG).log" ./$(CHECK_EVENT_PROG) || echo "$(CHECK_EVENT_PROG) failed" >> fails; fi - if test $(have_libev) = 1 ; then CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EV_PROG).log" ./$(CHECK_EV_PROG) || echo "$(CHECK_EV_PROG) failed" >> fails; fi - if test $(have_libuv) = 1 ; then CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_UV_PROG).log" ./$(CHECK_UV_PROG) || echo "$(CHECK_UV_PROG) failed" >> fails; fi + if test -f $(CHECK_GETDNS).failed ; then cat $(CHECK_GETDNS).failed >> fails ; fi + if test -f $(CHECK_EVENT_PROG).failed ; then cat $(CHECK_EVENT_PROG).failed >> fails ; fi + if test -f $(CHECK_EV_PROG).failed ; then cat $(CHECK_EV_PROG).failed >> fails ; fi + if test -f $(CHECK_UV_PROG).failed ; then cat $(CHECK_UV_PROG).failed >> fails ; fi test ! -e fails @echo "All tests OK" diff --git a/src/test/check_getdns_context_set_timeout.c b/src/test/check_getdns_context_set_timeout.c index 26d25aa5..6dd65306 100644 --- a/src/test/check_getdns_context_set_timeout.c +++ b/src/test/check_getdns_context_set_timeout.c @@ -114,6 +114,23 @@ END_TEST #define GETDNS_STR_ADDRESS_TYPE "address_type" #define GETDNS_STR_ADDRESS_DATA "address_data" #define GETDNS_STR_PORT "port" +#define TEST_PORT 43210 + +static uint16_t get_test_port(void) +{ + char *test_port_str; + uint16_t test_port; + struct timeval tv; + + if (!(test_port_str = getenv("GETDNS_TEST_PORT")) || + !(test_port = (uint16_t)atoi(test_port_str))) + test_port = TEST_PORT; + + (void)gettimeofday(&tv, NULL); + srandom((int)getpid() + (int)tv.tv_usec); + test_port += random() % 1000; + return test_port; +} /* utilities to start a junk udp listener */ typedef struct timeout_thread_data { @@ -281,7 +298,7 @@ START_TEST (getdns_context_set_timeout_3) t_data.running = 0; t_data.num_callbacks = 0; t_data.num_timeouts = 0; - t_data.port = 43210; + t_data.port = get_test_port(); pthread_create(&thread, NULL, run_server, (void *)&t_data); @@ -301,7 +318,7 @@ START_TEST (getdns_context_set_timeout_3) bindata.data = (uint8_t*) &local_addr; ASSERT_RC(getdns_dict_set_bindata(server_dict, GETDNS_STR_ADDRESS_DATA, &bindata), GETDNS_RETURN_GOOD, "set addr bindata"); - ASSERT_RC(getdns_dict_set_int(server_dict, GETDNS_STR_PORT, 43210), + ASSERT_RC(getdns_dict_set_int(server_dict, GETDNS_STR_PORT, t_data.port), GETDNS_RETURN_GOOD, "set addr port"); upstream_list = getdns_list_create_with_context(context); diff --git a/src/test/check_getdns_transport.c b/src/test/check_getdns_transport.c index 4b93fdd1..bf457257 100644 --- a/src/test/check_getdns_transport.c +++ b/src/test/check_getdns_transport.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #define GETDNS_STR_IPV4 "IPv4" @@ -42,7 +44,23 @@ #define GETDNS_STR_ADDRESS_TYPE "address_type" #define GETDNS_STR_ADDRESS_DATA "address_data" #define GETDNS_STR_PORT "port" -#define TEST_PORT 43210 +#define TEST_PORT 42100 + +static uint16_t get_test_port(void) +{ + char *test_port_str; + uint16_t test_port; + struct timeval tv; + + if (!(test_port_str = getenv("GETDNS_TEST_PORT")) || + !(test_port = (uint16_t)atoi(test_port_str))) + test_port = TEST_PORT; + + (void)gettimeofday(&tv, NULL); + srandom((int)getpid() + (int)tv.tv_usec); + test_port += random() % 1000; + return test_port; +} /* utilities to start a junk listener */ typedef struct transport_thread_data { @@ -219,7 +237,7 @@ START_TEST(getdns_transport_udp_sync) { t_data.running = 0; t_data.udp_count = 0; t_data.tcp_count = 0; - t_data.port = TEST_PORT; + t_data.port = get_test_port(); pthread_create(&thread, NULL, run_transport_server, (void *) &t_data); @@ -293,7 +311,7 @@ START_TEST(getdns_transport_tcp_sync) { t_data.running = 0; t_data.udp_count = 0; t_data.tcp_count = 0; - t_data.port = TEST_PORT; + t_data.port = get_test_port(); pthread_create(&thread, NULL, run_transport_server, (void *) &t_data); @@ -367,7 +385,7 @@ START_TEST(getdns_transport_udp_async) { t_data.running = 0; t_data.udp_count = 0; t_data.tcp_count = 0; - t_data.port = TEST_PORT; + t_data.port = get_test_port(); pthread_create(&thread, NULL, run_transport_server, (void *) &t_data); @@ -445,7 +463,7 @@ START_TEST(getdns_transport_tcp_async) { t_data.running = 0; t_data.udp_count = 0; t_data.tcp_count = 0; - t_data.port = TEST_PORT; + t_data.port = get_test_port(); pthread_create(&thread, NULL, run_transport_server, (void *) &t_data); diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test index 09473687..a2b5aa1d 100644 --- a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test +++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test @@ -4,7 +4,13 @@ # use .tpkg.var.test for in test variable passing [ -f .tpkg.var.test ] && source .tpkg.var.test +(cd $(srcdir)/../.. && ) + rm -f report.txt +( + cd ${SRCROOT} + find . -type f -executable -and \( -name "*.[ch]" -or -name "*.html" -or -name "*.in" -or -name "*.good" -or -name "*.ac" \) | sed 's/^/*** ERROR! Executable bit found on /g' +) >> report.txt ( cd ${SRCROOT}/src if [ `grep '[^!=]=[ ][ ]*NET_REQ_' *.[ch] */*.[ch] | wc -l` -gt 1 ]