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";
20 my $sep="-----------------------------------------------------------------------------\n";
22 open(OUT,">$report") or die;
24 print OUT "OpenSSL self-test report:\n\n";
29 foreach $_ (split("\n",$c)) {
30 $os=$1 if (/Operating system: (.*)$/);
31 $platform0=$1 if (/Configuring for (.*)$/);
34 system "sh config" if (! -f "Makefile.ssl");
36 if (open(IN,"<Makefile.ssl")) {
38 $version=$1 if (/^VERSION=(.*)$/);
39 $platform=$1 if (/^PLATFORM=(.*)$/);
40 $options=$1 if (/^OPTIONS=(.*)$/);
41 $cc=$1 if (/^CC=(.*)$/);
45 print OUT "Error running config: no Makefile.ssl!\n";
48 if (open(IN,"<CHANGES")) {
50 if (/\*\) (.{0,55})/) {
58 print OUT "OpenSSL version: $version\n";
59 print OUT "Last change: $last...\n";
60 print OUT "OS (uname): $uname";
61 print OUT "OS (config): $os\n";
62 print OUT "Target (default): $platform0\n";
63 print OUT "Target: $platform\n";
66 print "Checking compiler...\n";
67 if (open(TEST,">test.c")) {
68 print TEST "#include <stdio.h>\nmain(){printf(\"Hello world\\n\");}\n";
70 system("$cc -o cctest test.c");
71 if (`./cctest` !~ /Hello world/) {
72 print OUT "Compiler doesn't work.\n";
76 print OUT "Can't create test.c\n";
78 if (open(TEST,">test.c")) {
79 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
81 system("$cc -o cctest -Iinclude test.c");
83 if ($cctest !~ /OpenSSL $version/) {
84 if ($cctest =~ /OpenSSL/) {
85 print OUT "#include uses headers from different OpenSSL version!\n";
87 print OUT "Can't compile test program!\n";
92 print OUT "Can't create test.c\n";
95 print "Running make...\n";
96 if (system("make 2>&1 | tee make.log") > 255) {
98 print OUT "make failed!\n";
99 if (open(IN,"<make.log")) {
107 print OUT "make.log not found!\n";
112 print "Running make test...\n";
113 if (system("make test 2>&1 | tee make.log") > 255)
115 print OUT "make test failed!\n";
120 if ($ok and open(IN,"<make.log")) {
122 $ok=2 if /^platform: $platform/;
128 print OUT "Failure!\n";
129 if (open(IN,"<make.log")) {
137 print OUT "make.log not found!\n";
140 print OUT "Test passed.\n";
146 open(IN,"<$report") or die;
151 print "Test report in file $report\n";