2010-08-11 16:28:01 -05:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2010-08-09 09:27:39 -05:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import glob
|
|
|
|
import fnmatch
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
|
|
rustDir = os.path.abspath('.')
|
|
|
|
rustTestDir = rustDir + "/test";
|
|
|
|
rustTestRunPassDir = rustTestDir + "/run-pass";
|
|
|
|
rustTestRunFailDir = rustTestDir + "/run-fail";
|
|
|
|
rustTestCompileFailDir = rustTestDir + "/run-compile-fail";
|
|
|
|
rustTestRunBenchDir = rustTestDir + "/run-bench";
|
|
|
|
|
|
|
|
parser = OptionParser()
|
|
|
|
parser.set_usage("run.py [options] pattern : run.py -n 100 \"bas*\" -q");
|
2010-08-11 16:28:01 -05:00
|
|
|
parser.add_option("-n", dest="repetitions",
|
2010-08-09 09:27:39 -05:00
|
|
|
help="number of repetitions", metavar="NUMBER")
|
2010-08-11 16:28:01 -05:00
|
|
|
parser.add_option("-q", action="store_true", dest="quiet", default=False,
|
2010-08-09 09:27:39 -05:00
|
|
|
help="suppresses rust log output")
|
2010-08-18 01:10:20 -05:00
|
|
|
parser.add_option("-l", dest="log", default="",
|
|
|
|
help="rust log")
|
2010-08-11 18:01:40 -05:00
|
|
|
parser.add_option("-v", action="store_true", dest="valgrind", default=False,
|
|
|
|
help="runs under valgrind")
|
2010-08-18 01:10:20 -05:00
|
|
|
parser.add_option("-t", action="store_true", dest="terminate", default=False,
|
|
|
|
help="terminate on first failure")
|
2010-08-11 16:28:01 -05:00
|
|
|
parser.add_option("-p", action="store_true", dest="printSource",
|
2010-08-09 09:27:39 -05:00
|
|
|
default=False, help="prints the test case's source")
|
|
|
|
parser.add_option("-s", dest="seed", metavar="NUMBER", default=-1,
|
|
|
|
help="seeds the rust scheduler, use -1 to generate seeds, "
|
|
|
|
+ " or >= 0 to specify a seed")
|
2010-08-11 16:28:01 -05:00
|
|
|
|
2010-08-09 09:27:39 -05:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
def getRustTests(filter):
|
|
|
|
tests = []
|
|
|
|
for root, dirnames, filenames in os.walk(rustTestDir):
|
|
|
|
for filename in fnmatch.filter(filenames, filter + '.rs'):
|
|
|
|
tests.append(os.path.join(root, filename).
|
|
|
|
replace(rustDir + "/", ""));
|
|
|
|
return tests
|
|
|
|
|
|
|
|
|
|
|
|
if len(args) != 1:
|
|
|
|
parser.print_usage();
|
|
|
|
sys.exit(0);
|
|
|
|
|
|
|
|
tests = getRustTests(args[0]);
|
|
|
|
|
2010-08-11 16:28:01 -05:00
|
|
|
# Make
|
2010-08-09 09:27:39 -05:00
|
|
|
for rustProgram in tests:
|
|
|
|
print "Making: " + rustProgram;
|
|
|
|
result = os.system("make " + rustProgram.replace(".rs", ".x86")) >> 8;
|
|
|
|
if (result != 0):
|
|
|
|
print "Make failed!";
|
|
|
|
sys.exit(1);
|
|
|
|
|
2010-08-18 01:10:20 -05:00
|
|
|
if (options.log != ""):
|
|
|
|
os.putenv("RUST_LOG", options.log);
|
|
|
|
|
2010-08-09 09:27:39 -05:00
|
|
|
if (options.quiet):
|
2010-08-18 01:10:20 -05:00
|
|
|
os.putenv("RUST_LOG", "none");
|
2010-08-09 09:27:39 -05:00
|
|
|
|
|
|
|
# Rut
|
|
|
|
totalPassed = 0;
|
2010-08-11 16:28:01 -05:00
|
|
|
repetitions = 1;
|
2010-08-09 09:27:39 -05:00
|
|
|
for rustProgram in tests:
|
|
|
|
repetitions = 1;
|
|
|
|
if (options.repetitions):
|
|
|
|
repetitions = int(options.repetitions);
|
|
|
|
passed = 0;
|
|
|
|
if (options.printSource):
|
|
|
|
os.system("cat " + rustProgram);
|
|
|
|
for i in range(0, repetitions):
|
|
|
|
print "Running: " + rustProgram + " " + str(i) + \
|
|
|
|
" of " + str(repetitions);
|
|
|
|
if (options.seed):
|
|
|
|
if (int(options.seed) >= 0):
|
|
|
|
os.putenv("RUST_SEED", options.seed);
|
|
|
|
else:
|
|
|
|
os.putenv("RUST_SEED", str(i));
|
2010-08-11 18:01:40 -05:00
|
|
|
command = rustProgram.replace(".rs", ".x86");
|
|
|
|
if (options.valgrind):
|
2010-08-18 01:10:20 -05:00
|
|
|
command = "valgrind --leak-check=full " + \
|
|
|
|
"--quiet --vex-iropt-level=0 " + \
|
|
|
|
"--suppressions=etc/x86.supp " + \
|
|
|
|
command;
|
2010-08-11 18:01:40 -05:00
|
|
|
print "Running Command: " + command;
|
|
|
|
result = os.system(command);
|
2010-08-09 09:27:39 -05:00
|
|
|
exitStatus = result >> 8;
|
|
|
|
signalNumber = result & 0xF;
|
|
|
|
if (result == 0):
|
|
|
|
passed += 1;
|
2010-08-18 01:10:20 -05:00
|
|
|
elif (options.terminate):
|
|
|
|
sys.exit(1);
|
2010-08-09 09:27:39 -05:00
|
|
|
print "Result for: " + rustProgram + " " + str(passed) + \
|
|
|
|
" of " + str(repetitions) + " passed.";
|
|
|
|
totalPassed += passed;
|
|
|
|
print "Total: " + str(totalPassed) + " of " + \
|
2010-08-11 16:28:01 -05:00
|
|
|
str(len(tests) * repetitions) + " passed."
|