Remove shlib_wrap.sh as it is not needed (all algorithm tests are
staticly linked to fipscanister.o). Add option to generate a shell script to run all tests: this is useful for platforms that don't have perl.
This commit is contained in:
parent
5fabb88a78
commit
ca8630ba81
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
# Perl utility to run or verify FIPS 140-2 CMVP algorithm tests based on the
|
# Perl utility to run or verify FIPS 140-2 CAVP algorithm tests based on the
|
||||||
# pathnames of input algorithm test files actually present (the unqualified
|
# pathnames of input algorithm test files actually present (the unqualified
|
||||||
# file names are consistent but the pathnames are not).
|
# file names are consistent but the pathnames are not).
|
||||||
#
|
#
|
||||||
@ -373,7 +373,6 @@ my $onedir = 0;
|
|||||||
my $filter = "";
|
my $filter = "";
|
||||||
my $tvdir;
|
my $tvdir;
|
||||||
my $tprefix;
|
my $tprefix;
|
||||||
my $shwrap_prefix;
|
|
||||||
my $debug = 0;
|
my $debug = 0;
|
||||||
my $quiet = 0;
|
my $quiet = 0;
|
||||||
my $notest = 0;
|
my $notest = 0;
|
||||||
@ -383,6 +382,8 @@ my $ignore_missing = 0;
|
|||||||
my $ignore_bogus = 0;
|
my $ignore_bogus = 0;
|
||||||
my $bufout = '';
|
my $bufout = '';
|
||||||
my $list_tests = 0;
|
my $list_tests = 0;
|
||||||
|
my $minimal_script = 0;
|
||||||
|
my $outfile = '';
|
||||||
|
|
||||||
my %fips_enabled = (
|
my %fips_enabled = (
|
||||||
dsa => 1,
|
dsa => 1,
|
||||||
@ -417,7 +418,13 @@ foreach (@ARGV) {
|
|||||||
elsif ( $_ eq "--ignore-bogus" ) {
|
elsif ( $_ eq "--ignore-bogus" ) {
|
||||||
$ignore_bogus = 1;
|
$ignore_bogus = 1;
|
||||||
}
|
}
|
||||||
elsif ( $_ eq "--generate" ) {
|
elsif ( $_ eq "--minimal-script" ) {
|
||||||
|
$minimal_script = 1;
|
||||||
|
}
|
||||||
|
elsif (/--generate-script=(.*)$/) {
|
||||||
|
$outfile = $1;
|
||||||
|
$verify = 0;
|
||||||
|
} elsif ( $_ eq "--generate" ) {
|
||||||
$verify = 0;
|
$verify = 0;
|
||||||
}
|
}
|
||||||
elsif ( $_ eq "--notest" ) {
|
elsif ( $_ eq "--notest" ) {
|
||||||
@ -435,9 +442,6 @@ foreach (@ARGV) {
|
|||||||
elsif (/--tprefix=(.*)$/) {
|
elsif (/--tprefix=(.*)$/) {
|
||||||
$tprefix = $1;
|
$tprefix = $1;
|
||||||
}
|
}
|
||||||
elsif (/--shwrap_prefix=(.*)$/) {
|
|
||||||
$shwrap_prefix = $1;
|
|
||||||
}
|
|
||||||
elsif (/^--(enable|disable)-(.*)$/) {
|
elsif (/^--(enable|disable)-(.*)$/) {
|
||||||
if ( !exists $fips_enabled{$2} ) {
|
if ( !exists $fips_enabled{$2} ) {
|
||||||
print STDERR "Unknown test $2\n";
|
print STDERR "Unknown test $2\n";
|
||||||
@ -491,9 +495,9 @@ if ($list_tests) {
|
|||||||
|
|
||||||
foreach (@fips_test_list) {
|
foreach (@fips_test_list) {
|
||||||
next unless ref($_);
|
next unless ref($_);
|
||||||
my $nm = $_->[0];
|
my $nm = $$_[0];
|
||||||
$_->[3] = "";
|
$$_[3] = "";
|
||||||
$_->[4] = "";
|
$$_[4] = "";
|
||||||
print STDERR "Duplicate test $nm\n" if exists $fips_tests{$nm};
|
print STDERR "Duplicate test $nm\n" if exists $fips_tests{$nm};
|
||||||
$fips_tests{$nm} = $_;
|
$fips_tests{$nm} = $_;
|
||||||
}
|
}
|
||||||
@ -513,17 +517,13 @@ if ($win32) {
|
|||||||
else {
|
else {
|
||||||
if ($onedir) {
|
if ($onedir) {
|
||||||
$tprefix = "./" unless defined $tprefix;
|
$tprefix = "./" unless defined $tprefix;
|
||||||
$shwrap_prefix = "./" unless defined $shwrap_prefix;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tprefix = "../test/" unless defined $tprefix;
|
$tprefix = "../test/" unless defined $tprefix;
|
||||||
$shwrap_prefix = "../util/" unless defined $shwrap_prefix;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sanity_check_exe( $win32, $tprefix, $shwrap_prefix );
|
sanity_check_exe( $win32, $tprefix) if $outfile eq "";
|
||||||
|
|
||||||
my $cmd_prefix = $win32 ? "" : "${shwrap_prefix}shlib_wrap.sh ";
|
|
||||||
|
|
||||||
find_files( $filter, $tvdir );
|
find_files( $filter, $tvdir );
|
||||||
|
|
||||||
@ -533,8 +533,8 @@ my ( $runerr, $cmperr, $cmpok, $scheckrunerr, $scheckerr, $scheckok, $skipcnt )
|
|||||||
= ( 0, 0, 0, 0, 0, 0, 0 );
|
= ( 0, 0, 0, 0, 0, 0, 0 );
|
||||||
|
|
||||||
exit(0) if $notest;
|
exit(0) if $notest;
|
||||||
|
print "Outputting commands to $outfile\n" if $outfile ne "";
|
||||||
run_tests( $verify, $win32, $tprefix, $filter, $tvdir );
|
run_tests( $verify, $win32, $tprefix, $filter, $tvdir, $outfile );
|
||||||
|
|
||||||
if ($verify) {
|
if ($verify) {
|
||||||
print "ALGORITHM TEST VERIFY SUMMARY REPORT:\n";
|
print "ALGORITHM TEST VERIFY SUMMARY REPORT:\n";
|
||||||
@ -553,7 +553,7 @@ if ($verify) {
|
|||||||
print "***ALL TESTS SUCCESSFUL***\n";
|
print "***ALL TESTS SUCCESSFUL***\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
elsif ($outfile eq "") {
|
||||||
print "ALGORITHM TEST SUMMARY REPORT:\n";
|
print "ALGORITHM TEST SUMMARY REPORT:\n";
|
||||||
print "Tests skipped due to missing files: $skipcnt\n";
|
print "Tests skipped due to missing files: $skipcnt\n";
|
||||||
print "Algorithm test program execution failures: $runerr\n";
|
print "Algorithm test program execution failures: $runerr\n";
|
||||||
@ -570,13 +570,12 @@ else {
|
|||||||
sub Help {
|
sub Help {
|
||||||
( my $cmd ) = ( $0 =~ m#([^/]+)$# );
|
( my $cmd ) = ( $0 =~ m#([^/]+)$# );
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
$cmd: generate run CMVP algorithm tests
|
$cmd: generate run CAVP algorithm tests
|
||||||
--debug Enable debug output
|
--debug Enable debug output
|
||||||
--dir=<dirname> Optional root for *.req file search
|
--dir=<dirname> Optional root for *.req file search
|
||||||
--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 "rsp"
|
--rspdir=<dirname> Name of subdirectories containing *.rsp files, default "rsp"
|
||||||
--shwrap_prefix=<prefix>
|
|
||||||
--tprefix=<prefix>
|
--tprefix=<prefix>
|
||||||
--ignore-bogus Ignore duplicate or bogus files
|
--ignore-bogus Ignore duplicate or bogus files
|
||||||
--ignore-missing Ignore missing test files
|
--ignore-missing Ignore missing test files
|
||||||
@ -598,10 +597,9 @@ while (my ($key, $value) = each %fips_enabled)
|
|||||||
# Sanity check to see if all necessary executables exist
|
# Sanity check to see if all necessary executables exist
|
||||||
|
|
||||||
sub sanity_check_exe {
|
sub sanity_check_exe {
|
||||||
my ( $win32, $tprefix, $shwrap_prefix ) = @_;
|
my ( $win32, $tprefix, ) = @_;
|
||||||
my %exe_list;
|
my %exe_list;
|
||||||
my $bad = 0;
|
my $bad = 0;
|
||||||
$exe_list{ $shwrap_prefix . "shlib_wrap.sh" } = 1 unless $win32;
|
|
||||||
foreach (@fips_test_list) {
|
foreach (@fips_test_list) {
|
||||||
next unless ref($_);
|
next unless ref($_);
|
||||||
my $cmd = $_->[1];
|
my $cmd = $_->[1];
|
||||||
@ -638,8 +636,8 @@ sub find_files {
|
|||||||
if ( -f "$_" ) {
|
if ( -f "$_" ) {
|
||||||
if (/\/([^\/]*)\.rsp$/) {
|
if (/\/([^\/]*)\.rsp$/) {
|
||||||
$tref = find_test($1, $_);
|
$tref = find_test($1, $_);
|
||||||
$testname = $$tref[0];
|
|
||||||
if ( defined $tref ) {
|
if ( defined $tref ) {
|
||||||
|
$testname = $$tref[0];
|
||||||
if ( $$tref[4] eq "" ) {
|
if ( $$tref[4] eq "" ) {
|
||||||
$$tref[4] = $_;
|
$$tref[4] = $_;
|
||||||
}
|
}
|
||||||
@ -657,8 +655,8 @@ sub find_files {
|
|||||||
next unless /$filter.*\.req$/i;
|
next unless /$filter.*\.req$/i;
|
||||||
if (/\/([^\/]*)\.req$/) {
|
if (/\/([^\/]*)\.req$/) {
|
||||||
$tref = find_test($1, $_);
|
$tref = find_test($1, $_);
|
||||||
$testname = $$tref[0];
|
|
||||||
if ( defined $tref ) {
|
if ( defined $tref ) {
|
||||||
|
$testname = $$tref[0];
|
||||||
if ( $$tref[3] eq "" ) {
|
if ( $$tref[3] eq "" ) {
|
||||||
$$tref[3] = $_;
|
$$tref[3] = $_;
|
||||||
}
|
}
|
||||||
@ -745,12 +743,47 @@ sub sanity_check_files {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub run_tests {
|
sub run_tests {
|
||||||
my ( $verify, $win32, $tprefix, $filter, $tvdir ) = @_;
|
my ( $verify, $win32, $tprefix, $filter, $tvdir, $outfile ) = @_;
|
||||||
my ( $tname, $tref );
|
my ( $tname, $tref );
|
||||||
my $bad = 0;
|
my $bad = 0;
|
||||||
|
my $lastdir = "";
|
||||||
|
if ($outfile ne "") {
|
||||||
|
open OUT, ">$outfile" || die "Can't open $outfile";
|
||||||
|
}
|
||||||
|
if ($outfile ne "" && !$minimal_script) {
|
||||||
|
if ($win32) {
|
||||||
|
print OUT <<\END;
|
||||||
|
@echo off
|
||||||
|
rem Test vector run script
|
||||||
|
rem Auto generated by fipsalgtest.pl script
|
||||||
|
rem Do not edit
|
||||||
|
|
||||||
|
echo Running Algorithm Tests
|
||||||
|
|
||||||
|
END
|
||||||
|
} else {
|
||||||
|
print OUT <<\END;
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Test vector run script
|
||||||
|
# Auto generated by fipsalgtest.pl script
|
||||||
|
# Do not edit
|
||||||
|
|
||||||
|
echo Running Algorithm Tests
|
||||||
|
|
||||||
|
END
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
foreach (@fips_test_list) {
|
foreach (@fips_test_list) {
|
||||||
if ( !ref($_) ) {
|
if ( !ref($_) ) {
|
||||||
print "Running $_ tests\n" unless $quiet;
|
if ($outfile ne "") {
|
||||||
|
print "Generating script for $_ tests\n";
|
||||||
|
print OUT "\n\n\necho \"Running $_ tests\"\n" unless $minimal_script;
|
||||||
|
} else {
|
||||||
|
print "Running $_ tests\n" unless $quiet;
|
||||||
|
}
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
my ( $tname, $tcmd, $regexp, $req, $rsp ) = @$_;
|
my ( $tname, $tcmd, $regexp, $req, $rsp ) = @$_;
|
||||||
@ -779,32 +812,53 @@ sub run_tests {
|
|||||||
$out =~ s|/req/(\S+)\.req|/$rspdir/$1.rsp|;
|
$out =~ s|/req/(\S+)\.req|/$rspdir/$1.rsp|;
|
||||||
my $outdir = $out;
|
my $outdir = $out;
|
||||||
$outdir =~ s|/[^/]*$||;
|
$outdir =~ s|/[^/]*$||;
|
||||||
if ( !-d $outdir ) {
|
if ($outfile ne "") {
|
||||||
|
if ($win32) {
|
||||||
|
$outdir =~ tr|/|\\|;
|
||||||
|
$req =~ tr|/|\\|;
|
||||||
|
$out =~ tr|/|\\|;
|
||||||
|
}
|
||||||
|
if ($outdir ne $lastdir && !$minimal_script) {
|
||||||
|
if ($win32) {
|
||||||
|
print OUT <<END
|
||||||
|
if exist \"$outdir\" rd /s /q "$outdir"
|
||||||
|
md \"$outdir\"
|
||||||
|
|
||||||
|
END
|
||||||
|
} else {
|
||||||
|
print OUT <<END
|
||||||
|
rm -rf \"$outdir\"
|
||||||
|
mkdir \"$outdir\"
|
||||||
|
|
||||||
|
END
|
||||||
|
}
|
||||||
|
$lastdir = $outdir;
|
||||||
|
}
|
||||||
|
} elsif ( !-d $outdir ) {
|
||||||
print STDERR "DEBUG: Creating directory $outdir\n" if $debug;
|
print STDERR "DEBUG: Creating directory $outdir\n" if $debug;
|
||||||
mkdir($outdir) || die "Can't create directory $outdir";
|
mkdir($outdir) || die "Can't create directory $outdir";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $cmd = "$cmd_prefix$tprefix$tcmd ";
|
my $cmd = "$tprefix$tcmd \"$req\" \"$out\"";
|
||||||
if ( $tcmd =~ /-f$/ ) {
|
|
||||||
$cmd .= "\"$req\" \"$out\"";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$cmd .= "\"$req\" \"$out\"";
|
|
||||||
}
|
|
||||||
print STDERR "DEBUG: running test $tname\n" if ( $debug && !$verify );
|
print STDERR "DEBUG: running test $tname\n" if ( $debug && !$verify );
|
||||||
system($cmd);
|
if ($outfile ne "") {
|
||||||
if ( $? != 0 ) {
|
print OUT "echo \" running $tname test\"\n" unless $minimal_script;
|
||||||
print STDERR
|
print OUT "$cmd\n";
|
||||||
"WARNING: error executing test $tname for command: $cmd\n";
|
} else {
|
||||||
$runerr++;
|
system($cmd);
|
||||||
next;
|
if ( $? != 0 ) {
|
||||||
|
print STDERR
|
||||||
|
"WARNING: error executing test $tname for command: $cmd\n";
|
||||||
|
$runerr++;
|
||||||
|
next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($verify) {
|
if ($verify) {
|
||||||
if ( exists $verify_special{$tname} ) {
|
if ( exists $verify_special{$tname} ) {
|
||||||
my $vout = $rsp;
|
my $vout = $rsp;
|
||||||
$vout =~ s/\.rsp$/.ver/;
|
$vout =~ s/\.rsp$/.ver/;
|
||||||
$tcmd = $verify_special{$tname};
|
$tcmd = $verify_special{$tname};
|
||||||
$cmd = "$cmd_prefix$tprefix$tcmd ";
|
$cmd = "$tprefix$tcmd ";
|
||||||
$cmd .= "\"$out\" \"$vout\"";
|
$cmd .= "\"$out\" \"$vout\"";
|
||||||
system($cmd);
|
system($cmd);
|
||||||
if ( $? != 0 ) {
|
if ( $? != 0 ) {
|
||||||
@ -850,6 +904,10 @@ sub run_tests {
|
|||||||
unlink $out;
|
unlink $out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($outfile ne "") {
|
||||||
|
print OUT "\n\necho All Tests Completed\n" unless $minimal_script;
|
||||||
|
close OUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub cmp_file {
|
sub cmp_file {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user