summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/README.testsuite2
-rwxr-xr-xtest/TEST-03-JOBS/test-jobs.sh8
-rwxr-xr-xtest/mocks/fsck27
-rw-r--r--test/splash.bmpbin0 -> 289238 bytes
-rw-r--r--test/sysv-generator-test.py39
-rwxr-xr-xtest/test-efi-create-disk.sh42
-rw-r--r--test/test-functions2
-rwxr-xr-xtest/udev-test.pl9
8 files changed, 105 insertions, 24 deletions
diff --git a/test/README.testsuite b/test/README.testsuite
index 2ae85a2ce1..5c7aca43a8 100644
--- a/test/README.testsuite
+++ b/test/README.testsuite
@@ -10,8 +10,6 @@ $ sudo make clean check
make[1]: Entering directory `/mnt/data/harald/git/systemd/test/TEST-01-BASIC'
Making all in .
Making all in po
-Making all in docs/libudev
-Making all in docs/gudev
TEST: Basic systemd setup [OK]
make[1]: Leaving directory `/mnt/data/harald/git/systemd/test/TEST-01-BASIC'
...
diff --git a/test/TEST-03-JOBS/test-jobs.sh b/test/TEST-03-JOBS/test-jobs.sh
index 28368b70e4..6f32c240cd 100755
--- a/test/TEST-03-JOBS/test-jobs.sh
+++ b/test/TEST-03-JOBS/test-jobs.sh
@@ -1,6 +1,6 @@
#!/bin/bash -x
-# Test merging of a --ignore-dependencies job into a previously
+# Test merging of a --job-mode=ignore-dependencies job into a previously
# installed job.
systemctl start --no-block hello-after-sleep.target
@@ -11,7 +11,7 @@ grep 'hello\.service.*waiting' /root/list-jobs.txt || exit 1
# This is supposed to finish quickly, not wait for sleep to finish.
START_SEC=$(date -u '+%s')
-systemctl start --ignore-dependencies hello
+systemctl start --job-mode=ignore-dependencies hello
END_SEC=$(date -u '+%s')
ELAPSED=$(($END_SEC-$START_SEC))
@@ -27,7 +27,7 @@ systemctl stop sleep.service hello-after-sleep.target || exit 1
systemctl start --no-block hello-after-sleep.target || exit 1
# hello.service should still be waiting, so these try-restarts will collapse
# into NOPs.
-systemctl try-restart --fail hello.service || exit 1
+systemctl try-restart --job-mode=fail hello.service || exit 1
systemctl try-restart hello.service || exit 1
systemctl stop hello.service sleep.service hello-after-sleep.target || exit 1
@@ -39,7 +39,7 @@ systemctl start unstoppable.service || exit 1
# This is expected to fail with 'job cancelled'
systemctl stop unstoppable.service && exit 1
# But this should succeed
-systemctl stop --irreversible unstoppable.service || exit 1
+systemctl stop --job-mode=replace-irreversibly unstoppable.service || exit 1
# We're going to shutdown soon. Let's see if it succeeds when
# there's an active service that tries to be unstoppable.
diff --git a/test/mocks/fsck b/test/mocks/fsck
new file mode 100755
index 0000000000..77b50d7234
--- /dev/null
+++ b/test/mocks/fsck
@@ -0,0 +1,27 @@
+#!/bin/bash
+fd=0
+
+OPTIND=1
+while getopts "C:aTlM" opt; do
+ case "$opt" in
+ C)
+ fd=$OPTARG
+ ;;
+ \?);;
+ esac
+done
+
+shift "$((OPTIND-1))"
+device=$1
+
+echo "Running fake fsck on $device"
+
+declare -a maxpass=(30 5 2 30 60)
+
+for pass in {1..5}; do
+ maxprogress=${maxpass[$((pass-1))]}
+ for (( current=0; current<=${maxprogress}; current++)); do
+ echo "$pass $current $maxprogress $device">&$fd
+ sleep 0.1
+ done
+done
diff --git a/test/splash.bmp b/test/splash.bmp
new file mode 100644
index 0000000000..27247f7a22
--- /dev/null
+++ b/test/splash.bmp
Binary files differ
diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py
index 09f5c01762..e74f8533c7 100644
--- a/test/sysv-generator-test.py
+++ b/test/sysv-generator-test.py
@@ -126,18 +126,18 @@ class SysvGeneratorTest(unittest.TestCase):
return script
- def assert_enabled(self, unit, runlevels):
- '''assert that a unit is enabled in precisely the given runlevels'''
+ def assert_enabled(self, unit, targets):
+ '''assert that a unit is enabled in precisely the given targets'''
- all_runlevels = [2, 3, 4, 5]
+ all_targets = ['multi-user', 'graphical']
# should be enabled
- for runlevel in all_runlevels:
- link = os.path.join(self.out_dir, 'runlevel%i.target.wants' % runlevel, unit)
- if runlevel in runlevels:
- target = os.readlink(link)
- self.assertTrue(os.path.exists(target))
- self.assertEqual(os.path.basename(target), unit)
+ for target in all_targets:
+ link = os.path.join(self.out_dir, '%s.target.wants' % target, unit)
+ if target in targets:
+ unit_file = os.readlink(link)
+ self.assertTrue(os.path.exists(unit_file))
+ self.assertEqual(os.path.basename(unit_file), unit)
else:
self.assertFalse(os.path.exists(link),
'%s unexpectedly exists' % link)
@@ -178,13 +178,16 @@ class SysvGeneratorTest(unittest.TestCase):
self.assertEqual(s.get('Service', 'ExecStop'),
'%s stop' % init_script)
+ self.assertNotIn('Overwriting', err)
+
def test_simple_enabled_all(self):
'''simple service without dependencies, enabled in all runlevels'''
self.add_sysv('foo', {}, enable=True)
err, results = self.run_generator()
self.assertEqual(list(results), ['foo.service'])
- self.assert_enabled('foo.service', [2, 3, 4, 5])
+ self.assert_enabled('foo.service', ['multi-user', 'graphical'])
+ self.assertNotIn('Overwriting', err)
def test_simple_enabled_some(self):
'''simple service without dependencies, enabled in some runlevels'''
@@ -192,7 +195,7 @@ class SysvGeneratorTest(unittest.TestCase):
self.add_sysv('foo', {'Default-Start': '2 4'}, enable=True)
err, results = self.run_generator()
self.assertEqual(list(results), ['foo.service'])
- self.assert_enabled('foo.service', [2, 4])
+ self.assert_enabled('foo.service', ['multi-user'])
def test_lsb_macro_dep_single(self):
'''single LSB macro dependency: $network'''
@@ -270,6 +273,7 @@ class SysvGeneratorTest(unittest.TestCase):
for f in ['bar.service', 'baz.service']:
self.assertEqual(os.readlink(os.path.join(self.out_dir, f)),
'foo.service')
+ self.assertNotIn('Overwriting', err)
def test_same_provides_in_multiple_scripts(self):
'''multiple init.d scripts provide the same name'''
@@ -289,6 +293,9 @@ class SysvGeneratorTest(unittest.TestCase):
self.add_sysv('bar', {'Provides': 'bar'}, enable=True)
err, results = self.run_generator()
self.assertEqual(sorted(results), ['bar.service', 'foo.service'])
+ # we do expect an overwrite here, bar.service should overwrite the
+ # alias link from foo.service
+ self.assertIn('Overwriting', err)
def test_nonexecutable_script(self):
'''ignores non-executable init.d script'''
@@ -315,7 +322,7 @@ class SysvGeneratorTest(unittest.TestCase):
self.assertEqual(s.get('Service', 'ExecStop'),
'%s stop' % init_script)
- self.assert_enabled('foo.service', [2, 3, 4, 5])
+ self.assert_enabled('foo.service', ['multi-user', 'graphical'])
def test_sh_suffix_with_provides(self):
'''init.d script with .sh suffix and Provides:'''
@@ -323,7 +330,7 @@ class SysvGeneratorTest(unittest.TestCase):
self.add_sysv('foo.sh', {'Provides': 'foo bar'})
err, results = self.run_generator()
# ensure we don't try to create a symlink to itself
- self.assertNotIn(err, 'itself')
+ self.assertNotIn('itself', err)
self.assertEqual(list(results), ['foo.service'])
self.assertEqual(results['foo.service'].get('Unit', 'Description'),
'LSB: test foo service')
@@ -345,7 +352,7 @@ class SysvGeneratorTest(unittest.TestCase):
err, results = self.run_generator()
self.assertEqual(list(results), ['foo.service'])
- self.assert_enabled('foo.service', [2, 3, 4, 5])
+ self.assert_enabled('foo.service', ['multi-user', 'graphical'])
def test_backup_file(self):
'''init.d script with backup file'''
@@ -361,9 +368,9 @@ class SysvGeneratorTest(unittest.TestCase):
['foo.bak.service', 'foo.old.service', 'foo.service'])
# ensure we don't try to create a symlink to itself
- self.assertNotIn(err, 'itself')
+ self.assertNotIn('itself', err)
- self.assert_enabled('foo.service', [2, 3, 4, 5])
+ self.assert_enabled('foo.service', ['multi-user', 'graphical'])
self.assert_enabled('foo.bak.service', [])
self.assert_enabled('foo.old.service', [])
diff --git a/test/test-efi-create-disk.sh b/test/test-efi-create-disk.sh
new file mode 100755
index 0000000000..56dd09abd7
--- /dev/null
+++ b/test/test-efi-create-disk.sh
@@ -0,0 +1,42 @@
+#!/bin/bash -e
+
+# create GPT table with EFI System Partition
+rm -f test-efi-disk.img
+dd if=/dev/null of=test-efi-disk.img bs=1M seek=512 count=1
+parted --script test-efi-disk.img "mklabel gpt" "mkpart ESP fat32 1MiB 511MiB" "set 1 boot on"
+
+# create FAT32 file system
+LOOP=$(losetup --show -f -P test-efi-disk.img)
+mkfs.vfat -F32 ${LOOP}p1
+mkdir -p mnt
+mount ${LOOP}p1 mnt
+
+mkdir -p mnt/EFI/{Boot,systemd}
+cp systemd-bootx64.efi mnt/EFI/Boot/bootx64.efi
+
+[ -e /boot/shellx64.efi ] && cp /boot/shellx64.efi mnt/
+
+mkdir mnt/EFI/Linux
+echo -n "foo=yes bar=no root=/dev/fakeroot debug rd.break=initqueue" > mnt/cmdline.txt
+objcopy \
+ --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \
+ --add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \
+ --add-section .splash=test/splash.bmp --change-section-vma .splash=0x40000 \
+ --add-section .linux=/boot/$(cat /etc/machine-id)/$(uname -r)/linux --change-section-vma .linux=0x2000000 \
+ --add-section .initrd=/boot/$(cat /etc/machine-id)/$(uname -r)/initrd --change-section-vma .initrd=0x3000000 \
+ linuxx64.efi.stub mnt/EFI/Linux/linux-test.efi
+
+# install entries
+mkdir -p mnt/loader/entries
+echo -e "timeout 3\n" > mnt/loader/loader.conf
+echo -e "title Test\nefi /test\n" > mnt/loader/entries/test.conf
+echo -e "title Test2\nlinux /test2\noptions option=yes word number=1000 more\n" > mnt/loader/entries/test2.conf
+echo -e "title Test3\nlinux /test3\n" > mnt/loader/entries/test3.conf
+echo -e "title Test4\nlinux /test4\n" > mnt/loader/entries/test4.conf
+echo -e "title Test5\nefi /test5\n" > mnt/loader/entries/test5.conf
+echo -e "title Test6\nlinux /test6\n" > mnt/loader/entries/test6.conf
+
+sync
+umount mnt
+rmdir mnt
+losetup -d $LOOP
diff --git a/test/test-functions b/test/test-functions
index 901ff48605..8272e52e17 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -125,7 +125,7 @@ install_systemd() {
# install compiled files
(cd $TEST_BASE_DIR/..; set -x; make DESTDIR=$initdir install)
# remove unneeded documentation
- rm -fr $initdir/usr/share/{man,doc,gtk-doc}
+ rm -fr $initdir/usr/share/{man,doc}
# we strip binaries since debug symbols increase binaries size a lot
# and it could fill the available space
strip_binaries
diff --git a/test/udev-test.pl b/test/udev-test.pl
index d9b7967004..64d7f93444 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -22,7 +22,9 @@ use strict;
my $udev_bin = "./test-udev";
my $valgrind = 0;
-my $udev_bin_valgrind = "valgrind --tool=memcheck --leak-check=yes --quiet $udev_bin";
+my $gdb = 0;
+my $udev_bin_valgrind = "valgrind --tool=memcheck --leak-check=yes --track-origins=yes --quiet $udev_bin";
+my $udev_bin_gdb = "gdb --args $udev_bin";
my $udev_dev = "test/dev";
my $udev_run = "test/run";
my $udev_rules_dir = "$udev_run/udev/rules.d";
@@ -1326,6 +1328,8 @@ sub udev {
if ($valgrind > 0) {
system("$udev_bin_valgrind $action $devpath");
+ } elsif ($gdb > 0) {
+ system("$udev_bin_gdb $action $devpath");
} else {
system("$udev_bin", "$action", "$devpath");
}
@@ -1502,6 +1506,9 @@ foreach my $arg (@ARGV) {
if ($arg =~ m/--valgrind/) {
$valgrind = 1;
printf("using valgrind\n");
+ } elsif ($arg =~ m/--gdb/) {
+ $gdb = 1;
+ printf("using gdb\n");
} else {
push(@list, $arg);
}