]>
Commit | Line | Data |
---|---|---|
720b590f UM |
1 | #!/usr/local/bin/perl -w |
2 | # | |
3 | # Run the test suite and generate a report | |
4 | # | |
5 | ||
6 | if (! -f "Configure") { | |
7 | print "Please run perl util/selftest.pl in the OpenSSL directory.\n"; | |
8 | exit 1; | |
9 | } | |
10 | ||
11 | my $report="testlog"; | |
12 | my $os="??"; | |
13 | my $version="??"; | |
14 | my $platform0="??"; | |
15 | my $platform="??"; | |
16 | my $options="??"; | |
17 | my $last="??"; | |
18 | my $ok=0; | |
19 | my $cc="cc"; | |
d7f0ab5f | 20 | my $cversion="??"; |
720b590f | 21 | my $sep="-----------------------------------------------------------------------------\n"; |
e7cae747 | 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"; |
720b590f UM |
23 | |
24 | open(OUT,">$report") or die; | |
25 | ||
26 | print OUT "OpenSSL self-test report:\n\n"; | |
27 | ||
28 | $uname=`uname -a`; | |
c7fecee8 | 29 | $uname="??\n" if $uname eq ""; |
720b590f UM |
30 | |
31 | $c=`sh config -t`; | |
32 | foreach $_ (split("\n",$c)) { | |
33 | $os=$1 if (/Operating system: (.*)$/); | |
34 | $platform0=$1 if (/Configuring for (.*)$/); | |
35 | } | |
36 | ||
69af4fae | 37 | system "sh config" if (! -f "Makefile"); |
720b590f | 38 | |
69af4fae | 39 | if (open(IN,"<Makefile")) { |
720b590f UM |
40 | while (<IN>) { |
41 | $version=$1 if (/^VERSION=(.*)$/); | |
42 | $platform=$1 if (/^PLATFORM=(.*)$/); | |
43 | $options=$1 if (/^OPTIONS=(.*)$/); | |
d7f0ab5f | 44 | $cc=$1 if (/^CC= *(.*)$/); |
720b590f UM |
45 | } |
46 | close(IN); | |
47 | } else { | |
d7f0ab5f | 48 | print OUT "Error running config!\n"; |
720b590f UM |
49 | } |
50 | ||
d7f0ab5f | 51 | $cversion=`$cc -v 2>&1`; |
7a5ad5d5 | 52 | $cversion=`$cc -V 2>&1` if $cversion =~ "[Uu]sage"; |
7b4c588f | 53 | $cversion=`$cc -V |head -1` if $cversion =~ "Error"; |
4c5fac4a | 54 | $cversion=`$cc --version` if $cversion eq ""; |
d7f0ab5f UM |
55 | $cversion =~ s/Reading specs.*\n//; |
56 | $cversion =~ s/usage.*\n//; | |
57 | chomp $cversion; | |
58 | ||
720b590f UM |
59 | if (open(IN,"<CHANGES")) { |
60 | while(<IN>) { | |
e29f478a | 61 | if (/\*\) (.{0,55})/ && !/applies to/) { |
720b590f UM |
62 | $last=$1; |
63 | last; | |
64 | } | |
65 | } | |
66 | close(IN); | |
67 | } | |
68 | ||
69 | print OUT "OpenSSL version: $version\n"; | |
70 | print OUT "Last change: $last...\n"; | |
4c5fac4a | 71 | print OUT "Options: $options\n" if $options ne ""; |
720b590f UM |
72 | print OUT "OS (uname): $uname"; |
73 | print OUT "OS (config): $os\n"; | |
74 | print OUT "Target (default): $platform0\n"; | |
75 | print OUT "Target: $platform\n"; | |
d7f0ab5f | 76 | print OUT "Compiler: $cversion\n"; |
720b590f UM |
77 | print OUT "\n"; |
78 | ||
79 | print "Checking compiler...\n"; | |
331b5921 | 80 | if (open(TEST,">cctest.c")) { |
e5fa864f | 81 | print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\nmain(){printf(\"Hello world\\n\");}\n"; |
720b590f | 82 | close(TEST); |
331b5921 | 83 | system("$cc -o cctest cctest.c"); |
71308c3b | 84 | if (`./cctest` !~ /Hello world/) { |
720b590f | 85 | print OUT "Compiler doesn't work.\n"; |
e7cae747 | 86 | print OUT $not_our_fault; |
720b590f UM |
87 | goto err; |
88 | } | |
b313adc4 | 89 | system("ar r cctest.a /dev/null"); |
c7fecee8 | 90 | if (not -f "cctest.a") { |
0cff2550 | 91 | print OUT "Check your archive tool (ar).\n"; |
e7cae747 | 92 | print OUT $not_our_fault; |
c7fecee8 UM |
93 | goto err; |
94 | } | |
720b590f | 95 | } else { |
331b5921 | 96 | print OUT "Can't create cctest.c\n"; |
720b590f | 97 | } |
331b5921 | 98 | if (open(TEST,">cctest.c")) { |
e5fa864f | 99 | print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n"; |
720b590f | 100 | close(TEST); |
331b5921 | 101 | system("$cc -o cctest -Iinclude cctest.c"); |
720b590f UM |
102 | $cctest = `./cctest`; |
103 | if ($cctest !~ /OpenSSL $version/) { | |
104 | if ($cctest =~ /OpenSSL/) { | |
105 | print OUT "#include uses headers from different OpenSSL version!\n"; | |
106 | } else { | |
107 | print OUT "Can't compile test program!\n"; | |
108 | } | |
e7cae747 | 109 | print OUT $not_our_fault; |
720b590f UM |
110 | goto err; |
111 | } | |
112 | } else { | |
331b5921 | 113 | print OUT "Can't create cctest.c\n"; |
720b590f UM |
114 | } |
115 | ||
116 | print "Running make...\n"; | |
117 | if (system("make 2>&1 | tee make.log") > 255) { | |
118 | ||
119 | print OUT "make failed!\n"; | |
120 | if (open(IN,"<make.log")) { | |
121 | print OUT $sep; | |
122 | while (<IN>) { | |
123 | print OUT; | |
124 | } | |
125 | close(IN); | |
126 | print OUT $sep; | |
127 | } else { | |
128 | print OUT "make.log not found!\n"; | |
129 | } | |
130 | goto err; | |
131 | } | |
132 | ||
34f0b264 RL |
133 | # Not sure why this is here. The tests themselves can detect if their |
134 | # particular feature isn't included, and should therefore skip themselves. | |
135 | # To skip *all* tests just because one algorithm isn't included is like | |
136 | # shooting mosquito with an elephant gun... | |
137 | # -- Richard Levitte, inspired by problem report 1089 | |
138 | # | |
139 | #$_=$options; | |
140 | #s/no-asm//; | |
141 | #s/no-shared//; | |
142 | #s/no-krb5//; | |
143 | #if (/no-/) | |
144 | #{ | |
145 | # print OUT "Test skipped.\n"; | |
146 | # goto err; | |
147 | #} | |
4c5fac4a | 148 | |
720b590f | 149 | print "Running make test...\n"; |
c7fecee8 | 150 | if (system("make test 2>&1 | tee maketest.log") > 255) |
720b590f UM |
151 | { |
152 | print OUT "make test failed!\n"; | |
153 | } else { | |
154 | $ok=1; | |
155 | } | |
156 | ||
c7fecee8 | 157 | if ($ok and open(IN,"<maketest.log")) { |
720b590f UM |
158 | while (<IN>) { |
159 | $ok=2 if /^platform: $platform/; | |
160 | } | |
161 | close(IN); | |
162 | } | |
163 | ||
164 | if ($ok != 2) { | |
165 | print OUT "Failure!\n"; | |
166 | if (open(IN,"<make.log")) { | |
167 | print OUT $sep; | |
168 | while (<IN>) { | |
169 | print OUT; | |
170 | } | |
171 | close(IN); | |
172 | print OUT $sep; | |
173 | } else { | |
174 | print OUT "make.log not found!\n"; | |
175 | } | |
c7fecee8 UM |
176 | if (open(IN,"<maketest.log")) { |
177 | while (<IN>) { | |
178 | print OUT; | |
179 | } | |
180 | close(IN); | |
181 | print OUT $sep; | |
182 | } else { | |
183 | print OUT "maketest.log not found!\n"; | |
184 | } | |
720b590f UM |
185 | } else { |
186 | print OUT "Test passed.\n"; | |
187 | } | |
188 | err: | |
189 | close(OUT); | |
190 | ||
191 | print "\n"; | |
192 | open(IN,"<$report") or die; | |
193 | while (<IN>) { | |
4c5fac4a UM |
194 | if (/$sep/) { |
195 | print "[...]\n"; | |
196 | last; | |
197 | } | |
720b590f UM |
198 | print; |
199 | } | |
4c5fac4a | 200 | print "\nTest report in file $report\n"; |
d7f0ab5f | 201 |