Skip to content

Commit e91e6fd

Browse files
committed
Make path for module tests configurable
This commit introduces env variable TEST_PATH, to specify custom module test directory other than conf/testing/module_tests
1 parent 8ba320a commit e91e6fd

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

bessctl/conf/testing/run_module_tests.bess

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ import sugar
3838
import traceback
3939
from time import gmtime, strftime
4040

41-
# Env variable used to run a single test
42-
test_name = $TEST_NAME!'*'
43-
4441
## HANDY UTILS AND GLOBAL VARS ##
4542
SOCKET_PATH = '/tmp/bess_unix_'
4643
SCRIPT_STARTTIME = strftime("%Y-%m-%d-%H-%M-%S", gmtime())
@@ -156,15 +153,19 @@ def monitor_task(module, wid):
156153
def run_tests():
157154
DID_TESTS_FAIL = False
158155

159-
path = os.path.dirname(os.path.realpath(sys.argv[0]))
156+
# Env variable used to run a subset of tests
157+
test_name = $TEST_NAME!'*'
158+
159+
default_path = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
160+
'conf/testing/module_tests')
161+
test_path = $TEST_PATH!default_path
160162

161163
# Note: os.path.join will discard the leading parts if test
162164
# begins with '/', so callers should provide an absolute path
165+
163166
# if and only if they want to override the internal BESS
164167
# path prefixing.
165-
for filename in glob.glob(os.path.join(path,
166-
"conf/testing/module_tests",
167-
test_name + ".py")):
168+
for filename in glob.glob(os.path.join(test_path, test_name + ".py")):
168169
bess.reset_all()
169170

170171
print("-- Running Module Tests for %s --" % filename.split("/")[-1])

0 commit comments

Comments
 (0)