Skip to content

Commit 1fbbcc2

Browse files
committed
tests:gen:base: Don't fail inside sbuild/chroot environment
sbuild does not provide a fully functional systemd environment, as indicated by the existance of /run/systemd/system. Therefore, we cannot rely on the systemd-run sandbox in such environments.
1 parent d686126 commit 1fbbcc2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/generator/base.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,20 @@ def generate(self, yaml, expect_fail=False, extra_args=[], confs=None, skip_gene
372372
# Allow writing of test coverage data inside the project root (meson's _build-cov/ dir)
373373
'--property=ReadWritePaths=' + os.path.dirname(os.environ.get('COVERAGE_PROCESS_START', '/home/'))]
374374

375+
if os.environ.get('NETPLAN_PARSER_IGNORE_ERRORS'):
376+
del os.environ['NETPLAN_PARSER_IGNORE_ERRORS']
375377
if not ignore_errors:
376-
sandbox += ['--setenv=NETPLAN_PARSER_IGNORE_ERRORS=0'] # for testing only
378+
# for testing only
379+
os.environ.setdefault('NETPLAN_PARSER_IGNORE_ERRORS', '0')
380+
sandbox += ['--setenv=NETPLAN_PARSER_IGNORE_ERRORS={}'
381+
.format(os.environ.get('NETPLAN_PARSER_IGNORE_ERRORS'))]
382+
383+
# Avoid the systemd-run sandbox when run in chroot (e.g. during sbuild),
384+
# as it does not provide a functional systemd environment. The
385+
# ReadWritePaths restriction will still be tested inside the upstream CI
386+
# and locally, using 'make check'.
387+
if not os.path.isdir('/run/systemd/system'):
388+
sandbox = [] # pragma: nocover (runs during sbuild)
377389

378390
argv_gen = sandbox + [self.sd_generator, '--root-dir', self.workdir.name,
379391
self.generator_dir, self.generator_early_dir, self.generator_late_dir]

0 commit comments

Comments
 (0)