Add more tree sanity checks. Make sure verifies must produce at least one

successful output. Fix typos.
This commit is contained in:
Dr. Stephen Henson 2007-12-23 14:20:50 +00:00
parent 86fbdae6e8
commit 012d1c8dd9

View File

@ -321,11 +321,12 @@ my $tprefix;
my $shwrap_prefix; my $shwrap_prefix;
my $debug = 0; my $debug = 0;
my $quiet = 0; my $quiet = 0;
my $notest = 0;
my $verify = 1; my $verify = 1;
my $rspdir = "rsp"; my $rspdir = "rsp";
my $ignore_missing = 0; my $ignore_missing = 0;
my $ignore_bogus = 1;
my $rspignore = 0; my $rspignore = 0;
my @bogus = (); # list of unmatched *.rsp files
my $bufout = ''; my $bufout = '';
foreach (@ARGV) { foreach (@ARGV) {
@ -341,9 +342,15 @@ foreach (@ARGV) {
elsif ( $_ eq "--ignore-missing" ) { elsif ( $_ eq "--ignore-missing" ) {
$ignore_missing = 1; $ignore_missing = 1;
} }
elsif ( $_ eq "--ignore-bogus" ) {
$ignore_bogus = 1;
}
elsif ( $_ eq "--generate" ) { elsif ( $_ eq "--generate" ) {
$verify = 0; $verify = 0;
} }
elsif ( $_ eq "--notest" ) {
$notest = 1;
}
elsif ( $_ eq "--quiet" ) { elsif ( $_ eq "--quiet" ) {
$quiet = 1; $quiet = 1;
} }
@ -412,6 +419,8 @@ sanity_check_files();
my ( $runerr, $cmperr, $cmpok, $scheckrunerr, $scheckerr, $scheckok, $skipcnt ) my ( $runerr, $cmperr, $cmpok, $scheckrunerr, $scheckerr, $scheckok, $skipcnt )
= ( 0, 0, 0, 0, 0, 0 ); = ( 0, 0, 0, 0, 0, 0 );
exit (0) if $notest;
run_tests( $verify, $win32, $tprefix, $filter, $tvdir ); run_tests( $verify, $win32, $tprefix, $filter, $tvdir );
if ($verify) { if ($verify) {
@ -420,7 +429,7 @@ if ($verify) {
print "Algorithm test program execution failures: $runerr\n"; print "Algorithm test program execution failures: $runerr\n";
print "Test comparisons successful: $cmpok\n"; print "Test comparisons successful: $cmpok\n";
print "Test comparisons failed: $cmperr\n"; print "Test comparisons failed: $cmperr\n";
print "Test sanity checks succeessul: $scheckok\n"; print "Test sanity checks successful: $scheckok\n";
print "Test sanity checks failed: $scheckerr\n"; print "Test sanity checks failed: $scheckerr\n";
print "Sanity check program execution failures: $scheckrunerr\n"; print "Sanity check program execution failures: $scheckrunerr\n";
@ -442,9 +451,9 @@ $cmd: generate run CMVP algorithm tests
--filter=<regexp> --filter=<regexp>
--onedir <dirname> Assume all components in current directory --onedir <dirname> Assume all components in current directory
--rspdir=<dirname> Name of subdirectories containing *.rsp files, default "resp" --rspdir=<dirname> Name of subdirectories containing *.rsp files, default "resp"
--rspignore Ignore any bogus *.rsp files
--shwrap_prefix=<prefix> --shwrap_prefix=<prefix>
--tprefix=<prefix> --tprefix=<prefix>
--ignore-bogus Ignore duplicate or bogus files
--ignore-missing Ignore missing test files --ignore-missing Ignore missing test files
--quiet Shhh.... --quiet Shhh....
--generate Generate algorithm test output --generate Generate algorithm test output
@ -495,21 +504,35 @@ sub find_files {
if (/\/([^\/]*)\.rsp$/) { if (/\/([^\/]*)\.rsp$/) {
$testname = fix_pss( $1, $_ ); $testname = fix_pss( $1, $_ );
if ( exists $fips_tests{$testname} ) { if ( exists $fips_tests{$testname} ) {
$fips_files{$testname}->[1] = $_; if ($fips_files{$testname}->[1] eq "") {
$fips_files{$testname}->[1] = $_;
}
else {
print STDERR "WARNING: duplicate response file $_ for test $testname\n";
$nbogus++;
}
} }
else { else {
print STDERR "ERROR: bogus file $_\n"; print STDERR "WARNING: bogus file $_\n";
push @bogus, $_; $nbogus++;
} }
} }
next unless /$filter.*\.req$/i; next unless /$filter.*\.req$/i;
if (/\/([^\/]*)\.req$/) { if (/\/([^\/]*)\.req$/) {
$testname = fix_pss( $1, $_ ); $testname = fix_pss( $1, $_ );
if ( exists $fips_tests{$testname} ) { if ( exists $fips_tests{$testname} ) {
$fips_files{$testname}->[0] = $_; if ($fips_files{$testname}->[0] eq "") {
$fips_files{$testname}->[0] = $_;
}
else {
print STDERR "WARNING: duplicate request file $_ for test $testname\n";
$nbogus++;
}
} }
elsif ( !/SHAmix\.req$/ ) { elsif ( !/SHAmix\.req$/ ) {
print STDERR "WARNING: unrecognized filename $_\n"; print STDERR "WARNING: unrecognized filename $_\n";
$nbogus++;
} }
} }
} }
@ -564,7 +587,11 @@ sub sanity_check_files {
print STDERR "ERROR: test vector file set not complete\n"; print STDERR "ERROR: test vector file set not complete\n";
exit(1) unless $ignore_missing; exit(1) unless $ignore_missing;
} }
elsif ($debug) { if ($nbogus) {
print STDERR "ERROR: $nbogus bogus or duplicate request and response files\n";
exit(1) unless $ignore_bogus;
}
if ($debug && !$nbogus && !$bad) {
print STDERR "test vector file set complete\n"; print STDERR "test vector file set complete\n";
} }
} }
@ -639,7 +666,7 @@ sub run_tests {
if ( $fcount || $debug ) { if ( $fcount || $debug ) {
print STDERR "DEBUG: $tname, Pass=$pcount, Fail=$fcount\n"; print STDERR "DEBUG: $tname, Pass=$pcount, Fail=$fcount\n";
} }
if ($fcount) { if ($fcount || !$pcount) {
$scheckerr++; $scheckerr++;
} }
else { else {
@ -662,8 +689,14 @@ sub cmp_file {
my ( $tname, $rsp, $tst ) = @_; my ( $tname, $rsp, $tst ) = @_;
my ( $rspf, $tstf ); my ( $rspf, $tstf );
my ( $rspline, $tstline ); my ( $rspline, $tstline );
open $rspf, $rsp; if (!open ($rspf, $rsp)) {
open $tstf, $tst; print STDERR "ERROR: can't open request file $rsp\n";
return 0;
}
if (!open ($tstf, $tst)) {
print STDERR "ERROR: can't open output file $tst\n";
return 0;
}
for ( ; ; ) { for ( ; ; ) {
$rspline = next_line($rspf); $rspline = next_line($rspf);
$tstline = next_line($tstf); $tstline = next_line($tstf);