Revert "Merge pull request #19 from rlane/move-oftest"
This reverts commit 130b6a33a9858351886668f7ef07be121cc6a0e1, reversing
changes made to 5d2a768c671a549473f68131a0fc11737bf43952.
Moving testutils.py broke some imports.
diff --git a/tests/oft b/tests/oft
deleted file mode 120000
index 0b189a0..0000000
--- a/tests/oft
+++ /dev/null
@@ -1 +0,0 @@
-../oft
\ No newline at end of file
diff --git a/oft b/tests/oft
similarity index 96%
rename from oft
rename to tests/oft
index c3e46c2..091193e 100755
--- a/oft
+++ b/tests/oft
@@ -94,6 +94,7 @@
Examine oft.log if things don't work.
@todo Support per-component debug levels (esp controller vs dataplane)
+@todo Consider moving oft up a level
Current test case setup:
Files in the tests direcoty that contain a function test_set_init are
@@ -116,13 +117,12 @@
import imp
import random
-root_dir = os.path.dirname(os.path.realpath(__file__))
-pydir = os.path.join(root_dir, 'src', 'python')
+pydir = os.path.join(os.path.dirname(__file__), '..', 'src', 'python')
if os.path.exists(os.path.join(pydir, 'oftest')):
# Running from source tree
sys.path.insert(0, pydir)
-import oftest.testutils
+import testutils
import oftest.ofutils
try:
@@ -151,6 +151,8 @@
_debug_default = "warning"
_debug_level_default = DEBUG_LEVELS[_debug_default]
+root_dir = os.path.join(os.path.dirname(__file__), "..")
+
##@var config_default
# The default configuration dictionary for OFT
config_default = {
@@ -161,6 +163,7 @@
"controller_port" : 6633,
"relax" : False,
"test_spec" : "all",
+ "test_dir" : os.path.dirname(__file__),
"log_file" : "oft.log",
"list" : False,
"list_test_names" : False,
@@ -174,7 +177,6 @@
"default_timeout" : 2,
"minsize" : 0,
"random_seed" : None,
- "test_dir" : os.path.join(root_dir, "tests"),
"platform_dir" : os.path.join(root_dir, "platforms"),
"profile_dir" : os.path.join(root_dir, "profiles"),
}
@@ -406,9 +408,6 @@
# Get configuration, set up logging, import platform from file
(config, args) = config_setup(config_default)
-# Allow modules to import each other.
-sys.path.insert(0, config["test_dir"])
-
test_list_generate(config)
oft_config = config
@@ -553,7 +552,7 @@
_verb = 2
oftest.ofutils.default_timeout = config["default_timeout"]
-oftest.testutils.MINSIZE = config['minsize']
+testutils.MINSIZE = config['minsize']
if os.getuid() != 0 and not config["allow_user"]:
print "ERROR: Super-user privileges required. Please re-run with " \
@@ -568,15 +567,14 @@
if __name__ == "__main__":
logging.info("*** TEST RUN START: " + time.asctime())
result = unittest.TextTestRunner(verbosity=_verb).run(suite)
- skipped_test_count = oftest.testutils.skipped_test_count
- if skipped_test_count > 0:
+ if testutils.skipped_test_count > 0:
ts = " tests"
- if skipped_test_count == 1: ts = " test"
- logging.info("Skipped " + str(skipped_test_count) + ts)
- print("Skipped " + str(skipped_test_count) + ts)
+ if testutils.skipped_test_count == 1: ts = " test"
+ logging.info("Skipped " + str(testutils.skipped_test_count) + ts)
+ print("Skipped " + str(testutils.skipped_test_count) + ts)
logging.info("*** TEST RUN END : " + time.asctime())
if result.failures or result.errors:
# exit(1) hangs sometimes
os._exit(1)
- if skipped_test_count > 0 and config["fail_skipped"]:
+ if testutils.skipped_test_count > 0 and config["fail_skipped"]:
os._exit(1)
diff --git a/src/python/oftest/testutils.py b/tests/testutils.py
similarity index 100%
rename from src/python/oftest/testutils.py
rename to tests/testutils.py