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