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

Merge branch 'wip/fake_home_tests' into 'master'

tests: Check the correctness of unsharing the home directory

See merge request !268
parents 4bb50537 783a0548
No related branches found
No related tags found
1 merge request!268tests: Check the correctness of unsharing the home directory
Pipeline #10293 passed
...@@ -481,6 +481,7 @@ class TestContainers(BaseTest): ...@@ -481,6 +481,7 @@ class TestContainers(BaseTest):
runtime: str, runtime: str,
*, *,
copy: bool = False, copy: bool = False,
fake_home: bool = False,
gc: bool = True, gc: bool = True,
gc_legacy: bool = True, gc_legacy: bool = True,
locales: bool = False, locales: bool = False,
...@@ -490,6 +491,7 @@ class TestContainers(BaseTest): ...@@ -490,6 +491,7 @@ class TestContainers(BaseTest):
test_name, test_name,
runtime, runtime,
copy=copy, copy=copy,
fake_home=fake_home,
gc=gc, gc=gc,
gc_legacy=gc_legacy, gc_legacy=gc_legacy,
is_scout=True, is_scout=True,
...@@ -503,6 +505,7 @@ class TestContainers(BaseTest): ...@@ -503,6 +505,7 @@ class TestContainers(BaseTest):
runtime: str, runtime: str,
*, *,
copy: bool = False, copy: bool = False,
fake_home: bool = False,
gc: bool = True, gc: bool = True,
gc_legacy: bool = True, gc_legacy: bool = True,
locales: bool = False, locales: bool = False,
...@@ -526,6 +529,7 @@ class TestContainers(BaseTest): ...@@ -526,6 +529,7 @@ class TestContainers(BaseTest):
*, *,
archive: str = '', archive: str = '',
copy: bool = False, copy: bool = False,
fake_home: bool = False,
fast_path: bool = False, fast_path: bool = False,
gc: bool = True, gc: bool = True,
gc_legacy: bool = True, gc_legacy: bool = True,
...@@ -585,7 +589,9 @@ class TestContainers(BaseTest): ...@@ -585,7 +589,9 @@ class TestContainers(BaseTest):
prefix='test-', dir=var_dir prefix='test-', dir=var_dir
) as temp, tempfile.TemporaryDirectory( ) as temp, tempfile.TemporaryDirectory(
prefix='test-mock-base-', dir=var_dir 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(['--runtime-base', mock_base])
argv.extend(['--variable-dir', temp]) argv.extend(['--variable-dir', temp])
...@@ -626,6 +632,11 @@ class TestContainers(BaseTest): ...@@ -626,6 +632,11 @@ class TestContainers(BaseTest):
else: else:
argv.append('--no-gc-legacy-runtimes') argv.append('--no-gc-legacy-runtimes')
if fake_home:
argv.append('--home=' + fake_home_temp)
else:
argv.append('--share-home')
if is_scout: if is_scout:
python = 'python3.5' python = 'python3.5'
else: else:
...@@ -639,6 +650,9 @@ class TestContainers(BaseTest): ...@@ -639,6 +650,9 @@ class TestContainers(BaseTest):
'env', 'env',
'TEST_INSIDE_RUNTIME_ARTIFACTS=' + artifacts, 'TEST_INSIDE_RUNTIME_ARTIFACTS=' + artifacts,
'TEST_INSIDE_RUNTIME_IS_COPY=' + ('1' if copy else ''), '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=' + ( 'TEST_INSIDE_RUNTIME_IS_SCOUT=' + (
'1' if is_scout else '' '1' if is_scout else ''
), ),
...@@ -769,6 +783,13 @@ class TestContainers(BaseTest): ...@@ -769,6 +783,13 @@ class TestContainers(BaseTest):
self.assertIn('scout_dontdelete', members) self.assertIn('scout_dontdelete', members)
self.assertIn('soldier_0.20200101.0_keep', 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: if copy:
members = set(os.listdir(temp)) members = set(os.listdir(temp))
...@@ -1214,6 +1235,11 @@ class TestContainers(BaseTest): ...@@ -1214,6 +1235,11 @@ class TestContainers(BaseTest):
with self.subTest('copy'): with self.subTest('copy'):
self._test_scout('scout_sysroot_copy', scout, copy=True, gc=False) 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'): with self.subTest('transient'):
self._test_scout('scout_sysroot', scout, locales=True) self._test_scout('scout_sysroot', scout, locales=True)
...@@ -1232,6 +1258,11 @@ class TestContainers(BaseTest): ...@@ -1232,6 +1258,11 @@ class TestContainers(BaseTest):
copy=True, gc=False, gc_legacy=False, 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'): with self.subTest('transient'):
self._test_scout('scout_sysroot_usrmerge', scout, locales=True) self._test_scout('scout_sysroot_usrmerge', scout, locales=True)
...@@ -1244,6 +1275,9 @@ class TestContainers(BaseTest): ...@@ -1244,6 +1275,9 @@ class TestContainers(BaseTest):
with self.subTest('copy'): with self.subTest('copy'):
self._test_scout('scout_copy', scout, copy=True, locales=True) 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'): with self.subTest('transient'):
self._test_scout('scout', scout) self._test_scout('scout', scout)
...@@ -1293,6 +1327,11 @@ class TestContainers(BaseTest): ...@@ -1293,6 +1327,11 @@ class TestContainers(BaseTest):
'soldier_sysroot_copy', soldier, copy=True, gc=False, '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'): with self.subTest('transient'):
self._test_soldier('soldier_sysroot', soldier, locales=True) self._test_soldier('soldier_sysroot', soldier, locales=True)
...@@ -1309,6 +1348,11 @@ class TestContainers(BaseTest): ...@@ -1309,6 +1348,11 @@ class TestContainers(BaseTest):
'soldier_copy', soldier, copy=True, locales=True, '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'): with self.subTest('transient'):
self._test_soldier('soldier', soldier) self._test_soldier('soldier', soldier)
......
...@@ -262,6 +262,17 @@ class TestInsideRuntime(BaseTest): ...@@ -262,6 +262,17 @@ class TestInsideRuntime(BaseTest):
return False 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: def test_srsi(self) -> None:
overrides = Path('/overrides').resolve() overrides = Path('/overrides').resolve()
...@@ -322,6 +333,40 @@ class TestInsideRuntime(BaseTest): ...@@ -322,6 +333,40 @@ class TestInsideRuntime(BaseTest):
logger.info('Host OS is not Debian-derived') logger.info('Host OS is not Debian-derived')
host_is_debian_derived = False 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( with self.catch(
'runtime information', 'runtime information',
diagnostic=parsed.get('runtime'), diagnostic=parsed.get('runtime'),
......
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