Integrate mainline as of _55
[p5sagit/p5-mst-13.2.git] / vms / test.com
1 $!  Test.Com - DCL driver for perl5 regression tests
2 $!
3 $!  Version 1.1   4-Dec-1995
4 $!  Charles Bailey  bailey@genetics.upenn.edu
5 $
6 $!  A little basic setup
7 $   On Error Then Goto wrapup
8 $   olddef = F$Environment("Default")
9 $   oldmsg = F$Environment("Message")
10 $   If F$Search("t.dir").nes.""
11 $   Then
12 $       Set Default [.t]
13 $   Else
14 $       If F$TrnLNm("Perl_Root").nes.""
15 $       Then 
16 $           Set Default Perl_Root:[t]
17 $       Else
18 $           Write Sys$Error "Can't find test directory"
19 $           Exit 44
20 $       EndIf
21 $   EndIf
22 $   Set Message /Facility/Severity/Identification/Text
23 $
24 $  exe = ".Exe"
25 $  If p1.nes."" Then exe = p1
26 $!  Pick up a copy of perl to use for the tests
27 $   Delete/Log/NoConfirm Perl.;*
28 $   Copy/Log/NoConfirm [-]Perl'exe' []Perl.
29 $
30 $!  Make the environment look a little friendlier to tests which assume Unix
31 $   cat = "Type"
32 $   Macro/NoDebug/NoList/Object=Echo.Obj Sys$Input
33                 .title echo
34                 .psect data,wrt,noexe
35         dsc:
36                 .word 0
37                 .byte 14 ; DSC$K_DTYPE_T
38                 .byte 2  ; DSC$K_CLASS_D
39                 .long 0
40                 .psect code,nowrt,exe
41                 .entry  echo,^m<r2,r3>
42                 movab   dsc,r2
43                 pushab  (r2)
44                 calls   #1,G^LIB$GET_FOREIGN
45                 movl    4(r2),r3
46                 movzwl  (r2),r0
47                 addl2   4(r2),r0
48                 cmpl    r3,r0
49                 bgtru   sym.3
50                 nop     
51         sym.1:
52                 movb    (r3),r0
53                 cmpb    r0,#65
54                 blss    sym.2
55                 cmpb    r0,#90
56                 bgtr    sym.2
57                 cvtbl   r0,r0
58                 addl2   #32,r0
59                 cvtlb   r0,(r3)
60         sym.2:
61                 incl    r3
62                 movzwl  (r2),r0
63                 addl2   4(r2),r0
64                 cmpl    r3,r0
65                 blequ   sym.1
66         sym.3:
67                 pushab  (r2)
68                 calls   #1,G^LIB$PUT_OUTPUT
69                 movl    #1,r0
70                 ret     
71                 .end echo
72 $   Link/NoMap/NoTrace/Exe=Echo.Exe Echo.Obj;
73 $   Delete/Log/NoConfirm Echo.Obj;*
74 $   echo = "$" + F$Parse("Echo.Exe")
75 $
76 $!  And do it
77 $   testdir = "Directory/NoHead/NoTrail/Column=1"
78 $   Define/User Perlshr Sys$Disk:[-]PerlShr'exe'
79 $   MCR Sys$Disk:[]Perl. "-I[-.lib]" - "''p2'" "''p3'" "''p4'" "''p5'" "''p6'"
80 $   Deck/Dollar=$$END-OF-TEST$$
81 # $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
82 # Modified for VMS 30-Sep-1994  Charles Bailey  bailey@genetics.upenn.edu
83 #
84 # This is written in a peculiar style, since we're trying to avoid
85 # most of the constructs we'll be testing for.
86
87 # skip those tests we know will fail entirely or cause perl to hang bacause
88 # of Unixisms in the tests.  (The Perl operators being tested may work fine,
89 # but the tests may use other operators which don't.)
90 use Config;
91
92 @compexcl=('cpp.t');
93 @ioexcl=('argv.t','dup.t','fs.t','inplace.t','pipe.t');
94 @libexcl=('anydbm.t','db-btree.t','db-hash.t','db-recno.t',
95           'gdbm.t','io_dup.t', 'io_pipe.t', 'io_sel.t', 'io_sock.t',
96           'ndbm.t','odbm.t','open2.t','open3.t','posix.t',
97           'sdbm.t');
98
99 # Note: POSIX is not part of basic build, but can be built
100 # separately if you're using DECC
101 # io_xs.t tests the new_tmpfile routine, which doesn't work with the
102 # VAXCRTL, since the file can't be stat()d, an Perl's do_open()
103 # insists on stat()ing a file descriptor before it'll use it.
104 push(@libexcl,'io_xs.t') if $Config{'vms_cc_type'} ne 'decc';
105
106 @opexcl=('exec.t','fork.t','glob.t','groups.t','magic.t','misc.t','stat.t');
107 @exclist=(@compexcl,@ioexcl,@libexcl,@opexcl);
108 foreach $file (@exclist) { $skip{$file}++; }
109
110 $| = 1;
111
112 @ARGV = grep($_,@ARGV);  # remove empty elements due to "''p1'" syntax
113
114 if ($ARGV[0] eq '-v') {
115     $verbose = 1;
116     shift;
117 }
118
119 chdir 't' if -f 't/TEST';
120
121 if ($ARGV[0] eq '') {
122     foreach (<[.*]*.t>) {
123       s/.*[\[.]t./[./;
124       ($fname = $_) =~ s/.*\]//;
125       if ($skip{"\L$fname"}) { push(@skipped,$_); }
126       else { push(@ARGV,$_); }
127     }
128 }
129
130 if (@skipped) {
131   print "The following tests were skipped because they rely extensively on\n";
132   print " Unixisms not compatible with the current version of perl for VMS:\n";
133   print "\t",join("\n\t",@skipped),"\n\n";
134 }
135
136 $bad = 0;
137 $good = 0;
138 $total = @ARGV;
139 while ($test = shift) {
140     if ($test =~ /^$/) {
141         next;
142     }
143     $te = $test;
144     chop($te);
145     $te .= '.' x (24 - length($te));
146         open(script,"$test") || die "Can't run $test.\n";
147         $_ = <script>;
148         close(script);
149         if (/#!..perl(.*)/) {
150             $switch = $1;
151             # Add "" to protect uppercase switches on command line
152             $switch =~ s/-(\S*[A-Z]\S*)/"-$1"/g;
153         } else {
154             $switch = '';
155         }
156         open(results,"\$ MCR Sys\$Disk:[]Perl. $switch $test |") || (print "can't run.\n");
157     $ok = 0;
158     $next = 0;
159     while (<results>) {
160         if ($verbose) {
161             print "$te$_";
162             $te = '';
163         }
164         unless (/^#/) {
165             if (/^1\.\.([0-9]+)/) {
166                 $max = $1;
167                 $totmax += $max;
168                 $files += 1;
169                 $next = 1;
170                 $ok = 1;
171             } else {
172                 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
173                 next if /^\s*$/; # our 'echo' substitute produces one more \n than Unix'
174                 if (/^ok (.*)/ && $1 == $next) {
175                     $next = $next + 1;
176                 } else {
177                     $ok = 0;
178                 }
179             }
180         }
181     }
182     $next = $next - 1;
183     if ($ok && $next == $max) {
184         if ($max) {
185             print "${te}ok\n";
186             $good = $good + 1;
187         } else {
188             print "${te}skipping test on this platform\n";
189             $files -= 1;
190         }
191     } else {
192         $next += 1;
193         print "${te}FAILED on test $next\n";
194         $bad = $bad + 1;
195         $_ = $test;
196         if (/^base/) {
197             die "Failed a basic test--cannot continue.\n";
198         }
199     }
200 }
201
202 if ($bad == 0) {
203     if ($ok) {
204         print "All tests successful.\n";
205     } else {
206         die "FAILED--no tests were run for some reason.\n";
207     }
208 } else {
209     $pct = sprintf("%.2f", $good / $total * 100);
210     if ($bad == 1) {
211         warn "Failed 1 test, $pct% okay.\n";
212     } else {
213         warn "Failed $bad/$total tests, $pct% okay.\n";
214     }
215 }
216 ($user,$sys,$cuser,$csys) = times;
217 print sprintf("u=%g  s=%g  cu=%g  cs=%g  files=%d  tests=%d\n",
218     $user,$sys,$cuser,$csys,$files,$totmax);
219 $$END-OF-TEST$$
220 $ wrapup:
221 $   If F$Search("Echo.Exe").nes."" Then Delete/Log/NoConfirm Echo.Exe;*
222 $   Set Default &olddef
223 $   Set Message 'oldmsg'
224 $   Exit