test.py: add "launcher" option support

before this change, all "tool" test suites use "pytest" to launch their
tests. but some of the tests might need a dedicated namespace so they
do not interfere with each other. fortunately, "unshare(1)" allows us
to run a progame in new namespaces.

in this change, we add a "launcher" option to "tool" test suites. so
that these tests can run with the specified "launcher" instead of using
"launcher". if "launcher" is not specified, its default value of
"pytest" is used.

Refs #16542
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2024-01-15 11:08:55 +08:00
parent 0fbfc96619
commit 35b3c51f40

View File

@@ -1015,12 +1015,15 @@ class ToolTest(Test):
def __init__(self, test_no: int, shortname: str, suite) -> None:
super().__init__(test_no, shortname, suite)
self.path = "pytest"
launcher = self.suite.cfg.get("launcher", "pytest")
self.path = launcher.split(maxsplit=1)[0]
self.xmlout = os.path.join(self.suite.options.tmpdir, self.mode, "xml", self.uname + ".xunit.xml")
ToolTest._reset(self)
def _prepare_pytest_params(self, options: argparse.Namespace):
self.args = [
launcher = self.suite.cfg.get("launcher", "pytest")
self.args = launcher.split()[1:]
self.args += [
"-s", # don't capture print() output inside pytest
"--log-level=DEBUG", # Capture logs
"-o",