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";
22 my $not_our_fault="\nPlease ask your system administrator/vendor for more information.\n[Problems with your operating system setup should not be reported\nto the OpenSSL project.]\n";
24 open(OUT
,">$report") or die;
26 print OUT
"OpenSSL self-test report:\n\n";
29 $uname="??\n" if $uname eq "";
32 foreach $_ (split("\n",$c)) {
33 $os=$1 if (/Operating system: (.*)$/);
34 $platform0=$1 if (/Configuring for (.*)$/);
37 system "sh config" if (! -f
"Makefile.ssl");
39 if (open(IN
,"<Makefile.ssl")) {
41 $version=$1 if (/^VERSION=(.*)$/);
42 $platform=$1 if (/^PLATFORM=(.*)$/);
43 $options=$1 if (/^OPTIONS=(.*)$/);
44 $cc=$1 if (/^CC= *(.*)$/);
48 print OUT
"Error running config!\n";
51 $cversion=`$cc -v 2>&1`;
52 $cversion=`$cc -V 2>&1` if $cversion =~ "usage";
53 $cversion=`$cc --version` if $cversion eq "";
54 $cversion =~ s/Reading specs.*\n//;
55 $cversion =~ s/usage.*\n//;
58 if (open(IN
,"<CHANGES")) {
60 if (/\*\) (.{0,55})/ && !/applies to/) {
68 print OUT
"OpenSSL version: $version\n";
69 print OUT
"Last change: $last...\n";
70 print OUT
"Options: $options\n" if $options ne "";
71 print OUT
"OS (uname): $uname";
72 print OUT
"OS (config): $os\n";
73 print OUT
"Target (default): $platform0\n";
74 print OUT
"Target: $platform\n";
75 print OUT
"Compiler: $cversion\n";
78 print "Checking compiler...\n";
79 if (open(TEST
,">cctest.c")) {
80 print TEST
"#include <stdio.h>\n#include <errno.h>\nmain(){printf(\"Hello world\\n\");}\n";
82 system("$cc -o cctest cctest.c");
83 if (`./cctest` !~ /Hello world
/) {
84 print OUT
"Compiler doesn't work.\n";
85 print OUT
$not_our_fault;
88 system("ar r cctest.a /dev/null");
89 if (not -f
"cctest.a") {
90 print OUT
"Check your archive tool (ar).\n";
91 print OUT
$not_our_fault;
95 print OUT
"Can't create cctest.c\n";
97 if (open(TEST
,">cctest.c")) {
98 print TEST
"#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
100 system("$cc -o cctest -Iinclude cctest.c");
101 $cctest = `./cctest`;
102 if ($cctest !~ /OpenSSL $version/) {
103 if ($cctest =~ /OpenSSL/) {
104 print OUT
"#include uses headers from different OpenSSL version!\n";
106 print OUT
"Can't compile test program!\n";
108 print OUT
$not_our_fault;
112 print OUT
"Can't create cctest.c\n";
115 print "Running make...\n";
116 if (system("make 2>&1 | tee make.log") > 255) {
118 print OUT
"make failed!\n";
119 if (open(IN
,"<make.log")) {
127 print OUT
"make.log not found!\n";
136 print OUT
"Test skipped.\n";
140 if (`echo 4+1 | bc` != 5)
142 print OUT
"Can't run bc! Test skipped.\n";
143 print OUT
$not_our_fault;
147 print "Running make test...\n";
148 if (system("make test 2>&1 | tee maketest.log") > 255)
150 print OUT
"make test failed!\n";
155 if ($ok and open(IN
,"<maketest.log")) {
157 $ok=2 if /^platform: $platform/;
163 print OUT
"Failure!\n";
164 if (open(IN
,"<make.log")) {
172 print OUT
"make.log not found!\n";
174 if (open(IN
,"<maketest.log")) {
181 print OUT
"maketest.log not found!\n";
184 print OUT
"Test passed.\n";
190 open(IN
,"<$report") or die;
198 print "\nTest report in file $report\n";