Added switch profile command option
Added --profile command line argument. If present, it must specify
a python file which is imported. Currently the only profile related
code is a variable called skip_test_list which gives a list of tests
that should _not_ be run for the platform. Only the test names
are currently checked; test-module checking is not checked.
A sample profile file is also included.
diff --git a/tests/oft b/tests/oft
index c397372..a0f8c61 100755
--- a/tests/oft
+++ b/tests/oft
@@ -134,6 +134,9 @@
except:
sys.exit("Need to install scapy for packet parsing")
+##@var Profile module
+profile_mod = None
+
##@var DEBUG_LEVELS
# Map from strings to debugging levels
DEBUG_LEVELS = {
@@ -167,11 +170,13 @@
"debug" : _debug_default,
"dbg_level" : _debug_level_default,
"port_map" : {},
- "test_params" : "None"
+ "test_params" : "None",
+ "profile" : None
}
# Default test priority
TEST_PRIO_DEFAULT=100
+TEST_PRIO_SKIP=-1
#@todo Set up a dict of config params so easier to manage:
# <param> <cmdline flags> <default value> <help> <optional parser>
@@ -245,6 +250,8 @@
help="Relax packet match checks allowing other packets")
parser.add_option("--param", type="int",
help="Parameter sent to test (for debugging)")
+ parser.add_option("--profile",
+ help="File listing tests to skip/run")
parser.add_option("-t", "--test-params",
help="""Set test parameters: key=val;...
NOTE: key MUST be a valid Python identifier, egr_count not egr-count
@@ -257,6 +264,21 @@
return (config, args)
+def check_profile(config):
+ global profile_mod
+ if "profile" in config and config["profile"]:
+ logging.info("Importing profile: %s.py" % config["profile"])
+ try:
+ profile_mod = __import__(config["profile"])
+ except:
+ logging.info("Could not import profile: %s.py" %
+ config["profile"])
+ print "Failed to import profile: %s.py" % config["profile"]
+ profile_mod = None
+ else:
+ logging.info("No profile specified")
+
+
def logging_setup(config):
"""
Set up logging based on config
@@ -359,9 +381,16 @@
def test_prio_get(mod, test):
"""
Return the priority of a test
+
+ If test is in "skip list" from profile, return the skip value
+
If set in the test_prio variable for the module, return
that value. Otherwise return 100 (default)
"""
+ if profile_mod:
+ if profile_mod.skip_test_list and test in profile_mod.skip_test_list:
+ logging.info("Skipping test %s due to profile" % test)
+ return TEST_PRIO_SKIP
if 'test_prio' in dir(mod):
if test in mod.test_prio.keys():
return mod.test_prio[test]
@@ -410,11 +439,14 @@
print "Tests preceded by * are not run by default"
print "Tests marked (TP1) after name take --test-params including:"
print " 'vid=N;strip_vlan=bool;add_vlan=bool'"
+ print "Note that --profile may override which tests are run"
sys.exit(0)
logging_setup(config)
logging.info("++++++++ " + time.asctime() + " ++++++++")
+check_profile(config)
+
# Generate the test suite
#@todo Decide if multiple suites are ever needed
suite = unittest.TestSuite()
diff --git a/tests/profile.py b/tests/profile.py
new file mode 100644
index 0000000..938a6f2
--- /dev/null
+++ b/tests/profile.py
@@ -0,0 +1,36 @@
+"""
+Sample profile
+
+A profile determines run specific behavior. It is meant to capture
+variations between different switch targets.
+
+A profile defines two target specific variables.
+
+1. A set of tests to skip
+
+TO BE IMPLEMENTED:
+
+2. A set of tests to run (overriding the default "skip" priority)
+optionally specifying a test parameters specific to the test run
+
+This file should be imported "as profile" so references to the
+module will properly map.
+
+@todo Allow a test to be run multiple times with different params
+"""
+
+#@var skip_test_list The list of tests to skip for this run
+skip_test_list = []
+
+# TO BE IMPLEMENTED
+# A list of test cases with parameters(?)
+# TBD
+#@var run_test_list List of tests to run which would normally be skipped
+run_test_list = dict(
+ # Example
+ # SomeTestCase = [dict(<params1>), dict(<params2>),...],
+)
+
+# for test_dict in profile.run_test_list:
+# for test_name, test_params in test_dict.items():
+# ...