]> git.ipfire.org Git - thirdparty/pdns.git/blame - regression-tests/runtests
regression tests: Use environment vars to determine program location
[thirdparty/pdns.git] / regression-tests / runtests
CommitLineData
cf4d037d 1#!/usr/bin/env bash
fc132a05 2PATH=.:$PATH:/usr/sbin
04aaf527 3MAKE=${MAKE:-make}
d4886eb4 4
d9c6538e
PL
5export PDNS=${PDNS:-${PWD}/../pdns/pdns_server}
6export PDNS2=${PDNS2:-${PWD}/../pdns/pdns_server}
7export PDNSRECURSOR=${PDNSRECURSOR:-${PWD}/../pdns_recursor}
8export SDIG=${SDIG:-${PWD}/../pdns/sdig}
9export NSEC3DIG=${NSEC3DIG:-${PWD}/../pdns/nsec3dig}
10export SAXFR=${SAXFR:-${PWD}/../pdns/saxfr}
11export ZONE2SQL=${ZONE2SQL:-${PWD}/../pdns/zone2sql}
12export PDNSSEC=${PDNSSEC:-${PWD}/../pdns/pdnssec}
13export PDNSCONTROL=${PDNSCONTROL:-${PWD}/../pdns/pdns_control}
14
388cdf7a
RA
15spectest=$1
16[ -z $spectest ] && spectest=""
17
d9c6538e
PL
18for prog in $SDIG $SAXFR $NSEC3DIG; do
19 if `echo $prog | grep -q '../pdns'`; then
20 ${MAKE} -C ../pdns ${prog##../pdns/} || exit
21 fi
22done
388cdf7a 23
ff83f2ff 24rm -f test-results failed_tests passed_tests skipped_tests ${testsdir}/*/real_result ${testsdir}/*/diff ${testsdir}/*/*.out ${testsdir}/*/start ${testsdir}/*/step.*
d4886eb4
BH
25
26passed=0
27failed=0
e87e682b 28skipped=0
d4886eb4 29
7dbdd1e7
PD
30touch passed_tests failed_tests skipped_tests
31
53f66707 32for a in $(find $testsdir -type d | grep -v ^.$ | grep -v .svn | grep -v ^confdir | LC_ALL=C sort)
d4886eb4 33do
7241f22f
PD
34 if [ ! -x $a/command ]
35 then
36 continue
37 fi
53f66707 38 testname=$(basename $a)
d3625be4 39 export testname
c823f41c 40 echo "$testname: "
d4886eb4
BH
41 cat $a/description
42
53f66707 43 echo "$testname: " >> test-results
d4886eb4
BH
44 cat $a/description >> test-results
45
1bccd246 46 SKIPIT=0
e87e682b 47 if [ -e $a/skip ]
d4886eb4 48 then
1bccd246 49 SKIPIT=1
e87e682b 50 result=" Skipped test $a"
1bccd246 51 else
388cdf7a 52 for reason in $skipreasons $context
1bccd246
PD
53 do
54 if [ -e $a/skip.$reason ]
55 then
56 SKIPIT=1
57 result=" Skipped test $a for reason $reason"
58 break
59 fi
60 done
61 fi
388cdf7a
RA
62
63 if [ "$spectest" != "" ] && [ "$spectest" != "$testname" ] && [ "$testname" != "00dnssec-grabkeys" ]
64 then
65 SKIPIT=1
66 result=" Skipped test $a because it's not the specified single test"
67 fi
68
1bccd246
PD
69
70 if [ $SKIPIT = 1 ]
71 then
53f66707 72 echo $testname >> skipped_tests
e87e682b 73 skipped=$[$skipped+1]
914353ca 74 else
e87e682b 75 $a/command > $a/real_result
dff80aa2 76 expected=$a/expected_result
8a4a3c5c 77
a9330594
MS
78 diffopts="-u"
79 if [ -e $a/expected_result.i ]; then
80 expected=$a/expected_result.i
81 diffopts="${diffopts} -i"
82 fi
8a4a3c5c 83
9eb3131a 84 for extracontext in $extracontexts
1bccd246
PD
85 do
86 [ -e "$a/expected_result.$extracontext" ] && expected=$a/expected_result.$extracontext
87 done
dff80aa2 88 [ -n "$context" ] && [ -e "$a/expected_result.$context" ] && expected=$a/expected_result.$context
8a4a3c5c 89 diff ${diffopts} $expected $a/real_result > $a/diff 2>&1
e87e682b
BH
90 if [ -s $a/diff ]
91 then
92 result=" Failed test $a"
53f66707 93 echo $testname >> failed_tests
e87e682b
BH
94 failed=$[$failed+1]
95 else
96 result=" Passed test $a"
53f66707 97 echo $testname >> passed_tests
e87e682b
BH
98 passed=$[$passed+1]
99 fi
100 fi
c823f41c 101 echo "$result"
d4886eb4
BH
102 echo
103 echo "$result" >> test-results
104 echo >> test-results
105done
106
e87e682b 107echo -n $passed out of $[$passed+$failed]
d4886eb4
BH
108echo -n " ("
109res=$((echo scale=2; echo 100*$passed/\($passed+$failed\)) | bc )
110echo -n "$res%) "
c823f41c 111echo tests passed, $skipped were skipped