Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / bin / perlivp
CommitLineData
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
8sub usage {
9 warn "@_\n" if @_;
10 print << " EOUSAGE";
11Usage:
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
24use 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
28while ($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
43my $pass__total = 0;
44my $error_total = 0;
45my $tests_total = 0;
46
47my $perlpath = '/import/bw/tools/local/perl-5.8.0/bin/perl';
48my $useithreads = '';
49
50print "## Checking Perl binary via variable `\$perlpath' = $perlpath.\n" if $opt{'p'};
51
52if (-x $perlpath) {
53 print "## Perl binary `$perlpath' appears executable.\n" if $opt{'v'};
54 print "ok 1\n";
55 $pass__total++;
56}
57else {
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
65print "## Checking Perl version via variable `\$]'.\n" if $opt{'p'};
66
67my $ivp_VERSION = 5.008;
68
69if ($ivp_VERSION == $]) {
70 print "## Perl version `$]' appears installed as expected.\n" if $opt{'v'};
71 print "ok 2\n";
72 $pass__total++;
73}
74else {
75 print "# Perl version `$]' installed, expected $ivp_VERSION.\n";
76 print "not ok 2\n";
77 $error_total++;
78}
79$tests_total++;
80
81
82print "## Checking roots of the Perl library directory tree via variable `\@INC'.\n" if $opt{'p'};
83
84my $INC_total = 0;
85my $INC_there = 0;
86foreach (@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}
101if ($INC_total == $INC_there) {
102 print "ok 3\n";
103 $pass__total++;
104}
105else {
106 print "not ok 3\n";
107 $error_total++;
108}
109$tests_total++;
110
111
112print "## Checking installations of modules necessary for ivp.\n" if $opt{'p'};
113
114my $needed_total = 0;
115my $needed_there = 0;
116foreach (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}
129if ($needed_total == $needed_there) {
130 print "ok 4\n";
131 $pass__total++;
132}
133else {
134 print "not ok 4\n";
135 $error_total++;
136}
137$tests_total++;
138
139
140print "## Checking installations of extensions built with perl.\n" if $opt{'p'};
141
142use Config;
143
144my $extensions_total = 0;
145my $extensions_there = 0;
146if (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}
189if ($extensions_total == $extensions_there) {
190 print "ok 5\n";
191 $pass__total++;
192}
193else {
194 print "not ok 5\n";
195 $error_total++;
196}
197$tests_total++;
198
199
200print "## Checking installations of later additional extensions.\n" if $opt{'p'};
201
202use ExtUtils::Installed;
203
204my $installed_total = 0;
205my $installed_there = 0;
206my $version_check = 0;
207my $installed = ExtUtils::Installed -> new();
208my @modules = $installed -> modules();
209my @missing = ();
210my $version = undef;
211for (@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}
237if (($installed_total == $installed_there) &&
238 ($installed_total == $version_check)) {
239 print "ok 6\n";
240 $pass__total++;
241}
242else {
243 print "not ok 6\n";
244 $error_total++;
245}
246$tests_total++;
247
248
249print "## Checking installations of *.h -> *.ph header files.\n" if $opt{'p'};
250my $ph_there = 0;
251my $var = undef;
252my $val = undef;
253my $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).
256my @ph_files = qw(stdio.ph);
257# Add the ones that we know that perl thinks are there:
258while (($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)) {
276foreach (@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
289if (scalar(@ph_files) == $ph_there) {
290 print "ok 7\n";
291 $pass__total++;
292}
293else {
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
303if ($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
316B<perlivp> - Perl Installation Verification Procedure
317
318=head1 SYNOPSIS
319
320B<perlivp> [B<-p>] [B<-v>] [B<-h>]
321
322=head1 DESCRIPTION
323
324The B<perlivp> program is set up at Perl source code build time to test the
325Perl 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
330libraries have been installed correctly. A correct installation is verified
331by output that looks like:
332
333 ok 1
334 ok 2
335
336etc.
337
338=head1 OPTIONS
339
340=over 5
341
342=item B<-h> help
343
344Prints out a brief help message.
345
346=item B<-p> print preface
347
348Gives a description of each test prior to performing it.
349
350=item B<-v> verbose
351
352Gives more detailed information about each test, after it has been performed.
353Note that any failed tests ought to print out some extra information whether
354or 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
364Likely to occur for a perl binary that was not properly installed.
365Correct by conducting a proper installation.
366
367=item * print "# Perl version `$]' installed, expected $ivp_VERSION.\n";
368
369Likely to occur for a perl that was not properly installed.
370Correct by conducting a proper installation.
371
372=item * print "# Perl \@INC directory `$_' does not appear to exist.\n";
373
374Likely to occur for a perl library tree that was not properly installed.
375Correct by conducting a proper installation.
376
377=item * print "# Needed module `$_' does not appear to be properly installed.\n";
378
379One of the two modules that is used by perlivp was not present in the
380installation. This is a serious error since it adversely affects perlivp's
381ability to function. You may be able to correct this by performing a
382proper perl installation.
383
384=item * print "# Required module `$_' does not appear to be properly installed.\n";
385
386An attempt to C<eval "require $module"> failed, even though the list of
387extensions indicated that it should succeed. Correct by conducting a proper
388installation.
389
390=item * print "# Unnecessary module `bLuRfle' appears to be installed.\n";
391
392This test not coming out ok could indicate that you have in fact installed
393a bLuRfle.pm module or that the C<eval " require \"$module_name.pm\"; ">
394test may give misleading results with your installation of perl. If yours
395is the latter case then please let the author know.
396
397=item * print "# file",+($#missing == 0) ? '' : 's'," missing from installation:\n";
398
399One or more files turned up missing according to a run of
400C<ExtUtils::Installed -E<gt> validate()> over your installation.
401Correct by conducting a proper installation.
402
403=item * print "# Perl header `$_' does not appear to be properly installed.\n";
404
405Correct by running B<h2ph> over your system's C header files. If necessary,
406edit the resulting *.ph files to eliminate perl syntax errors.
407
408=back
409
410For further information on how to conduct a proper installation consult the
411INSTALL file that comes with the perl source and the README file for your
412platform.
413
414=head1 AUTHOR
415
416Peter Prymmer
417
418=cut
419