#!/usr/bin/perl $run = shift or do { print STDERR <) { /^##\s*(.*)$/ and $out .= "$1\n"; } open (R, "$run < $fn 2>/dev/null |"); $real = ""; while () { $real .= $_; } $res = close(R); if ($out =~ /ERROR/) { if ($res) { print STDERR "WRONG! expected error\n"; $err++ } else { print STDERR "OK, got error\n"; } } else { if (!$res) { print STDERR "WRONG! expected success\n"; $err++ } elsif (! ($real eq $out)) { print STDERR "WRONG! answer, got $real, needed $out\n"; $err++; } else { print STDERR "OK\n"; # unlink("output.exe"); # system("il2 output.il >/dev/null"); # if (-f "output.exe") { # print STDERR "ilasm OK..."; # open (R, "mono output.exe < $fn |"); # $real = ""; # while () { # $real .= $_; # } # $res = close(R); # if ($real eq $out) { # print STDERR "OK\n"; # } else { # print STDERR "WRONG compiled output! ($real vs $out)\n"; # $err++; # } # }else { # print STDERR "ilasm FAILED\n"; # $err++; # } } } } if ($err == 0) { exit 0 } else { print STDERR "$err test(s) failed.\n"; exit 1 }