1
0
mirror of https://github.com/fachat/xa65.git synced 2024-09-08 16:54:32 +00:00
xa65/xa/tests/harness
Andre Fachat c0f334bac9 beta1
2023-10-25 11:42:14 +02:00

88 lines
1.9 KiB
Perl
Executable File

#!/usr/bin/perl -s
$cc ||= "cc";
$make ||= "make";
$cflags ||= '';
$makeflags ||= '';
# defeat multiple jobs, this doesn't do parallel right now
#$make =~ s/-j\d*(\s|$)//;
#$make =~ s/--jobserver-[^\s]+//;
#$makeflags =~ s/-j\d*(\s|$)//;
#$makeflags =~ s/--jobserver-[^\s]+//;
$ENV{'CC'} = $cc;
$ENV{'MAKE'} = $make;
$ENV{'CFLAGS'} = $cflags;
$ENV{'MFLAGS'} = $makeflags;
$ENV{'MAKEFLAGS'} = $makeflags;
$|++;
$ntests = 0;
$dtests = $tests || "ALL";
$tests = '' if ($tests eq "ALL");
print <<"EOF";
CC = $cc
CFLAGS = $cflags
MAKE = $make
MAKEFLAGS = $makeflags
tests to run: $dtests
EOF
# Get a list of all directories. If there is a Makefile there, do it.
# If there is not, see if there is an .s file and an ok binary to cmp to.
# Otherwise, do nothing (acknowledge and ignore directories we don't grok).
opendir(D, ".") || die("test harness failed: $!\n");
W: while($x = readdir(D)) {
next W if ($x =~ /^\./);
next W if (length($tests) && ($tests !~ /$x/));
next W if (!chdir($x));
$x = substr($x . " " . ("." x 79), 0, 50);
print STDOUT "$x > ";
if (-e "Makefile") {
print STDOUT "running Makefile\n";
print STDOUT "=" x 79, "\n";
system("$make clean");
print STDOUT "-" x 79, "\n";
system("$make");
print STDOUT "-" x 79, "\n";
if ($?) {
print STDOUT "## FAILURE (make clean NOT run) ##\n";
exit 1;
}
system("$make clean");
print STDOUT "=" x 35, " PASSED! ", "=" x 35, "\n";
$ntests++;
} elsif (-e "ok" && -e "test.s") {
unlink("a.o65");
&failed("../../xa test.s");
&failed("../hextool -cmp=ok < a.o65");
unlink("a.o65");
print STDOUT "PASSED\n";
$ntests++;
} else {
print STDOUT "ignored\n";
}
chdir("..");
}
closedir(D);
print STDOUT "=" x 79, "\n";
if ($ntests) { # ntestacy is a terrible thing
print STDOUT "\n## ALL SELECTED TESTS PASS ($dtests, n=$ntests) ##\n";
exit 0;
}
print STDOUT "\n## NO TESTS WERE RUN ##\n";
exit 1;
sub failed {
system(@_);
if ($?) {
print STDOUT "## FAILURE ##\n";
exit 1;
}
}