diff options
author | Michael Richardson <mcr@sandelman.ca> | 2020-02-02 18:25:37 -0500 |
---|---|---|
committer | Denis Ovsienko <denis@ovsienko.info> | 2020-02-04 22:19:17 +0000 |
commit | eaa76f6c4444fcb8cc999b2a0f6253d5c440bdb4 (patch) | |
tree | c3f4a614a7327c1fe18551430c56235733ca9742 | |
parent | 09dbb915c2c140d4f6e1f89a63110e9a92875371 (diff) | |
download | tcpdump-eaa76f6c4444fcb8cc999b2a0f6253d5c440bdb4.tar.gz |
use perl hashes for configuration, rather than YAML things
-rwxr-xr-x | tests/TESTrun | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/tests/TESTrun b/tests/TESTrun index 55518757..65ac389d 100755 --- a/tests/TESTrun +++ b/tests/TESTrun @@ -7,8 +7,6 @@ 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 -eval 'use YAML qw(LoadFile); 1' || die "TESTrun needs YAML.pm. apt install libyaml-perl/yum install perl-YAML/cpanm YAML"; - # these are created in the directory where we are run, which might be # a build directory. my $newdir = "tests/NEW"; @@ -57,7 +55,7 @@ my $failureoutput=$origdir . "/tests/failure-outputs.txt"; open(FAILUREOUTPUT, ">" . $failureoutput); close(FAILUREOUTPUT); -sub runComplexTests { +sub runShellTests { my @files = glob( $testsdir . '/*.sh' ); foreach $file (@files) { @@ -73,16 +71,16 @@ sub runComplexTests { # have to update passed/failed here } -sub runOneYamlTest { - local($yamltest) = @_; +sub runOneComplexTest { + local($testconfig) = @_; - my $output = $yamltest->{output}; - my $input = $yamltest->{input}; - my $name = $yamltest->{name}; - my $options= $yamltest->{args}; + my $output = $testconfig->{output}; + my $input = $testconfig->{input}; + my $name = $testconfig->{name}; + my $options= $testconfig->{args}; #use Data::Dumper; - #print Dumper($yamltest); + #print Dumper($testconfig); my $result = runtest($name, $testsdir . "/" . $input, @@ -96,14 +94,27 @@ sub runOneYamlTest { } } -sub runYamlTests { - my @files = glob( $testsdir . '/*.yaml' ); +# *.tests files are PERL hash definitions. They should create an array of hashes +# one per test, and place it into the variable @testlist. +sub runComplexTests { + my @files = glob( $testsdir . '/*.tests' ); foreach $file (@files) { - #print "FILE: ${file}\n"; - my $yaml = LoadFile($file); - - foreach $name (keys %$yaml) { - runOneYamlTest($yaml->{$name}); + my @testlist = undef; + print "FILE: ${file}\n"; + open(FILE, "<".$file) || die "can not open $file: $!"; + local $/ = undef; + $definitions = <FILE>; + close(FILE); + #print "STUFF: ${definitions}\n"; + eval $definitions; + if(defined($testlist)) { + #use Data::Dumper; + #print Dumper($testlist); + foreach $test (@$testlist) { + runOneComplexTest($test); + } + } else { + warn "File: ${file} could not be loaded as PERL: $!"; } } } @@ -130,14 +141,14 @@ sub runSimpleTests { output=>$output, args => $options }; - runOneYamlTest($hash); + runOneComplexTest($hash); } } if(scalar(@ARGV) == 0) { - runComplexTests(); + runShellTests(); runSimpleTests(); - runYamlTests(); + runComplexTests(); } else { runSimpleTests($ARGV[0]); } |