2012-04-12 22:42:55 +00:00
|
|
|
import std.array, std.exception, std.getopt, std.process, std.stdio,
|
|
|
|
std.traits;
|
|
|
|
|
|
|
|
|
|
|
|
enum OpDefs
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Delegates = 1,
|
2012-04-14 01:35:40 +00:00
|
|
|
Switch = 2,
|
|
|
|
NestedSwitch = 4,
|
|
|
|
All = 7
|
2012-04-12 22:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum Tests
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Func = 1,
|
|
|
|
Bus = 2,
|
|
|
|
Dec = 4,
|
2012-04-25 20:50:03 +00:00
|
|
|
Int = 8,
|
|
|
|
All = 15
|
2012-04-12 22:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string[OpDefs] defStrings;
|
|
|
|
string[Tests] fNames;
|
|
|
|
|
|
|
|
static this()
|
|
|
|
{
|
|
|
|
fNames = [
|
|
|
|
Tests.Func:" test_func.d ",
|
|
|
|
Tests.Bus:" test_bus.d ",
|
2012-04-25 20:50:03 +00:00
|
|
|
Tests.Dec:" test_decimal.d ",
|
|
|
|
Tests.Int:" test_signal.d "
|
2012-04-12 22:42:55 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
version(DigitalMars)
|
|
|
|
{
|
|
|
|
static this()
|
|
|
|
{
|
|
|
|
defStrings = [
|
|
|
|
OpDefs.Delegates:" -version=OpDelegates",
|
|
|
|
OpDefs.Switch:" -version=OpSwitch",
|
|
|
|
OpDefs.NestedSwitch:" -version=OpNestedSwitch"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
string[] stStrings = [" ", " -version=Strict"];
|
|
|
|
string[] cmStrings = [" ", " -version=Cumulative"];
|
|
|
|
}
|
|
|
|
else version(GNU)
|
|
|
|
{
|
|
|
|
static assert(false, "TODO: add support for GDC.");
|
|
|
|
}
|
|
|
|
else version(LDC)
|
|
|
|
{
|
|
|
|
static assert(false, "TODO: add support for LDC.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
static assert(false, "Unknown compiler.");
|
|
|
|
|
|
|
|
|
|
|
|
OpDefs opdefs;
|
|
|
|
bool strict, cumulative;
|
|
|
|
Tests tests;
|
|
|
|
bool help;
|
|
|
|
|
|
|
|
OpDefs[] deflist;
|
|
|
|
Tests[] testlist;
|
|
|
|
|
|
|
|
void main(string[] args)
|
|
|
|
{
|
|
|
|
if (args.length == 1)
|
|
|
|
writeln("(running default tests; use --help for options)");
|
|
|
|
|
|
|
|
getopt(args,
|
|
|
|
std.getopt.config.passThrough,
|
|
|
|
"def", &deflist,
|
|
|
|
"test", &testlist,
|
|
|
|
"help", &help);
|
|
|
|
|
|
|
|
if (help)
|
|
|
|
{
|
|
|
|
writeln(
|
|
|
|
`Options:
|
2012-04-25 20:50:03 +00:00
|
|
|
--test=type Func, Bus, Dec, Int, or All
|
|
|
|
--def=style Delegates, Switch, NestedSwitch, or All
|
2012-04-12 22:42:55 +00:00
|
|
|
--op=num test opcode 'num' (num is hex)
|
|
|
|
--op=name test all opcodes named 'name'
|
|
|
|
--addr=mode test all opcodes with addressing mode 'mode'
|
|
|
|
|
|
|
|
(All options con be specified multiple times.
|
|
|
|
--op and --addr have no effect on decimal mode tests.)`
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(def; deflist) opdefs |= def;
|
|
|
|
foreach(test; testlist) tests |= test;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
runTests(args);
|
|
|
|
}
|
|
|
|
catch (ErrnoException e) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
void runTests(string[] args)
|
|
|
|
{
|
|
|
|
// If no opdef specified, use Delegates.
|
|
|
|
if (opdefs == OpDefs.None) opdefs = OpDefs.Delegates;
|
|
|
|
|
|
|
|
int defcount;
|
|
|
|
foreach (def; EnumMembers!OpDefs)
|
|
|
|
if ((opdefs & def) && def != OpDefs.All) defcount++;
|
|
|
|
|
|
|
|
// If no tests specified, run all (but exclude Dec by default if
|
|
|
|
// running with more than one opdef).
|
|
|
|
if (tests == Tests.None)
|
|
|
|
tests = Tests.Func | Tests.Bus;
|
|
|
|
if (!defcount) tests |= Tests.Dec;
|
|
|
|
|
|
|
|
foreach (def; EnumMembers!OpDefs)
|
|
|
|
if ((opdefs & def) && def != OpDefs.All)
|
|
|
|
foreach (test; EnumMembers!Tests)
|
|
|
|
if ((tests & test) && test != Tests.All)
|
|
|
|
runTest(def, test, args[1..$]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void runTest(OpDefs def, Tests test, string[] args)
|
|
|
|
{
|
|
|
|
writeln("Using ", defStrings[def]);
|
|
|
|
foreach (s; [false, true])
|
|
|
|
{
|
|
|
|
foreach (c; [false, true])
|
|
|
|
{
|
|
|
|
writeln("With strict=", s, " cumulative=", c);
|
|
|
|
string cmdline = defStrings[def] ~ stStrings[s] ~ cmStrings[c] ~
|
|
|
|
fNames[test] ~ join(args, " ");
|
2012-04-14 15:26:27 +00:00
|
|
|
system("rdmd --force -I../.. -I../../src -version=RunTest " ~
|
|
|
|
cmdline);
|
2012-04-12 22:42:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|