2 # Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
9 # Run the test suite and generate a report
11 if (! -f "Configure") {
12 print "Please run perl util/selftest.pl in the OpenSSL directory.\n";
26 my $sep="-----------------------------------------------------------------------------\n";
27 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";
29 open(OUT,">$report") or die;
31 print OUT "OpenSSL self-test report:\n\n";
34 $uname="??\n" if $uname eq "";
37 foreach $_ (split("\n",$c)) {
38 $os=$1 if (/Operating system: (.*)$/);
39 $platform0=$1 if (/Configuring for (.*)$/);
42 system "sh config" if (! -f "Makefile");
44 if (open(IN,"<Makefile")) {
46 $version=$1 if (/^VERSION=(.*)$/);
47 $platform=$1 if (/^PLATFORM=(.*)$/);
48 $options=$1 if (/^OPTIONS=(.*)$/);
49 $cc=$1 if (/^CC= *(.*)$/);
53 print OUT "Error running config!\n";
56 $cversion=`$cc -v 2>&1`;
57 $cversion=`$cc -V 2>&1` if $cversion =~ "[Uu]sage";
58 $cversion=`$cc -V |head -1` if $cversion =~ "Error";
59 $cversion=`$cc --version` if $cversion eq "";
60 $cversion =~ s/Reading specs.*\n//;
61 $cversion =~ s/usage.*\n//;
64 if (open(IN,"<CHANGES")) {
66 if (/\*\) (.{0,55})/ && !/applies to/) {
74 print OUT "OpenSSL version: $version\n";
75 print OUT "Last change: $last...\n";
76 print OUT "Options: $options\n" if $options ne "";
77 print OUT "OS (uname): $uname";
78 print OUT "OS (config): $os\n";
79 print OUT "Target (default): $platform0\n";
80 print OUT "Target: $platform\n";
81 print OUT "Compiler: $cversion\n";
84 print "Checking compiler...\n";
85 if (open(TEST,">cctest.c")) {
86 print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\nmain(){printf(\"Hello world\\n\");}\n";
88 system("$cc -o cctest cctest.c");
89 if (`./cctest` !~ /Hello world/) {
90 print OUT "Compiler doesn't work.\n";
91 print OUT $not_our_fault;
94 system("ar r cctest.a /dev/null");
95 if (not -f "cctest.a") {
96 print OUT "Check your archive tool (ar).\n";
97 print OUT $not_our_fault;
101 print OUT "Can't create cctest.c\n";
103 if (open(TEST,">cctest.c")) {
104 print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
106 system("$cc -o cctest -Iinclude cctest.c");
107 $cctest = `./cctest`;
108 if ($cctest !~ /OpenSSL $version/) {
109 if ($cctest =~ /OpenSSL/) {
110 print OUT "#include uses headers from different OpenSSL version!\n";
112 print OUT "Can't compile test program!\n";
114 print OUT $not_our_fault;
118 print OUT "Can't create cctest.c\n";
121 print "Running make...\n";
122 if (system("make 2>&1 | tee make.log") > 255) {
124 print OUT "make failed!\n";
125 if (open(IN,"<make.log")) {
133 print OUT "make.log not found!\n";
138 # Not sure why this is here. The tests themselves can detect if their
139 # particular feature isn't included, and should therefore skip themselves.
140 # To skip *all* tests just because one algorithm isn't included is like
141 # shooting mosquito with an elephant gun...
142 # -- Richard Levitte, inspired by problem report 1089
150 # print OUT "Test skipped.\n";
154 print "Running make test...\n";
155 if (system("make test 2>&1 | tee maketest.log") > 255)
157 print OUT "make test failed!\n";
162 if ($ok and open(IN,"<maketest.log")) {
164 $ok=2 if /^platform: $platform/;
170 print OUT "Failure!\n";
171 if (open(IN,"<make.log")) {
179 print OUT "make.log not found!\n";
181 if (open(IN,"<maketest.log")) {
188 print OUT "maketest.log not found!\n";
191 print OUT "Test passed.\n";
197 open(IN,"<$report") or die;
205 print "\nTest report in file $report\n";