Skip to content

Commit 1309daa

Browse files
mcrinfrastation
authored andcommitted
process config_set
1 parent eaa76f6 commit 1309daa

File tree

2 files changed

+105
-10
lines changed

2 files changed

+105
-10
lines changed

tests/TESTrun

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use File::Basename;
66
use POSIX qw( WEXITSTATUS WIFEXITED);
77
use Cwd qw(abs_path getcwd);
88
use File::Path qw(mkpath); # mkpath works with ancient perl, as well as newer perl
9+
use Data::Dumper; # for debugging.
910

1011
# these are created in the directory where we are run, which might be
1112
# a build directory.
@@ -71,20 +72,71 @@ sub runShellTests {
7172
# have to update passed/failed here
7273
}
7374

75+
$confighhash = undef;
76+
77+
sub loadconfighash {
78+
if(defined($confighhash)) {
79+
return $confighhash;
80+
}
81+
82+
$main::confighhash = {};
83+
84+
# this could be loaded once perhaps.
85+
open(CONFIG_H, "config.h") || die "Can not open config.h: $!\n";
86+
while(<CONFIG_H>) {
87+
chomp;
88+
if(/^\#define (.*) 1/) {
89+
#print "Setting $1\n";
90+
$main::confighhash->{$1} = 1;
91+
}
92+
}
93+
close(CONFIG_H);
94+
#print Dumper($main::confighhash);
95+
return $main::confighhash;
96+
}
97+
98+
7499
sub runOneComplexTest {
75100
local($testconfig) = @_;
76101

77102
my $output = $testconfig->{output};
78103
my $input = $testconfig->{input};
79104
my $name = $testconfig->{name};
80105
my $options= $testconfig->{args};
81-
106+
my $foundit = 1;
107+
my $unfoundit=1;
108+
109+
my $configset = $testconfig->{config_set};
110+
my $configunset = $testconfig->{config_unset};
111+
my $ch = loadconfighash();
112+
#print Dumper($ch);
113+
114+
if(defined($configset)) {
115+
$foundit = ($ch->{$configset} == 1);
116+
}
117+
if(defined($configunset)) {
118+
$unfoundit=($ch->{$configunset} != 1);
119+
}
120+
121+
if(!$foundit) {
122+
print "${name} ... skipped, no ${configset}\n";
123+
return 0;
124+
}
125+
126+
if(!$unfoundit) {
127+
print "${name} ... skipped, ${configunset} is set\n";
128+
return 0;
129+
}
130+
82131
#use Data::Dumper;
83132
#print Dumper($testconfig);
84-
85-
my $result = runtest($name,
86-
$testsdir . "/" . $input,
87-
$testsdir . "/" . $output,
133+
134+
# EXPAND any occurances of @TESTDIR@ to $testsdir
135+
$options =~ s/\@TESTDIR\@/$testsdir/;
136+
137+
my $result = runtest($name,
138+
$testsdir . "/" . $input,
139+
$testsdir . "/" . $output,
88140
$options);
89141

90142
if($result == 0) {
@@ -100,10 +152,13 @@ sub runComplexTests {
100152
my @files = glob( $testsdir . '/*.tests' );
101153
foreach $file (@files) {
102154
my @testlist = undef;
155+
my $definitions;
103156
print "FILE: ${file}\n";
104157
open(FILE, "<".$file) || die "can not open $file: $!";
105-
local $/ = undef;
106-
$definitions = <FILE>;
158+
{
159+
local $/ = undef;
160+
$definitions = <FILE>;
161+
}
107162
close(FILE);
108163
#print "STUFF: ${definitions}\n";
109164
eval $definitions;
@@ -116,13 +171,13 @@ sub runComplexTests {
116171
} else {
117172
warn "File: ${file} could not be loaded as PERL: $!";
118173
}
119-
}
174+
}
120175
}
121176

122177
sub runSimpleTests {
123178

124179
local($only)=@_;
125-
180+
126181
open(TESTLIST, "<" . "${testsdir}/TESTLIST") || die "no ${testsdir}/TESTFILE: $!\n";
127182
while(<TESTLIST>) {
128183
next if /^\#/;
@@ -132,7 +187,7 @@ sub runSimpleTests {
132187
($name, $input, $output, @options) = split;
133188
#print "processing ${only} vs ${name}\n";
134189
next if(defined($only) && $only ne $name);
135-
190+
136191
my $options = join(" ", @options);
137192
#print "@{options} becomes ${options}\n";
138193

tests/crypto.tests

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- perl -*-
2+
3+
$testlist = [
4+
{
5+
config_set => 'HAVE_LIBCRYPTO',
6+
name => 'esp1',
7+
input => '02-sunrise-sunset-esp.pcap',
8+
output => 'esp1.out',
9+
args => '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
10+
},
11+
12+
{
13+
config_set => 'HAVE_LIBCRYPTO',
14+
name => 'esp2',
15+
input => '08-sunrise-sunset-esp2.pcap',
16+
output => 'esp2.out',
17+
args => '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
18+
},
19+
20+
{
21+
config_set => 'HAVE_LIBCRYPTO',
22+
name => 'esp3',
23+
input => '02-sunrise-sunset-esp.pcap',
24+
output => 'esp1.out',
25+
args => '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"',
26+
},
27+
28+
{
29+
config_set => 'HAVE_LIBCRYPTO',
30+
config_unset => 'HAVE_CAPSICUM',
31+
name => 'esp4',
32+
input => '08-sunrise-sunset-esp2.pcap',
33+
output => 'esp2.out',
34+
args => '-E "file @TESTDIR@/esp-secrets.txt"',
35+
}
36+
];
37+
38+
1;
39+
40+

0 commit comments

Comments
 (0)