Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | #!/import/archperf/ws/devtools/4/v9/bin/perl |
2 | eval 'exec /import/archperf/ws/devtools/4/v9/bin/perl -S $0 ${1+"$@"}' | |
3 | if $running_under_some_shell; | |
4 | ||
5 | # perlivp V 0.02 | |
6 | ||
7 | ||
8 | sub usage { | |
9 | warn "@_\n" if @_; | |
10 | print << " EOUSAGE"; | |
11 | Usage: | |
12 | ||
13 | $0 [-a] [-p] [-v] | [-h] | |
14 | ||
15 | -a Run all tests (default is to skip .ph tests) | |
16 | -p Print a preface before each test telling what it will test. | |
17 | -v Verbose mode in which extra information about test results | |
18 | is printed. Test failures always print out some extra information | |
19 | regardless of whether or not this switch is set. | |
20 | -h Prints this help message. | |
21 | EOUSAGE | |
22 | exit; | |
23 | } | |
24 | ||
25 | use vars qw(%opt); # allow testing with older versions (do not use our) | |
26 | ||
27 | @opt{ qw/? H h P p V v/ } = qw(0 0 0 0 0 0 0); | |
28 | ||
29 | while ($ARGV[0] =~ /^-/) { | |
30 | $ARGV[0] =~ s/^-//; | |
31 | for my $flag (split(//,$ARGV[0])) { | |
32 | usage() if '?' =~ /\Q$flag/; | |
33 | usage() if 'h' =~ /\Q$flag/; | |
34 | usage() if 'H' =~ /\Q$flag/; | |
35 | usage("unknown flag: `$flag'") unless 'HhPpVva' =~ /\Q$flag/; | |
36 | warn "$0: `$flag' flag already set\n" if $opt{$flag}++; | |
37 | } | |
38 | shift; | |
39 | } | |
40 | ||
41 | $opt{p}++ if $opt{P}; | |
42 | $opt{v}++ if $opt{V}; | |
43 | ||
44 | my $pass__total = 0; | |
45 | my $error_total = 0; | |
46 | my $tests_total = 0; | |
47 | ||
48 | my $perlpath = '/import/archperf/ws/devtools/4/v9/bin/perl'; | |
49 | my $useithreads = ''; | |
50 | ||
51 | print "## Checking Perl binary via variable `\$perlpath' = $perlpath.\n" if $opt{'p'}; | |
52 | ||
53 | if (-x $perlpath) { | |
54 | print "## Perl binary `$perlpath' appears executable.\n" if $opt{'v'}; | |
55 | print "ok 1\n"; | |
56 | $pass__total++; | |
57 | } | |
58 | else { | |
59 | print "# Perl binary `$perlpath' does not appear executable.\n"; | |
60 | print "not ok 1\n"; | |
61 | $error_total++; | |
62 | } | |
63 | $tests_total++; | |
64 | ||
65 | ||
66 | print "## Checking Perl version via variable `\$]'.\n" if $opt{'p'}; | |
67 | ||
68 | my $ivp_VERSION = 5.008008; | |
69 | ||
70 | if ($ivp_VERSION eq $]) { | |
71 | print "## Perl version `$]' appears installed as expected.\n" if $opt{'v'}; | |
72 | print "ok 2\n"; | |
73 | $pass__total++; | |
74 | } | |
75 | else { | |
76 | print "# Perl version `$]' installed, expected $ivp_VERSION.\n"; | |
77 | print "not ok 2\n"; | |
78 | $error_total++; | |
79 | } | |
80 | $tests_total++; | |
81 | ||
82 | ||
83 | print "## Checking roots of the Perl library directory tree via variable `\@INC'.\n" if $opt{'p'}; | |
84 | ||
85 | my $INC_total = 0; | |
86 | my $INC_there = 0; | |
87 | foreach (@INC) { | |
88 | next if $_ eq '.'; # skip -d test here | |
89 | if ($^O eq 'MacOS') { | |
90 | next if $_ eq ':'; # skip -d test here | |
91 | next if $_ eq 'Dev:Pseudo:'; # why is this in @INC? | |
92 | } | |
93 | if (-d $_) { | |
94 | print "## Perl \@INC directory `$_' exists.\n" if $opt{'v'}; | |
95 | $INC_there++; | |
96 | } | |
97 | else { | |
98 | print "# Perl \@INC directory `$_' does not appear to exist.\n"; | |
99 | } | |
100 | $INC_total++; | |
101 | } | |
102 | if ($INC_total == $INC_there) { | |
103 | print "ok 3\n"; | |
104 | $pass__total++; | |
105 | } | |
106 | else { | |
107 | print "not ok 3\n"; | |
108 | $error_total++; | |
109 | } | |
110 | $tests_total++; | |
111 | ||
112 | ||
113 | print "## Checking installations of modules necessary for ivp.\n" if $opt{'p'}; | |
114 | ||
115 | my $needed_total = 0; | |
116 | my $needed_there = 0; | |
117 | foreach (qw(Config.pm ExtUtils/Installed.pm)) { | |
118 | $@ = undef; | |
119 | $needed_total++; | |
120 | eval "require \"$_\";"; | |
121 | if (!$@) { | |
122 | print "## Module `$_' appears to be installed.\n" if $opt{'v'}; | |
123 | $needed_there++; | |
124 | } | |
125 | else { | |
126 | print "# Needed module `$_' does not appear to be properly installed.\n"; | |
127 | } | |
128 | $@ = undef; | |
129 | } | |
130 | if ($needed_total == $needed_there) { | |
131 | print "ok 4\n"; | |
132 | $pass__total++; | |
133 | } | |
134 | else { | |
135 | print "not ok 4\n"; | |
136 | $error_total++; | |
137 | } | |
138 | $tests_total++; | |
139 | ||
140 | ||
141 | print "## Checking installations of extensions built with perl.\n" if $opt{'p'}; | |
142 | ||
143 | use Config; | |
144 | ||
145 | my $extensions_total = 0; | |
146 | my $extensions_there = 0; | |
147 | if (defined($Config{'extensions'})) { | |
148 | my @extensions = split(/\s+/,$Config{'extensions'}); | |
149 | foreach (@extensions) { | |
150 | next if ($_ eq ''); | |
151 | if ( $useithreads !~ /define/i ) { | |
152 | next if ($_ eq 'threads'); | |
153 | next if ($_ eq 'threads/shared'); | |
154 | } | |
155 | next if ($_ eq 'Devel/DProf'); | |
156 | # VMS$ perl -e "eval ""require \""Devel/DProf.pm\"";"" print $@" | |
157 | # \NT> perl -e "eval \"require 'Devel/DProf.pm'\"; print $@" | |
158 | # DProf: run perl with -d to use DProf. | |
159 | # Compilation failed in require at (eval 1) line 1. | |
160 | eval " require \"$_.pm\"; "; | |
161 | if (!$@) { | |
162 | print "## Module `$_' appears to be installed.\n" if $opt{'v'}; | |
163 | $extensions_there++; | |
164 | } | |
165 | else { | |
166 | print "# Required module `$_' does not appear to be properly installed.\n"; | |
167 | $@ = undef; | |
168 | } | |
169 | $extensions_total++; | |
170 | } | |
171 | ||
172 | # A silly name for a module (that hopefully won't ever exist). | |
173 | # Note that this test serves more as a check of the validity of the | |
174 | # actuall required module tests above. | |
175 | my $unnecessary = 'bLuRfle'; | |
176 | ||
177 | if (!grep(/$unnecessary/, @extensions)) { | |
178 | $@ = undef; | |
179 | eval " require \"$unnecessary.pm\"; "; | |
180 | if ($@) { | |
181 | print "## Unnecessary module `$unnecessary' does not appear to be installed.\n" if $opt{'v'}; | |
182 | } | |
183 | else { | |
184 | print "# Unnecessary module `$unnecessary' appears to be installed.\n"; | |
185 | $extensions_there++; | |
186 | } | |
187 | } | |
188 | $@ = undef; | |
189 | } | |
190 | if ($extensions_total == $extensions_there) { | |
191 | print "ok 5\n"; | |
192 | $pass__total++; | |
193 | } | |
194 | else { | |
195 | print "not ok 5\n"; | |
196 | $error_total++; | |
197 | } | |
198 | $tests_total++; | |
199 | ||
200 | ||
201 | print "## Checking installations of later additional extensions.\n" if $opt{'p'}; | |
202 | ||
203 | use ExtUtils::Installed; | |
204 | ||
205 | my $installed_total = 0; | |
206 | my $installed_there = 0; | |
207 | my $version_check = 0; | |
208 | my $installed = ExtUtils::Installed -> new(); | |
209 | my @modules = $installed -> modules(); | |
210 | my @missing = (); | |
211 | my $version = undef; | |
212 | for (@modules) { | |
213 | $installed_total++; | |
214 | # Consider it there if it contains one or more files, | |
215 | # and has zero missing files, | |
216 | # and has a defined version | |
217 | $version = undef; | |
218 | $version = $installed -> version($_); | |
219 | if ($version) { | |
220 | print "## $_; $version\n" if $opt{'v'}; | |
221 | $version_check++; | |
222 | } | |
223 | else { | |
224 | print "# $_; NO VERSION\n" if $opt{'v'}; | |
225 | } | |
226 | $version = undef; | |
227 | @missing = (); | |
228 | @missing = $installed -> validate($_); | |
229 | if ($#missing >= 0) { | |
230 | print "# file",+($#missing == 0) ? '' : 's'," missing from installation:\n"; | |
231 | print '# ',join(' ',@missing),"\n"; | |
232 | } | |
233 | elsif ($#missing == -1) { | |
234 | $installed_there++; | |
235 | } | |
236 | @missing = (); | |
237 | } | |
238 | if (($installed_total == $installed_there) && | |
239 | ($installed_total == $version_check)) { | |
240 | print "ok 6\n"; | |
241 | $pass__total++; | |
242 | } | |
243 | else { | |
244 | print "not ok 6\n"; | |
245 | $error_total++; | |
246 | } | |
247 | $tests_total++; | |
248 | ||
249 | ||
250 | if ($opt{'a'}) { | |
251 | print "## Checking installations of *.h -> *.ph header files.\n" if $opt{'p'}; | |
252 | my $ph_there = 0; | |
253 | my $var = undef; | |
254 | my $val = undef; | |
255 | my $h_file = undef; | |
256 | # Just about "any" C implementation ought to have a stdio.h (even if | |
257 | # Config.pm may not list a i_stdio var). | |
258 | my @ph_files = qw(stdio.ph); | |
259 | # Add the ones that we know that perl thinks are there: | |
260 | while (($var, $val) = each %Config) { | |
261 | if ($var =~ m/i_(.+)/ && $val eq 'define') { | |
262 | $h_file = $1; | |
263 | # Some header and symbol names don't match for hysterical raisins. | |
264 | $h_file = 'arpa/inet' if $h_file eq 'arpainet'; | |
265 | $h_file = 'netinet/in' if $h_file eq 'niin'; | |
266 | $h_file = 'netinet/tcp' if $h_file eq 'netinettcp'; | |
267 | $h_file = 'sys/resource' if $h_file eq 'sysresrc'; | |
268 | $h_file = 'sys/select' if $h_file eq 'sysselct'; | |
269 | $h_file = 'sys/security' if $h_file eq 'syssecrt'; | |
270 | $h_file = 'rpcsvc/dbm' if $h_file eq 'rpcsvcdbm'; | |
271 | # This ought to distinguish syslog from sys/syslog. | |
272 | # (NB syslog.ph is heavily used for the DBI pre-requisites). | |
273 | $h_file =~ s{^sys(\w.+)}{sys/$1} unless $h_file eq 'syslog'; | |
274 | push(@ph_files, "$h_file.ph"); | |
275 | } | |
276 | } | |
277 | #foreach (qw(stdio.ph syslog.ph)) { | |
278 | foreach (@ph_files) { | |
279 | $@ = undef; | |
280 | eval "require \"$_\";"; | |
281 | if (!$@) { | |
282 | print "## Perl header `$_' appears to be installed.\n" if $opt{'v'}; | |
283 | $ph_there++; | |
284 | } | |
285 | else { | |
286 | print "# Perl header `$_' does not appear to be properly installed.\n"; | |
287 | } | |
288 | $@ = undef; | |
289 | } | |
290 | ||
291 | if (scalar(@ph_files) == $ph_there) { | |
292 | print "ok 7\n"; | |
293 | $pass__total++; | |
294 | } | |
295 | else { | |
296 | print "not ok 7\n"; | |
297 | $error_total++; | |
298 | } | |
299 | $tests_total++; | |
300 | } | |
301 | else { | |
302 | print "## Skip checking of *.ph header files.\n" if $opt{'p'}; | |
303 | } | |
304 | ||
305 | # Final report (rather than feed ousrselves to Test::Harness::runtests() | |
306 | # we simply format some output on our own to keep things simple and | |
307 | # easier to "fix" - at least for now. | |
308 | ||
309 | if ($error_total == 0 && $tests_total) { | |
310 | print "All tests successful.\n"; | |
311 | } elsif ($tests_total==0){ | |
312 | die "FAILED--no tests were run for some reason.\n"; | |
313 | } else { | |
314 | my $rate = 0.0; | |
315 | if ($tests_total > 0) { $rate = sprintf "%.2f", 100.0 * ($pass__total / $tests_total); } | |
316 | printf " %d/%d subtests failed, %.2f%% okay.\n", | |
317 | $error_total, $tests_total, $rate; | |
318 | } | |
319 | ||
320 | =head1 NAME | |
321 | ||
322 | perlivp - Perl Installation Verification Procedure | |
323 | ||
324 | =head1 SYNOPSIS | |
325 | ||
326 | B<perlivp> [B<-a>] [B<-p>] [B<-v>] [B<-h>] | |
327 | ||
328 | =head1 DESCRIPTION | |
329 | ||
330 | The B<perlivp> program is set up at Perl source code build time to test the | |
331 | Perl version it was built under. It can be used after running: | |
332 | ||
333 | make install | |
334 | ||
335 | (or your platform's equivalent procedure) to verify that B<perl> and its | |
336 | libraries have been installed correctly. A correct installation is verified | |
337 | by output that looks like: | |
338 | ||
339 | ok 1 | |
340 | ok 2 | |
341 | ||
342 | etc. | |
343 | ||
344 | =head1 OPTIONS | |
345 | ||
346 | =over 5 | |
347 | ||
348 | =item B<-h> help | |
349 | ||
350 | Prints out a brief help message. | |
351 | ||
352 | =item B<-a> run all tests | |
353 | ||
354 | Normally tests for optional features are skipped. With -a all tests | |
355 | are executed. | |
356 | ||
357 | =item B<-p> print preface | |
358 | ||
359 | Gives a description of each test prior to performing it. | |
360 | ||
361 | =item B<-v> verbose | |
362 | ||
363 | Gives more detailed information about each test, after it has been performed. | |
364 | Note that any failed tests ought to print out some extra information whether | |
365 | or not -v is thrown. | |
366 | ||
367 | =back | |
368 | ||
369 | =head1 DIAGNOSTICS | |
370 | ||
371 | =over 4 | |
372 | ||
373 | =item * print "# Perl binary `$perlpath' does not appear executable.\n"; | |
374 | ||
375 | Likely to occur for a perl binary that was not properly installed. | |
376 | Correct by conducting a proper installation. | |
377 | ||
378 | =item * print "# Perl version `$]' installed, expected $ivp_VERSION.\n"; | |
379 | ||
380 | Likely to occur for a perl that was not properly installed. | |
381 | Correct by conducting a proper installation. | |
382 | ||
383 | =item * print "# Perl \@INC directory `$_' does not appear to exist.\n"; | |
384 | ||
385 | Likely to occur for a perl library tree that was not properly installed. | |
386 | Correct by conducting a proper installation. | |
387 | ||
388 | =item * print "# Needed module `$_' does not appear to be properly installed.\n"; | |
389 | ||
390 | One of the two modules that is used by perlivp was not present in the | |
391 | installation. This is a serious error since it adversely affects perlivp's | |
392 | ability to function. You may be able to correct this by performing a | |
393 | proper perl installation. | |
394 | ||
395 | =item * print "# Required module `$_' does not appear to be properly installed.\n"; | |
396 | ||
397 | An attempt to C<eval "require $module"> failed, even though the list of | |
398 | extensions indicated that it should succeed. Correct by conducting a proper | |
399 | installation. | |
400 | ||
401 | =item * print "# Unnecessary module `bLuRfle' appears to be installed.\n"; | |
402 | ||
403 | This test not coming out ok could indicate that you have in fact installed | |
404 | a bLuRfle.pm module or that the C<eval " require \"$module_name.pm\"; "> | |
405 | test may give misleading results with your installation of perl. If yours | |
406 | is the latter case then please let the author know. | |
407 | ||
408 | =item * print "# file",+($#missing == 0) ? '' : 's'," missing from installation:\n"; | |
409 | ||
410 | One or more files turned up missing according to a run of | |
411 | C<ExtUtils::Installed -E<gt> validate()> over your installation. | |
412 | Correct by conducting a proper installation. | |
413 | ||
414 | =item * print "# Perl header `$_' does not appear to be properly installed.\n"; | |
415 | ||
416 | Correct by running B<h2ph> over your system's C header files. If necessary, | |
417 | edit the resulting *.ph files to eliminate perl syntax errors. | |
418 | ||
419 | =back | |
420 | ||
421 | For further information on how to conduct a proper installation consult the | |
422 | INSTALL file that comes with the perl source and the README file for your | |
423 | platform. | |
424 | ||
425 | =head1 AUTHOR | |
426 | ||
427 | Peter Prymmer | |
428 | ||
429 | =cut | |
430 |