aboutsummaryrefslogtreecommitdiff
path: root/src/run.py
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-08-09 07:27:39 -0700
committerMichael Bebenita <[email protected]>2010-08-09 07:27:39 -0700
commit768adb3ddda730ae300f57797b2c0587e1211e80 (patch)
tree0fcc31d71098416133a694e417799391515027ae /src/run.py
parentAdded "none" option to rust_log env string to disable all log output. (diff)
downloadrust-768adb3ddda730ae300f57797b2c0587e1211e80.tar.xz
rust-768adb3ddda730ae300f57797b2c0587e1211e80.zip
Added a python script to run test cases repeatedly. This helps with debugging race conditions.
Diffstat (limited to 'src/run.py')
-rw-r--r--src/run.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/run.py b/src/run.py
new file mode 100644
index 00000000..4cce4102
--- /dev/null
+++ b/src/run.py
@@ -0,0 +1,81 @@
+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");
+parser.add_option("-n", dest="repetitions",
+ help="number of repetitions", metavar="NUMBER")
+parser.add_option("-q", action="store_true", dest="quiet", default=False,
+ help="suppresses rust log output")
+parser.add_option("-p", action="store_true", dest="printSource",
+ 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")
+
+(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]);
+
+# Make
+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);
+
+if (options.quiet):
+ os.putenv("RUST_LOG", "none")
+
+# Rut
+totalPassed = 0;
+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));
+ result = os.system(rustProgram.replace(".rs", ".x86"));
+ exitStatus = result >> 8;
+ signalNumber = result & 0xF;
+ if (result == 0):
+ passed += 1;
+ print "Result for: " + rustProgram + " " + str(passed) + \
+ " of " + str(repetitions) + " passed.";
+ totalPassed += passed;
+print "Total: " + str(totalPassed) + " of " + \
+ str(len(tests) * repetitions) + " passed." \ No newline at end of file