move profiles into a top level directory and clean up importing
diff --git a/tests/oft b/tests/oft
index d527cb8..091193e 100755
--- a/tests/oft
+++ b/tests/oft
@@ -171,13 +171,14 @@
"dbg_level" : _debug_level_default,
"port_map" : {},
"test_params" : "None",
- "profile" : None,
+ "profile" : "default",
"allow_user" : False,
"fail_skipped" : False,
"default_timeout" : 2,
"minsize" : 0,
"random_seed" : None,
"platform_dir" : os.path.join(root_dir, "platforms"),
+ "profile_dir" : os.path.join(root_dir, "profiles"),
}
# Default test priority
@@ -281,6 +282,8 @@
help="Directory containing tests")
parser.add_option("--platform-dir", type="string",
help="Directory containing platform modules")
+ parser.add_option("--profile-dir", type="string",
+ help="Directory containing profile modules")
# Might need this if other parsers want command line
# parser.allow_interspersed_args = False
@@ -290,28 +293,21 @@
return (config, args)
-def check_profile(config):
+def load_profile(config):
"""
Import a profile from the profiles library
"""
global profile_mod
- if "profile" in config and config["profile"]:
- logging.info("Importing profile: %s" % config["profile"])
- profile_name = "profiles." + config["profile"]
- try:
- top_mod = __import__(profile_name)
- profile_mod = eval("top_mod." + config["profile"])
- logging.info("Imported profile %s. Dir: %s" %
- (config["profile"], str(dir(profile_mod))))
- except:
- logging.info("Could not import profile: %s.py" %
- config["profile"])
- print "Failed to import profile: %s" % config["profile"]
- raise
- else:
- logging.info("No profile specified")
-
+ logging.info("Importing profile: %s" % config["profile"])
+ try:
+ profile_mod = imp.load_module(config["profile"], *imp.find_module(config["profile"], [config["profile_dir"]]))
+ if not "skip_test_list" in dir(profile_mod):
+ die("Profile did not define skip_test_list")
+ except:
+ logging.info("Could not import profile: %s.py" % config["profile"])
+ print "Failed to import profile: %s" % config["profile"]
+ raise
def logging_setup(config):
"""
@@ -397,10 +393,9 @@
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 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]
@@ -474,7 +469,7 @@
logging_setup(config)
logging.info("++++++++ " + time.asctime() + " ++++++++")
-check_profile(config)
+load_profile(config)
# Generate the test suite
#@todo Decide if multiple suites are ever needed
diff --git a/tests/profiles/__init__.py b/tests/profiles/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tests/profiles/__init__.py
+++ /dev/null
diff --git a/tests/profiles/example.py b/tests/profiles/example.py
deleted file mode 100644
index 938a6f2..0000000
--- a/tests/profiles/example.py
+++ /dev/null
@@ -1,36 +0,0 @@
-"""
-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():
-# ...
diff --git a/tests/profiles/noing.py b/tests/profiles/noing.py
deleted file mode 100644
index bfd1c70..0000000
--- a/tests/profiles/noing.py
+++ /dev/null
@@ -1,20 +0,0 @@
-"""
-No-ingress action profile
-
-Profile for switch that does not support the IN_PORT port
-in the output action.
-
-We also don't run the port config modify test for this profile.
-"""
-
-#@var skip_test_list The list of tests to skip for this run
-skip_test_list = [
- "PortConfigMod",
- "FloodMinusPort",
- "ModifyL2DstIngressMC",
- "ModifyL2DstIngress",
- "DirectMC",
- "AllPlusIngress",
- "FloodPlusIngress",
- "ModifyVIDToIngress",
-]