]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Have the scripts get the tests directory from $0.
authorGuy Harris <[email protected]>
Mon, 19 Aug 2019 03:24:18 +0000 (20:24 -0700)
committerGuy Harris <[email protected]>
Mon, 19 Aug 2019 03:24:18 +0000 (20:24 -0700)
That means we don't have to cook up a way to pass $(srcdir) to them - we
run them from $(srcdir), so they can pick it up from there.  If you run
them by running tests/TESTrun.sh from the command line, that will also
work; we assume that it's not found from $PATH.

TESTrun.sh and the other scripts run scripts with a path that includes
${testsdir}, so the other scripts are run with a path (they're not
intended to be run from the command line - you're supposed to use
TESTrun.sh, even if you're just running one test).

Makefile.in
tests/TESTrun.sh
tests/crypto.sh
tests/isis-seg-fault-1-v.sh
tests/lmp-v.sh

index adbaa03ee2eda2ade3e11b1d7ce26648b44af3ca..a7aa17645d0cd277b650f6610a75972c25f03c67 100644 (file)
@@ -443,7 +443,7 @@ distclean:
        rm -rf autom4te.cache tests/DIFF tests/NEW
 
 check: tcpdump
-       export SRCDIR=`cd ${srcdir}; pwd` && $${SRCDIR}/tests/TESTrun.sh
+       $(srcdir)/tests/TESTrun.sh
 
 extags: $(TAGFILES)
        ctags $(TAGFILES)
index eb145666b52c97b97acccf011d1d1777382fa85b..cf28fd4d102147597a4508b53b7de4073b78a653 100755 (executable)
@@ -1,17 +1,23 @@
 #!/bin/sh
 
+#
+# Force UTC, so time stamps are printed in a standard time zone, and
+# tests don't have to be run in the time zone in which the output
+# file was generated.
+#
 TZ=GMT0; export TZ
-srcdir=${SRCDIR-.}
 
-echo RUNNING from ${srcdir}
+#
+# Get the tests directory from $0.
+#
+testsdir=`dirname "$0"`
 
-# make it absolute
-srcdir=`cd $srcdir; pwd`
+#
+# Convert it to an absolute path, so it works even after we do a cd.
+#
+testsdir=`cd ${testsdir}; pwd`
 
-# this should be run from the compiled build directory,
-# with srcdir= set to wherever the source code is.
-# not from the tests directory.
-echo RUNNING from ${srcdir}
+echo Running tests from ${testsdir}
 
 passedfile=$(pwd)/tests/.passed
 failedfile=$(pwd)/tests/.failed
@@ -22,11 +28,11 @@ cat /dev/null > ${failureoutput}
 
 runComplexTests()
 {
-  for i in ${srcdir}/tests/*.sh
+  for i in ${testsdir}/*.sh
   do
     case $i in
-        ${srcdir}/tests/TEST*.sh) continue;;
-        ${srcdir}/tests/\*.sh) continue;;
+        ${testsdir}/TEST*.sh) continue;;
+        ${testsdir}/\*.sh) continue;;
     esac
     echo Running $i
     (cd tests && sh $i ${srcdir})
@@ -38,7 +44,7 @@ runComplexTests()
 runSimpleTests()
 {
   only=$1
-  cat ${srcdir}/tests/TESTLIST | while read name input output options
+  cat ${testsdir}/TESTLIST | while read name input output options
   do
     case $name in
       \#*) continue;;
@@ -46,12 +52,11 @@ runSimpleTests()
     esac
     rm -f core
     [ "$only" != "" -a "$name" != "$only" ] && continue
-    export SRCDIR=${srcdir}
     # I hate shells with their stupid, useless subshells.
     passed=`cat ${passedfile}`
     failed=`cat ${failedfile}`
     (cd tests  # run TESTonce in tests directory
-    if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options"
+    if ${testsdir}/TESTonce $name ${testsdir}/$input ${testsdir}/$output "$options"
     then
       passed=`expr $passed + 1`
       echo $passed >${passedfile}
index 7be49a9350cb4b9b815af1f46057eaba028f41e1..a32f5b876921fc8d76ee32252cc09b4487809040 100755 (executable)
@@ -1,6 +1,9 @@
 #!/bin/sh
 
-srcdir=${SRCDIR-.}
+#
+# Get the tests directory from $0.
+#
+testsdir=`dirname "$0"`
 
 exitcode=0
 passed=`cat .passed`
@@ -10,7 +13,7 @@ failed=`cat .failed`
 
 if grep '^#define HAVE_LIBCRYPTO 1$' ../config.h >/dev/null
 then
-       if ${srcdir}/tests/TESTonce esp1 ${srcdir}/tests/02-sunrise-sunset-esp.pcap ${srcdir}/tests/esp1.out '-E "[email protected] 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
+       if ${testsdir}/TESTonce esp1 ${testsdir}/02-sunrise-sunset-esp.pcap ${testsdir}/esp1.out '-E "[email protected] 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
@@ -19,7 +22,7 @@ then
                echo $failed >.failed
                exitcode=1
        fi
-       if ${srcdir}/tests/TESTonce esp2 ${srcdir}/tests/08-sunrise-sunset-esp2.pcap ${srcdir}/tests/esp2.out '-E "[email protected] 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,[email protected] 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
+       if ${testsdir}/TESTonce esp2 ${testsdir}/08-sunrise-sunset-esp2.pcap ${testsdir}/esp2.out '-E "[email protected] 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,[email protected] 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
@@ -28,7 +31,7 @@ then
                echo $failed >.failed
                exitcode=1
        fi
-       if ${srcdir}/tests/TESTonce esp3 ${srcdir}/tests/02-sunrise-sunset-esp.pcap ${srcdir}/tests/esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
+       if ${testsdir}/TESTonce esp3 ${testsdir}/02-sunrise-sunset-esp.pcap ${testsdir}/esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
@@ -47,7 +50,7 @@ then
                printf "$FORMAT" ikev2pI2
                printf "$FORMAT" isakmp4
        else
-               if ${srcdir}/tests/TESTonce esp4 ${srcdir}/tests/08-sunrise-sunset-esp2.pcap ${srcdir}/tests/esp2.out "-E \"file ${srcdir}/tests/esp-secrets.txt\""
+               if ${testsdir}/TESTonce esp4 ${testsdir}/08-sunrise-sunset-esp2.pcap ${testsdir}/esp2.out "-E \"file ${testsdir}/esp-secrets.txt\""
                then
                        passed=`expr $passed + 1`
                        echo $passed >.passed
@@ -56,7 +59,7 @@ then
                        echo $failed >.failed
                        exitcode=1
                fi
-               if ${srcdir}/tests/TESTonce esp5 ${srcdir}/tests/08-sunrise-sunset-aes.pcap ${srcdir}/tests/esp5.out "-E \"file ${srcdir}/tests/esp-secrets.txt\""
+               if ${testsdir}/TESTonce esp5 ${testsdir}/08-sunrise-sunset-aes.pcap ${testsdir}/esp5.out "-E \"file ${testsdir}/esp-secrets.txt\""
                then
                        passed=`expr $passed + 1`
                        echo $passed >.passed
@@ -65,7 +68,7 @@ then
                        echo $failed >.failed
                        exitcode=1
                fi
-               if ${srcdir}/tests/TESTonce espudp1 ${srcdir}/tests/espudp1.pcap ${srcdir}/tests/espudp1.out "-nnnn -E \"file ${srcdir}/tests/esp-secrets.txt\""
+               if ${testsdir}/TESTonce espudp1 ${testsdir}/espudp1.pcap ${testsdir}/espudp1.out "-nnnn -E \"file ${testsdir}/esp-secrets.txt\""
                then
                        passed=`expr $passed + 1`
                        echo $passed >.passed
@@ -74,7 +77,7 @@ then
                        echo $failed >.failed
                        exitcode=1
                fi
-               if ${srcdir}/tests/TESTonce ikev2pI2 ${srcdir}/tests/ikev2pI2.pcap ${srcdir}/tests/ikev2pI2.out "-E \"file ${srcdir}/tests/ikev2pI2-secrets.txt\" -v -v -v -v"
+               if ${testsdir}/TESTonce ikev2pI2 ${testsdir}/ikev2pI2.pcap ${testsdir}/ikev2pI2.out "-E \"file ${testsdir}/ikev2pI2-secrets.txt\" -v -v -v -v"
                then
                        passed=`expr $passed + 1`
                        echo $passed >.passed
@@ -83,7 +86,7 @@ then
                        echo $failed >.failed
                        exitcode=1
                fi
-               if ${srcdir}/tests/TESTonce isakmp4 ${srcdir}/tests/isakmp4500.pcap ${srcdir}/tests/isakmp4.out "-E \"${srcdir}/tests/file esp-secrets.txt\""
+               if ${testsdir}/TESTonce isakmp4 ${testsdir}/isakmp4500.pcap ${testsdir}/isakmp4.out "-E \"${testsdir}/file esp-secrets.txt\""
                then
                        passed=`expr $passed + 1`
                        echo $passed >.passed
@@ -93,7 +96,7 @@ then
                        exitcode=1
                fi
        fi
-       if ${srcdir}/tests/TESTonce bgp-as-path-oobr-ssl ${srcdir}/tests/bgp-as-path-oobr.pcap ${srcdir}/tests/bgp-as-path-oobr-ssl.out '-vvv -e'
+       if ${testsdir}/TESTonce bgp-as-path-oobr-ssl ${testsdir}/bgp-as-path-oobr.pcap ${testsdir}/bgp-as-path-oobr-ssl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
@@ -102,7 +105,7 @@ then
                echo $failed >.failed
                exitcode=1
        fi
-       if ${srcdir}/tests/TESTonce bgp-aigp-oobr-ssl ${srcdir}/tests/bgp-aigp-oobr.pcap ${srcdir}/tests/bgp-aigp-oobr-ssl.out '-vvv -e'
+       if ${testsdir}/TESTonce bgp-aigp-oobr-ssl ${testsdir}/bgp-aigp-oobr.pcap ${testsdir}/bgp-aigp-oobr-ssl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
@@ -126,7 +129,7 @@ else
        printf "$FORMAT" isakmp4
        printf "$FORMAT" bgp-as-path-oobr-ssl
        printf "$FORMAT" bgp-aigp-oobr-ssl
-       if ${srcdir}/tests/TESTonce bgp-as-path-oobr-nossl ${srcdir}/tests/bgp-as-path-oobr.pcap ${srcdir}/tests/bgp-as-path-oobr-nossl.out '-vvv -e'
+       if ${testsdir}/TESTonce bgp-as-path-oobr-nossl ${testsdir}/bgp-as-path-oobr.pcap ${testsdir}/bgp-as-path-oobr-nossl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
@@ -135,7 +138,7 @@ else
                echo $failed >.failed
                exitcode=1
        fi
-       if ${srcdir}/tests/TESTonce bgp-aigp-oobr-nossl ${srcdir}/tests/bgp-aigp-oobr.pcap ${srcdir}/tests/bgp-aigp-oobr-nossl.out '-vvv -e'
+       if ${testsdir}/TESTonce bgp-aigp-oobr-nossl ${testsdir}/bgp-aigp-oobr.pcap ${testsdir}/bgp-aigp-oobr-nossl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
index 31200fa873dae24a79513f29e1649368af5fe3f5..da5440649b53df1e014b5a657b2f257faf30345f 100755 (executable)
@@ -4,7 +4,10 @@
 # may produce a slightly different result if the compiler is not GCC.
 # Test only with GCC (similar to GitHub issue #333).
 
-srcdir=${SRCDIR-.}
+#
+# Get the tests directory from $0.
+#
+testsdir=`dirname "$0"`
 
 exitcode=0
 test_name=isis-seg-fault-1-v
@@ -16,7 +19,7 @@ elif grep '^CC = .*gcc' ../Makefile >/dev/null
 then
        passed=`cat .passed`
        failed=`cat .failed`
-       if ${srcdir}/tests/TESTonce $test_name ${srcdir}/tests/isis-seg-fault-1.pcapng ${srcdir}/tests/isis-seg-fault-1-v.out '-v'
+       if ${testsdir}/TESTonce $test_name ${testsdir}/isis-seg-fault-1.pcapng ${testsdir}/isis-seg-fault-1-v.out '-v'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed
index b8058811694c7a8c49522cf8b25eaa4344ddd506..1fc1f05c4dddb9a9fa35252e7224e8859db71c93 100755 (executable)
@@ -6,7 +6,10 @@
 # GCC build and must reproduce correctly on any other GCC build regardless of
 # the architecture.
 
-srcdir=${SRCDIR-.}
+#
+# Get the tests directory from $0.
+#
+testsdir=`dirname "$0"`
 
 exitcode=0
 
@@ -19,7 +22,7 @@ elif grep '^CC = .*gcc' ../Makefile >/dev/null
 then
        passed=`cat .passed`
        failed=`cat .failed`
-       if ${srcdir}/tests/TESTonce lmp-v ${srcdir}/tests/lmp.pcap ${srcdir}/tests/lmp-v.out '-T lmp -v'
+       if ${testsdir}/TESTonce lmp-v ${testsdir}/lmp.pcap ${testsdir}/lmp-v.out '-T lmp -v'
        then
                passed=`expr $passed + 1`
                echo $passed >.passed