diff options
author | Michael Richardson <mcr@sandelman.ca> | 2020-01-24 21:56:43 -0500 |
---|---|---|
committer | Michael Richardson <mcr@sandelman.ca> | 2020-01-24 21:57:24 -0500 |
commit | abb9e14790d95d2e23625c76361bc533b2960ee6 (patch) | |
tree | b6d7cedefe4e17b073e88eda6ef9bad79af84d9a | |
parent | dc593751664e06e0cacefa503b2622f6c38e51e2 (diff) | |
download | tcpdump-abb9e14790d95d2e23625c76361bc533b2960ee6.tar.gz |
initial effort to process YAML format testlist
-rw-r--r-- | TESTING.md | 2 | ||||
-rwxr-xr-x | tests/TESTrun | 51 |
2 files changed, 45 insertions, 8 deletions
diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..3eaa4cbf --- /dev/null +++ b/TESTING.md @@ -0,0 +1,2 @@ + +* requires YAML.pm, from libyaml-perl (perl-YAML on RHEL) diff --git a/tests/TESTrun b/tests/TESTrun index 6a4f7537..44f0edb3 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(make_path remove_tree); +use YAML qw(LoadFile); # these are created in the directory where we are run, which might be # a build directory. @@ -61,6 +62,41 @@ sub runComplexTests { # have to update passed/failed here } +sub runOneYamlTest { + local($yamltest) = @_; + + my $output = $yamltest->{output}; + my $input = $yamltest->{input}; + my $name = $yamltest->{name}; + my $options= $yamltest->{args}; + + #use Data::Dumper; + #print Dumper($yamltest); + + my $result = runtest($name, + $testsdir . "/" . $input, + $testsdir . "/" . $output, + $options); + + if($result == 0) { + $passedcount++; + } else { + $failedcount++; + } +} + +sub runYamlTests { + my @files = glob( $testsdir . '/*.yaml' ); + foreach $file (@files) { + #print "FILE: ${file}\n"; + my $yaml = LoadFile($file); + + foreach $name (keys %$yaml) { + runOneYamlTest($yaml->{$name}); + } + } +} + sub runSimpleTests { local($only)=@_; @@ -78,20 +114,19 @@ sub runSimpleTests { my $options = join(" ", @options); #print "@{options} becomes ${options}\n"; - my $result =runtest($name, "${testsdir}/$input", "${testsdir}/${output}",$options); - if($result == 0) { - $passedcount++; - } else { - $failedcount++; - } - - return if(defined($only)); + my $hash = { name => $name, + input=> $input, + output=>$output, + args => $options }; + + runOneYamlTest($hash); } } if(scalar(@ARGV) == 0) { runComplexTests(); runSimpleTests(); + runYamlTests(); } else { runSimpleTests($ARGV[0]); } |