Tests: fixed tests to run as privileged user.

This commit is contained in:
Andrei Zeliankou
2022-12-09 14:17:49 +00:00
parent e70653c766
commit 55b9a5307d
2 changed files with 15 additions and 8 deletions

View File

@@ -63,24 +63,25 @@ class TestPythonIsolation(TestApplicationPython):
pytest.skip('requires root') pytest.skip('requires root')
isolation = {'rootfs': temp_dir, 'automount': {'language_deps': False}} isolation = {'rootfs': temp_dir, 'automount': {'language_deps': False}}
self.load('empty', isolation=isolation) self.load('empty', isolation=isolation)
assert findmnt().find(temp_dir) == -1 python_path = temp_dir + '/usr'
assert findmnt().find(python_path) == -1
assert self.get()['status'] != 200, 'disabled language_deps' assert self.get()['status'] != 200, 'disabled language_deps'
assert findmnt().find(temp_dir) == -1 assert findmnt().find(python_path) == -1
isolation['automount']['language_deps'] = True isolation['automount']['language_deps'] = True
self.load('empty', isolation=isolation) self.load('empty', isolation=isolation)
assert findmnt().find(temp_dir) == -1 assert findmnt().find(python_path) == -1
assert self.get()['status'] == 200, 'enabled language_deps' assert self.get()['status'] == 200, 'enabled language_deps'
assert waitformount(temp_dir), 'language_deps mount' assert waitformount(python_path), 'language_deps mount'
self.conf({"listeners": {}, "applications": {}}) self.conf({"listeners": {}, "applications": {}})
assert waitforunmount(temp_dir), 'language_deps unmount' assert waitforunmount(python_path), 'language_deps unmount'
def test_python_isolation_procfs(self, is_su, temp_dir): def test_python_isolation_procfs(self, is_su, temp_dir):
if not is_su: if not is_su:

View File

@@ -12,9 +12,15 @@ def public_dir(path):
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for d in dirs: for d in dirs:
os.chmod(os.path.join(root, d), 0o777) try:
os.chmod(os.path.join(root, d), 0o777)
except FileNotFoundError:
pass
for f in files: for f in files:
os.chmod(os.path.join(root, f), 0o777) try:
os.chmod(os.path.join(root, f), 0o777)
except FileNotFoundError:
pass
def waitforfiles(*files, timeout=50): def waitforfiles(*files, timeout=50):