Added per-test priority support
In each module, a variable test_prio[] may be added which
is indexed by the test name.
Currently the only application of this is to exclude tests
from the "default" set of tests that are run: If a test
has a negative priority, then it is not run by default. This
addresses the issue with "fill exact match table" taking almost
an hour to run.
diff --git a/tests/oft b/tests/oft
index c851ae9..b4314fe 100755
--- a/tests/oft
+++ b/tests/oft
@@ -39,6 +39,12 @@
value is a list of functions in that module
</pre>
+Each test may be assigned a priority by setting test_prio["TestName"] in
+the respective module. For now, the only use of this is to avoid
+automatic inclusion of tests into the default list. This is done by
+setting the test_prio value less than 0. Eventually we may add ordering
+of test execution by test priority.
+
To add a test to the system, either: edit an existing test case file (like
basic.py) to add a test class which inherits from unittest.TestCase (directly
or indirectly); or add a new file which includes a function definition
@@ -159,6 +165,9 @@
"port_map" : {}
}
+# Default test priority
+TEST_PRIO_DEFAULT=100
+
#@todo Set up a dict of config params so easier to manage:
# <param> <cmdline flags> <default value> <help> <optional parser>
@@ -334,6 +343,17 @@
return " " * spaces
return " "
+def test_prio_get(mod, test):
+ """
+ Return the priority of a test
+ If set in the test_prio variable for the module, return
+ that value. Otherwise return 100 (default)
+ """
+ if 'test_prio' in dir(mod):
+ if test in mod.test_prio.keys():
+ return mod.test_prio[test]
+ return TEST_PRIO_DEFAULT
+
#
# Main script
#
@@ -359,11 +379,16 @@
for test in config["all_tests"][mod]:
desc = eval('mod.' + test + '.__doc__.strip()')
desc = desc.split('\n')[0]
- start_str = " " + test + ":"
+ if test_prio_get(mod, test) < 0:
+ start_str = " * " + test + ":"
+ else:
+ start_str = " " + test + ":"
print start_str + _space_to(22, start_str) + desc
print
if not did_print:
print "No tests found for " + config["test_spec"]
+ else:
+ print "Tests marked * are not run by default"
sys.exit(0)
logging_setup(config)
@@ -373,10 +398,13 @@
#@todo Decide if multiple suites are ever needed
suite = unittest.TestSuite()
+#@todo Allow specification of priority to override prio check
if config["test_spec"] == "all":
for mod in config["all_tests"].keys():
for test in config["all_tests"][mod]:
- add_test(suite, mod, test)
+ # For now, a way to avoid tests
+ if test_prio_get(mod, test) >= 0:
+ add_test(suite, mod, test)
else:
for ts_entry in config["test_spec"].split(","):