move profiles into a top level directory and clean up importing
diff --git a/profiles/default.py b/profiles/default.py
new file mode 100644
index 0000000..8313eb7
--- /dev/null
+++ b/profiles/default.py
@@ -0,0 +1,9 @@
+"""
+Default profile
+
+No tests skipped.
+"""
+
+#@var skip_test_list The list of tests to skip for this run
+skip_test_list = [
+]
diff --git a/tests/profiles/example.py b/profiles/example.py
similarity index 89%
rename from tests/profiles/example.py
rename to profiles/example.py
index 938a6f2..6e23b92 100644
--- a/tests/profiles/example.py
+++ b/profiles/example.py
@@ -1,7 +1,7 @@
"""
Sample profile
-A profile determines run specific behavior. It is meant to capture
+A profile determines run specific behavior. It is meant to capture
variations between different switch targets.
A profile defines two target specific variables.
@@ -13,9 +13,6 @@
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
"""
diff --git a/tests/profiles/noing.py b/profiles/noing.py
similarity index 100%
rename from tests/profiles/noing.py
rename to profiles/noing.py
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