Skip to content
Snippets Groups Projects
Commit 9b1e84d8 authored by Simon McVittie's avatar Simon McVittie
Browse files

tests: Assert that various filesystems are mounted read-only


A possible future enhancement would be to have an option to mount some
of these (those that live in the mutable sysroot) read/write, but for
now any ad-hoc developer modifications will have to happen outside the
container.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent e29d8a3c
No related branches found
No related tags found
No related merge requests found
...@@ -404,6 +404,7 @@ class TestContainers(BaseTest): ...@@ -404,6 +404,7 @@ class TestContainers(BaseTest):
'--', '--',
'env', 'env',
'TEST_INSIDE_SCOUT_ARTIFACTS=' + artifacts, 'TEST_INSIDE_SCOUT_ARTIFACTS=' + artifacts,
'TEST_INSIDE_SCOUT_IS_COPY=' + ('1' if copy else ''),
'TEST_INSIDE_SCOUT_LOCALES=' + ('1' if locales else ''), 'TEST_INSIDE_SCOUT_LOCALES=' + ('1' if locales else ''),
'python3.5', 'python3.5',
os.path.join(self.artifacts, 'tmp', 'inside-scout.py'), os.path.join(self.artifacts, 'tmp', 'inside-scout.py'),
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import contextlib import contextlib
import ctypes import ctypes
import errno
import json import json
import logging import logging
import os import os
...@@ -541,6 +542,44 @@ class TestInsideScout(BaseTest): ...@@ -541,6 +542,44 @@ class TestInsideScout(BaseTest):
set(arch_info['library-issues-summary']), set(arch_info['library-issues-summary']),
) )
def test_read_only(self) -> None:
for read_only_place in (
'/bin',
'/etc/ld.so.conf.d',
'/lib',
'/overrides',
'/overrides/lib',
'/run/host/bin',
'/run/host/lib',
'/run/host/usr',
'/run/host/usr/bin',
'/run/host/usr/lib',
'/run/pressure-vessel/pv-from-host',
'/run/pressure-vessel/pv-from-host/bin',
'/sbin',
'/usr',
'/usr/lib',
'/usr/lib/pressure-vessel/from-host/bin',
):
with self.subTest(read_only_place):
if (
read_only_place.startswith('/overrides')
and not os.getenv('TEST_INSIDE_SCOUT_IS_COPY')
):
# If we aren't working from a temporary copy of the
# runtime, /overrides is on a tmpfs
continue
with self.assertRaises(OSError) as raised:
open(os.path.join(read_only_place, 'hello'), 'w')
if isinstance(raised.exception, FileNotFoundError):
# Some of these paths don't exist under all
# circumstances
continue
self.assertEqual(raised.exception.errno, errno.EROFS)
if __name__ == '__main__': if __name__ == '__main__':
assert sys.version_info >= (3, 5), 'Python 3.5+ is required' assert sys.version_info >= (3, 5), 'Python 3.5+ is required'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment