提交 3b4d86bf 编写于 作者: B Ben Laurie

Get closer to a working single Makefile with test support.

上级 282a480a
...@@ -12,7 +12,7 @@ PERL= perl ...@@ -12,7 +12,7 @@ PERL= perl
# KRB5 stuff # KRB5 stuff
KRB5_INCLUDES= KRB5_INCLUDES=
LIBKRB5= LIBKRB5=
TEST= fips_algvs.c TEST= fips_algvs.c igetest.c
PEX_LIBS= PEX_LIBS=
EX_LIBS= #-lnsl -lsocket EX_LIBS= #-lnsl -lsocket
...@@ -192,67 +192,67 @@ alltests: \ ...@@ -192,67 +192,67 @@ alltests: \
test_jpake test_srp test_cms test_v3name test_ocsp \ test_jpake test_srp test_cms test_v3name test_ocsp \
test_gost2814789 test_gost2814789
test_evp: test_evp: $(EVPTEST) evptests.txt
../util/shlib_wrap.sh ./$(EVPTEST) evptests.txt ../util/shlib_wrap.sh ./$(EVPTEST) evptests.txt
test_des: test_des: $(DESTEST)
../util/shlib_wrap.sh ./$(DESTEST) ../util/shlib_wrap.sh ./$(DESTEST)
test_idea: test_idea: $(IDEATEST)
../util/shlib_wrap.sh ./$(IDEATEST) ../util/shlib_wrap.sh ./$(IDEATEST)
test_sha: test_sha: $(SHATEST) $(SHA1TEST) $(SHA256TEST) $(SHA512TEST)
../util/shlib_wrap.sh ./$(SHATEST) ../util/shlib_wrap.sh ./$(SHATEST)
../util/shlib_wrap.sh ./$(SHA1TEST) ../util/shlib_wrap.sh ./$(SHA1TEST)
../util/shlib_wrap.sh ./$(SHA256TEST) ../util/shlib_wrap.sh ./$(SHA256TEST)
../util/shlib_wrap.sh ./$(SHA512TEST) ../util/shlib_wrap.sh ./$(SHA512TEST)
test_mdc2: test_mdc2: $(MDC2TEST)
../util/shlib_wrap.sh ./$(MDC2TEST) ../util/shlib_wrap.sh ./$(MDC2TEST)
test_md5: test_md5: $(MD5TEST)
../util/shlib_wrap.sh ./$(MD5TEST) ../util/shlib_wrap.sh ./$(MD5TEST)
test_md4: test_md4: $(MD4TEST)
../util/shlib_wrap.sh ./$(MD4TEST) ../util/shlib_wrap.sh ./$(MD4TEST)
test_hmac: test_hmac: $(HMACTEST)
../util/shlib_wrap.sh ./$(HMACTEST) ../util/shlib_wrap.sh ./$(HMACTEST)
test_wp: test_wp: $(WPTEST)
../util/shlib_wrap.sh ./$(WPTEST) ../util/shlib_wrap.sh ./$(WPTEST)
test_md2: test_md2: $(MD2TEST)
../util/shlib_wrap.sh ./$(MD2TEST) ../util/shlib_wrap.sh ./$(MD2TEST)
test_rmd: test_rmd: $(RMDTEST)
../util/shlib_wrap.sh ./$(RMDTEST) ../util/shlib_wrap.sh ./$(RMDTEST)
test_bf: test_bf: $(BFTEST)
../util/shlib_wrap.sh ./$(BFTEST) ../util/shlib_wrap.sh ./$(BFTEST)
test_cast: test_cast: $(CASTTEST)
../util/shlib_wrap.sh ./$(CASTTEST) ../util/shlib_wrap.sh ./$(CASTTEST)
test_rc2: test_rc2: $(RC2TEST)
../util/shlib_wrap.sh ./$(RC2TEST) ../util/shlib_wrap.sh ./$(RC2TEST)
test_rc4: test_rc4: $(RC4TEST)
../util/shlib_wrap.sh ./$(RC4TEST) ../util/shlib_wrap.sh ./$(RC4TEST)
test_rc5: test_rc5: $(RC5TEST)
../util/shlib_wrap.sh ./$(RC5TEST) ../util/shlib_wrap.sh ./$(RC5TEST)
test_rand: test_rand: $(RANDTEST)
../util/shlib_wrap.sh ./$(RANDTEST) ../util/shlib_wrap.sh ./$(RANDTEST)
test_gost2814789: test_gost2814789: $(GOST2814789TEST)
../util/shlib_wrap.sh ./$(GOST2814789TEST) ../util/shlib_wrap.sh ./$(GOST2814789TEST)
test_enc: test_enc: ../apps/openssl
@sh ./testenc @sh ./testenc
test_x509: test_x509: ../apps/openssl
echo test normal x509v1 certificate echo test normal x509v1 certificate
sh ./tx509 2>/dev/null sh ./tx509 2>/dev/null
echo test first x509v3 certificate echo test first x509v3 certificate
...@@ -260,25 +260,25 @@ test_x509: ...@@ -260,25 +260,25 @@ test_x509:
echo test second x509v3 certificate echo test second x509v3 certificate
sh ./tx509 v3-cert2.pem 2>/dev/null sh ./tx509 v3-cert2.pem 2>/dev/null
test_rsa: $(RSATEST)$(EXE_EXT) test_rsa: $(RSATEST)$(EXE_EXT) ../apps/openssl
@sh ./trsa 2>/dev/null @sh ./trsa 2>/dev/null
../util/shlib_wrap.sh ./$(RSATEST) ../util/shlib_wrap.sh ./$(RSATEST)
test_crl: test_crl: ../apps/openssl
@sh ./tcrl 2>/dev/null @sh ./tcrl 2>/dev/null
test_sid: test_sid: ../apps/openssl
@sh ./tsid 2>/dev/null @sh ./tsid 2>/dev/null
test_req: test_req: ../apps/openssl
@sh ./treq 2>/dev/null @sh ./treq 2>/dev/null
@sh ./treq testreq2.pem 2>/dev/null @sh ./treq testreq2.pem 2>/dev/null
test_pkcs7: test_pkcs7: ../apps/openssl
@sh ./tpkcs7 2>/dev/null @sh ./tpkcs7 2>/dev/null
@sh ./tpkcs7d 2>/dev/null @sh ./tpkcs7d 2>/dev/null
test_bn: test_bn: $(BNTEST) $(EXPTEST) bctest
@echo starting big number library test, could take a while... @echo starting big number library test, could take a while...
@../util/shlib_wrap.sh ./$(BNTEST) >tmp.bntest @../util/shlib_wrap.sh ./$(BNTEST) >tmp.bntest
@echo quit >>tmp.bntest @echo quit >>tmp.bntest
...@@ -287,33 +287,33 @@ test_bn: ...@@ -287,33 +287,33 @@ test_bn:
@echo 'test a^b%c implementations' @echo 'test a^b%c implementations'
../util/shlib_wrap.sh ./$(EXPTEST) ../util/shlib_wrap.sh ./$(EXPTEST)
test_ec: test_ec: $(ECTEST)
@echo 'test elliptic curves' @echo 'test elliptic curves'
../util/shlib_wrap.sh ./$(ECTEST) ../util/shlib_wrap.sh ./$(ECTEST)
test_ecdsa: test_ecdsa: $(ECDSATEST)
@echo 'test ecdsa' @echo 'test ecdsa'
../util/shlib_wrap.sh ./$(ECDSATEST) ../util/shlib_wrap.sh ./$(ECDSATEST)
test_ecdh: test_ecdh: $(ECDHTEST)
@echo 'test ecdh' @echo 'test ecdh'
../util/shlib_wrap.sh ./$(ECDHTEST) ../util/shlib_wrap.sh ./$(ECDHTEST)
test_verify: test_verify: ../apps/openssl
@echo "The following command should have some OK's and some failures" @echo "The following command should have some OK's and some failures"
@echo "There are definitly a few expired certificates" @echo "There are definitly a few expired certificates"
../util/shlib_wrap.sh ../apps/openssl verify -CApath ../certs/demo ../certs/demo/*.pem ../util/shlib_wrap.sh ../apps/openssl verify -CApath ../certs/demo ../certs/demo/*.pem
test_dh: test_dh: $(DHTEST)
@echo "Generate a set of DH parameters" @echo "Generate a set of DH parameters"
../util/shlib_wrap.sh ./$(DHTEST) ../util/shlib_wrap.sh ./$(DHTEST)
test_dsa: test_dsa: $(DSATEST)
@echo "Generate a set of DSA parameters" @echo "Generate a set of DSA parameters"
../util/shlib_wrap.sh ./$(DSATEST) ../util/shlib_wrap.sh ./$(DSATEST)
../util/shlib_wrap.sh ./$(DSATEST) -app2_1 ../util/shlib_wrap.sh ./$(DSATEST) -app2_1
test_gen: test_gen: ../apps/openssl testgen
@echo "Generate and verify a certificate request" @echo "Generate and verify a certificate request"
@sh ./testgen @sh ./testgen
...@@ -324,7 +324,7 @@ test_ss keyU.ss certU.ss certCA.ss certP1.ss keyP1.ss certP2.ss keyP2.ss \ ...@@ -324,7 +324,7 @@ test_ss keyU.ss certU.ss certCA.ss certP1.ss keyP1.ss certP2.ss keyP2.ss \
@cat certCA.ss certU.ss > intP1.ss @cat certCA.ss certU.ss > intP1.ss
@cat certCA.ss certU.ss certP1.ss > intP2.ss @cat certCA.ss certU.ss certP1.ss > intP2.ss
test_engine: test_engine: $(ENGINETEST)
@echo "Manipulate the ENGINE structures" @echo "Manipulate the ENGINE structures"
../util/shlib_wrap.sh ./$(ENGINETEST) ../util/shlib_wrap.sh ./$(ENGINETEST)
...@@ -336,7 +336,7 @@ test_ssl: keyU.ss certU.ss certCA.ss certP1.ss keyP1.ss certP2.ss keyP2.ss \ ...@@ -336,7 +336,7 @@ test_ssl: keyU.ss certU.ss certCA.ss certP1.ss keyP1.ss certP2.ss keyP2.ss \
@sh ./testsslproxy keyP1.ss certP1.ss intP1.ss @sh ./testsslproxy keyP1.ss certP1.ss intP1.ss
@sh ./testsslproxy keyP2.ss certP2.ss intP2.ss @sh ./testsslproxy keyP2.ss certP2.ss intP2.ss
test_ca: test_ca: ../apps/openssl
@if ../util/shlib_wrap.sh ../apps/openssl no-rsa; then \ @if ../util/shlib_wrap.sh ../apps/openssl no-rsa; then \
echo "skipping CA.sh test -- requires RSA"; \ echo "skipping CA.sh test -- requires RSA"; \
else \ else \
...@@ -348,7 +348,7 @@ test_aes: #$(AESTEST) ...@@ -348,7 +348,7 @@ test_aes: #$(AESTEST)
# @echo "test Rijndael" # @echo "test Rijndael"
# ../util/shlib_wrap.sh ./$(AESTEST) # ../util/shlib_wrap.sh ./$(AESTEST)
test_tsa: test_tsa: ../apps/openssl
@if ../util/shlib_wrap.sh ../apps/openssl no-rsa; then \ @if ../util/shlib_wrap.sh ../apps/openssl no-rsa; then \
echo "skipping testtsa test -- requires RSA"; \ echo "skipping testtsa test -- requires RSA"; \
else \ else \
...@@ -363,7 +363,7 @@ test_jpake: $(JPAKETEST)$(EXE_EXT) ...@@ -363,7 +363,7 @@ test_jpake: $(JPAKETEST)$(EXE_EXT)
@echo "Test JPAKE" @echo "Test JPAKE"
../util/shlib_wrap.sh ./$(JPAKETEST) ../util/shlib_wrap.sh ./$(JPAKETEST)
test_cms: test_cms: ../apps/openssl cms-test.pl
@echo "CMS consistency test" @echo "CMS consistency test"
$(PERL) cms-test.pl $(PERL) cms-test.pl
...@@ -375,7 +375,7 @@ test_v3name: $(V3NAMETEST)$(EXE_EXT) ...@@ -375,7 +375,7 @@ test_v3name: $(V3NAMETEST)$(EXE_EXT)
@echo "Test X509v3_check_*" @echo "Test X509v3_check_*"
../util/shlib_wrap.sh ./$(V3NAMETEST) ../util/shlib_wrap.sh ./$(V3NAMETEST)
test_ocsp: test_ocsp: ../apps/openssl
@echo "Test OCSP" @echo "Test OCSP"
@sh ./tocsp @sh ./tocsp
......
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
# A bit of an evil hack but it post processes the file ../MINFO which # A bit of an evil hack but it post processes the file ../MINFO which
# is generated by `make files` in the top directory. # is generated by `make files` in the top directory.
# This script outputs one mega makefile that has no shell stuff or any # This script outputs one mega makefile that has no shell stuff or any
# funny stuff # funny stuff (if the target is not "copy").
# # If the target is "copy", then it tries to create a makefile that can be
# safely used with the -j flag and that is compatible with the top-level
# Makefile, in the sense that it uses the same options and assembler files etc.
use Cwd;
$INSTALLTOP="/usr/local/ssl"; $INSTALLTOP="/usr/local/ssl";
$OPENSSLDIR="/usr/local/ssl"; $OPENSSLDIR="/usr/local/ssl";
...@@ -188,7 +192,7 @@ $mkdir="-mkdir" unless defined $mkdir; ...@@ -188,7 +192,7 @@ $mkdir="-mkdir" unless defined $mkdir;
$ranlib="echo ranlib"; $ranlib="echo ranlib";
$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:getcwd();
$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
# $bin_dir.=$o causes a core dump on my sparc :-( # $bin_dir.=$o causes a core dump on my sparc :-(
...@@ -748,6 +752,10 @@ $banner ...@@ -748,6 +752,10 @@ $banner
\$(INC_D): \$(INC_D):
\$(MKDIR) \"\$(INC_D)\" \$(MKDIR) \"\$(INC_D)\"
# This needs to be invoked once, when the makefile is first constructed, or
# after cleaning.
init: \$(TMP_D) \$(LIB_D) headers
headers: \$(HEADER) \$(EXHEADER) headers: \$(HEADER) \$(EXHEADER)
lib: \$(LIBS_DEP) \$(E_SHLIB) lib: \$(LIBS_DEP) \$(E_SHLIB)
...@@ -762,11 +770,6 @@ install: all ...@@ -762,11 +770,6 @@ install: all
\$(MKDIR) \"\$(INSTALLTOP)${o}lib\" \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
$extra_install $extra_install
test: \$(T_EXE)
cd \$(BIN_D)
..${o}ms${o}test
clean: clean:
\$(RM) \$(TMP_D)$o*.* \$(RM) \$(TMP_D)$o*.*
...@@ -782,7 +785,17 @@ reallyclean: ...@@ -782,7 +785,17 @@ reallyclean:
\$(RM) -rf \$(INC_D) \$(RM) -rf \$(INC_D)
EOF EOF
if ($orig_platform ne 'copy')
{
$rules .= <<"EOF";
test: \$(T_EXE)
cd \$(BIN_D)
..${o}ms${o}test
EOF
}
my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
$platform_cpp_symbol =~ s/-/_/g; $platform_cpp_symbol =~ s/-/_/g;
if (open(IN,"crypto/buildinf.h")) if (open(IN,"crypto/buildinf.h"))
...@@ -1014,6 +1027,8 @@ if ($fips) ...@@ -1014,6 +1027,8 @@ if ($fips)
$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0); $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
$rules .= get_tests('test/Makefile') if $orig_platform eq 'copy';
print $defs; print $defs;
if ($platform eq "linux-elf") { if ($platform eq "linux-elf") {
...@@ -1288,9 +1303,10 @@ sub cc_compile_target ...@@ -1288,9 +1303,10 @@ sub cc_compile_target
$ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
$target =~ s/\//$o/g if $o ne "/"; $target =~ s/\//$o/g if $o ne "/";
$source =~ s/\//$o/g if $o ne "/"; $source =~ s/\//$o/g if $o ne "/";
# FIXME: do dependencies instead of all headers. $ret ="$target: \$(SRC_D)$o$source\n\t";
$ret ="$target: \$(SRC_D)$o$source \$(HEADER) \$(EXHEADER)\n\t"; $ret.="\$(CC) -MMD ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
$ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; $target =~ s/\.o$/.d/;
$ret.=".sinclude \"$target\"\n\n";
return($ret); return($ret);
} }
......
...@@ -152,7 +152,7 @@ sub do_link_rule ...@@ -152,7 +152,7 @@ sub do_link_rule
{ {
local($target,$files,$dep_libs,$libs)=@_; local($target,$files,$dep_libs,$libs)=@_;
local($ret,$_); local($ret,$_);
$file =~ s/\//$o/g if $o ne '/'; $file =~ s/\//$o/g if $o ne '/';
$n=&bname($target); $n=&bname($target);
$ret.="$target: $files $dep_libs\n"; $ret.="$target: $files $dep_libs\n";
...@@ -173,4 +173,156 @@ sub which ...@@ -173,4 +173,156 @@ sub which
} }
} }
sub fixtests
{
my ($str, $tests) = @_;
foreach my $t (keys %$tests)
{
$str =~ s/(\.\/)?\$\($t\)/\$(TEST_D)\/$tests->{$t}/g;
}
return $str;
}
sub fixdeps
{
my ($str) = @_;
my @t = split(/\s+/, $str);
$str = '';
foreach my $t (@t)
{
$str .= ' ' if $str ne '';
if ($t =~ /^[^\/]+$/)
{
$str .= '$(TEST_D)/' . $t;
}
else
{
$str .= $t;
}
}
return $str;
}
sub fixrules
{
my ($str) = @_;
return $str;
my @t = split("\n", $str);
$str = '';
foreach my $t (@t)
{
$t =~ s/^\s+//;
if ($t =~ /^@/)
{
$t =~ s/^@/\@cd \$(TEST_D) && /;
}
else
{
$t = 'cd $(TEST_D) && ' . $t;
}
$str .= "\t$t\n";
}
return $str;
}
sub get_tests
{
my ($makefile) = @_;
open(M, $makefile) || die "Can't open $makefile: $!";
my %targets;
my %deps;
my %tests;
while (my $line = <M>)
{
chomp $line;
while ($line =~ /^(.*)\\$/)
{
$line = $1 . <M>;
}
if ($line =~ /^alltests:(.*)$/)
{
my @t = split(/\s+/, $1);
foreach my $t (@t)
{
$targets{$t} = '';
}
}
if (($line =~ /^(\S+):(.*)$/ && exists $targets{$1})
|| $line =~ /^(test_ss .*):(.*)/)
{
my $t = $1;
$deps{$t} = $2;
$deps{$t} =~ s/#.*$//;
for (;;)
{
$line = <M>;
chomp $line;
last if $line eq '';
$targets{$t} .= "$line\n";
}
next;
}
if ($line =~ /^(\S+TEST)=\s*(\S+)$/)
{
$tests{$1} = $2;
next;
}
}
delete $targets{test_jpake} if $no_jpake;
delete $targets{test_ige} if $no_ige;
delete $targets{test_md2} if $no_md2;
delete $targets{test_rc5} if $no_rc5;
my $tests;
foreach my $t (keys %tests)
{
$tests .= "$t = $tests{$t}\n";
}
my $all = 'test:';
my $each;
foreach my $t (keys %targets)
{
next if $t eq '';
if ($t =~ /^test_ss/)
{
$t =~ s/\s+/ \$(TEST_D)\//g;
$all .= ' test_ss';
}
else
{
$all .= " $t";
}
my $d = $deps{$t};
$d =~ s/\.\.\/apps/\$(BIN_D)/g;
$d = fixtests($d, \%tests);
$d = fixdeps($d);
my $r = $targets{$t};
$r =~ s/\.\.\/apps/\$(BIN_D)/g;
$r =~ s/\.\.\/(\S+)/\$(SRC_D)\/$1/g;
$r = fixrules($r);
$each .= "$t: \$(TEST_D) $d\n\tcd \$(TEST_D)\n$r\n";
}
# FIXME: Might be a clever way to figure out what needs copying
my $copies = do_copy_rule('$(TEST_D)', 'test/bctest test/evptests.txt test/testgen test/cms-test.pl', '');
return "$copies\n$tests\n$all\n\n$each";
}
1; 1;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册