2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / tests / test-driver
1 #!/usr/bin/env perl 
2
3 my $interpreter = shift;
4 my $test = shift;
5 my $disabled_tests = shift;
6 my $output = $test;
7 my $stdout = $test.'.stdout';
8 my $stderr = $test.'.stderr';
9
10 $output =~ s/\.exe$/.output/;
11
12 $| = 0;
13 print "Testing $test... ";
14
15 if (index ($disabled_tests, $test) >= 0) {
16         print "disabled.\n";
17         exit (0);
18 }
19
20 my $res = system("$interpreter @ARGV $test 2>$stderr 1>$stdout");
21
22 if ($res) {
23         printf ("failed $? (%d) signal (%d).\n", $? >> 8, $? & 127);
24         if (($? & 127) == 2) {
25                 exit (2);
26         } else {
27                 exit (1);
28         }
29 }
30 if (-f $output && (read_file ($output) ne read_file ($stdout))) {
31         print "failed output.\n";
32         exit (1);
33 }
34
35 print "pass.\n";
36 unlink ($stderr);
37 exit (0);
38
39 sub read_file {
40         local ($/);
41         my $out = shift;
42         open (F, "<$out") || die $!;
43         $out = <F>;
44         close(F);
45         return $out;
46 }