Deleted Added
sdiff udiff text old ( 59191 ) new ( 68651 )
full compact
1#!/usr/local/bin/perl -w
2#
3# Run the test suite and generate a report
4#
5
6if (! -f "Configure") {
7 print "Please run perl util/selftest.pl in the OpenSSL directory.\n";
8 exit 1;
9}
10
11my $report="testlog";
12my $os="??";
13my $version="??";
14my $platform0="??";
15my $platform="??";
16my $options="??";
17my $last="??";
18my $ok=0;
19my $cc="cc";
20my $cversion="??";
21my $sep="-----------------------------------------------------------------------------\n";
22
23open(OUT,">$report") or die;
24
25print OUT "OpenSSL self-test report:\n\n";
26
27$uname=`uname -a`;
28$uname="??\n" if $uname eq "";
29
30$c=`sh config -t`;
31foreach $_ (split("\n",$c)) {
32 $os=$1 if (/Operating system: (.*)$/);
33 $platform0=$1 if (/Configuring for (.*)$/);
34}
35
36system "sh config" if (! -f "Makefile.ssl");
37
38if (open(IN,"<Makefile.ssl")) {
39 while (<IN>) {
40 $version=$1 if (/^VERSION=(.*)$/);
41 $platform=$1 if (/^PLATFORM=(.*)$/);
42 $options=$1 if (/^OPTIONS=(.*)$/);
43 $cc=$1 if (/^CC= *(.*)$/);
44 }
45 close(IN);
46} else {
47 print OUT "Error running config!\n";
48}
49
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//;
55chomp $cversion;
56
57if (open(IN,"<CHANGES")) {
58 while(<IN>) {
59 if (/\*\) (.{0,55})/) {
60 $last=$1;
61 last;
62 }
63 }
64 close(IN);
65}
66
67print OUT "OpenSSL version: $version\n";
68print OUT "Last change: $last...\n";
69print OUT "Options: $options\n" if $options ne "";
70print OUT "OS (uname): $uname";
71print OUT "OS (config): $os\n";
72print OUT "Target (default): $platform0\n";
73print OUT "Target: $platform\n";
74print OUT "Compiler: $cversion\n";
75print OUT "\n";
76
77print "Checking compiler...\n";
78if (open(TEST,">cctest.c")) {
79 print TEST "#include \nmain(){printf(\"Hello world\\n\");}\n";
80 close(TEST);
81 system("$cc -o cctest cctest.c");
82 if (`./cctest` !~ /Hello world/) {
83 print OUT "Compiler doesn't work.\n";
84 goto err;
85 }
86 system("ar r cctest.a /dev/null");
87 if (not -f "cctest.a") {
88 print OUT "Check your archive tool (ar).\n";
89 goto err;
90 }
91} else {
92 print OUT "Can't create cctest.c\n";
93}
94if (open(TEST,">cctest.c")) {
95 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
96 close(TEST);
97 system("$cc -o cctest -Iinclude cctest.c");
98 $cctest = `./cctest`;
99 if ($cctest !~ /OpenSSL $version/) {
100 if ($cctest =~ /OpenSSL/) {
101 print OUT "#include uses headers from different OpenSSL version!\n";
102 } else {
103 print OUT "Can't compile test program!\n";
104 }
105 goto err;
106 }
107} else {
108 print OUT "Can't create cctest.c\n";
109}
110
111print "Running make...\n";
112if (system("make 2>&1 | tee make.log") > 255) {
113
114 print OUT "make failed!\n";
115 if (open(IN,"<make.log")) {
116 print OUT $sep;
117 while (<IN>) {
118 print OUT;
119 }
120 close(IN);
121 print OUT $sep;
122 } else {
123 print OUT "make.log not found!\n";
124 }
125 goto err;
126}
127
128$_=$options;
129s/no-asm//;
130if (/no-/)
131{
132 print OUT "Test skipped.\n";
133 goto err;
134}
135
136print "Running make test...\n";
137if (system("make test 2>&1 | tee maketest.log") > 255)
138 {
139 print OUT "make test failed!\n";
140} else {
141 $ok=1;
142}
143
144if ($ok and open(IN,"<maketest.log")) {
145 while (<IN>) {
146 $ok=2 if /^platform: $platform/;
147 }
148 close(IN);
149}
150
151if ($ok != 2) {
152 print OUT "Failure!\n";
153 if (open(IN,"<make.log")) {
154 print OUT $sep;
155 while (<IN>) {
156 print OUT;
157 }
158 close(IN);
159 print OUT $sep;
160 } else {
161 print OUT "make.log not found!\n";
162 }
163 if (open(IN,"<maketest.log")) {
164 while (<IN>) {
165 print OUT;
166 }
167 close(IN);
168 print OUT $sep;
169 } else {
170 print OUT "maketest.log not found!\n";
171 }
172} else {
173 print OUT "Test passed.\n";
174}
175err:
176close(OUT);
177
178print "\n";
179open(IN,"<$report") or die;
180while (<IN>) {
181 if (/$sep/) {
182 print "[...]\n";
183 last;
184 }
185 print;
186}
187print "\nTest report in file $report\n";
188