1#!/usr/bin/env bash
2. testdata/common.sh
3quiet=0
4if test "$1" = "-q"; then
5	quiet=1
6	tdirarg="-q"
7	shift
8fi
9
10NEED_SPLINT='00-lint.tdir'
11NEED_DOXYGEN='01-doc.tdir'
12NEED_XXD='fwd_compress_c00c.tdir fwd_zero.tdir'
13NEED_NC='fwd_compress_c00c.tdir fwd_zero.tdir'
14NEED_CURL='06-ianaports.tdir root_anchor.tdir'
15NEED_WHOAMI='07-confroot.tdir'
16NEED_IPV6='fwd_ancil.tdir fwd_tcp_tc6.tdir stub_udp6.tdir edns_cache.tdir'
17NEED_NOMINGW='tcp_sigpipe.tdir 07-confroot.tdir 08-host-lib.tdir fwd_ancil.tdir'
18NEED_DNSCRYPT_PROXY='dnscrypt_queries.tdir dnscrypt_queries_chacha.tdir'
19
20# test if dig and ldns-testns are available.
21test_tool_avail "dig"
22test_tool_avail "ldns-testns"
23
24# test for ipv6, uses streamtcp peculiarity.
25if ./streamtcp -f ::1 2>&1 | grep "not supported" >/dev/null 2>&1; then
26	HAVE_IPV6=no
27else
28	HAVE_IPV6=yes
29fi
30
31# test mingw. no signals and so on.
32if uname | grep MINGW >/dev/null; then
33	HAVE_MINGW=yes
34else
35	HAVE_MINGW=no
36fi
37
38# stop tests from notifying systemd, if that is compiled in.
39export -n NOTIFY_SOCKET
40
41cd testdata;
42sh ../testcode/mini_tdir.sh $tdirarg clean
43rm -f .perfstats.txt
44for test in `ls -d *.tdir`; do
45	SKIP=0
46	skip_if_in_list $test "$NEED_SPLINT" "splint"
47	skip_if_in_list $test "$NEED_DOXYGEN" "doxygen"
48	skip_if_in_list $test "$NEED_CURL" "curl"
49	skip_if_in_list $test "$NEED_XXD" "xxd"
50	skip_if_in_list $test "$NEED_NC" "nc"
51	skip_if_in_list $test "$NEED_WHOAMI" "whoami"
52	skip_if_in_list $test "$NEED_DNSCRYPT_PROXY" "dnscrypt-proxy"
53
54	if echo $NEED_IPV6 | grep $test >/dev/null; then
55		if test "$HAVE_IPV6" = no; then
56			SKIP=1;
57		fi
58	fi
59	if echo $NEED_NOMINGW | grep $test >/dev/null; then
60		if test "$HAVE_MINGW" = yes; then
61			SKIP=1;
62		fi
63	fi
64	if test $SKIP -eq 0; then
65		echo $test
66		sh ../testcode/mini_tdir.sh -a ../.. $tdirarg exe $test
67	else
68		echo "skip $test"
69	fi
70done
71sh ../testcode/mini_tdir.sh $tdirarg report
72cat .perfstats.txt
73