Skip to content

Commit 8cf6217

Browse files
committed
address comments
Signed-off-by: Mai Bui <[email protected]>
1 parent cdf6957 commit 8cf6217

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/container_hardening/test_container_hardening.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ def test_bgp_dev(duthost):
1313
"""
1414
Test bgp container has no access to /dev/vda* or /dev/sda*
1515
"""
16-
device = duthost.shell("docker exec bgp bash -c 'df -h | grep /etc/hosts' | awk '{print $1}'")['stdout']
16+
cmd = duthost.shell("docker exec bgp bash -c 'df -h | grep /etc/hosts' | awk '{print $1}'")
17+
rc, device = cmd['rc'], cmd['stdout']
18+
if rc != 0:
19+
pytest_assert(False, 'Failed to get the device name.')
20+
if not device.startswith('/dev/'):
21+
pytest_assert(False, 'Invalid device {}.'.format(device))
1722
output = duthost.shell("docker exec bgp bash -c 'ls {}'".format(device), module_ignore_errors=True)['stdout']
1823
pytest_assert(not output, 'The partition {} exists.'.format(device))

0 commit comments

Comments
 (0)