2014-08-20 19:53:15 +00:00
|
|
|
#!/usr/bin/perl -s
|
|
|
|
|
|
|
|
$cc ||= "cc";
|
2023-10-25 09:42:14 +00:00
|
|
|
$make ||= "make";
|
2014-08-20 19:53:15 +00:00
|
|
|
$cflags ||= '';
|
2023-10-25 09:42:14 +00:00
|
|
|
$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]+//;
|
|
|
|
|
2014-08-20 19:53:15 +00:00
|
|
|
$ENV{'CC'} = $cc;
|
2023-10-25 09:42:14 +00:00
|
|
|
$ENV{'MAKE'} = $make;
|
2014-08-20 19:53:15 +00:00
|
|
|
$ENV{'CFLAGS'} = $cflags;
|
2023-10-25 09:42:14 +00:00
|
|
|
$ENV{'MFLAGS'} = $makeflags;
|
|
|
|
$ENV{'MAKEFLAGS'} = $makeflags;
|
2014-08-20 19:53:15 +00:00
|
|
|
$|++;
|
|
|
|
|
2023-02-11 13:09:07 +00:00
|
|
|
$ntests = 0;
|
2014-08-20 19:53:15 +00:00
|
|
|
$dtests = $tests || "ALL";
|
2023-02-11 13:09:07 +00:00
|
|
|
$tests = '' if ($tests eq "ALL");
|
2014-08-20 19:53:15 +00:00
|
|
|
|
|
|
|
print <<"EOF";
|
|
|
|
CC = $cc
|
|
|
|
CFLAGS = $cflags
|
|
|
|
MAKE = $make
|
2023-10-25 09:42:14 +00:00
|
|
|
MAKEFLAGS = $makeflags
|
2014-08-20 19:53:15 +00:00
|
|
|
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");
|
2023-11-14 20:32:35 +00:00
|
|
|
while($x = readdir(D)) {
|
|
|
|
next if ($x =~ /^\./ || $x =~ /\s/);
|
|
|
|
next if (length($tests) && ($tests !~ /$x/));
|
|
|
|
next if (! -d $x);
|
|
|
|
if (-r "$x/Makefile") {
|
|
|
|
push(@mtests, $x);
|
|
|
|
} else {
|
|
|
|
push(@stests, $x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(D);
|
|
|
|
|
|
|
|
@tests = ();
|
|
|
|
push(@tests, sort @mtests) if (scalar(@mtests));
|
|
|
|
push(@tests, sort @stests) if (scalar(@stests));
|
|
|
|
print "matching tests: ";
|
|
|
|
print join(",", @tests);
|
|
|
|
print "\n\n";
|
|
|
|
|
|
|
|
W: foreach $x (@tests) {
|
2014-08-20 19:53:15 +00:00
|
|
|
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";
|
2023-02-11 13:09:07 +00:00
|
|
|
$ntests++;
|
2014-08-20 19:53:15 +00:00
|
|
|
} 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";
|
2023-02-11 13:09:07 +00:00
|
|
|
$ntests++;
|
2014-08-20 19:53:15 +00:00
|
|
|
} else {
|
|
|
|
print STDOUT "ignored\n";
|
|
|
|
}
|
|
|
|
chdir("..");
|
|
|
|
}
|
2022-03-27 21:01:03 +00:00
|
|
|
print STDOUT "=" x 79, "\n";
|
2023-02-11 13:09:07 +00:00
|
|
|
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;
|
2014-08-20 19:53:15 +00:00
|
|
|
|
|
|
|
sub failed {
|
|
|
|
system(@_);
|
|
|
|
if ($?) {
|
|
|
|
print STDOUT "## FAILURE ##\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|