1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | ################################################################# |
---|
4 | # $Id$ |
---|
5 | # FILE: regress.cmd |
---|
6 | # PURPOSE: Script which runs regress test of Singular |
---|
7 | # CREATED: 2/16/98 |
---|
8 | # AUTHOR: obachman@mathematik.uni-kl.de |
---|
9 | |
---|
10 | ################################################################# |
---|
11 | # |
---|
12 | # usage |
---|
13 | # |
---|
14 | sub Usage |
---|
15 | { |
---|
16 | print <<_EOM_ |
---|
17 | Usage: |
---|
18 | regress.cmd -- regress test of Singular |
---|
19 | [-s <Singular>] -- use <Singular> as executable to test |
---|
20 | [-h] -- print out help and exit |
---|
21 | [-k] -- keep all intermediate files |
---|
22 | [-v num] -- set verbosity to num (used range 0..4, default: 2) |
---|
23 | [-g] -- generate result (*.res.gz.uu) files, only |
---|
24 | [-r [crit%[val]]] -- report if status differences [of crit] > val (in %) |
---|
25 | [-c regexp] -- when comparing results, version must match this regexp |
---|
26 | [-e [crit%[val]]] -- throw error if status difference [of crit] > val (in %) |
---|
27 | [-a [crit]] -- add status results [of crit] to result file |
---|
28 | [-m] -- add status result for current version to result file |
---|
29 | [-t] -- compute and call system("mtrack", 1) at the end, no diffs |
---|
30 | [-A num] -- set timeout [in sec.] for executed Singular |
---|
31 | [-tt max] -- compute and call system("mtrack", max) at the end |
---|
32 | [-T] -- simply compute and determine timmings, no diffs |
---|
33 | [file.lst] -- read tst files from file.lst |
---|
34 | [file.tst] -- test Singular script file.tst |
---|
35 | _EOM_ |
---|
36 | } |
---|
37 | |
---|
38 | ################################################################# |
---|
39 | # |
---|
40 | # used programs |
---|
41 | # |
---|
42 | $sh="/bin/sh"; |
---|
43 | $diff = "diff"; |
---|
44 | $gunzip = "gunzip"; |
---|
45 | $gzip = "gzip"; |
---|
46 | $rm = "rm"; |
---|
47 | $mv = "mv"; |
---|
48 | $cp = "cp"; |
---|
49 | $tr = "tr"; |
---|
50 | $sed = "sed"; |
---|
51 | $cat = "cat"; |
---|
52 | $tee = "tee"; |
---|
53 | $grep = "grep"; |
---|
54 | |
---|
55 | sub mysystem |
---|
56 | { |
---|
57 | local($call) = $_[0]; |
---|
58 | local($exit_status); |
---|
59 | |
---|
60 | $call =~ s/"/\\"/g; |
---|
61 | $call = "$sh -c \"$call\""; |
---|
62 | print "$call\n" if ($verbosity > 2); |
---|
63 | return (system $call); |
---|
64 | } |
---|
65 | |
---|
66 | sub mysystem_catch |
---|
67 | { |
---|
68 | local($call) = $_[0]; |
---|
69 | local($output) = ""; |
---|
70 | |
---|
71 | $call = "$call > catch_$$"; |
---|
72 | & mysystem($call); |
---|
73 | |
---|
74 | open(CATCH_FILE, "<catch_$$"); |
---|
75 | while (<CATCH_FILE>) |
---|
76 | { |
---|
77 | $output = $output.$_; |
---|
78 | } |
---|
79 | close(CATCH_FILE); |
---|
80 | & mysystem("$rm -f catch_$$"); |
---|
81 | return $output; |
---|
82 | } |
---|
83 | |
---|
84 | $WINNT = 1 if (&mysystem("uname -a | $grep CYGWIN > /dev/null 2>&1") == 0); |
---|
85 | $uuencode = "uuencode"; |
---|
86 | $uudecode = "uudecode"; |
---|
87 | |
---|
88 | # |
---|
89 | # flush stdout and stderr after every write |
---|
90 | # |
---|
91 | select(STDERR); |
---|
92 | $| = 1; |
---|
93 | select(STDOUT); |
---|
94 | $| = 1; |
---|
95 | |
---|
96 | ################################################################# |
---|
97 | # |
---|
98 | # the default settings |
---|
99 | # |
---|
100 | $singularOptions = "--ticks-per-sec=100 -teqsr12345678 --no-rc"; |
---|
101 | # for testing under Windows, remove "e" option above and compile |
---|
102 | # res files on Linux, then copy to Windows and compare. Otherwise |
---|
103 | # you have problems with diff on Win. Just uncomment the next line: |
---|
104 | # $singularOptions = "--ticks-per-sec=100 -tqsr12345678 --no-rc"; |
---|
105 | |
---|
106 | $keep = "no"; |
---|
107 | $verbosity = 2; |
---|
108 | $generate = "no"; |
---|
109 | $exit_code = 0; |
---|
110 | chop($curr_dir=`pwd`); |
---|
111 | # singular -- use the one in curr directory or the one found above |
---|
112 | $ext=".exe" if ($WINNT); |
---|
113 | $singular = "$curr_dir/Singular$ext"; |
---|
114 | if ( (! (-e $singular)) || (! (-x $singular))) |
---|
115 | { |
---|
116 | $singular = $curr_dir."/../Singular$ext"; |
---|
117 | } |
---|
118 | # timeout for Singular execution (in seconds!) |
---|
119 | $timeout = 0; |
---|
120 | # sed scripts which are applied to res files before they are diff'ed |
---|
121 | $sed_scripts = "-e '/used time:/d' -e '/tst_ignore:/d' -e '/Id[:\$]/d' -e '/error occurred in/d' -e '/tst_status/d' -e'/init >>/d' -e 's/\\[[0-9]*:[0-9]*\\]//g'"; |
---|
122 | # default value (in %) above which differences are reported on -r |
---|
123 | $report_val = 5; |
---|
124 | # default value (in %) above which differences cause an error on -e |
---|
125 | $error_val = 5; |
---|
126 | # default value in 1/100 seconds, above which time differences are reported |
---|
127 | $mintime_val = 100; |
---|
128 | $hostname = &mysystem_catch("hostname"); |
---|
129 | chop $hostname; |
---|
130 | |
---|
131 | ################################################################# |
---|
132 | # |
---|
133 | # auxiallary routines |
---|
134 | # |
---|
135 | |
---|
136 | sub GetSingularVersionDate |
---|
137 | { |
---|
138 | &mysystem("$singular -t -v --execute=\"exit;\"> SingularVersionDate"); |
---|
139 | open(FD, "<SingularVersionDate"); |
---|
140 | while (<FD>) |
---|
141 | { |
---|
142 | $singular_uname = (/for\s+([^\s]*)\s+/ ? $1 : "uname"); |
---|
143 | $singular_version = (/version\s+([^\s]*)\s+/ ? $1 : "0-0-0"); |
---|
144 | $singular_date = (/\((.*)\)/ ? $1 : "1970010100"); |
---|
145 | $this_time = time; |
---|
146 | last; |
---|
147 | } |
---|
148 | close(FD); |
---|
149 | } |
---|
150 | |
---|
151 | sub Set_withMP |
---|
152 | { |
---|
153 | if (! $withMP) |
---|
154 | { |
---|
155 | $withMP = "no"; |
---|
156 | open(MP_TEST, ">MPTest"); |
---|
157 | print(MP_TEST "system(\"with\", \"MP\"); \$"); |
---|
158 | close(MP_TEST); |
---|
159 | &mysystem("$singular -qt MPTest > withMPtest"); |
---|
160 | if (open(MP_TEST, "<withMPtest")) |
---|
161 | { |
---|
162 | $_ = <MP_TEST>; |
---|
163 | $withMP = "yes" if (/^1/); |
---|
164 | close(MP_TEST); |
---|
165 | } |
---|
166 | &mysystem("$rm -f withMPtest MPTest"); |
---|
167 | } |
---|
168 | } |
---|
169 | |
---|
170 | |
---|
171 | sub MPok |
---|
172 | { |
---|
173 | local($root) = $_[0]; |
---|
174 | |
---|
175 | if (! open(TST_FILE, "<$root.tst")) |
---|
176 | { |
---|
177 | print (STDERR "Can not open $root.tst for reading\n"); |
---|
178 | return (0); |
---|
179 | } |
---|
180 | while (<TST_FILE>) |
---|
181 | { |
---|
182 | if (/\"MP.+:.*\"/) |
---|
183 | { |
---|
184 | &Set_withMP; |
---|
185 | return (0) if ($withMP eq "no"); |
---|
186 | } |
---|
187 | } |
---|
188 | return (1); |
---|
189 | } |
---|
190 | |
---|
191 | sub Diff |
---|
192 | { |
---|
193 | local($root) = $_[0]; |
---|
194 | local($exit_status); |
---|
195 | |
---|
196 | # prepare the result files: |
---|
197 | &mysystem("$cat \"$root.res\" | $tr -d '\\013' | $sed $sed_scripts > \"$root.res.cleaned\""); |
---|
198 | &mysystem("$cat \"$root.new.res\" | $tr -d '\\013' | $sed $sed_scripts > \"$root.new.res.cleaned\""); |
---|
199 | |
---|
200 | # doo the diff call |
---|
201 | $exit_status = &mysystem("$diff -w -b \"$root.res.cleaned\" \"$root.new.res.cleaned\" > \"$root.diff\" 2>&1"); |
---|
202 | |
---|
203 | # clean up time |
---|
204 | &mysystem("$rm -f \"$root.res.cleaned\" \"$root.new.res.cleaned\""); |
---|
205 | |
---|
206 | # there seems to be a bug here somewhere: even if diff reported |
---|
207 | # differenceses and exited with status != 0, then system still |
---|
208 | # returns exit status 0. Hence we manually need to find out whether |
---|
209 | # or not differences were reported: |
---|
210 | # iff diff-file exists and has non-zero size |
---|
211 | $exit_status = $exit_status || (-e "$root.diff" && -s "$root.diff"); |
---|
212 | |
---|
213 | return($exit_status); |
---|
214 | } |
---|
215 | |
---|
216 | sub tst_status_check |
---|
217 | { |
---|
218 | local($root) = $_[0]; |
---|
219 | local($line,$new_line,$prefix,$crit,$res,$new_res); |
---|
220 | local($res_diff,$res_diff_pc,$res_diff_line); |
---|
221 | my($exit_status, $reported) = (0, 0); |
---|
222 | local($error_cause) = ""; |
---|
223 | |
---|
224 | open(RES_FILE, "<$root.stat") || |
---|
225 | return (1, "Can not open $root.stat \n"); |
---|
226 | open(NEW_RES_FILE, "<$root.new.stat") || |
---|
227 | return (1, "Can not open $root.new.stat \n"); |
---|
228 | open(STATUS_DIFF_FILE, ">$root.stat.sdiff") || |
---|
229 | return (1, "Can not open $root.stat.sdiff \n"); |
---|
230 | |
---|
231 | while (1) |
---|
232 | { |
---|
233 | while ($new_line = <NEW_RES_FILE>) |
---|
234 | { |
---|
235 | last if $new_line =~ /(\d+) >> (\w+) ::.*$hostname:(\d+)/ && $checks{$2}; |
---|
236 | } |
---|
237 | last unless $new_line =~ /(\d+) >> (\w+) ::.*$hostname:(\d+)/; |
---|
238 | $prefix = $1; |
---|
239 | $crit = $2; |
---|
240 | $new_res = $3; |
---|
241 | next unless $new_res > $mintime_val; |
---|
242 | |
---|
243 | while ($line = <RES_FILE>) |
---|
244 | { |
---|
245 | last if $line =~ /$prefix >> $crit ::.*?$hostname:(\d+)/; |
---|
246 | } |
---|
247 | last unless $line =~ /$prefix >> $crit ::.*?$hostname:(\d+)/; |
---|
248 | my $res_version; |
---|
249 | $res = 0; |
---|
250 | |
---|
251 | # search for smallest |
---|
252 | while ($line =~ /([^\s]*)$hostname:(\d+)/g) |
---|
253 | { |
---|
254 | my $this_res = $2; |
---|
255 | my $this_res_version = $1; |
---|
256 | if ((!$res || $this_res <= $res) && (!$status_check_regexp || $this_res_version =~ /$status_check_regexp/)) |
---|
257 | { |
---|
258 | $res = $this_res; |
---|
259 | $res_version = $this_res_version; |
---|
260 | } |
---|
261 | } |
---|
262 | next unless $res; |
---|
263 | $res_diff = $new_res - $res; |
---|
264 | $res_diff_pc = int((($new_res / $res) - 1)*100); |
---|
265 | $res_diff_line = |
---|
266 | "$prefix >> $crit :: new:$new_res old:$res_version$res diff:$res_diff %:$res_diff_pc\n"; |
---|
267 | print STATUS_DIFF_FILE $res_diff_line; |
---|
268 | |
---|
269 | if ((defined($error{$crit}) && $error{$crit}<abs($res_diff_pc)) |
---|
270 | || |
---|
271 | (defined($report{$crit}) && $report{$crit}<abs($res_diff_pc))) |
---|
272 | { |
---|
273 | print "$prefix >> $crit :: new:$new_res old:$res diff:$res_diff %:$res_diff_pc\n" |
---|
274 | if ($verbosity > 0); |
---|
275 | } |
---|
276 | |
---|
277 | if ($exit_status == 0) |
---|
278 | { |
---|
279 | $exit_status = (defined($error{$crit}) |
---|
280 | && $error{$crit} < abs($res_diff_pc)); |
---|
281 | $error_cause = "Status error for $crit at $prefix\n" |
---|
282 | if ($exit_status); |
---|
283 | } |
---|
284 | } |
---|
285 | close(RES_FILE); |
---|
286 | close(NEW_RES_FILE); |
---|
287 | close(STATUS_DIFF_FILE); |
---|
288 | return ($exit_status, $error_cause); |
---|
289 | } |
---|
290 | |
---|
291 | sub tst_status_merge |
---|
292 | { |
---|
293 | local($root) = $_[0]; |
---|
294 | local($line, $new_line, $crit, $res); |
---|
295 | |
---|
296 | GetSingularVersionDate() |
---|
297 | unless $singular_version; |
---|
298 | |
---|
299 | if (! -e "$root.stat") |
---|
300 | { |
---|
301 | open(RES_FILE, ">$root.stat") || |
---|
302 | return (1, "Can not open $root.stat \n"); |
---|
303 | open(NEW_RES_FILE, "<$root.new.stat") || |
---|
304 | return (1, "Can not open $root.new.stat \n"); |
---|
305 | |
---|
306 | while (<NEW_RES_FILE>) |
---|
307 | { |
---|
308 | if (/(\d+) >> (\w+) :: /) |
---|
309 | { |
---|
310 | s/$hostname:(\d+)/$this_time:$singular_date:$singular_version:$singular_uname:$hostname:$1/g; |
---|
311 | print RES_FILE $_; |
---|
312 | } |
---|
313 | } |
---|
314 | close(RES_FILE); |
---|
315 | close(NEW_RES_FILE); |
---|
316 | return; |
---|
317 | } |
---|
318 | |
---|
319 | open(RES_FILE, "<$root.stat") || |
---|
320 | return (1, "Can not open $root.stat \n"); |
---|
321 | open(NEW_RES_FILE, "<$root.new.stat") || |
---|
322 | return (1, "Can not open $root.new.stat \n"); |
---|
323 | open(TEMP_FILE, ">$root.tmp.stat") || |
---|
324 | return (1, "Can not open $root.tmp.stat \n"); |
---|
325 | |
---|
326 | while (1) |
---|
327 | { |
---|
328 | while (($new_line = <NEW_RES_FILE>) && $new_line !~ /(\d+) >> (\w+) ::/){} |
---|
329 | last unless $new_line =~ /(\d+) >> (\w+) ::.*$hostname:(\d+)/; |
---|
330 | my $prefix = $1; |
---|
331 | my $crit = $2; |
---|
332 | my $new_res = "$this_time:$singular_date:$singular_version:$singular_uname:$hostname:$3"; |
---|
333 | while (($line = <RES_FILE>) && $line !~ /$prefix >> $crit ::/){} |
---|
334 | unless ($line) |
---|
335 | { |
---|
336 | close(RES_FILE); |
---|
337 | close(NEW_RES_FILE); |
---|
338 | close(TEMP_FILE); |
---|
339 | &mysystem("$rm \"$root.tmp.stat\""); |
---|
340 | return (1, "Can not find '$prefix >> $crit' in $root.stat\n"); |
---|
341 | } |
---|
342 | if ($merge_version) |
---|
343 | { |
---|
344 | $line =~ s/[^ ]*:$singular_version:$singular_uname:$hostname:\d+//g; |
---|
345 | chop $line; |
---|
346 | $line .= " $new_res\n"; |
---|
347 | } |
---|
348 | else |
---|
349 | { |
---|
350 | chop $line; |
---|
351 | $line .= " $new_res\n"; |
---|
352 | } |
---|
353 | print TEMP_FILE $line; |
---|
354 | } |
---|
355 | |
---|
356 | close(RES_FILE); |
---|
357 | close(NEW_RES_FILE); |
---|
358 | close(TEMP_FILE); |
---|
359 | &mysystem("$mv -f \"$root.tmp.stat\" \"$root.stat\""); |
---|
360 | &mysystem("$rm -f \"$root.new.stat\" \"$root.stat.sdiff\"") unless $keep eq "yes"; |
---|
361 | return ; |
---|
362 | } |
---|
363 | |
---|
364 | sub tst_check |
---|
365 | { |
---|
366 | local($root) = $_[0]; |
---|
367 | local($system_call, $exit_status, $ignore_pattern, $error_cause); |
---|
368 | |
---|
369 | print "--- $root " unless ($verbosity == 0); |
---|
370 | $total_checks++; |
---|
371 | |
---|
372 | # check for existence/readablity of tst and res file |
---|
373 | if (! (-r "$root.tst")) |
---|
374 | { |
---|
375 | print (STDERR "Can not read $root.tst\n"); |
---|
376 | return (1); |
---|
377 | } |
---|
378 | |
---|
379 | # ignore MP stuff, if this singular does not have MP |
---|
380 | if (! &MPok($root)) |
---|
381 | { |
---|
382 | print "Warning: $root not tested: needs MP\n"; |
---|
383 | return (0); |
---|
384 | } |
---|
385 | |
---|
386 | # generate $root.res |
---|
387 | if ($generate ne "yes" && ! defined($mtrack) && !defined($timings_only)) |
---|
388 | { |
---|
389 | if ((-r "$root.res.gz.uu") && ! ( -z "$root.res.gz.uu")) |
---|
390 | { |
---|
391 | $exit_status = &mysystem("$uudecode \"$root.res.gz.uu\" > /dev/null 2>&1; $gunzip -f \"$root.res.gz\""); |
---|
392 | if ($exit_status) |
---|
393 | { |
---|
394 | print (STDERR "Can not decode $root.res.gz.uu\n"); |
---|
395 | return ($exit_status); |
---|
396 | } |
---|
397 | } |
---|
398 | elsif (! (-r "$root.res") || ( -z "$root.res")) |
---|
399 | { |
---|
400 | print (STDERR "Can not read $root.res[.gz.uu]\n"); |
---|
401 | return (1); |
---|
402 | } |
---|
403 | } |
---|
404 | |
---|
405 | my $resfile = "\"$root.new.res\""; |
---|
406 | $resfile = "\"$root.mtrack.res\"" if (defined($mtrack)); |
---|
407 | my $statfile = "$root.new.stat"; |
---|
408 | &mysystem("$rm -f \"$statfile\""); |
---|
409 | if (defined($mtrack)) |
---|
410 | { |
---|
411 | $system_call = "$cat \"$root.tst\" | sed -e 's/\\\\\$/LIB \"general.lib\"; killall(); killall(\"proc\");kill killall;system(\"mtrack\", \"$root.mtrack.unused\", $mtrack); \\\$/' | $singular $singularOptions "; |
---|
412 | $system_call .= ($verbosity > 3 ? " | $tee " : " > "); |
---|
413 | $system_call .= "\"$root.mtrack.res\""; |
---|
414 | $system_call .= " 2>&1 " if ($verbosity <= 3); |
---|
415 | } |
---|
416 | else |
---|
417 | { |
---|
418 | |
---|
419 | # prepare Singular run |
---|
420 | if ($verbosity > 3 && !$WINNT) |
---|
421 | { |
---|
422 | $system_call = "$cat \"$root.tst\" | $singular --execute 'string tst_status_file=\"$statfile\";' $singularOptions | $tee $resfile"; |
---|
423 | } |
---|
424 | else |
---|
425 | { |
---|
426 | $system_call = "$cat \"$root.tst\" | $singular --execute 'string tst_status_file=\"$statfile\";' $singularOptions > $resfile 2>&1"; |
---|
427 | } |
---|
428 | } |
---|
429 | # Go Singular, Go! |
---|
430 | |
---|
431 | my ($user_t,$system_t,$cuser_t,$csystem_t) = times; |
---|
432 | $exit_status = &mysystem($system_call); |
---|
433 | my ($user_t,$system_t,$cuser_t2,$csystem_t2) = times; |
---|
434 | $cuser_t = $cuser_t2 - $cuser_t; |
---|
435 | $csystem_t = $csystem_t2 - $csystem_t; |
---|
436 | if ($exit_status != 0) |
---|
437 | { |
---|
438 | $error_cause = "Singular call exited with status != 0"; |
---|
439 | } |
---|
440 | else |
---|
441 | { |
---|
442 | # check for Segment fault in res file |
---|
443 | $exit_status = ! (&mysystem("$grep \"Segment fault\" $resfile > /dev/null 2>&1")); |
---|
444 | |
---|
445 | if ($exit_status) |
---|
446 | { |
---|
447 | $error_cause = "Segment fault"; |
---|
448 | } |
---|
449 | elsif (! defined($mtrack) && !defined($timings_only)) |
---|
450 | { |
---|
451 | &mysystem("$rm -f \"$root.diff\""); |
---|
452 | if ($generate eq "yes") |
---|
453 | { |
---|
454 | &mysystem("$cp $resfile \"$root.res\""); |
---|
455 | } |
---|
456 | else |
---|
457 | { |
---|
458 | # call Diff |
---|
459 | $exit_status = &Diff($root); |
---|
460 | if ($exit_status) |
---|
461 | { |
---|
462 | unless ($verbosity == 0) |
---|
463 | { |
---|
464 | print "\n"; |
---|
465 | mysystem("$cat \"$root.diff\""); |
---|
466 | } |
---|
467 | $error_cause = "Differences in res files"; |
---|
468 | } |
---|
469 | else |
---|
470 | { |
---|
471 | &mysystem("$rm -f \"$root.diff\""); |
---|
472 | } |
---|
473 | } |
---|
474 | } |
---|
475 | } |
---|
476 | |
---|
477 | |
---|
478 | |
---|
479 | mysystem("mv tst_status.out \"$statfile\"") |
---|
480 | if (! -e $statfile && -e "tst_status.out"); |
---|
481 | |
---|
482 | if (%checks && ! $exit_status && $generate ne "yes" && ! defined($mtrack)) |
---|
483 | { |
---|
484 | if (-e "$statfile") |
---|
485 | { |
---|
486 | # do status checks |
---|
487 | ($exit_status, $error_cause) = & tst_status_check($root); |
---|
488 | } |
---|
489 | else |
---|
490 | { |
---|
491 | print "Warning: no file $statfile\n"; |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | |
---|
496 | # complain even if verbosity == 0 |
---|
497 | if ($exit_status) |
---|
498 | { |
---|
499 | if (! -e "$root.diff") |
---|
500 | { |
---|
501 | open (DIFF_FILE, ">$root.diff"); |
---|
502 | print DIFF_FILE "!!! $root : $error_cause\n"; |
---|
503 | print "\n"; |
---|
504 | } |
---|
505 | print STDERR "!!! $root : $error_cause\n"; |
---|
506 | } |
---|
507 | else |
---|
508 | { |
---|
509 | unless (defined($mtrack)) |
---|
510 | { |
---|
511 | #clean up |
---|
512 | if ($generate eq "yes") |
---|
513 | { |
---|
514 | mysystem("$rm -f \"$root.stat\"") unless %merge; |
---|
515 | ($exit_status, $error_cause) = tst_status_merge($root); |
---|
516 | if (! $WINNT) |
---|
517 | { |
---|
518 | &mysystem("$gzip -cf \"$root.res\" | $uuencode \"$root.res.gz\" > \"$root.res.gz.uu\""); |
---|
519 | } |
---|
520 | else |
---|
521 | { |
---|
522 | # uuencode is broken under windows |
---|
523 | print "Warning: Can not generate $root.res.gz.uu under Windows\n"; |
---|
524 | } |
---|
525 | } |
---|
526 | elsif (%merge) |
---|
527 | { |
---|
528 | ($exit_status, $error_cause) = & tst_status_merge($root); |
---|
529 | |
---|
530 | print (STDERR "Warning: Merge Problems: $error_cause\n") |
---|
531 | if ($verbosity > 0 && $exit_status); |
---|
532 | } |
---|
533 | } |
---|
534 | if ($keep ne "yes") |
---|
535 | { |
---|
536 | &mysystem("$rm -f tst_status.out $resfile \"$root.res\" \"$root.diff\" \"$root.new.stat\""); |
---|
537 | } |
---|
538 | } |
---|
539 | # und tschuess |
---|
540 | unless ($verbosity == 0 || $exit_status) |
---|
541 | { |
---|
542 | if ($verbosity > 1 || $timings_only) |
---|
543 | { |
---|
544 | my $used_time = $cuser_t + $csystem_t; |
---|
545 | $total_used_time += $used_time; |
---|
546 | $lst_used_time += $used_time; |
---|
547 | print " " x (23 - length($root)); |
---|
548 | printf("%.2f", $used_time); |
---|
549 | } |
---|
550 | print " \n"; |
---|
551 | } |
---|
552 | $total_checks_pass++ unless $exit_status; |
---|
553 | |
---|
554 | mysystem("mv gmon.out \"gmon.$root.out\"") |
---|
555 | if (-e "gmon.out"); |
---|
556 | |
---|
557 | return ($exit_status); |
---|
558 | } |
---|
559 | |
---|
560 | |
---|
561 | ################################################################# |
---|
562 | # |
---|
563 | # Main program |
---|
564 | # |
---|
565 | |
---|
566 | # process switches |
---|
567 | while ($ARGV[0] =~ /^-/) |
---|
568 | { |
---|
569 | $_ = shift; |
---|
570 | if (/^-s$/) |
---|
571 | { |
---|
572 | $singular = shift; |
---|
573 | } |
---|
574 | elsif (/^-h$/) |
---|
575 | { |
---|
576 | &Usage && exit (0); |
---|
577 | } |
---|
578 | elsif (/^-k$/) |
---|
579 | { |
---|
580 | $keep = "yes"; |
---|
581 | } |
---|
582 | elsif (/^-g$/) |
---|
583 | { |
---|
584 | $generate = "yes"; |
---|
585 | } |
---|
586 | elsif(/^-v$/) |
---|
587 | { |
---|
588 | $verbosity = shift; |
---|
589 | } |
---|
590 | elsif (/^-tt/) |
---|
591 | { |
---|
592 | $mtrack = shift; |
---|
593 | } |
---|
594 | elsif (/^-A/) |
---|
595 | { |
---|
596 | $timeout = shift; |
---|
597 | } |
---|
598 | elsif(/^-t$/) |
---|
599 | { |
---|
600 | $mtrack = 1; |
---|
601 | } |
---|
602 | elsif (/^-T/) |
---|
603 | { |
---|
604 | $timings_only = 1; |
---|
605 | } |
---|
606 | elsif(/^-r$/) |
---|
607 | { |
---|
608 | $crit = "all"; |
---|
609 | $val = $report_val; |
---|
610 | if ($ARGV[0] =~ /.*%.*/) |
---|
611 | { |
---|
612 | ($crit, $val) = split(/%/, shift); |
---|
613 | } |
---|
614 | elsif ($ARGV[0] && |
---|
615 | $ARGV[0] !~ /^-/ && $ARGV[0] !~ /.*\.tst/ && $ARGV[0] !~ /.*\.lst/) |
---|
616 | { |
---|
617 | $crit = shift; |
---|
618 | } |
---|
619 | if ($crit eq "all") |
---|
620 | { |
---|
621 | $report{"tst_memory_0"} = $val; |
---|
622 | $report{"tst_memory_1"} = $val; |
---|
623 | $report{"tst_memory_2"} = $val; |
---|
624 | $report{"tst_timer"} = $val; |
---|
625 | $report{"tst_timer_1"} = $val; |
---|
626 | $checks{"tst_memory_0"} = 1; |
---|
627 | $checks{"tst_memory_1"} = 1; |
---|
628 | $checks{"tst_memory_2"} = 1; |
---|
629 | $checks{"tst_timer"} = 1; |
---|
630 | $checks{"tst_timer_1"} = 1; |
---|
631 | } |
---|
632 | else |
---|
633 | { |
---|
634 | $report{$crit} = $val; |
---|
635 | $checks{$crit} = 1; |
---|
636 | } |
---|
637 | } |
---|
638 | elsif(/^-e$/) |
---|
639 | { |
---|
640 | $crit = "all"; |
---|
641 | $val = $error_val; |
---|
642 | if ($ARGV[0] =~ /.*%.*/) |
---|
643 | { |
---|
644 | ($crit, $val) = split(/%/, shift); |
---|
645 | } |
---|
646 | elsif ($ARGV[0] && |
---|
647 | $ARGV[0] !~ /^-/ && $ARGV[0] !~ /.*\.tst/ && $ARGV[0] !~ /.*\.lst/) |
---|
648 | { |
---|
649 | $crit = shift; |
---|
650 | } |
---|
651 | if ($crit eq "all") |
---|
652 | { |
---|
653 | $error{"tst_memory_0"} = $val; |
---|
654 | $error{"tst_memory_1"} = $val; |
---|
655 | $error{"tst_memory_2"} = $val; |
---|
656 | $error{"tst_timer"} = $val; |
---|
657 | $error{"tst_timer_1"} = $val; |
---|
658 | $checks{"tst_memory_0"} = 1; |
---|
659 | $checks{"tst_memory_1"} = 1; |
---|
660 | $checks{"tst_memory_2"} = 1; |
---|
661 | $checks{"tst_timer"} = 1; |
---|
662 | $checks{"tst_timer_1"} = 1; |
---|
663 | } |
---|
664 | else |
---|
665 | { |
---|
666 | $error{$crit} = $val; |
---|
667 | $checks{$crit} = 1; |
---|
668 | } |
---|
669 | } |
---|
670 | elsif(/^-a/ || /^-m/) |
---|
671 | { |
---|
672 | $merge_version = 1 if /^-m/; |
---|
673 | if ($ARGV[0] && |
---|
674 | $ARGV[0] !~ /^-/ && $ARGV[0] !~ /.*\.tst/ && $ARGV[0] !~ /.*\.lst/) |
---|
675 | { |
---|
676 | $crit = shift; |
---|
677 | $merge{$crit} = 1; |
---|
678 | } |
---|
679 | else |
---|
680 | { |
---|
681 | $merge{"tst_memory_0"} = 1; |
---|
682 | $merge{"tst_memory_1"} = 1; |
---|
683 | $merge{"tst_memory_2"} = 1; |
---|
684 | $merge{"tst_timer"} = 1; |
---|
685 | $merge{"tst_timer_1"} = 1; |
---|
686 | } |
---|
687 | } |
---|
688 | elsif (/^-c/) |
---|
689 | { |
---|
690 | $status_check_regexp = shift; |
---|
691 | } |
---|
692 | else |
---|
693 | { |
---|
694 | print (STDERR "Unrecognised option: $_\n") && &Usage && die; |
---|
695 | } |
---|
696 | } |
---|
697 | |
---|
698 | # if no command line arguments are left, use regress.lst |
---|
699 | if ($#ARGV == -1) |
---|
700 | { |
---|
701 | $ARGV[0] = "regress.lst"; |
---|
702 | } |
---|
703 | |
---|
704 | # make sure $singular exists and is executable |
---|
705 | $singular = "$curr_dir/$singular" unless ($singular =~ /^\/.*/); |
---|
706 | |
---|
707 | if ( ! (-e $singular)) |
---|
708 | { |
---|
709 | $singular = "$singular$ext" if ($WINNT && $singular !~ /.*$ext$/); |
---|
710 | } |
---|
711 | |
---|
712 | if ( ! (-e $singular)) |
---|
713 | { |
---|
714 | print (STDERR "Can not find $singular \n") && &Usage && die; |
---|
715 | } |
---|
716 | |
---|
717 | if (! (-x $singular) && (! WINNT)) |
---|
718 | { |
---|
719 | print (STDERR "Can not execute $singular \n") && &Usage && die; |
---|
720 | } |
---|
721 | if (-d $singular) |
---|
722 | { |
---|
723 | print (STDERR "$singular is a directory\n") && &Usage && die; |
---|
724 | } |
---|
725 | |
---|
726 | |
---|
727 | if ($timeout > 0) |
---|
728 | { |
---|
729 | $singular = "perl -e 'alarm $timeout; exec \@ARGV' $singular"; |
---|
730 | print ("Set exec timeout to $timeout sec.\n") if ($verbosity > 1); |
---|
731 | # die; |
---|
732 | } |
---|
733 | # now do the work |
---|
734 | foreach (@ARGV) |
---|
735 | { |
---|
736 | |
---|
737 | if ( /^(.*)\.([^\.\/]*)$/ ) |
---|
738 | { |
---|
739 | $_ = $1; |
---|
740 | $extension = $2; |
---|
741 | } |
---|
742 | |
---|
743 | if ( /^(.*)\/([^\/]*)$/ ) |
---|
744 | { |
---|
745 | $path = $1; |
---|
746 | $base = $2; |
---|
747 | chdir($path); |
---|
748 | print "cd $path\n" if ($verbosity > 2); |
---|
749 | } |
---|
750 | else |
---|
751 | { |
---|
752 | $path = ""; |
---|
753 | $base = $_; |
---|
754 | } |
---|
755 | $file = "$base.$extension"; |
---|
756 | chop ($tst_curr_dir = `pwd`); |
---|
757 | |
---|
758 | if ($extension eq "tst") |
---|
759 | { |
---|
760 | $exit_code = &tst_check($base) || $exit_code; |
---|
761 | } |
---|
762 | elsif ($extension eq "lst") |
---|
763 | { |
---|
764 | |
---|
765 | if (! open(LST_FILE, "<$file")) |
---|
766 | { |
---|
767 | print (STDERR "Can not open $path/$file for reading\n"); |
---|
768 | $exit_code = 1; |
---|
769 | next; |
---|
770 | } |
---|
771 | $lst_used_time = 0; |
---|
772 | $lst_checks = 0; |
---|
773 | $lst_checks_pass = 0; |
---|
774 | while (<LST_FILE>) |
---|
775 | { |
---|
776 | if (/^;/) # ignore lines starting with ; |
---|
777 | { |
---|
778 | print unless ($verbosity == 0); |
---|
779 | next; |
---|
780 | } |
---|
781 | next if (/^\s*$/); #ignore whitespaced lines |
---|
782 | chop if (/\n$/); #chop of \n |
---|
783 | |
---|
784 | $_ = $1 if (/^(.*)\.([^\.\/]*)$/ ); # chop of extension |
---|
785 | if ( /^(.*)\/([^\/]*)$/ ) |
---|
786 | { |
---|
787 | $tst_path = $1; |
---|
788 | $tst_base = $2; |
---|
789 | chdir($tst_path); |
---|
790 | print "cd $tst_path\n" if ($verbosity > 2); |
---|
791 | } |
---|
792 | else |
---|
793 | { |
---|
794 | $tst_path = ""; |
---|
795 | $tst_base = $_; |
---|
796 | } |
---|
797 | $tst_base =~ s/^\s*//; |
---|
798 | $tst_base =~ s/(.*?)\s+.*/$1/; |
---|
799 | $lst_checks++; |
---|
800 | my $this_exit_code = &tst_check($tst_base); |
---|
801 | $lst_checks_pass++ unless $this_exit_code; |
---|
802 | $exit_code = $this_exit_code || $exit_code; |
---|
803 | |
---|
804 | if ($tst_path ne "") |
---|
805 | { |
---|
806 | chdir($tst_curr_dir); |
---|
807 | print "cd $tst_curr_dir\n" if ($verbosity > 2); |
---|
808 | } |
---|
809 | } |
---|
810 | close (LST_FILE); |
---|
811 | printf("$base Summary: Checks:$lst_checks Failed:%d Time:%.2f\n", $lst_checks - $lst_checks_pass, $lst_used_time) |
---|
812 | unless ($verbosity < 2) |
---|
813 | } |
---|
814 | else |
---|
815 | { |
---|
816 | print (STDERR "Unknown extension of $_: Need extension lst or tst\n"); |
---|
817 | $exit_code = 1; |
---|
818 | } |
---|
819 | if ($path ne "") |
---|
820 | { |
---|
821 | chdir($curr_dir); |
---|
822 | print "cd $curr_dir\n" if ($verbosity > 2); |
---|
823 | } |
---|
824 | } |
---|
825 | |
---|
826 | unless ($verbosity < 2 || $lst_checks == $total_checks) |
---|
827 | { |
---|
828 | printf("Summary: Checks:$total_checks Failed:%d Time:%.2f\n", $total_checks - $total_checks_pass, $total_used_time); |
---|
829 | } |
---|
830 | |
---|
831 | # Und Tschuess |
---|
832 | exit $exit_code; |
---|
833 | |
---|
834 | |
---|