diff --git a/debian/tests/boot-and-services b/debian/tests/boot-and-services index c26bf30df..8ebbfd613 100755 --- a/debian/tests/boot-and-services +++ b/debian/tests/boot-and-services @@ -13,6 +13,8 @@ import time import re from glob import glob +is_container = subprocess.call(['systemd-detect-virt', '--container']) == 0 + def wait_unit_stop(unit, timeout=10): '''Wait until given unit is not running any more @@ -53,6 +55,9 @@ class ServicesTest(unittest.TestCase): failed = [f for f in failed if 'console-setup' not in f] # cpi.service fails on s390x failed = [f for f in failed if 'cpi.service' not in f] + # https://bugs.debian.org/926138 + if is_container: + failed = [f for f in failed if 'e2scrub_reap.service' not in f] if failed: for f in failed: f = f.split()[0] @@ -63,7 +68,7 @@ class ServicesTest(unittest.TestCase): @unittest.skipUnless(shutil.which('gdm3') is not None, 'gdm3 not found') def test_gdm3(self): - subprocess.check_call(['pgrep', '-af', 'gdm-.*-session']) + subprocess.check_call(['pgrep', '-af', '/gdm[-3]']) self.active_unit('gdm') def test_dbus(self): @@ -102,13 +107,15 @@ class ServicesTest(unittest.TestCase): self.active_unit('rsyslog') with open('/var/log/syslog') as f: log = f.read() - # has kernel messages - self.assertRegex(log, 'kernel:.*[cC]ommand line:') + if not is_container: + # has kernel messages + self.assertRegex(log, 'kernel:.*[cC]ommand line:') # has init messages self.assertRegex(log, 'systemd.*Reached target Graphical Interface') # has other services self.assertRegex(log, 'NetworkManager.*:') + @unittest.skipIf(is_container, 'udev does not work in containers') def test_udev(self): out = subprocess.check_output(['udevadm', 'info', '--export-db']) self.assertIn(b'\nP: /devices/', out) @@ -146,12 +153,14 @@ class ServicesTest(unittest.TestCase): ['systemctl', 'status', 'systemd-tmpfiles-clean.timer'], stdout=subprocess.PIPE), 0) subprocess.check_call(['systemctl', 'start', 'systemd-tmpfiles-clean']) - # all files in /tmp/ should get cleaned up on boot - self.assertFalse(os.path.exists('/tmp/oldfile.test')) + if not is_container: + # all files in /tmp/ should get cleaned up on boot + self.assertFalse(os.path.exists('/tmp/oldfile.test')) self.assertFalse(os.path.exists('/tmp/newfile.test')) # files in /var/tmp/ older than 30d should get cleaned up # XXX FIXME: /var/tmp/ cleanup was disabled in #675422 - # self.assertFalse(os.path.exists('/var/tmp/oldfile.test')) + # if not is_container: + # self.assertFalse(os.path.exists('/var/tmp/oldfile.test')) self.assertTrue(os.path.exists('/var/tmp/newfile.test')) # next run should leave the recent ones @@ -175,8 +184,9 @@ class JournalTest(unittest.TestCase): def test_no_options(self): out = subprocess.check_output(['journalctl']) - # has kernel messages - self.assertRegex(out, b'kernel:.*[cC]ommand line:') + if not is_container: + # has kernel messages + self.assertRegex(out, b'kernel:.*[cC]ommand line:') # has init messages self.assertRegex(out, b'systemd.*Reached target Graphical Interface') # has other services @@ -190,6 +200,7 @@ class JournalTest(unittest.TestCase): self.assertNotIn(b'systemd:', out) +@unittest.skipIf(is_container, 'nspawn does not work in most containers') class NspawnTest(unittest.TestCase): '''Check nspawn''' @@ -412,6 +423,7 @@ SystemCallFilter=access self.assertNotIn(f.read().strip().encode('ASCII'), out) +@unittest.skipIf(is_container, 'systemd-coredump does not work in containers') class CoredumpTest(unittest.TestCase): '''Check systemd-coredump''' @@ -510,15 +522,16 @@ def pre_boot_setup(): os.close(os.open('/var/tmp/newfile.test', os.O_CREAT | os.O_EXCL | os.O_WRONLY)) # we can't use utime() here, as systemd looks for ctime - cur_time = time.clock_gettime(time.CLOCK_REALTIME) - time.clock_settime(time.CLOCK_REALTIME, cur_time - 2 * 30 * 86400) - try: - os.close(os.open('/tmp/oldfile.test', - os.O_CREAT | os.O_EXCL | os.O_WRONLY)) - os.close(os.open('/var/tmp/oldfile.test', - os.O_CREAT | os.O_EXCL | os.O_WRONLY)) - finally: - time.clock_settime(time.CLOCK_REALTIME, cur_time) + if not is_container: + cur_time = time.clock_gettime(time.CLOCK_REALTIME) + time.clock_settime(time.CLOCK_REALTIME, cur_time - 2 * 30 * 86400) + try: + os.close(os.open('/tmp/oldfile.test', + os.O_CREAT | os.O_EXCL | os.O_WRONLY)) + os.close(os.open('/var/tmp/oldfile.test', + os.O_CREAT | os.O_EXCL | os.O_WRONLY)) + finally: + time.clock_settime(time.CLOCK_REALTIME, cur_time) # allow X to start even on headless machines os.makedirs('/etc/X11/xorg.conf.d/', exist_ok=True) diff --git a/debian/tests/control b/debian/tests/control index ccfdcd1cf..0ae1c8be2 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -82,10 +82,11 @@ Depends: systemd-sysv, cron, network-manager, busybox-static, + rsyslog, apparmor, pkg-config, python3 -Restrictions: needs-root, isolation-machine, breaks-testbed +Restrictions: needs-root, isolation-container, breaks-testbed Tests: udev Depends: systemd-tests,