Skip to content
Snippets Groups Projects
Commit 783a0548 authored by Ludovico de Nittis's avatar Ludovico de Nittis :palm_tree:
Browse files

tests: Check the correctness of unsharing the home directory


Features without tests can easily regress.
For this reason we added a check about the directories that we expect to
have inside the container when we don't share the home directory.
And we also compare the "steam-installation" issues of the container
srsi with the one on the host.

Signed-off-by: default avatarLudovico de Nittis <ludovico.denittis@collabora.com>
parent 4bb50537
Branches
Tags
1 merge request!268tests: Check the correctness of unsharing the home directory
Pipeline #10288 passed
This commit is part of merge request !268. Comments created here will be created in the context of that merge request.
......@@ -481,6 +481,7 @@ class TestContainers(BaseTest):
runtime: str,
*,
copy: bool = False,
fake_home: bool = False,
gc: bool = True,
gc_legacy: bool = True,
locales: bool = False,
......@@ -490,6 +491,7 @@ class TestContainers(BaseTest):
test_name,
runtime,
copy=copy,
fake_home=fake_home,
gc=gc,
gc_legacy=gc_legacy,
is_scout=True,
......@@ -503,6 +505,7 @@ class TestContainers(BaseTest):
runtime: str,
*,
copy: bool = False,
fake_home: bool = False,
gc: bool = True,
gc_legacy: bool = True,
locales: bool = False,
......@@ -526,6 +529,7 @@ class TestContainers(BaseTest):
*,
archive: str = '',
copy: bool = False,
fake_home: bool = False,
fast_path: bool = False,
gc: bool = True,
gc_legacy: bool = True,
......@@ -585,7 +589,9 @@ class TestContainers(BaseTest):
prefix='test-', dir=var_dir
) as temp, tempfile.TemporaryDirectory(
prefix='test-mock-base-', dir=var_dir
) as mock_base:
) as mock_base, tempfile.TemporaryDirectory(
prefix='test-fake-home-', dir=var_dir
) as fake_home_temp:
argv.extend(['--runtime-base', mock_base])
argv.extend(['--variable-dir', temp])
......@@ -626,6 +632,11 @@ class TestContainers(BaseTest):
else:
argv.append('--no-gc-legacy-runtimes')
if fake_home:
argv.append('--home=' + fake_home_temp)
else:
argv.append('--share-home')
if is_scout:
python = 'python3.5'
else:
......@@ -639,6 +650,9 @@ class TestContainers(BaseTest):
'env',
'TEST_INSIDE_RUNTIME_ARTIFACTS=' + artifacts,
'TEST_INSIDE_RUNTIME_IS_COPY=' + ('1' if copy else ''),
'TEST_INSIDE_RUNTIME_IS_HOME_UNSHARED=' + (
'1' if fake_home else ''
),
'TEST_INSIDE_RUNTIME_IS_SCOUT=' + (
'1' if is_scout else ''
),
......@@ -769,6 +783,13 @@ class TestContainers(BaseTest):
self.assertIn('scout_dontdelete', members)
self.assertIn('soldier_0.20200101.0_keep', members)
if fake_home:
members = set(os.listdir(fake_home_temp))
self.assertIn('.cache', members)
self.assertIn('.config', members)
self.assertIn('.local', members)
if copy:
members = set(os.listdir(temp))
......@@ -1214,6 +1235,11 @@ class TestContainers(BaseTest):
with self.subTest('copy'):
self._test_scout('scout_sysroot_copy', scout, copy=True, gc=False)
with self.subTest('fake-home'):
self._test_scout(
'scout_sysroot_fake_home', scout, copy=True, fake_home=True,
)
with self.subTest('transient'):
self._test_scout('scout_sysroot', scout, locales=True)
......@@ -1232,6 +1258,11 @@ class TestContainers(BaseTest):
copy=True, gc=False, gc_legacy=False,
)
with self.subTest('fake-home'):
self._test_scout(
'scout_sysroot_fake_home', scout, copy=True, fake_home=True,
)
with self.subTest('transient'):
self._test_scout('scout_sysroot_usrmerge', scout, locales=True)
......@@ -1244,6 +1275,9 @@ class TestContainers(BaseTest):
with self.subTest('copy'):
self._test_scout('scout_copy', scout, copy=True, locales=True)
with self.subTest('fake-home'):
self._test_scout('scout_fake_home', scout, copy=True, fake_home=True)
with self.subTest('transient'):
self._test_scout('scout', scout)
......@@ -1293,6 +1327,11 @@ class TestContainers(BaseTest):
'soldier_sysroot_copy', soldier, copy=True, gc=False,
)
with self.subTest('fake-home'):
self._test_soldier(
'soldier_sysroot_fake_home', soldier, copy=True, fake_home=True,
)
with self.subTest('transient'):
self._test_soldier('soldier_sysroot', soldier, locales=True)
......@@ -1309,6 +1348,11 @@ class TestContainers(BaseTest):
'soldier_copy', soldier, copy=True, locales=True,
)
with self.subTest('fake-home'):
self._test_soldier(
'soldier_fake_home', soldier, copy=True, fake_home=True,
)
with self.subTest('transient'):
self._test_soldier('soldier', soldier)
......
......@@ -262,6 +262,17 @@ class TestInsideRuntime(BaseTest):
return False
def test_home_directory(self) -> None:
if os.environ.get('TEST_INSIDE_RUNTIME_IS_HOME_UNSHARED'):
# If we unshared the real home there are a few directories that
# we always expect to have
home_path = os.environ.get('HOME')
members = set(os.listdir(home_path))
self.assertIn('.cache', members)
self.assertIn('.config', members)
self.assertIn('.local', members)
def test_srsi(self) -> None:
overrides = Path('/overrides').resolve()
......@@ -322,6 +333,40 @@ class TestInsideRuntime(BaseTest):
logger.info('Host OS is not Debian-derived')
host_is_debian_derived = False
if host_parsed:
# If the Steam installation on the host system is sane, we expect
# the same in the container too.
self.assertIn('steam-installation', host_parsed)
self.assertIn('steam-installation', parsed)
host_issues = host_parsed['steam-installation'].get('issues', [])
issues = parsed['steam-installation'].get('issues', [])
self.assertEqual(
'cannot-find' in host_issues,
'cannot-find' in issues,
)
self.assertEqual(
'dot-steam-steam-not-symlink' in host_issues,
'dot-steam-steam-not-symlink' in issues,
)
self.assertEqual(
'cannot-find-data' in host_issues,
'cannot-find-data' in issues,
)
self.assertEqual(
'dot-steam-steam-not-directory' in host_issues,
'dot-steam-steam-not-directory' in issues,
)
self.assertEqual(
'dot-steam-root-not-symlink' in host_issues,
'dot-steam-root-not-symlink' in issues,
)
self.assertEqual(
'dot-steam-root-not-directory' in host_issues,
'dot-steam-root-not-directory' in issues,
)
with self.catch(
'runtime information',
diagnostic=parsed.get('runtime'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment