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