1 #!/usr/local/bin/perl -w
3 # Run the test suite and generate a report
6 if (! -f "Configure") {
7 print "Please run perl util/selftest.pl in the OpenSSL directory.\n";
21 my $sep="-----------------------------------------------------------------------------\n";
23 open(OUT,">$report") or die;
25 print OUT "OpenSSL self-test report:\n\n";
30 foreach $_ (split("\n",$c)) {
31 $os=$1 if (/Operating system: (.*)$/);
32 $platform0=$1 if (/Configuring for (.*)$/);
35 system "sh config" if (! -f "Makefile.ssl");
37 if (open(IN,"<Makefile.ssl")) {
39 $version=$1 if (/^VERSION=(.*)$/);
40 $platform=$1 if (/^PLATFORM=(.*)$/);
41 $options=$1 if (/^OPTIONS=(.*)$/);
42 $cc=$1 if (/^CC= *(.*)$/);
46 print OUT "Error running config!\n";
49 $cversion=`$cc -v 2>&1`;
50 $cversion=`$cc -V 2>&1` if $cversion =~ "usage";
51 $cversion =~ s/Reading specs.*\n//;
52 $cversion =~ s/usage.*\n//;
55 if (open(IN,"<CHANGES")) {
57 if (/\*\) (.{0,55})/) {
65 print OUT "OpenSSL version: $version\n";
66 print OUT "Last change: $last...\n";
67 print OUT "OS (uname): $uname";
68 print OUT "OS (config): $os\n";
69 print OUT "Target (default): $platform0\n";
70 print OUT "Target: $platform\n";
71 print OUT "Compiler: $cversion\n";
74 print "Checking compiler...\n";
75 if (open(TEST,">test.c")) {
76 print TEST "#include <stdio.h>\nmain(){printf(\"Hello world\\n\");}\n";
78 system("$cc -o cctest test.c");
79 if (`./cctest` !~ /Hello world/) {
80 print OUT "Compiler doesn't work.\n";
84 print OUT "Can't create test.c\n";
86 if (open(TEST,">test.c")) {
87 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
89 system("$cc -o cctest -Iinclude test.c");
91 if ($cctest !~ /OpenSSL $version/) {
92 if ($cctest =~ /OpenSSL/) {
93 print OUT "#include uses headers from different OpenSSL version!\n";
95 print OUT "Can't compile test program!\n";
100 print OUT "Can't create test.c\n";
103 print "Running make...\n";
104 if (system("make 2>&1 | tee make.log") > 255) {
106 print OUT "make failed!\n";
107 if (open(IN,"<make.log")) {
115 print OUT "make.log not found!\n";
120 print "Running make test...\n";
121 if (system("make test 2>&1 | tee make.log") > 255)
123 print OUT "make test failed!\n";
128 if ($ok and open(IN,"<make.log")) {
130 $ok=2 if /^platform: $platform/;
136 print OUT "Failure!\n";
137 if (open(IN,"<make.log")) {
145 print OUT "make.log not found!\n";
148 print OUT "Test passed.\n";
154 open(IN,"<$report") or die;
159 print "Test report in file $report\n";