diff options
author | Michael Richardson <mcr@sandelman.ca> | 2020-02-03 03:06:33 +0100 |
---|---|---|
committer | Denis Ovsienko <denis@ovsienko.info> | 2020-02-04 22:19:17 +0000 |
commit | 1309daa4a46dc7340a45586f83313e5d42152613 (patch) | |
tree | 30bc766f950f62a8966f9c3ba5e2f96c80413f93 /tests | |
parent | eaa76f6c4444fcb8cc999b2a0f6253d5c440bdb4 (diff) | |
download | tcpdump-1309daa4a46dc7340a45586f83313e5d42152613.tar.gz |
process config_set
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/TESTrun | 75 | ||||
-rw-r--r-- | tests/crypto.tests | 40 |
2 files changed, 105 insertions, 10 deletions
diff --git a/tests/TESTrun b/tests/TESTrun index 65ac389d..3267acbb 100755 --- a/tests/TESTrun +++ b/tests/TESTrun @@ -6,6 +6,7 @@ use File::Basename; use POSIX qw( WEXITSTATUS WIFEXITED); use Cwd qw(abs_path getcwd); use File::Path qw(mkpath); # mkpath works with ancient perl, as well as newer perl +use Data::Dumper; # for debugging. # these are created in the directory where we are run, which might be # a build directory. @@ -71,6 +72,30 @@ sub runShellTests { # have to update passed/failed here } +$confighhash = undef; + +sub loadconfighash { + if(defined($confighhash)) { + return $confighhash; + } + + $main::confighhash = {}; + + # this could be loaded once perhaps. + open(CONFIG_H, "config.h") || die "Can not open config.h: $!\n"; + while(<CONFIG_H>) { + chomp; + if(/^\#define (.*) 1/) { + #print "Setting $1\n"; + $main::confighhash->{$1} = 1; + } + } + close(CONFIG_H); + #print Dumper($main::confighhash); + return $main::confighhash; +} + + sub runOneComplexTest { local($testconfig) = @_; @@ -78,13 +103,40 @@ sub runOneComplexTest { my $input = $testconfig->{input}; my $name = $testconfig->{name}; my $options= $testconfig->{args}; - + my $foundit = 1; + my $unfoundit=1; + + my $configset = $testconfig->{config_set}; + my $configunset = $testconfig->{config_unset}; + my $ch = loadconfighash(); + #print Dumper($ch); + + if(defined($configset)) { + $foundit = ($ch->{$configset} == 1); + } + if(defined($configunset)) { + $unfoundit=($ch->{$configunset} != 1); + } + + if(!$foundit) { + print "${name} ... skipped, no ${configset}\n"; + return 0; + } + + if(!$unfoundit) { + print "${name} ... skipped, ${configunset} is set\n"; + return 0; + } + #use Data::Dumper; #print Dumper($testconfig); - - my $result = runtest($name, - $testsdir . "/" . $input, - $testsdir . "/" . $output, + + # EXPAND any occurances of @TESTDIR@ to $testsdir + $options =~ s/\@TESTDIR\@/$testsdir/; + + my $result = runtest($name, + $testsdir . "/" . $input, + $testsdir . "/" . $output, $options); if($result == 0) { @@ -100,10 +152,13 @@ sub runComplexTests { my @files = glob( $testsdir . '/*.tests' ); foreach $file (@files) { my @testlist = undef; + my $definitions; print "FILE: ${file}\n"; open(FILE, "<".$file) || die "can not open $file: $!"; - local $/ = undef; - $definitions = <FILE>; + { + local $/ = undef; + $definitions = <FILE>; + } close(FILE); #print "STUFF: ${definitions}\n"; eval $definitions; @@ -116,13 +171,13 @@ sub runComplexTests { } else { warn "File: ${file} could not be loaded as PERL: $!"; } - } + } } sub runSimpleTests { local($only)=@_; - + open(TESTLIST, "<" . "${testsdir}/TESTLIST") || die "no ${testsdir}/TESTFILE: $!\n"; while(<TESTLIST>) { next if /^\#/; @@ -132,7 +187,7 @@ sub runSimpleTests { ($name, $input, $output, @options) = split; #print "processing ${only} vs ${name}\n"; next if(defined($only) && $only ne $name); - + my $options = join(" ", @options); #print "@{options} becomes ${options}\n"; diff --git a/tests/crypto.tests b/tests/crypto.tests new file mode 100644 index 00000000..27c8ce5f --- /dev/null +++ b/tests/crypto.tests @@ -0,0 +1,40 @@ +# -*- perl -*- + +$testlist = [ + { + config_set => 'HAVE_LIBCRYPTO', + name => 'esp1', + input => '02-sunrise-sunset-esp.pcap', + output => 'esp1.out', + args => '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"' + }, + + { + config_set => 'HAVE_LIBCRYPTO', + name => 'esp2', + input => '08-sunrise-sunset-esp2.pcap', + output => 'esp2.out', + args => '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"' + }, + + { + config_set => 'HAVE_LIBCRYPTO', + name => 'esp3', + input => '02-sunrise-sunset-esp.pcap', + output => 'esp1.out', + args => '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"', + }, + + { + config_set => 'HAVE_LIBCRYPTO', + config_unset => 'HAVE_CAPSICUM', + name => 'esp4', + input => '08-sunrise-sunset-esp2.pcap', + output => 'esp2.out', + args => '-E "file @TESTDIR@/esp-secrets.txt"', + } + ]; + +1; + + |