New test.
[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 foreach $disabled (split (/ /, $disabled_tests)) {
16         if ($disabled eq $test) {
17                 print "disabled.\n";
18                 exit (0);
19         }
20 }
21
22 my $res = system("$interpreter @ARGV $test 2>$stderr 1>$stdout");
23
24 if ($res) {
25         printf ("failed $? (%d) signal (%d).\n", $? >> 8, $? & 127);
26         if (($? & 127) == 2) {
27                 exit (2);
28         } else {
29                 exit (1);
30         }
31 }
32 if (-f $output && (read_file ($output) ne read_file ($stdout))) {
33         print "failed output.\n";
34         exit (1);
35 }
36
37 print "pass.\n";
38 unlink ($stderr);
39 exit (0);
40
41 sub read_file {
42         local ($/);
43         my $out = shift;
44         open (F, "<$out") || die $!;
45         $out = <F>;
46         close(F);
47         return $out;
48 }