summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Richardson <mcr@sandelman.ca>2019-09-14 14:51:36 -0400
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2019-09-24 14:12:09 +0200
commit8f704e96444fcd4ce0745f66d11e8fbb3da06c7a (patch)
tree6d637189d90b1bf20d8dcf28901cefd5b3af4f22
parent1613feb480bb076139fe965f572919a36e83727e (diff)
downloadtcpdump-8f704e96444fcd4ce0745f66d11e8fbb3da06c7a.tar.gz
updates to scripts for running in testdir vs builddir
-rw-r--r--Makefile.in2
-rwxr-xr-xtests/TESTonce8
-rwxr-xr-xtests/TESTrun.sh6
-rwxr-xr-xtests/crypto.sh66
-rwxr-xr-xtests/isis-seg-fault-1-v.sh21
-rwxr-xr-xtests/lmp-v.sh22
-rwxr-xr-xtests/nflog-e.sh18
7 files changed, 82 insertions, 61 deletions
diff --git a/Makefile.in b/Makefile.in
index 160b50d1..b1e7e684 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -438,7 +438,7 @@ distclean:
rm -rf autom4te.cache tests/DIFF tests/NEW
check: tcpdump
- (mkdir -p tests && export SRCDIR=$$(cd ${srcdir}; pwd) && cd tests && $$SRCDIR/tests/TESTrun.sh )
+ (mkdir -p tests && export SRCDIR=$$(cd ${srcdir}; pwd) && $$SRCDIR/tests/TESTrun.sh )
extags: $(TAGFILES)
ctags $(TAGFILES)
diff --git a/tests/TESTonce b/tests/TESTonce
index d499c07f..dd681c44 100755
--- a/tests/TESTonce
+++ b/tests/TESTonce
@@ -1,11 +1,11 @@
#!/usr/bin/env perl
-$TCPDUMP = "../tcpdump" if (!($TCPDUMP = $ENV{TCPDUMP_BIN}));
+$TCPDUMP = "tcpdump" if (!($TCPDUMP = $ENV{TCPDUMP_BIN}));
use File::Basename;
use POSIX qw( WEXITSTATUS WIFEXITED);
-system("mkdir -p NEW DIFF");
+system("mkdir -p tests/NEW tests/DIFF");
if(@ARGV != 4) {
print "Usage: TESTonce name input output options\n";
@@ -29,13 +29,13 @@ my $diffstat = 0;
my $errdiffstat = 0;
if ($^O eq 'MSWin32') {
- $r = system "..\\windump -# -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$outputbase | diff $output - >DIFF/$outputbase.diff";
+ $r = system "..\\windump -t -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$outputbase | diff $output - >DIFF/$outputbase.diff";
# need to do same as below for Cygwin.
}
else {
# we used to do this as a nice pipeline, but the problem is that $r fails to
# to be set properly if the tcpdump core dumps.
- $r = system "$TCPDUMP 2>${rawstderrlog} -# -n -r $input $options >NEW/${outputbase}";
+ $r = system "$TCPDUMP 2>${rawstderrlog} -t -n -r $input $options >NEW/${outputbase}";
if($r == -1) {
# failed to start due to error.
$status = $!;
diff --git a/tests/TESTrun.sh b/tests/TESTrun.sh
index 02e89082..075d357a 100755
--- a/tests/TESTrun.sh
+++ b/tests/TESTrun.sh
@@ -3,9 +3,7 @@
TZ=GMT0; export TZ
srcdir=${SRCDIR-..}
-echo RUNNING from ${srcdir}
-
-# make it absolute
+# make it absolute for later use.
srcdir=$(cd $srcdir && pwd)
# this should be run from the compiled build directory,
@@ -29,7 +27,7 @@ runComplexTests()
${srcdir}/tests/\*.sh) continue;;
esac
echo Running $i
- (cd tests && sh $i ${srcdir})
+ (sh $i ${srcdir})
done
passed=`cat ${passedfile}`
failed=`cat ${failedfile}`
diff --git a/tests/crypto.sh b/tests/crypto.sh
index 52974c2b..fffcec28 100755
--- a/tests/crypto.sh
+++ b/tests/crypto.sh
@@ -1,13 +1,15 @@
#!/bin/sh
srcdir=${1-..}
-echo crypto.sh using ${srcdir}
+echo crypto.sh using ${srcdir} from $(pwd)
testdir=${srcdir}/tests
exitcode=0
-passed=`cat .passed`
-failed=`cat .failed`
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
# Only attempt OpenSSL-specific tests when compiled with the library.
@@ -16,28 +18,28 @@ then
if ${testdir}/TESTonce esp1 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
if ${testdir}//TESTonce esp2 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp2.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
if ${testdir}/TESTonce esp3 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
# Reading the secret(s) from a file does not work with Capsicum.
@@ -50,68 +52,68 @@ then
printf "$FORMAT" ikev2pI2
printf "$FORMAT" isakmp4
else
- if ${testdir}/TESTonce esp4 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp2.out '-E "file esp-secrets.txt"'
+ if ${testdir}/TESTonce esp4 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp2.out '-E "file ${testdir}/esp-secrets.txt"'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
- if ${testdir}/TESTonce esp5 ${testdir}/08-sunrise-sunset-aes.pcap ${testdir}/esp5.out '-E "file esp-secrets.txt"'
+ if ${testdir}/TESTonce esp5 ${testdir}/08-sunrise-sunset-aes.pcap ${testdir}/esp5.out '-E "file ${testdir}/esp-secrets.txt"'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
- if ${testdir}/TESTonce espudp1 ${testdir}/espudp1.pcap ${testdir}/espudp1.out '-nnnn -E "file esp-secrets.txt"'
+ if ${testdir}/TESTonce espudp1 ${testdir}/espudp1.pcap ${testdir}/espudp1.out '-nnnn -E "file ${testdir}/esp-secrets.txt"'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
- if ${testdir}/TESTonce ikev2pI2 ${testdir}/ikev2pI2.pcap ${testdir}/ikev2pI2.out '-E "file ikev2pI2-secrets.txt" -v -v -v -v'
+ if ${testdir}/TESTonce ikev2pI2 ${testdir}/ikev2pI2.pcap ${testdir}/ikev2pI2.out '-E "file ${testdir}/ikev2pI2-secrets.txt" -v -v -v -v'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
- if ${testdir}/TESTonce isakmp4 ${testdir}/isakmp4500.pcap ${testdir}/isakmp4.out '-E "file esp-secrets.txt"'
+ if ${testdir}/TESTonce isakmp4 ${testdir}/isakmp4500.pcap ${testdir}/isakmp4.out '-E "file ${testdir}/esp-secrets.txt"'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
fi
if ${testdir}/TESTonce bgp-as-path-oobr-ssl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-ssl.out '-vvv -e'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
if ${testdir}/TESTonce bgp-aigp-oobr-ssl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-ssl.out '-vvv -e'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
FORMAT=' %-35s: TEST SKIPPED (compiled w/OpenSSL)\n'
@@ -132,19 +134,19 @@ else
if ${testdir}/TESTonce bgp-as-path-oobr-nossl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-nossl.out '-vvv -e'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
if ${testdir}/TESTonce bgp-aigp-oobr-nossl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-nossl.out '-vvv -e'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
fi
diff --git a/tests/isis-seg-fault-1-v.sh b/tests/isis-seg-fault-1-v.sh
index d19b4a87..47b59103 100755
--- a/tests/isis-seg-fault-1-v.sh
+++ b/tests/isis-seg-fault-1-v.sh
@@ -7,20 +7,27 @@
exitcode=0
test_name=isis-seg-fault-1-v
-if [ ! -f ../Makefile ]
+srcdir=${1-..}
+echo $0 using ${srcdir}
+
+testdir=${srcdir}/tests
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
+
+if [ ! -f Makefile ]
then
printf ' %-35s: TEST SKIPPED (no Makefile)\n' $test_name
-elif grep '^CC = .*gcc' ../Makefile >/dev/null
+elif grep '^CC = .*gcc' Makefile >/dev/null
then
- passed=`cat .passed`
- failed=`cat .failed`
- if ./TESTonce $test_name isis-seg-fault-1.pcap isis-seg-fault-1-v.out '-v'
+ if ${testdir}/TESTonce $test_name ${testdir}/isis-seg-fault-1.pcap ${testdir}/isis-seg-fault-1-v.out '-v'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
else
diff --git a/tests/lmp-v.sh b/tests/lmp-v.sh
index a8c6740e..2b9222f6 100755
--- a/tests/lmp-v.sh
+++ b/tests/lmp-v.sh
@@ -7,23 +7,31 @@
# the architecture.
exitcode=0
+srcdir=${1-..}
+echo $0 using ${srcdir}
+
+testdir=${srcdir}/tests
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
# A Windows build may have no file named Makefile and also a version of grep
# that won't return an error when the file does not exist. Work around.
-if [ ! -f ../Makefile ]
+if [ ! -f Makefile ]
then
printf ' %-35s: TEST SKIPPED (no Makefile)\n' 'lmp-v'
-elif grep '^CC = .*gcc' ../Makefile >/dev/null
+elif grep '^CC = .*gcc' Makefile >/dev/null
then
- passed=`cat .passed`
- failed=`cat .failed`
- if ./TESTonce lmp-v lmp.pcap lmp-v.out '-T lmp -v'
+ passed=`cat ${passedfile}`
+ failed=`cat ${failedfile}`
+ if ${testdir}/TESTonce lmp-v ${testdir}/lmp.pcap ${testdir}/lmp-v.out '-T lmp -v'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
else
diff --git a/tests/nflog-e.sh b/tests/nflog-e.sh
index 5b5b66ce..dfef3cc1 100755
--- a/tests/nflog-e.sh
+++ b/tests/nflog-e.sh
@@ -1,20 +1,26 @@
#!/bin/sh
exitcode=0
+srcdir=${1-..}
+echo $0 using ${srcdir}
+
+testdir=${srcdir}/tests
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
# NFLOG support depends on both DLT_NFLOG and working <pcap/nflog.h>
-if grep '^#define HAVE_PCAP_NFLOG_H 1$' ../config.h >/dev/null
+if grep '^#define HAVE_PCAP_NFLOG_H 1$' config.h >/dev/null
then
- passed=`cat .passed`
- failed=`cat .failed`
- if ./TESTonce nflog-e nflog.pcap nflog-e.out '-e'
+ if ${testdir}/TESTonce nflog-e ${testdir}/nflog.pcap ${testdir}/nflog-e.out '-e'
then
passed=`expr $passed + 1`
- echo $passed >.passed
+ echo $passed >${passedfile}
else
failed=`expr $failed + 1`
- echo $failed >.failed
+ echo $failed >${failedfile}
exitcode=1
fi
else