oft: add test-file option
This option reads a file that has one test name or group name per line.
Whitespace and comments starting with '#' are ignored. The resulting tests are
unioned with those given on the command line.
The main usecase for this is freezing a set of tests to be run against a
switch. You can use the --list-test-names option to get the current set of
tests in a format suitable for use with this option, then manually edit
it to add, remove, and comment tests.
diff --git a/oft b/oft
index 42d4d53..5e97857 100755
--- a/oft
+++ b/oft
@@ -155,6 +155,7 @@
"controller_port" : 6633,
"relax" : False,
"test_spec" : "",
+ "test_file" : None,
"log_file" : "oft.log",
"log_append" : False,
"list" : False,
@@ -247,6 +248,7 @@
module.testcase Run the specific test case
"""
parser.add_option("-T", "--test-spec", "--test-list", help=test_list_help)
+ parser.add_option("-f", "--test-file", help="File of tests to run, one per line")
parser.add_option("--log-file",
help="Name of log file, empty string to log to console")
parser.add_option("--log-append", action="store_true",
@@ -411,6 +413,13 @@
if config["test_spec"] != "":
print >> sys.stderr, "WARNING: The --test-spec option is deprecated"
test_specs += config["test_spec"].split(',')
+if config["test_file"] != None:
+ with open(config["test_file"], 'r') as f:
+ for line in f:
+ line, _, _ = line.partition('#') # remove comments
+ line = line.strip()
+ if line:
+ test_specs.append(line)
if test_specs == []:
test_specs = ["standard"]