mirror of
https://git.proxmox.com/git/systemd
synced 2026-01-14 05:53:29 +00:00
Add nspawn test to boot-and-services autopkgtest
This commit is contained in:
parent
457f782ee1
commit
91b71fcbba
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -5,6 +5,7 @@ systemd (215-7) UNRELEASED; urgency=medium
|
||||
* Add boot-and-services autopkgtest: Check booting with systemd-sysv and
|
||||
that the most crucial services behave as expected.
|
||||
* logind autopkgtest: Fix stderr output in waiting loop for scsi_debug.
|
||||
* Add nspawn test to boot-and-services autopkgtest.
|
||||
|
||||
[ Jon Severinsson]
|
||||
* Add /run/shm -> /dev/shm symlink in debian/tmpfiles.d/debian.conf. This
|
||||
|
||||
40
debian/tests/boot-and-services
vendored
40
debian/tests/boot-and-services
vendored
@ -7,6 +7,8 @@ import sys
|
||||
import os
|
||||
import unittest
|
||||
import subprocess
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
|
||||
class ServicesTest(unittest.TestCase):
|
||||
@ -99,6 +101,44 @@ class JournalTest(unittest.TestCase):
|
||||
self.assertNotIn(b'systemd:', out)
|
||||
|
||||
|
||||
class NspawnTest(unittest.TestCase):
|
||||
'''Check nspawn'''
|
||||
|
||||
@classmethod
|
||||
def setUpClass(kls):
|
||||
'''Build a bootable busybox mini-container'''
|
||||
|
||||
kls.td_c_busybox = tempfile.TemporaryDirectory(prefix='c_busybox.')
|
||||
kls.c_busybox = kls.td_c_busybox.name
|
||||
for d in ['etc/init.d', 'bin', 'sbin']:
|
||||
os.makedirs(os.path.join(kls.c_busybox, d))
|
||||
shutil.copy('/bin/busybox', os.path.join(kls.c_busybox, 'bin'))
|
||||
shutil.copy('/etc/os-release', os.path.join(kls.c_busybox, 'etc'))
|
||||
os.symlink('busybox', os.path.join(kls.c_busybox, 'bin', 'sh'))
|
||||
os.symlink('../bin/busybox', os.path.join(kls.c_busybox, 'sbin/init'))
|
||||
with open(os.path.join(kls.c_busybox, 'etc/init.d/rcS'), 'w') as f:
|
||||
f.write('''#!/bin/sh
|
||||
echo fake container started
|
||||
ps aux
|
||||
poweroff\n''')
|
||||
os.fchmod(f.fileno(), 0o755)
|
||||
|
||||
def setUp(self):
|
||||
self.workdir = tempfile.TemporaryDirectory()
|
||||
|
||||
def test_boot(self):
|
||||
cont = os.path.join(self.workdir.name, 'c1')
|
||||
shutil.copytree(self.c_busybox, cont, symlinks=True)
|
||||
shutil.copytree(self.c_busybox, '/tmp/cont', symlinks=True)
|
||||
out = subprocess.check_output(['systemd-nspawn', '-D', cont, '-b'],
|
||||
timeout=60, stderr=subprocess.STDOUT)
|
||||
self.assertIn(b'Spawning container c1', out)
|
||||
self.assertIn(b'fake container started', out)
|
||||
self.assertRegex(out, b'\n\s+1\s+0\s+init[\r\n]')
|
||||
self.assertRegex(out, b'\n\s+2+\s+0\s.*rcS[\r\n]')
|
||||
self.assertRegex(out, b'Container c1.*shut down')
|
||||
|
||||
|
||||
def boot_with_systemd():
|
||||
'''Reboot with systemd as init
|
||||
|
||||
|
||||
2
debian/tests/control
vendored
2
debian/tests/control
vendored
@ -9,5 +9,5 @@ Tests: python3
|
||||
Depends: python3-systemd
|
||||
|
||||
Tests: boot-and-services
|
||||
Depends: lightdm, cron, network-manager
|
||||
Depends: lightdm, cron, network-manager, busybox-static
|
||||
Restrictions: needs-root, isolation-machine, needs-recommends, breaks-testbed
|
||||
|
||||
Loading…
Reference in New Issue
Block a user