Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
378cc40b |
3 | # $Header: TEST,v 2.0 88/06/05 00:11:47 root Exp $ |
8d063cd8 |
4 | |
5 | # This is written in a peculiar style, since we're trying to avoid |
6 | # most of the constructs we'll be testing for. |
7 | |
8 | if ($ARGV[0] eq '-v') { |
9 | $verbose = 1; |
10 | shift; |
11 | } |
12 | |
378cc40b |
13 | chdir 't' if -f 't/TEST'; |
14 | |
8d063cd8 |
15 | if ($ARGV[0] eq '') { |
16 | @ARGV = split(/[ \n]/,`echo base.* comp.* cmd.* io.* op.*`); |
17 | } |
18 | |
135863df |
19 | open(config,"../config.sh"); |
20 | while (<config>) { |
21 | if (/sharpbang='(.*)'/) { |
22 | $sharpbang = ($1 eq '#!'); |
23 | last; |
24 | } |
25 | } |
8d063cd8 |
26 | $bad = 0; |
27 | while ($test = shift) { |
378cc40b |
28 | if ($test =~ /\.orig$/) { |
29 | next; |
30 | } |
8d063cd8 |
31 | print "$test..."; |
135863df |
32 | if ($sharpbang) { |
378cc40b |
33 | open(results,"./$test|") || (print "can't run.\n"); |
135863df |
34 | } else { |
378cc40b |
35 | open(script,"$test") || die "Can't run $test.\n"; |
135863df |
36 | $_ = <script>; |
37 | close(script); |
38 | if (/#!..perl(.*)/) { |
39 | $switch = $1; |
40 | } else { |
41 | $switch = ''; |
42 | } |
43 | open(results,"./perl$switch $test|") || (print "can't run.\n"); |
44 | } |
8d063cd8 |
45 | $ok = 0; |
378cc40b |
46 | $next = 0; |
8d063cd8 |
47 | while (<results>) { |
48 | if ($verbose) { |
49 | print $_; |
50 | } |
51 | unless (/^#/) { |
52 | if (/^1\.\.([0-9]+)/) { |
53 | $max = $1; |
54 | $next = 1; |
55 | $ok = 1; |
56 | } else { |
57 | if (/^ok (.*)/ && $1 == $next) { |
58 | $next = $next + 1; |
59 | } else { |
60 | $ok = 0; |
61 | } |
62 | } |
63 | } |
64 | } |
65 | $next = $next - 1; |
66 | if ($ok && $next == $max) { |
67 | print "ok\n"; |
68 | } else { |
69 | $next += 1; |
70 | print "FAILED on test $next\n"; |
71 | $bad = $bad + 1; |
72 | $_ = $test; |
73 | if (/^base/) { |
378cc40b |
74 | die "Failed a basic test--cannot continue.\n"; |
8d063cd8 |
75 | } |
76 | } |
77 | } |
78 | |
79 | if ($bad == 0) { |
80 | if ($ok) { |
81 | print "All tests successful.\n"; |
82 | } else { |
378cc40b |
83 | die "FAILED--no tests were run for some reason.\n"; |
8d063cd8 |
84 | } |
85 | } else { |
86 | if ($bad == 1) { |
378cc40b |
87 | die "Failed 1 test.\n"; |
8d063cd8 |
88 | } else { |
378cc40b |
89 | die "Failed $bad tests.\n"; |
8d063cd8 |
90 | } |
91 | } |
92 | ($user,$sys,$cuser,$csys) = times; |
93 | print sprintf("u=%g s=%g cu=%g cs=%g\n",$user,$sys,$cuser,$csys); |