|
14 | 14 | from swsscommon import swsscommon
|
15 | 15 |
|
16 | 16 | def ensure_system(cmd):
|
17 |
| - rc = os.WEXITSTATUS(os.system(cmd)) |
| 17 | + (rc, output) = commands.getstatusoutput(cmd) |
18 | 18 | if rc:
|
19 |
| - raise RuntimeError('Failed to run command: %s' % cmd) |
| 19 | + raise RuntimeError('Failed to run command: %s. rc=%d. output: %s' % (cmd, rc, output)) |
20 | 20 |
|
21 | 21 | def pytest_addoption(parser):
|
22 | 22 | parser.addoption("--dvsname", action="store", default=None,
|
@@ -214,7 +214,7 @@ def __init__(self, name=None, imgname=None, keeptb=False, fakeplatform=None):
|
214 | 214 |
|
215 | 215 | # mount redis to base to unique directory
|
216 | 216 | self.mount = "/var/run/redis-vs/{}".format(self.ctn_sw.name)
|
217 |
| - os.system("mkdir -p {}".format(self.mount)) |
| 217 | + ensure_system("mkdir -p {}".format(self.mount)) |
218 | 218 |
|
219 | 219 | self.environment = ["fake_platform={}".format(fakeplatform)] if fakeplatform else []
|
220 | 220 |
|
@@ -385,15 +385,15 @@ def get_logs(self, modname=None):
|
385 | 385 | else:
|
386 | 386 | log_dir = "log/{}".format(modname)
|
387 | 387 | os.system("rm -rf {}".format(log_dir))
|
388 |
| - os.system("mkdir -p {}".format(log_dir)) |
| 388 | + ensure_system("mkdir -p {}".format(log_dir)) |
389 | 389 | p = subprocess.Popen(["tar", "--no-same-owner", "-C", "./{}".format(log_dir), "-x"], stdin=subprocess.PIPE)
|
390 | 390 | for x in stream:
|
391 | 391 | p.stdin.write(x)
|
392 | 392 | p.stdin.close()
|
393 | 393 | p.wait()
|
394 | 394 | if p.returncode:
|
395 | 395 | raise RuntimeError("Failed to unpack the archive.")
|
396 |
| - os.system("chmod a+r -R log") |
| 396 | + ensure_system("chmod a+r -R log") |
397 | 397 |
|
398 | 398 | def add_log_marker(self, file=None):
|
399 | 399 | marker = "=== start marker {} ===".format(datetime.now().isoformat())
|
|
0 commit comments