diff --git a/tests/conftest.py b/tests/conftest.py index 16c0ad10b700..65d954a9a768 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,9 +14,9 @@ from swsscommon import swsscommon def ensure_system(cmd): - rc = os.WEXITSTATUS(os.system(cmd)) + (rc, output) = commands.getstatusoutput(cmd) if rc: - raise RuntimeError('Failed to run command: %s' % cmd) + raise RuntimeError('Failed to run command: %s. rc=%d. output: %s' % (cmd, rc, output)) def pytest_addoption(parser): parser.addoption("--dvsname", action="store", default=None, @@ -214,7 +214,7 @@ def __init__(self, name=None, imgname=None, keeptb=False, fakeplatform=None): # mount redis to base to unique directory self.mount = "/var/run/redis-vs/{}".format(self.ctn_sw.name) - os.system("mkdir -p {}".format(self.mount)) + ensure_system("mkdir -p {}".format(self.mount)) self.environment = ["fake_platform={}".format(fakeplatform)] if fakeplatform else [] @@ -385,7 +385,7 @@ def get_logs(self, modname=None): else: log_dir = "log/{}".format(modname) os.system("rm -rf {}".format(log_dir)) - os.system("mkdir -p {}".format(log_dir)) + ensure_system("mkdir -p {}".format(log_dir)) p = subprocess.Popen(["tar", "--no-same-owner", "-C", "./{}".format(log_dir), "-x"], stdin=subprocess.PIPE) for x in stream: p.stdin.write(x) @@ -393,7 +393,7 @@ def get_logs(self, modname=None): p.wait() if p.returncode: raise RuntimeError("Failed to unpack the archive.") - os.system("chmod a+r -R log") + ensure_system("chmod a+r -R log") def add_log_marker(self, file=None): marker = "=== start marker {} ===".format(datetime.now().isoformat())