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";
28 $uname="??\n" if $uname eq "";
31 foreach $_ (split("\n",$c)) {
32 $os=$1 if (/Operating system: (.*)$/);
33 $platform0=$1 if (/Configuring for (.*)$/);
36 system "sh config" if (! -f "Makefile.ssl");
38 if (open(IN,"<Makefile.ssl")) {
40 $version=$1 if (/^VERSION=(.*)$/);
41 $platform=$1 if (/^PLATFORM=(.*)$/);
42 $options=$1 if (/^OPTIONS=(.*)$/);
43 $cc=$1 if (/^CC= *(.*)$/);
47 print OUT "Error running config!\n";
50 $cversion=`$cc -v 2>&1`;
51 $cversion=`$cc -V 2>&1` if $cversion =~ "usage";
52 $cversion=`$cc --version` if $cversion eq "";
53 $cversion =~ s/Reading specs.*\n//;
54 $cversion =~ s/usage.*\n//;
57 if (open(IN,"<CHANGES")) {
59 if (/\*\) (.{0,55})/) {
67 print OUT "OpenSSL version: $version\n";
68 print OUT "Last change: $last...\n";
69 print OUT "Options: $options\n" if $options ne "";
70 print OUT "OS (uname): $uname";
71 print OUT "OS (config): $os\n";
72 print OUT "Target (default): $platform0\n";
73 print OUT "Target: $platform\n";
74 print OUT "Compiler: $cversion\n";
77 print "Checking compiler...\n";
78 if (open(TEST,">cctest.c")) {
79 print TEST "#include <stdio.h>\nmain(){printf(\"Hello world\\n\");}\n";
81 system("$cc -o cctest cctest.c");
82 if (`./cctest` !~ /Hello world/) {
83 print OUT "Compiler doesn't work.\n";
86 system("ar r cctest.a /dev/null");
87 if (not -f "cctest.a") {
88 print OUT "Check your archive tool (ar).\n";
92 print OUT "Can't create cctest.c\n";
94 if (open(TEST,">cctest.c")) {
95 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
97 system("$cc -o cctest -Iinclude cctest.c");
99 if ($cctest !~ /OpenSSL $version/) {
100 if ($cctest =~ /OpenSSL/) {
101 print OUT "#include uses headers from different OpenSSL version!\n";
103 print OUT "Can't compile test program!\n";
108 print OUT "Can't create cctest.c\n";
111 print "Running make...\n";
112 if (system("make 2>&1 | tee make.log") > 255) {
114 print OUT "make failed!\n";
115 if (open(IN,"<make.log")) {
123 print OUT "make.log not found!\n";
132 print OUT "Test skipped.\n";
136 print "Running make test...\n";
137 if (system("make test 2>&1 | tee maketest.log") > 255)
139 print OUT "make test failed!\n";
144 if ($ok and open(IN,"<maketest.log")) {
146 $ok=2 if /^platform: $platform/;
152 print OUT "Failure!\n";
153 if (open(IN,"<make.log")) {
161 print OUT "make.log not found!\n";
163 if (open(IN,"<maketest.log")) {
170 print OUT "maketest.log not found!\n";
173 print OUT "Test passed.\n";
179 open(IN,"<$report") or die;
187 print "\nTest report in file $report\n";