summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2015-04-03 18:26:54 +0200
committerAndy Wingo <wingo@pobox.com>2015-04-08 08:30:28 +0200
commit62b7106671d04f70d7f6b49e9d53e637d116b0db (patch)
tree46c08ca36cf75c090587ada5c49129816b240e24
parentccb03fc9015e6c8131e4d289a36e0145eaf2b5a2 (diff)
remove tests
-rw-r--r--test/.gitignore5
-rw-r--r--test/Makefile20
-rw-r--r--test/README.testsuite48
-rw-r--r--test/TEST-01-BASIC/Makefile10
-rwxr-xr-xtest/TEST-01-BASIC/test.sh74
l---------test/TEST-02-CRYPTSETUP/Makefile1
-rwxr-xr-xtest/TEST-02-CRYPTSETUP/test.sh97
l---------test/TEST-03-JOBS/Makefile1
-rwxr-xr-xtest/TEST-03-JOBS/test-jobs.sh50
-rwxr-xr-xtest/TEST-03-JOBS/test.sh79
-rw-r--r--test/a.service7
-rw-r--r--test/b.service6
l---------test/basic.target1
-rw-r--r--test/bus-policy/check-own-rules.conf14
-rw-r--r--test/bus-policy/hello.conf14
-rw-r--r--test/bus-policy/many-rules.conf61
-rw-r--r--test/bus-policy/methods.conf17
-rw-r--r--test/bus-policy/ownerships.conf24
-rw-r--r--test/bus-policy/signals.conf15
-rw-r--r--test/bus-policy/test.conf20
-rw-r--r--test/c.service6
-rw-r--r--test/d.service8
-rw-r--r--test/daughter.service7
-rw-r--r--test/e.service8
-rw-r--r--test/end.service.in6
-rw-r--r--test/exec-environment-empty.service7
-rw-r--r--test/exec-environment-multiple.service7
-rw-r--r--test/exec-environment.service6
-rw-r--r--test/exec-group.service6
-rw-r--r--test/exec-ignoresigpipe-no.service7
-rw-r--r--test/exec-ignoresigpipe-yes.service7
-rw-r--r--test/exec-personality-x86-64.service7
-rw-r--r--test/exec-personality-x86.service7
-rw-r--r--test/exec-privatedevices-no.service7
-rw-r--r--test/exec-privatedevices-yes.service7
-rw-r--r--test/exec-privatetmp-no.service7
-rw-r--r--test/exec-privatetmp-yes.service7
-rw-r--r--test/exec-systemcallerrornumber.service7
-rw-r--r--test/exec-systemcallfilter-failing.service8
-rw-r--r--test/exec-systemcallfilter-failing2.service6
-rw-r--r--test/exec-systemcallfilter-not-failing.service9
-rw-r--r--test/exec-systemcallfilter-not-failing2.service6
-rw-r--r--test/exec-umask-0177.service7
-rw-r--r--test/exec-umask-default.service6
-rw-r--r--test/exec-user.service6
-rw-r--r--test/exec-workingdirectory.service7
-rw-r--r--test/f.service5
-rw-r--r--test/g.service6
-rw-r--r--test/grandchild.service7
-rw-r--r--test/h.service6
-rw-r--r--test/hello-after-sleep.target5
-rw-r--r--test/hello.service5
-rw-r--r--test/loopy.service2
-rw-r--r--test/loopy.service.d/compat.conf5
l---------test/loopy2.service1
-rw-r--r--test/loopy3.service5
l---------test/loopy4.service1
-rwxr-xr-xtest/mocks/fsck27
-rw-r--r--test/parent-deep.slice5
-rw-r--r--test/parent.slice5
-rw-r--r--test/path-changed.path8
l---------test/path-changed.service1
-rw-r--r--test/path-directorynotempty.path8
l---------test/path-directorynotempty.service1
-rw-r--r--test/path-exists.path8
l---------test/path-exists.service1
-rw-r--r--test/path-existsglob.path8
l---------test/path-existsglob.service1
-rw-r--r--test/path-makedirectory.path10
l---------test/path-makedirectory.service1
-rw-r--r--test/path-modified.path8
l---------test/path-modified.service1
-rw-r--r--test/path-mycustomunit.service6
-rw-r--r--test/path-service.service6
-rw-r--r--test/path-unit.path9
l---------test/paths.target1
-rw-r--r--test/rule-syntax-check.py72
-rw-r--r--test/sched_idle_bad.service6
-rw-r--r--test/sched_idle_ok.service6
-rw-r--r--test/sched_rr_bad.service8
-rw-r--r--test/sched_rr_change.service9
-rw-r--r--test/sched_rr_ok.service6
l---------test/shutdown.target1
-rw-r--r--test/sleep.service6
l---------test/sockets.target1
-rw-r--r--test/son.service8
-rw-r--r--test/splash.bmpbin289238 -> 0 bytes
-rw-r--r--test/sys.tar.xzbin165116 -> 0 bytes
l---------test/sysinit.target1
-rw-r--r--test/sysv-generator-test.py391
-rwxr-xr-xtest/test-efi-create-disk.sh42
-rw-r--r--test/test-functions1186
-rw-r--r--test/testsuite.target6
l---------test/timers.target1
-rwxr-xr-xtest/udev-test.pl1545
-rw-r--r--test/unstoppable.service5
96 files changed, 0 insertions, 4206 deletions
diff --git a/test/.gitignore b/test/.gitignore
deleted file mode 100644
index fd7483da0a..0000000000
--- a/test/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.testdir
-test.log
-/dev
-/run
-/sys
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index 987a32548f..0000000000
--- a/test/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Just a little hook script to easy building when in this directory
-.PHONY: all check clean
-
-all:
- $(MAKE) -C ..
-
-clean:
- @for i in TEST-[0-9]*; do \
- [ -d $$i ] || continue ; \
- [ -f $$i/Makefile ] || continue ; \
- make -C $$i clean ; \
- done
-
-check:
- $(MAKE) -C .. all
- @for i in TEST-[0-9]*; do \
- [ -d $$i ] || continue ; \
- [ -f $$i/Makefile ] || continue ; \
- make -C $$i all ; \
- done
diff --git a/test/README.testsuite b/test/README.testsuite
deleted file mode 100644
index 2ae85a2ce1..0000000000
--- a/test/README.testsuite
+++ /dev/null
@@ -1,48 +0,0 @@
-The extended testsuite only works with uid=0. It contains of several
-subdirectories named "test/TEST-??-*", which are run one by one.
-
-To run the extended testsuite do the following:
-
-$ make all
-$ cd test
-$ 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'
-...
-
-If one of the tests fails, then $subdir/test.log contains the log file of
-the test.
-
-To debug a special testcase of the testsuite do:
-
-$ make all
-$ cd test/TEST-01-BASIC
-$ sudo make clean setup run
-
-QEMU
-====
-
-If you want to log in the testsuite virtual machine, you can specify
-additional kernel command line parameter with $KERNEL_APPEND.
-
-$ sudo make KERNEL_APPEND="systemd.unit=multi-user.target" clean setup run
-
-you can even skip the "clean" and "setup" if you want to run the machine again.
-
-$ sudo make KERNEL_APPEND="systemd.unit=multi-user.target" run
-
-You can specify a different kernel and initramfs with $KERNEL_BIN and $INITRD.
-(Fedora's default kernel path and initramfs are used by default)
-
-$ sudo make KERNEL_BIN=/boot/vmlinuz-foo INITRD=/boot/initramfs-bar clean check
-
-A script will try to find your QEMU binary. If you want to specify a different
-one you can use $QEMU_BIN.
-
-$ sudo make QEMU_BIN=/path/to/qemu/qemu-kvm clean check
diff --git a/test/TEST-01-BASIC/Makefile b/test/TEST-01-BASIC/Makefile
deleted file mode 100644
index 5e89a29eff..0000000000
--- a/test/TEST-01-BASIC/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-all:
- @make -s --no-print-directory -C ../.. all
- @basedir=../.. TEST_BASE_DIR=../ ./test.sh --all
-setup:
- @make --no-print-directory -C ../.. all
- @basedir=../.. TEST_BASE_DIR=../ ./test.sh --setup
-clean:
- @basedir=../.. TEST_BASE_DIR=../ ./test.sh --clean
-run:
- @basedir=../.. TEST_BASE_DIR=../ ./test.sh --run
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh
deleted file mode 100755
index d97fbe24d4..0000000000
--- a/test/TEST-01-BASIC/test.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-TEST_DESCRIPTION="Basic systemd setup"
-
-. $TEST_BASE_DIR/test-functions
-
-check_result_qemu() {
- ret=1
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
- [[ -e $TESTDIR/root/testok ]] && ret=0
- [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
- [[ -f $TESTDIR/root/var/log/journal ]] && cp -a $TESTDIR/root/var/log/journal $TESTDIR
- umount $TESTDIR/root
- [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
- ls -l $TESTDIR/journal/*/*.journal
- test -s $TESTDIR/failed && ret=$(($ret+1))
- return $ret
-}
-
-test_run() {
- if run_qemu; then
- check_result_qemu || return 1
- else
- dwarn "can't run QEMU, skipping"
- fi
- if check_nspawn; then
- run_nspawn
- check_result_nspawn || return 1
- else
- dwarn "can't run systemd-nspawn, skipping"
- fi
- return 0
-}
-
-test_setup() {
- create_empty_image
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
-
- # Create what will eventually be our root filesystem onto an overlay
- (
- LOG_LEVEL=5
- eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
-
- setup_basic_environment
-
- # setup the testsuite service
- cat >$initdir/etc/systemd/system/testsuite.service <<EOF
-[Unit]
-Description=Testsuite service
-After=multi-user.target
-
-[Service]
-ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;'
-Type=oneshot
-EOF
-
- setup_testsuite
- )
- setup_nspawn_root
-
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
-}
-
-test_cleanup() {
- umount $TESTDIR/root 2>/dev/null
- [[ $LOOPDEV ]] && losetup -d $LOOPDEV
- return 0
-}
-
-do_test "$@"
diff --git a/test/TEST-02-CRYPTSETUP/Makefile b/test/TEST-02-CRYPTSETUP/Makefile
deleted file mode 120000
index e9f93b1104..0000000000
--- a/test/TEST-02-CRYPTSETUP/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../TEST-01-BASIC/Makefile \ No newline at end of file
diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh
deleted file mode 100755
index 4be2365e2f..0000000000
--- a/test/TEST-02-CRYPTSETUP/test.sh
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-TEST_DESCRIPTION="cryptsetup systemd setup"
-
-. $TEST_BASE_DIR/test-functions
-
-check_result_qemu() {
- ret=1
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
- [[ -e $TESTDIR/root/testok ]] && ret=0
- [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
- cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
- mount /dev/mapper/varcrypt $TESTDIR/root/var
- [[ -f $TESTDIR/root/var/log/journal ]] && cp -a $TESTDIR/root/var/log/journal $TESTDIR
- umount $TESTDIR/root/var
- umount $TESTDIR/root
- cryptsetup luksClose /dev/mapper/varcrypt
- [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
- ls -l $TESTDIR/journal/*/*.journal
- test -s $TESTDIR/failed && ret=$(($ret+1))
- return $ret
-}
-
-
-test_run() {
- if run_qemu; then
- check_result_qemu || return 1
- else
- dwarn "can't run QEMU, skipping"
- fi
- return 0
-}
-
-test_setup() {
- create_empty_image
- echo -n test >$TESTDIR/keyfile
- cryptsetup -q luksFormat ${LOOPDEV}p2 $TESTDIR/keyfile
- cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
- mkfs.ext3 -L var /dev/mapper/varcrypt
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
- mkdir -p $TESTDIR/root/var
- mount /dev/mapper/varcrypt $TESTDIR/root/var
-
- # Create what will eventually be our root filesystem onto an overlay
- (
- LOG_LEVEL=5
- eval $(udevadm info --export --query=env --name=/dev/mapper/varcrypt)
- eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
-
- setup_basic_environment
-
- # setup the testsuite service
- cat >$initdir/etc/systemd/system/testsuite.service <<EOF
-[Unit]
-Description=Testsuite service
-After=multi-user.target
-
-[Service]
-ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do systemd-cat echo "testsuite service waiting for /var/log/journal" ; echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;'
-Type=oneshot
-EOF
-
- setup_testsuite
-
- install_dmevent
- generate_module_dependencies
- cat >$initdir/etc/crypttab <<EOF
-$DM_NAME UUID=$ID_FS_UUID /etc/varkey
-EOF
- echo -n test > $initdir/etc/varkey
- cat $initdir/etc/crypttab | ddebug
-
- cat >>$initdir/etc/fstab <<EOF
-/dev/mapper/varcrypt /var ext3 defaults 0 1
-EOF
- )
- setup_nspawn_root
-
- ddebug "umount $TESTDIR/root/var"
- umount $TESTDIR/root/var
- cryptsetup luksClose /dev/mapper/varcrypt
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
-}
-
-test_cleanup() {
- umount $TESTDIR/root/var 2>/dev/null
- [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
- umount $TESTDIR/root 2>/dev/null
- [[ $LOOPDEV ]] && losetup -d $LOOPDEV
- return 0
-}
-
-do_test "$@"
diff --git a/test/TEST-03-JOBS/Makefile b/test/TEST-03-JOBS/Makefile
deleted file mode 120000
index e9f93b1104..0000000000
--- a/test/TEST-03-JOBS/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../TEST-01-BASIC/Makefile \ No newline at end of file
diff --git a/test/TEST-03-JOBS/test-jobs.sh b/test/TEST-03-JOBS/test-jobs.sh
deleted file mode 100755
index 28368b70e4..0000000000
--- a/test/TEST-03-JOBS/test-jobs.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash -x
-
-# Test merging of a --ignore-dependencies job into a previously
-# installed job.
-
-systemctl start --no-block hello-after-sleep.target
-# sleep is now running, hello/start is waiting. Verify that:
-systemctl list-jobs > /root/list-jobs.txt
-grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1
-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
-END_SEC=$(date -u '+%s')
-ELAPSED=$(($END_SEC-$START_SEC))
-
-[ "$ELAPSED" -lt 3 ] || exit 1
-
-# sleep should still be running, hello not.
-systemctl list-jobs > /root/list-jobs.txt
-grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1
-grep 'hello\.service' /root/list-jobs.txt && exit 1
-systemctl stop sleep.service hello-after-sleep.target || exit 1
-
-# Test for a crash when enqueueing a JOB_NOP when other job already exists
-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 hello.service || exit 1
-systemctl stop hello.service sleep.service hello-after-sleep.target || exit 1
-
-# TODO: add more job queueing/merging tests here.
-
-# Test for irreversible jobs
-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
-
-# We're going to shutdown soon. Let's see if it succeeds when
-# there's an active service that tries to be unstoppable.
-# Shutdown of the container/VM will hang if not.
-systemctl start unstoppable.service || exit 1
-
-touch /testok
-exit 0
diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh
deleted file mode 100755
index 41e02e2c8a..0000000000
--- a/test/TEST-03-JOBS/test.sh
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-TEST_DESCRIPTION="Job-related tests"
-
-. $TEST_BASE_DIR/test-functions
-
-check_result_qemu() {
- ret=1
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
- [[ -e $TESTDIR/root/testok ]] && ret=0
- [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
- cp -a $TESTDIR/root/var/log/journal $TESTDIR
- umount $TESTDIR/root
- [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
- ls -l $TESTDIR/journal/*/*.journal
- test -s $TESTDIR/failed && ret=$(($ret+1))
- return $ret
-}
-
-test_run() {
- if run_qemu; then
- check_result_qemu || return 1
- else
- dwarn "can't run QEMU, skipping"
- fi
- if check_nspawn; then
- run_nspawn
- check_result_nspawn || return 1
- else
- dwarn "can't run systemd-nspawn, skipping"
- fi
- return 0
-}
-
-test_setup() {
- create_empty_image
- mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
-
- # Create what will eventually be our root filesystem onto an overlay
- (
- LOG_LEVEL=5
- eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
-
- setup_basic_environment
-
- # setup the testsuite service
- cat >$initdir/etc/systemd/system/testsuite.service <<EOF
-[Unit]
-Description=Testsuite service
-After=multi-user.target
-
-[Service]
-ExecStart=/test-jobs.sh
-Type=oneshot
-EOF
-
- # copy the units used by this test
- cp $TEST_BASE_DIR/{hello.service,sleep.service,hello-after-sleep.target,unstoppable.service} \
- $initdir/etc/systemd/system
- cp test-jobs.sh $initdir/
-
- setup_testsuite
- )
- setup_nspawn_root
-
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
-}
-
-test_cleanup() {
- umount $TESTDIR/root 2>/dev/null
- [[ $LOOPDEV ]] && losetup -d $LOOPDEV
- return 0
-}
-
-do_test "$@"
diff --git a/test/a.service b/test/a.service
deleted file mode 100644
index 4168d2d051..0000000000
--- a/test/a.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=A
-Requires=b.service
-Before=b.service
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/b.service b/test/b.service
deleted file mode 100644
index e03bae36be..0000000000
--- a/test/b.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=B
-Wants=f.service
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/basic.target b/test/basic.target
deleted file mode 120000
index 0612934682..0000000000
--- a/test/basic.target
+++ /dev/null
@@ -1 +0,0 @@
-../units/basic.target \ No newline at end of file
diff --git a/test/bus-policy/check-own-rules.conf b/test/bus-policy/check-own-rules.conf
deleted file mode 100644
index bc2f415fcb..0000000000
--- a/test/bus-policy/check-own-rules.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
- <user>mybususer</user>
- <listen>unix:path=/foo/bar</listen>
- <listen>tcp:port=1234</listen>
- <servicedir>/usr/share/foo</servicedir>
- <policy context="default">
- <allow user="*"/>
- <deny own="*"/>
- <allow own_prefix="org.freedesktop.ManySystems"/>
- </policy>
-
-</busconfig>
diff --git a/test/bus-policy/hello.conf b/test/bus-policy/hello.conf
deleted file mode 100644
index af09893de6..0000000000
--- a/test/bus-policy/hello.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0"?> <!--*-nxml-*-->
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
-
- <policy context="default">
- <allow user="*"/>
-
- <deny user="1"/>
- <deny group="1"/>
- </policy>
-
-</busconfig>
diff --git a/test/bus-policy/many-rules.conf b/test/bus-policy/many-rules.conf
deleted file mode 100644
index 70dd538c11..0000000000
--- a/test/bus-policy/many-rules.conf
+++ /dev/null
@@ -1,61 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
- <user>mybususer</user>
- <listen>unix:path=/foo/bar</listen>
- <listen>tcp:port=1234</listen>
- <includedir>basic.d</includedir>
- <standard_session_servicedirs />
- <servicedir>/usr/share/foo</servicedir>
- <include ignore_missing="yes">nonexistent.conf</include>
- <policy context="default">
- <allow user="*"/>
- <deny send_interface="org.freedesktop.System" send_member="Reboot"/>
- <deny receive_interface="org.freedesktop.System" receive_member="Reboot"/>
- <deny send_path="/foo/bar/SystemObjectThing" send_member="Reboot"/>
- <deny own="org.freedesktop.System"/>
- <deny own_prefix="org.freedesktop.ManySystems"/>
- <deny send_destination="org.freedesktop.System"/>
- <deny receive_sender="org.freedesktop.System"/>
- <deny user="root"/>
- <deny group="bin"/>
- <allow send_type="error"/>
- <allow send_type="method_call"/>
- <allow send_type="method_return"/>
- <allow send_type="signal"/>
- <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo"/>
- <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo" send_type="method_call"/>
- </policy>
-
- <policy context="mandatory">
- <allow user="*"/>
- <deny send_interface="org.freedesktop.System" send_member="Reboot"/>
- <deny receive_interface="org.freedesktop.System" receive_member="Reboot"/>
- <deny send_path="/foo/bar/SystemObjectThing" send_member="Reboot"/>
- <deny own="org.freedesktop.System"/>
- <deny own_prefix="org.freedesktop.ManySystems"/>
- <deny send_destination="org.freedesktop.System"/>
- <deny receive_sender="org.freedesktop.System"/>
- <deny user="root"/>
- <deny group="bin"/>
- <allow send_type="error"/>
- <allow send_type="method_call"/>
- <allow send_type="method_return"/>
- <allow send_type="signal"/>
- <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo"/>
- <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo" send_type="method_call"/>
- </policy>
-
- <limit name="max_incoming_bytes">5000</limit>
- <limit name="max_outgoing_bytes">5000</limit>
- <limit name="max_message_size">300</limit>
- <limit name="service_start_timeout">5000</limit>
- <limit name="auth_timeout">6000</limit>
- <limit name="max_completed_connections">50</limit>
- <limit name="max_incomplete_connections">80</limit>
- <limit name="max_connections_per_user">64</limit>
- <limit name="max_pending_service_starts">64</limit>
- <limit name="max_names_per_connection">256</limit>
- <limit name="max_match_rules_per_connection">512</limit>
-
-</busconfig>
diff --git a/test/bus-policy/methods.conf b/test/bus-policy/methods.conf
deleted file mode 100644
index 4bc38f9151..0000000000
--- a/test/bus-policy/methods.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0"?> <!--*-nxml-*-->
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
-
- <policy context="default">
- <deny send_type="method_call"/>
-
- <deny send_destination="org.test.test1"/>
- <allow send_destination="org.test.test1" send_interface="org.test.int1"/>
- <allow send_destination="org.test.test1" send_interface="org.test.int2"/>
-
- <allow receive_sender="org.test.test3" receive_interface="org.test.int3" receive_member="Member111"/>
- </policy>
-
-</busconfig>
diff --git a/test/bus-policy/ownerships.conf b/test/bus-policy/ownerships.conf
deleted file mode 100644
index bc3a230a26..0000000000
--- a/test/bus-policy/ownerships.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?> <!--*-nxml-*-->
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
-
- <policy context="default">
- <allow own="org.test.test1"/>
- </policy>
-
- <policy context="mandatory">
- <deny own="org.test.test3"/>
- </policy>
-
- <policy user="root">
- <allow own="org.test.test2"/>
- <allow own="org.test.test3"/>
- </policy>
-
- <policy user="1">
- <allow own="org.test.test4"/>
- </policy>
-
-</busconfig>
diff --git a/test/bus-policy/signals.conf b/test/bus-policy/signals.conf
deleted file mode 100644
index 440e3fe6d0..0000000000
--- a/test/bus-policy/signals.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0"?> <!--*-nxml-*-->
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
-
- <policy context="default">
- <allow send_type="signal"/>
- </policy>
-
- <policy user="1">
- <deny send_type="signal"/>
- </policy>
-
-</busconfig>
diff --git a/test/bus-policy/test.conf b/test/bus-policy/test.conf
deleted file mode 100644
index ee6afcdfbb..0000000000
--- a/test/bus-policy/test.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
- <!-- The following demonstrates how to punch holes in a default deny-all
- policy so that a particular user can own a service, and other
- connections can get messages from it -->
-
- <!-- Only root can own the FooService service, and
- this user can only send the one kind of message -->
- <policy user="root">
- <allow own="org.foo.FooService"/>
- <allow send_interface="org.foo.FooBroadcastInterface"/>
- </policy>
-
- <!-- Allow any connection to receive the message, but
- only if the message is sent by the owner of FooService -->
- <policy context="default">
- <allow receive_interface="org.foo.FooBroadcastInterface" receive_sender="org.foo.FooService"/>
- </policy>
-</busconfig>
diff --git a/test/c.service b/test/c.service
deleted file mode 100644
index e2f60a8fbf..0000000000
--- a/test/c.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=C
-Requires=a.service
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/d.service b/test/d.service
deleted file mode 100644
index 921fd2ee1b..0000000000
--- a/test/d.service
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=D:Cyclic
-After=b.service
-Before=a.service
-Requires=a.service
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/daughter.service b/test/daughter.service
deleted file mode 100644
index aebedca348..0000000000
--- a/test/daughter.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Daughter Service
-
-[Service]
-Slice=parent.slice
-Type=oneshot
-ExecStart=/bin/true
diff --git a/test/e.service b/test/e.service
deleted file mode 100644
index 5ba98c7c43..0000000000
--- a/test/e.service
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=E:Cyclic
-After=b.service
-Before=a.service
-Wants=a.service
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/end.service.in b/test/end.service.in
deleted file mode 100644
index 4857ffe02b..0000000000
--- a/test/end.service.in
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=End the test
-After=testsuite.service
-
-[Service]
-ExecStart=@SYSTEMCTL@ poweroff --no-block
diff --git a/test/exec-environment-empty.service b/test/exec-environment-empty.service
deleted file mode 100644
index 0219ca4fd7..0000000000
--- a/test/exec-environment-empty.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for Environment
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test ! "$VAR1" = "word1 word2") && $(test ! "$VAR2" = word3) && $(test ! "$VAR3" = \'$word 5 6\')'
-Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
-Environment=
diff --git a/test/exec-environment-multiple.service b/test/exec-environment-multiple.service
deleted file mode 100644
index 479005a5d8..0000000000
--- a/test/exec-environment-multiple.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for Environment
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test "$VAR1" = "word1 word2") && $(test "$VAR2" = word3) && $(test "$VAR3" = foobar)'
-Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
-Environment="VAR3=foobar"
diff --git a/test/exec-environment.service b/test/exec-environment.service
deleted file mode 100644
index 4586b4c4a9..0000000000
--- a/test/exec-environment.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Test for Environment
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test "$VAR1" = "word1 word2") && $(test "$VAR2" = word3) && $(test "$VAR3" = \'$word 5 6\')'
-Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
diff --git a/test/exec-group.service b/test/exec-group.service
deleted file mode 100644
index 1aa04b5bd2..0000000000
--- a/test/exec-group.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Test for Group
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test $(id -n -g) = nobody)'
-Group=nobody
diff --git a/test/exec-ignoresigpipe-no.service b/test/exec-ignoresigpipe-no.service
deleted file mode 100644
index 69b2e9d8a8..0000000000
--- a/test/exec-ignoresigpipe-no.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for IgnoreSIGPIPE=no
-
-[Service]
-ExecStart=/bin/sh -c 'kill -PIPE 0'
-Type=oneshot
-IgnoreSIGPIPE=no
diff --git a/test/exec-ignoresigpipe-yes.service b/test/exec-ignoresigpipe-yes.service
deleted file mode 100644
index 877ec8aed0..0000000000
--- a/test/exec-ignoresigpipe-yes.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for IgnoreSIGPIPE=yes
-
-[Service]
-ExecStart=/bin/sh -c 'kill -PIPE 0'
-Type=oneshot
-IgnoreSIGPIPE=yes
diff --git a/test/exec-personality-x86-64.service b/test/exec-personality-x86-64.service
deleted file mode 100644
index 5bb5d910d0..0000000000
--- a/test/exec-personality-x86-64.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for Personality=x86-64
-
-[Service]
-ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "x86_64")'
-Type=oneshot
-Personality=x86-64
diff --git a/test/exec-personality-x86.service b/test/exec-personality-x86.service
deleted file mode 100644
index 0b370a6480..0000000000
--- a/test/exec-personality-x86.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for Personality=x86
-
-[Service]
-ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "i686")'
-Type=oneshot
-Personality=x86
diff --git a/test/exec-privatedevices-no.service b/test/exec-privatedevices-no.service
deleted file mode 100644
index cf4f275fb6..0000000000
--- a/test/exec-privatedevices-no.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for PrivateDev=no
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test -c /dev/mem)'
-Type=oneshot
-PrivateDevices=no
diff --git a/test/exec-privatedevices-yes.service b/test/exec-privatedevices-yes.service
deleted file mode 100644
index 85b3f4f981..0000000000
--- a/test/exec-privatedevices-yes.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for PrivateDev=yes
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test ! -c /dev/mem)'
-Type=oneshot
-PrivateDevices=yes
diff --git a/test/exec-privatetmp-no.service b/test/exec-privatetmp-no.service
deleted file mode 100644
index d69e552a63..0000000000
--- a/test/exec-privatetmp-no.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for PrivateTmp=no
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test -f /tmp/test-exec_privatetmp)'
-Type=oneshot
-PrivateTmp=no
diff --git a/test/exec-privatetmp-yes.service b/test/exec-privatetmp-yes.service
deleted file mode 100644
index 881a040b87..0000000000
--- a/test/exec-privatetmp-yes.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for PrivateTmp=yes
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test ! -f /tmp/test-exec_privatetmp)'
-Type=oneshot
-PrivateTmp=yes
diff --git a/test/exec-systemcallerrornumber.service b/test/exec-systemcallerrornumber.service
deleted file mode 100644
index 255a8b231a..0000000000
--- a/test/exec-systemcallerrornumber.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for SystemCallErrorNumber
-
-[Service]
-ExecStart=/usr/bin/uname -a
-SystemCallFilter=~uname
-SystemCallErrorNumber=EACCES
diff --git a/test/exec-systemcallfilter-failing.service b/test/exec-systemcallfilter-failing.service
deleted file mode 100644
index c6ce9368c9..0000000000
--- a/test/exec-systemcallfilter-failing.service
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Test for SystemCallFilter
-
-[Service]
-ExecStart=/bin/echo "This should not be seen"
-SystemCallFilter=ioperm
-SystemCallFilter=~ioperm
-SystemCallFilter=ioperm
diff --git a/test/exec-systemcallfilter-failing2.service b/test/exec-systemcallfilter-failing2.service
deleted file mode 100644
index b7f7c2aff9..0000000000
--- a/test/exec-systemcallfilter-failing2.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Test for SystemCallFilter
-
-[Service]
-ExecStart=/bin/echo "This should not be seen"
-SystemCallFilter=~write open execve exit_group close mmap munmap fstat DONOTEXIST
diff --git a/test/exec-systemcallfilter-not-failing.service b/test/exec-systemcallfilter-not-failing.service
deleted file mode 100644
index feb206ab6d..0000000000
--- a/test/exec-systemcallfilter-not-failing.service
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=Test for SystemCallFilter
-
-[Service]
-ExecStart=/bin/echo "Foo bar"
-SystemCallFilter=~read write open execve ioperm
-SystemCallFilter=ioctl
-SystemCallFilter=read write open execve
-SystemCallFilter=~ioperm
diff --git a/test/exec-systemcallfilter-not-failing2.service b/test/exec-systemcallfilter-not-failing2.service
deleted file mode 100644
index cca469aa3d..0000000000
--- a/test/exec-systemcallfilter-not-failing2.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Test for SystemCallFilter
-
-[Service]
-ExecStart=/bin/echo "Foo bar"
-SystemCallFilter=
diff --git a/test/exec-umask-0177.service b/test/exec-umask-0177.service
deleted file mode 100644
index af9295888e..0000000000
--- a/test/exec-umask-0177.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for UMask
-
-[Service]
-ExecStart=/bin/sh -c 'touch /tmp/test-exec-umask; s=$(stat -c %a /tmp/test-exec-umask); echo $s; exit $(test $s = "600")'
-UMask=0177
-PrivateTmp=yes
diff --git a/test/exec-umask-default.service b/test/exec-umask-default.service
deleted file mode 100644
index 41e20a60a1..0000000000
--- a/test/exec-umask-default.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Test for UMask default
-
-[Service]
-ExecStart=/bin/sh -c 'touch /tmp/test-exec-umask; s=$(stat -c %a /tmp/test-exec-umask); echo $s; exit $(test $s = "644")'
-PrivateTmp=yes
diff --git a/test/exec-user.service b/test/exec-user.service
deleted file mode 100644
index 2ca08ebb42..0000000000
--- a/test/exec-user.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Test for User
-
-[Service]
-ExecStart=/bin/sh -c 'exit $(test "$USER" = nobody)'
-User=nobody
diff --git a/test/exec-workingdirectory.service b/test/exec-workingdirectory.service
deleted file mode 100644
index 10855d682a..0000000000
--- a/test/exec-workingdirectory.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Test for WorkingDirectory
-
-[Service]
-ExecStart=/bin/sh -c 'echo $PWD; exit $(test $PWD = "/tmp/test-exec_workingdirectory")'
-Type=oneshot
-WorkingDirectory=/tmp/test-exec_workingdirectory
diff --git a/test/f.service b/test/f.service
deleted file mode 100644
index 7dde681c17..0000000000
--- a/test/f.service
+++ /dev/null
@@ -1,5 +0,0 @@
-[Unit]
-Description=F
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/g.service b/test/g.service
deleted file mode 100644
index cbfa82a454..0000000000
--- a/test/g.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=G
-Conflicts=e.service
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/grandchild.service b/test/grandchild.service
deleted file mode 100644
index ab641300e4..0000000000
--- a/test/grandchild.service
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Grandchild Service
-
-[Service]
-Slice=parent-deep.slice
-Type=oneshot
-ExecStart=/bin/true
diff --git a/test/h.service b/test/h.service
deleted file mode 100644
index 74a7751cad..0000000000
--- a/test/h.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=H
-Wants=g.service
-
-[Service]
-ExecStart=/bin/true
diff --git a/test/hello-after-sleep.target b/test/hello-after-sleep.target
deleted file mode 100644
index 526fbd2a12..0000000000
--- a/test/hello-after-sleep.target
+++ /dev/null
@@ -1,5 +0,0 @@
-[Unit]
-Description=Sleep for a minute, then say hello.
-Wants=sleep.service hello.service
-After=sleep.service
-Before=hello.service
diff --git a/test/hello.service b/test/hello.service
deleted file mode 100644
index 82907b64e1..0000000000
--- a/test/hello.service
+++ /dev/null
@@ -1,5 +0,0 @@
-[Unit]
-Description=Hello World
-
-[Service]
-ExecStart=/bin/echo "Hello World"
diff --git a/test/loopy.service b/test/loopy.service
deleted file mode 100644
index 9eb645748e..0000000000
--- a/test/loopy.service
+++ /dev/null
@@ -1,2 +0,0 @@
-[Service]
-ExecStart=/bin/true
diff --git a/test/loopy.service.d/compat.conf b/test/loopy.service.d/compat.conf
deleted file mode 100644
index 51b84b89ed..0000000000
--- a/test/loopy.service.d/compat.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-[Unit]
-BindsTo=loopy2.service
-
-[Install]
-Also=loopy2.service
diff --git a/test/loopy2.service b/test/loopy2.service
deleted file mode 120000
index 961b1fe9bc..0000000000
--- a/test/loopy2.service
+++ /dev/null
@@ -1 +0,0 @@
-loopy.service \ No newline at end of file
diff --git a/test/loopy3.service b/test/loopy3.service
deleted file mode 100644
index 606e26b5da..0000000000
--- a/test/loopy3.service
+++ /dev/null
@@ -1,5 +0,0 @@
-[Service]
-ExecStart=/bin/true
-
-[Unit]
-Conflicts=loopy4.service
diff --git a/test/loopy4.service b/test/loopy4.service
deleted file mode 120000
index 43e5658bcd..0000000000
--- a/test/loopy4.service
+++ /dev/null
@@ -1 +0,0 @@
-loopy3.service \ No newline at end of file
diff --git a/test/mocks/fsck b/test/mocks/fsck
deleted file mode 100755
index 77b50d7234..0000000000
--- a/test/mocks/fsck
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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/parent-deep.slice b/test/parent-deep.slice
deleted file mode 100644
index 79b302f38d..0000000000
--- a/test/parent-deep.slice
+++ /dev/null
@@ -1,5 +0,0 @@
-[Unit]
-Description=Deeper Parent Slice
-
-[Slice]
-MemoryLimit=3G
diff --git a/test/parent.slice b/test/parent.slice
deleted file mode 100644
index 0222f8eb47..0000000000
--- a/test/parent.slice
+++ /dev/null
@@ -1,5 +0,0 @@
-[Unit]
-Description=Parent Slice
-
-[Slice]
-BlockIOWeight=200
diff --git a/test/path-changed.path b/test/path-changed.path
deleted file mode 100644
index e58bdd925f..0000000000
--- a/test/path-changed.path
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Test PathChanged
-
-[Path]
-PathChanged=/tmp/test-path_changed
-
-[Install]
-WantedBy=multi-user.target
diff --git a/test/path-changed.service b/test/path-changed.service
deleted file mode 120000
index 8bdf178830..0000000000
--- a/test/path-changed.service
+++ /dev/null
@@ -1 +0,0 @@
-path-service.service \ No newline at end of file
diff --git a/test/path-directorynotempty.path b/test/path-directorynotempty.path
deleted file mode 100644
index 17e599fc0e..0000000000
--- a/test/path-directorynotempty.path
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Test DirectoryNotEmpty
-
-[Path]
-DirectoryNotEmpty=/tmp/test-path_directorynotempty/
-
-[Install]
-WantedBy=multi-user.target
diff --git a/test/path-directorynotempty.service b/test/path-directorynotempty.service
deleted file mode 120000
index 8bdf178830..0000000000
--- a/test/path-directorynotempty.service
+++ /dev/null
@@ -1 +0,0 @@
-path-service.service \ No newline at end of file
diff --git a/test/path-exists.path b/test/path-exists.path
deleted file mode 100644
index c4c9105af4..0000000000
--- a/test/path-exists.path
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Test PathExists
-
-[Path]
-PathExists=/tmp/test-path_exists
-
-[Install]
-WantedBy=multi-user.target
diff --git a/test/path-exists.service b/test/path-exists.service
deleted file mode 120000
index 8bdf178830..0000000000
--- a/test/path-exists.service
+++ /dev/null
@@ -1 +0,0 @@
-path-service.service \ No newline at end of file
diff --git a/test/path-existsglob.path b/test/path-existsglob.path
deleted file mode 100644
index a058599605..0000000000
--- a/test/path-existsglob.path
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Test PathExistsGlob
-
-[Path]
-PathExistsGlob=/tmp/test-path_existsglob*
-
-[Install]
-WantedBy=multi-user.target
diff --git a/test/path-existsglob.service b/test/path-existsglob.service
deleted file mode 120000
index 8bdf178830..0000000000
--- a/test/path-existsglob.service
+++ /dev/null
@@ -1 +0,0 @@
-path-service.service \ No newline at end of file
diff --git a/test/path-makedirectory.path b/test/path-makedirectory.path
deleted file mode 100644
index 9408479c0f..0000000000
--- a/test/path-makedirectory.path
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Test MakeDirectory & DirectoryMode
-
-[Path]
-DirectoryNotEmpty=/tmp/test-path_makedirectory/
-MakeDirectory=yes
-DirectoryMode=0744
-
-[Install]
-WantedBy=multi-user.target
diff --git a/test/path-makedirectory.service b/test/path-makedirectory.service
deleted file mode 120000
index 8bdf178830..0000000000
--- a/test/path-makedirectory.service
+++ /dev/null
@@ -1 +0,0 @@
-path-service.service \ No newline at end of file
diff --git a/test/path-modified.path b/test/path-modified.path
deleted file mode 100644
index 18363227ba..0000000000
--- a/test/path-modified.path
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Test PathModified
-
-[Path]
-PathModified=/tmp/test-path_modified
-
-[Install]
-WantedBy=multi-user.target
diff --git a/test/path-modified.service b/test/path-modified.service
deleted file mode 120000
index 8bdf178830..0000000000
--- a/test/path-modified.service
+++ /dev/null
@@ -1 +0,0 @@
-path-service.service \ No newline at end of file
diff --git a/test/path-mycustomunit.service b/test/path-mycustomunit.service
deleted file mode 100644
index 172ac0d0d5..0000000000
--- a/test/path-mycustomunit.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Service Test Path Unit=
-
-[Service]
-ExecStart=/bin/true
-Type=oneshot
diff --git a/test/path-service.service b/test/path-service.service
deleted file mode 100644
index f8499ec619..0000000000
--- a/test/path-service.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Service Test for Path units
-
-[Service]
-ExecStart=/bin/true
-Type=oneshot
diff --git a/test/path-unit.path b/test/path-unit.path
deleted file mode 100644
index 95e572d6d5..0000000000
--- a/test/path-unit.path
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=Test Path Unit=
-
-[Path]
-PathExists=/tmp/test-path_unit
-Unit=path-mycustomunit.service
-
-[Install]
-WantedBy=multi-user.target
diff --git a/test/paths.target b/test/paths.target
deleted file mode 120000
index e9939c9801..0000000000
--- a/test/paths.target
+++ /dev/null
@@ -1 +0,0 @@
-../units/paths.target \ No newline at end of file
diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py
deleted file mode 100644
index 80bbe65bea..0000000000
--- a/test/rule-syntax-check.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# Simple udev rules syntax checker
-#
-# (C) 2010 Canonical Ltd.
-# Author: Martin Pitt <martin.pitt@ubuntu.com>
-#
-# systemd is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-
-# systemd is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-
-import re
-import sys
-import os
-from glob import glob
-
-if len(sys.argv) > 1:
- # explicit rule file list
- rules_files = sys.argv[1:]
-else:
- # take them from the build dir
- root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- rules_dir = os.path.join(os.environ.get('top_srcdir', root_dir), 'rules')
- if not os.path.isdir(rules_dir):
- sys.stderr.write('No rules files given, and %s does not exist, aborting' % rules_dir)
- sys.exit(2)
- rules_files = glob(os.path.join(rules_dir, '*.rules'))
-
-no_args_tests = re.compile('(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|RESULT|TEST)\s*(?:=|!)=\s*"([^"]*)"$')
-args_tests = re.compile('(ATTRS?|ENV|TEST){([a-zA-Z0-9/_.*%-]+)}\s*(?:=|!)=\s*"([^"]*)"$')
-no_args_assign = re.compile('(NAME|SYMLINK|OWNER|GROUP|MODE|TAG|PROGRAM|RUN|LABEL|GOTO|WAIT_FOR|OPTIONS|IMPORT)\s*(?:\+=|:=|=)\s*"([^"]*)"$')
-args_assign = re.compile('(ATTR|ENV|IMPORT|RUN){([a-zA-Z0-9/_.*%-]+)}\s*(=|\+=)\s*"([^"]*)"$')
-
-result = 0
-buffer = ''
-for path in rules_files:
- lineno = 0
- for line in open(path):
- lineno += 1
-
- # handle line continuation
- if line.endswith('\\\n'):
- buffer += line[:-2]
- continue
- else:
- line = buffer + line
- buffer = ''
-
- # filter out comments and empty lines
- line = line.strip()
- if not line or line.startswith('#'):
- continue
-
- for clause in line.split(','):
- clause = clause.strip()
- if not (no_args_tests.match(clause) or args_tests.match(clause) or
- no_args_assign.match(clause) or args_assign.match(clause)):
-
- print('Invalid line %s:%i: %s' % (path, lineno, line))
- print(' clause: %s' % clause)
- print('')
- result = 1
- break
-
-sys.exit(result)
diff --git a/test/sched_idle_bad.service b/test/sched_idle_bad.service
deleted file mode 100644
index 589a87ccfd..0000000000
--- a/test/sched_idle_bad.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Bad sched priority for Idle
-
-[Service]
-ExecStart=/bin/true
-CPUSchedulingPriority=1
diff --git a/test/sched_idle_ok.service b/test/sched_idle_ok.service
deleted file mode 100644
index 262ef3e319..0000000000
--- a/test/sched_idle_ok.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Sched idle with prio 0
-
-[Service]
-ExecStart=/bin/true
-CPUSchedulingPriority=0
diff --git a/test/sched_rr_bad.service b/test/sched_rr_bad.service
deleted file mode 100644
index 0be534a546..0000000000
--- a/test/sched_rr_bad.service
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Bad sched priority for RR
-
-[Service]
-ExecStart=/bin/true
-CPUSchedulingPolicy=rr
-CPUSchedulingPriority=0
-CPUSchedulingPriority=100
diff --git a/test/sched_rr_change.service b/test/sched_rr_change.service
deleted file mode 100644
index b3e3a000f8..0000000000
--- a/test/sched_rr_change.service
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=Change prio
-
-[Service]
-ExecStart=/bin/true
-CPUSchedulingPolicy=rr
-CPUSchedulingPriority=1
-CPUSchedulingPriority=2
-CPUSchedulingPriority=99
diff --git a/test/sched_rr_ok.service b/test/sched_rr_ok.service
deleted file mode 100644
index b88adc5434..0000000000
--- a/test/sched_rr_ok.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Default prio for RR
-
-[Service]
-ExecStart=/bin/true
-CPUSchedulingPolicy=rr
diff --git a/test/shutdown.target b/test/shutdown.target
deleted file mode 120000
index 1a3c2eec84..0000000000
--- a/test/shutdown.target
+++ /dev/null
@@ -1 +0,0 @@
-../units/shutdown.target \ No newline at end of file
diff --git a/test/sleep.service b/test/sleep.service
deleted file mode 100644
index 946c44b621..0000000000
--- a/test/sleep.service
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Sleep for 1 minute
-
-[Service]
-Type=oneshot
-ExecStart=/bin/sleep 60
diff --git a/test/sockets.target b/test/sockets.target
deleted file mode 120000
index 8ff86a0775..0000000000
--- a/test/sockets.target
+++ /dev/null
@@ -1 +0,0 @@
-../units/sockets.target \ No newline at end of file
diff --git a/test/son.service b/test/son.service
deleted file mode 100644
index 50bb96a941..0000000000
--- a/test/son.service
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Son Service
-
-[Service]
-Slice=parent.slice
-Type=oneshot
-ExecStart=/bin/true
-CPUShares=100
diff --git a/test/splash.bmp b/test/splash.bmp
deleted file mode 100644
index 27247f7a22..0000000000
--- a/test/splash.bmp
+++ /dev/null
Binary files differ
diff --git a/test/sys.tar.xz b/test/sys.tar.xz
deleted file mode 100644
index 49ee8027b2..0000000000
--- a/test/sys.tar.xz
+++ /dev/null
Binary files differ
diff --git a/test/sysinit.target b/test/sysinit.target
deleted file mode 120000
index 3301338185..0000000000
--- a/test/sysinit.target
+++ /dev/null
@@ -1 +0,0 @@
-../units/sysinit.target \ No newline at end of file
diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py
deleted file mode 100644
index cf7d467368..0000000000
--- a/test/sysv-generator-test.py
+++ /dev/null
@@ -1,391 +0,0 @@
-# systemd-sysv-generator integration test
-#
-# (C) 2015 Canonical Ltd.
-# Author: Martin Pitt <martin.pitt@ubuntu.com>
-#
-# systemd is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-
-# systemd is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-
-import unittest
-import sys
-import os
-import subprocess
-import tempfile
-import shutil
-from glob import glob
-
-try:
- from configparser import RawConfigParser
-except ImportError:
- # python 2
- from ConfigParser import RawConfigParser
-
-sysv_generator = os.path.join(os.environ.get('builddir', '.'), 'systemd-sysv-generator')
-
-
-class SysvGeneratorTest(unittest.TestCase):
- def setUp(self):
- self.workdir = tempfile.mkdtemp(prefix='sysv-gen-test.')
- self.init_d_dir = os.path.join(self.workdir, 'init.d')
- os.mkdir(self.init_d_dir)
- self.rcnd_dir = self.workdir
- self.unit_dir = os.path.join(self.workdir, 'systemd')
- os.mkdir(self.unit_dir)
- self.out_dir = os.path.join(self.workdir, 'output')
- os.mkdir(self.out_dir)
-
- def tearDown(self):
- shutil.rmtree(self.workdir)
-
- #
- # Helper methods
- #
-
- def run_generator(self, expect_error=False):
- '''Run sysv-generator.
-
- Fail if stderr contains any "Fail", unless expect_error is True.
- Return (stderr, filename -> ConfigParser) pair with ouput to stderr and
- parsed generated units.
- '''
- env = os.environ.copy()
- env['SYSTEMD_LOG_LEVEL'] = 'debug'
- env['SYSTEMD_SYSVINIT_PATH'] = self.init_d_dir
- env['SYSTEMD_SYSVRCND_PATH'] = self.rcnd_dir
- env['SYSTEMD_UNIT_PATH'] = self.unit_dir
- gen = subprocess.Popen(
- [sysv_generator, 'ignored', 'ignored', self.out_dir],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- universal_newlines=True, env=env)
- (out, err) = gen.communicate()
- if not expect_error:
- self.assertFalse('Fail' in err, err)
- self.assertEqual(gen.returncode, 0, err)
-
- results = {}
- for service in glob(self.out_dir + '/*.service'):
- if os.path.islink(service):
- continue
- cp = RawConfigParser()
- cp.optionxform = lambda o: o # don't lower-case option names
- with open(service) as f:
- cp.readfp(f)
- results[os.path.basename(service)] = cp
-
- return (err, results)
-
- def add_sysv(self, fname, keys, enable=False, prio=1):
- '''Create a SysV init script with the given keys in the LSB header
-
- There are sensible default values for all fields.
- If enable is True, links will be created in the rcN.d dirs. In that
- case, the priority can be given with "prio" (default to 1).
-
- Return path of generated script.
- '''
- name_without_sh = fname.endswith('.sh') and fname[:-3] or fname
- keys.setdefault('Provides', name_without_sh)
- keys.setdefault('Required-Start', '$local_fs')
- keys.setdefault('Required-Stop', keys['Required-Start'])
- keys.setdefault('Default-Start', '2 3 4 5')
- keys.setdefault('Default-Stop', '0 1 6')
- keys.setdefault('Short-Description', 'test %s service' %
- name_without_sh)
- keys.setdefault('Description', 'long description for test %s service' %
- name_without_sh)
- script = os.path.join(self.init_d_dir, fname)
- with open(script, 'w') as f:
- f.write('#!/bin/init-d-interpreter\n### BEGIN INIT INFO\n')
- for k, v in keys.items():
- if v is not None:
- f.write('#%20s %s\n' % (k + ':', v))
- f.write('### END INIT INFO\ncode --goes here\n')
- os.chmod(script, 0o755)
-
- if enable:
- def make_link(prefix, runlevel):
- d = os.path.join(self.rcnd_dir, 'rc%s.d' % runlevel)
- if not os.path.isdir(d):
- os.mkdir(d)
- os.symlink('../init.d/' + fname, os.path.join(d, prefix + fname))
-
- for rl in keys['Default-Start'].split():
- make_link('S%02i' % prio, rl)
- for rl in keys['Default-Stop'].split():
- make_link('K%02i' % (99 - prio), rl)
-
- return script
-
- def assert_enabled(self, unit, targets):
- '''assert that a unit is enabled in precisely the given targets'''
-
- all_targets = ['multi-user', 'graphical']
-
- # should be enabled
- 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)
-
- #
- # test cases
- #
-
- def test_nothing(self):
- '''no input files'''
-
- results = self.run_generator()[1]
- self.assertEqual(results, {})
- self.assertEqual(os.listdir(self.out_dir), [])
-
- def test_simple_disabled(self):
- '''simple service without dependencies, disabled'''
-
- self.add_sysv('foo', {}, enable=False)
- err, results = self.run_generator()
- self.assertEqual(len(results), 1)
-
- # no enablement links or other stuff
- self.assertEqual(os.listdir(self.out_dir), ['foo.service'])
-
- s = results['foo.service']
- self.assertEqual(s.sections(), ['Unit', 'Service'])
- self.assertEqual(s.get('Unit', 'Description'), 'LSB: test foo service')
- # $local_fs does not need translation, don't expect any dependency
- # fields here
- self.assertEqual(set(s.options('Unit')),
- set(['Documentation', 'SourcePath', 'Description']))
-
- self.assertEqual(s.get('Service', 'Type'), 'forking')
- init_script = os.path.join(self.init_d_dir, 'foo')
- self.assertEqual(s.get('Service', 'ExecStart'),
- '%s start' % init_script)
- 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', ['multi-user', 'graphical'])
- self.assertNotIn('Overwriting', err)
-
- def test_simple_enabled_some(self):
- '''simple service without dependencies, enabled in some runlevels'''
-
- 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', ['multi-user'])
-
- def test_lsb_macro_dep_single(self):
- '''single LSB macro dependency: $network'''
-
- self.add_sysv('foo', {'Required-Start': '$network'})
- s = self.run_generator()[1]['foo.service']
- self.assertEqual(set(s.options('Unit')),
- set(['Documentation', 'SourcePath', 'Description', 'After', 'Wants']))
- self.assertEqual(s.get('Unit', 'After'), 'network-online.target')
- self.assertEqual(s.get('Unit', 'Wants'), 'network-online.target')
-
- def test_lsb_macro_dep_multi(self):
- '''multiple LSB macro dependencies'''
-
- self.add_sysv('foo', {'Required-Start': '$named $portmap'})
- s = self.run_generator()[1]['foo.service']
- self.assertEqual(set(s.options('Unit')),
- set(['Documentation', 'SourcePath', 'Description', 'After']))
- self.assertEqual(s.get('Unit', 'After'), 'nss-lookup.target rpcbind.target')
-
- def test_lsb_deps(self):
- '''LSB header dependencies to other services'''
-
- # also give symlink priorities here; they should be ignored
- self.add_sysv('foo', {'Required-Start': 'must1 must2',
- 'Should-Start': 'may1 ne_may2'},
- enable=True, prio=40)
- self.add_sysv('must1', {}, enable=True, prio=10)
- self.add_sysv('must2', {}, enable=True, prio=15)
- self.add_sysv('may1', {}, enable=True, prio=20)
- # do not create ne_may2
- err, results = self.run_generator()
- self.assertEqual(sorted(results),
- ['foo.service', 'may1.service', 'must1.service', 'must2.service'])
-
- # foo should depend on all of them
- self.assertEqual(sorted(results['foo.service'].get('Unit', 'After').split()),
- ['may1.service', 'must1.service', 'must2.service', 'ne_may2.service'])
-
- # other services should not depend on each other
- self.assertFalse(results['must1.service'].has_option('Unit', 'After'))
- self.assertFalse(results['must2.service'].has_option('Unit', 'After'))
- self.assertFalse(results['may1.service'].has_option('Unit', 'After'))
-
- def test_symlink_prio_deps(self):
- '''script without LSB headers use rcN.d priority'''
-
- # create two init.d scripts without LSB header and enable them with
- # startup priorities
- for prio, name in [(10, 'provider'), (15, 'consumer')]:
- with open(os.path.join(self.init_d_dir, name), 'w') as f:
- f.write('#!/bin/init-d-interpreter\ncode --goes here\n')
- os.fchmod(f.fileno(), 0o755)
-
- d = os.path.join(self.rcnd_dir, 'rc2.d')
- if not os.path.isdir(d):
- os.mkdir(d)
- os.symlink('../init.d/' + name, os.path.join(d, 'S%02i%s' % (prio, name)))
-
- err, results = self.run_generator()
- self.assertEqual(sorted(results), ['consumer.service', 'provider.service'])
- self.assertFalse(results['provider.service'].has_option('Unit', 'After'))
- self.assertEqual(results['consumer.service'].get('Unit', 'After'),
- 'provider.service')
-
- def test_multiple_provides(self):
- '''multiple Provides: names'''
-
- self.add_sysv('foo', {'Provides': 'foo bar baz'})
- err, results = self.run_generator()
- self.assertEqual(list(results), ['foo.service'])
- self.assertEqual(set(results['foo.service'].options('Unit')),
- set(['Documentation', 'SourcePath', 'Description']))
- # should create symlinks for the alternative names
- 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'''
-
- self.add_sysv('foo', {'Provides': 'foo common'}, enable=True, prio=1)
- self.add_sysv('bar', {'Provides': 'bar common'}, enable=True, prio=2)
- err, results = self.run_generator()
- self.assertEqual(sorted(results), ['bar.service', 'foo.service'])
- # should create symlink for the alternative name for either unit
- self.assertIn(os.readlink(os.path.join(self.out_dir, 'common.service')),
- ['foo.service', 'bar.service'])
-
- def test_provide_other_script(self):
- '''init.d scripts provides the name of another init.d script'''
-
- self.add_sysv('foo', {'Provides': 'foo bar'}, enable=True)
- 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'''
-
- os.chmod(self.add_sysv('foo', {}), 0o644)
- err, results = self.run_generator()
- self.assertEqual(results, {})
-
- def test_sh_suffix(self):
- '''init.d script with .sh suffix'''
-
- self.add_sysv('foo.sh', {}, enable=True)
- err, results = self.run_generator()
- s = results['foo.service']
-
- self.assertEqual(s.sections(), ['Unit', 'Service'])
- # should not have a .sh
- self.assertEqual(s.get('Unit', 'Description'), 'LSB: test foo service')
-
- # calls correct script with .sh
- init_script = os.path.join(self.init_d_dir, 'foo.sh')
- self.assertEqual(s.get('Service', 'ExecStart'),
- '%s start' % init_script)
- self.assertEqual(s.get('Service', 'ExecStop'),
- '%s stop' % init_script)
-
- self.assert_enabled('foo.service', ['multi-user', 'graphical'])
-
- def test_sh_suffix_with_provides(self):
- '''init.d script with .sh suffix and Provides:'''
-
- 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.assertEqual(list(results), ['foo.service'])
- self.assertEqual(results['foo.service'].get('Unit', 'Description'),
- 'LSB: test foo service')
-
- # should create symlink for the alternative name
- self.assertEqual(os.readlink(os.path.join(self.out_dir, 'bar.service')),
- 'foo.service')
-
- def test_hidden_files(self):
- '''init.d script with hidden file suffix'''
-
- script = self.add_sysv('foo', {}, enable=True)
- # backup files (not enabled in rcN.d/)
- shutil.copy(script, script + '.dpkg-new')
- shutil.copy(script, script + '.dpkg-dist')
- shutil.copy(script, script + '.swp')
- shutil.copy(script, script + '.rpmsave')
-
- err, results = self.run_generator()
- self.assertEqual(list(results), ['foo.service'])
-
- self.assert_enabled('foo.service', ['multi-user', 'graphical'])
-
- def test_backup_file(self):
- '''init.d script with backup file'''
-
- script = self.add_sysv('foo', {}, enable=True)
- # backup files (not enabled in rcN.d/)
- shutil.copy(script, script + '.bak')
- shutil.copy(script, script + '.old')
-
- err, results = self.run_generator()
- print(err)
- self.assertEqual(sorted(results),
- ['foo.bak.service', 'foo.old.service', 'foo.service'])
-
- # ensure we don't try to create a symlink to itself
- self.assertNotIn(err, 'itself')
-
- self.assert_enabled('foo.service', ['multi-user', 'graphical'])
- self.assert_enabled('foo.bak.service', [])
- self.assert_enabled('foo.old.service', [])
-
- def test_existing_native_unit(self):
- '''existing native unit'''
-
- with open(os.path.join(self.unit_dir, 'foo.service'), 'w') as f:
- f.write('[Unit]\n')
-
- self.add_sysv('foo.sh', {'Provides': 'foo bar'}, enable=True)
- err, results = self.run_generator()
- self.assertEqual(list(results), [])
- # no enablement or alias links, as native unit is disabled
- self.assertEqual(os.listdir(self.out_dir), [])
-
-
-if __name__ == '__main__':
- unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))
diff --git a/test/test-efi-create-disk.sh b/test/test-efi-create-disk.sh
deleted file mode 100755
index 56dd09abd7..0000000000
--- a/test/test-efi-create-disk.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/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
deleted file mode 100644
index 901ff48605..0000000000
--- a/test/test-functions
+++ /dev/null
@@ -1,1186 +0,0 @@
-#!/bin/bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-export PATH
-
-KERNEL_VER=${KERNEL_VER-$(uname -r)}
-KERNEL_MODS="/lib/modules/$KERNEL_VER/"
-
-if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
- echo "WARNING! Cannot determine rootlibdir from pkg-config, assuming /usr/lib/systemd" >&2
- ROOTLIBDIR=/usr/lib/systemd
-fi
-
-BASICTOOLS="sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe"
-DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname"
-
-function find_qemu_bin() {
- # SUSE and Red Hat call the binary qemu-kvm
- # Debian and Gentoo call it kvm
- [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a kvm qemu-kvm 2>/dev/null | grep '^/' -m1)
-
- [ "$ARCH" ] || ARCH=$(uname -m)
- case $ARCH in
- x86_64)
- # QEMU's own build system calls it qemu-system-x86_64
- [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-x86_64 2>/dev/null | grep '^/' -m1)
- ;;
- i*86)
- # new i386 version of QEMU
- [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-i386 2>/dev/null | grep '^/' -m1)
-
- # i386 version of QEMU
- [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu 2>/dev/null | grep '^/' -m1)
- ;;
- esac
-
- if [ ! -e "$QEMU_BIN" ]; then
- echo "Could not find a suitable QEMU binary" >&2
- return 1
- fi
-}
-
-run_qemu() {
- if [ -f /etc/machine-id ]; then
- read MACHINE_ID < /etc/machine-id
- [ -z "$INITRD" ] && [ -e "/boot/$MACHINE_ID/$KERNEL_VER/initrd" ] \
- && INITRD="/boot/$MACHINE_ID/$KERNEL_VER/initrd"
- [ -z "$KERNEL_BIN" ] && [ -e "/boot/$MACHINE_ID/$KERNEL_VER/linux" ] \
- && KERNEL_BIN="/boot/$MACHINE_ID/$KERNEL_VER/linux"
- fi
-
- [ "$KERNEL_BIN" ] || KERNEL_BIN=/boot/vmlinuz-$KERNEL_VER
- [ "$INITRD" ] || INITRD=/boot/initramfs-${KERNEL_VER}.img
- [ "$QEMU_SMP" ] || QEMU_SMP=1
-
- find_qemu_bin || return 1
-
- KERNEL_APPEND="root=/dev/sda1 \
-systemd.log_level=debug \
-raid=noautodetect \
-loglevel=2 \
-init=$ROOTLIBDIR/systemd \
-ro \
-console=ttyS0 \
-selinux=0 \
-$KERNEL_APPEND \
-"
-
- QEMU_OPTIONS="-machine accel=kvm:tcg \
--smp $QEMU_SMP \
--net none \
--m 512M \
--nographic \
--kernel $KERNEL_BIN \
-"
-
- if [ "$INITRD" ]; then
- QEMU_OPTIONS="$QEMU_OPTIONS -initrd $INITRD"
- fi
-
- ( set -x
- $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND" $TESTDIR/rootdisk.img ) || return 1
-}
-
-run_nspawn() {
- set -x
- ../../systemd-nspawn --boot --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND
-}
-
-setup_basic_environment() {
- # create the basic filesystem layout
- setup_basic_dirs
-
- install_systemd
- install_missing_libraries
- install_config_files
- create_rc_local
- install_basic_tools
- install_libnss
- install_pam
- install_dbus
- install_fonts
- install_keymaps
- install_terminfo
- install_execs
- install_plymouth
- install_debug_tools
- install_ld_so_conf
- strip_binaries
- install_depmod_files
- generate_module_dependencies
- # softlink mtab
- ln -fs /proc/self/mounts $initdir/etc/mtab
-}
-
-install_dmevent() {
- instmods dm_crypt =crypto
- type -P dmeventd >/dev/null && dracut_install dmeventd
- inst_libdir_file "libdevmapper-event.so*"
- inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
-}
-
-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}
- # we strip binaries since debug symbols increase binaries size a lot
- # and it could fill the available space
- strip_binaries
-}
-
-install_missing_libraries() {
- # install possible missing libraries
- for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
- inst_libs $i
- done
-}
-
-create_empty_image() {
- rm -f "$TESTDIR/rootdisk.img"
- # Create the blank file to use as a root filesystem
- dd if=/dev/null of="$TESTDIR/rootdisk.img" bs=1M seek=300
- LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
- [ -b "$LOOPDEV" ] || return 1
- echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
- sfdisk "$LOOPDEV" <<EOF
-,290M
-,
-EOF
-
- mkfs.ext3 -L systemd "${LOOPDEV}p1"
-}
-
-check_result_nspawn() {
- ret=1
- [[ -e $TESTDIR/nspawn-root/testok ]] && ret=0
- [[ -f $TESTDIR/nspawn-root/failed ]] && cp -a $TESTDIR/nspawn-root/failed $TESTDIR
- cp -a $TESTDIR/nspawn-root/var/log/journal $TESTDIR
- [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
- ls -l $TESTDIR/journal/*/*.journal
- test -s $TESTDIR/failed && ret=$(($ret+1))
- return $ret
-}
-
-strip_binaries() {
- ddebug "Strip binaries"
- find "$initdir" -executable -not -path '*/lib/modules/*.ko' -type f | xargs strip --strip-unneeded | ddebug
-}
-
-create_rc_local() {
- mkdir -p $initdir/etc/rc.d
- cat >$initdir/etc/rc.d/rc.local <<EOF
-#!/bin/bash
-exit 0
-EOF
- chmod 0755 $initdir/etc/rc.d/rc.local
-}
-
-install_execs() {
- # install any Execs from the service files
- egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
- | while read i; do
- i=${i##Exec*=}; i=${i##-}
- inst $i
- done
-}
-
-generate_module_dependencies() {
- if [[ -d $initdir/lib/modules/$KERNEL_VER ]] && \
- ! depmod -a -b "$initdir" $KERNEL_VER; then
- dfatal "\"depmod -a $KERNEL_VER\" failed."
- exit 1
- fi
-}
-
-install_depmod_files() {
- inst /lib/modules/$KERNEL_VER/modules.order
- inst /lib/modules/$KERNEL_VER/modules.builtin
-}
-
-install_plymouth() {
- # install plymouth, if found... else remove plymouth service files
- # if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
- # PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
- # /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
- # dracut_install plymouth plymouthd
- # else
- rm -f $initdir/{usr/lib,etc}/systemd/system/plymouth* $initdir/{usr/lib,etc}/systemd/system/*/plymouth*
- # fi
-}
-
-install_ld_so_conf() {
- cp -a /etc/ld.so.conf* $initdir/etc
- ldconfig -r "$initdir"
-}
-
-install_config_files() {
- inst /etc/sysconfig/init
- inst /etc/passwd
- inst /etc/shadow
- inst /etc/group
- inst /etc/shells
- inst /etc/nsswitch.conf
- inst /etc/pam.conf
- inst /etc/securetty
- inst /etc/os-release
- inst /etc/localtime
- # we want an empty environment
- > $initdir/etc/environment
- > $initdir/etc/machine-id
- # set the hostname
- echo systemd-testsuite > $initdir/etc/hostname
- # fstab
- cat >$initdir/etc/fstab <<EOF
-LABEL=systemd / ext3 rw 0 1
-EOF
-}
-
-install_basic_tools() {
- [[ $BASICTOOLS ]] && dracut_install $BASICTOOLS
- dracut_install -o sushell
- # in Debian ldconfig is just a shell script wrapper around ldconfig.real
- dracut_install -o ldconfig.real
-}
-
-install_debug_tools() {
- [[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS
-}
-
-install_libnss() {
- # install libnss_files for login
- NSS_LIBS=$(LD_DEBUG=files getent passwd 2>&1 >/dev/null |sed -n '/calling init: .*libnss_/ {s!^.* /!/!; p}')
- dracut_install $NSS_LIBS
-}
-
-install_dbus() {
- inst $ROOTLIBDIR/system/dbus.socket
- inst $ROOTLIBDIR/system/dbus.service
-
- find \
- /etc/dbus-1 -xtype f \
- | while read file; do
- inst $file
- done
-}
-
-install_pam() {
- find \
- /etc/pam.d \
- /etc/security \
- /lib64/security \
- /lib/security -xtype f \
- | while read file; do
- inst $file
- done
-}
-
-install_keymaps() {
- for i in \
- /usr/lib/kbd/keymaps/include/* \
- /usr/lib/kbd/keymaps/i386/include/* \
- /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
- [[ -f $i ]] || continue
- inst $i
- done
-}
-
-install_fonts() {
- for i in \
- /usr/lib/kbd/consolefonts/eurlatgr* \
- /usr/lib/kbd/consolefonts/latarcyrheb-sun16*; do
- [[ -f $i ]] || continue
- inst $i
- done
-}
-
-install_terminfo() {
- for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
- [ -f ${_terminfodir}/l/linux ] && break
- done
- dracut_install -o ${_terminfodir}/l/linux
-}
-
-setup_testsuite() {
- cp $TEST_BASE_DIR/testsuite.target $initdir/etc/systemd/system/
- sed "s#@SYSTEMCTL@#$(type -P systemctl)#g" $TEST_BASE_DIR/end.service.in > $initdir/etc/systemd/system/end.service
-
- mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
- ln -fs $TEST_BASE_DIR/testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
- ln -fs $TEST_BASE_DIR/end.service $initdir/etc/systemd/system/testsuite.target.wants/end.service
-
- # make the testsuite the default target
- ln -fs testsuite.target $initdir/etc/systemd/system/default.target
-}
-
-setup_nspawn_root() {
- rm -fr $TESTDIR/nspawn-root
- ddebug "cp -ar $initdir $TESTDIR/nspawn-root"
- cp -ar $initdir $TESTDIR/nspawn-root
- # we don't mount in the nspawn root
- rm -f $TESTDIR/nspawn-root/etc/fstab
-}
-
-setup_basic_dirs() {
- mkdir -p $initdir/run
- mkdir -p $initdir/etc/systemd/system
- mkdir -p $initdir/var/log/journal
-
- for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log dev proc sys sysroot root run run/lock run/initramfs; do
- if [ -L "/$d" ]; then
- inst_symlink "/$d"
- else
- inst_dir "/$d"
- fi
- done
-
- ln -sfn /run "$initdir/var/run"
- ln -sfn /run/lock "$initdir/var/lock"
-}
-
-inst_libs() {
- local _bin=$1
- local _so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
- local _file _line
-
- LC_ALL=C ldd "$_bin" 2>/dev/null | while read _line; do
- [[ $_line = 'not a dynamic executable' ]] && break
-
- if [[ $_line =~ $_so_regex ]]; then
- _file=${BASH_REMATCH[1]}
- [[ -e ${initdir}/$_file ]] && continue
- inst_library "$_file"
- continue
- fi
-
- if [[ $_line =~ not\ found ]]; then
- dfatal "Missing a shared library required by $_bin."
- dfatal "Run \"ldd $_bin\" to find out what it is."
- dfatal "$_line"
- dfatal "dracut cannot create an initrd."
- exit 1
- fi
- done
-}
-
-import_testdir() {
- STATEFILE=".testdir"
- [[ -e $STATEFILE ]] && . $STATEFILE
- if [[ -z "$TESTDIR" ]] || [[ ! -d "$TESTDIR" ]]; then
- TESTDIR=$(mktemp --tmpdir=/var/tmp -d -t systemd-test.XXXXXX)
- echo "TESTDIR=\"$TESTDIR\"" > $STATEFILE
- export TESTDIR
- fi
-}
-
-import_initdir() {
- initdir=$TESTDIR/root
- export initdir
-}
-
-## @brief Converts numeric logging level to the first letter of level name.
-#
-# @param lvl Numeric logging level in range from 1 to 6.
-# @retval 1 if @a lvl is out of range.
-# @retval 0 if @a lvl is correct.
-# @result Echoes first letter of level name.
-_lvl2char() {
- case "$1" in
- 1) echo F;;
- 2) echo E;;
- 3) echo W;;
- 4) echo I;;
- 5) echo D;;
- 6) echo T;;
- *) return 1;;
- esac
-}
-
-## @brief Internal helper function for _do_dlog()
-#
-# @param lvl Numeric logging level.
-# @param msg Message.
-# @retval 0 It's always returned, even if logging failed.
-#
-# @note This function is not supposed to be called manually. Please use
-# dtrace(), ddebug(), or others instead which wrap this one.
-#
-# This function calls _do_dlog() either with parameter msg, or if
-# none is given, it will read standard input and will use every line as
-# a message.
-#
-# This enables:
-# dwarn "This is a warning"
-# echo "This is a warning" | dwarn
-LOG_LEVEL=4
-
-dlog() {
- [ -z "$LOG_LEVEL" ] && return 0
- [ $1 -le $LOG_LEVEL ] || return 0
- local lvl="$1"; shift
- local lvlc=$(_lvl2char "$lvl") || return 0
-
- if [ $# -ge 1 ]; then
- echo "$lvlc: $*"
- else
- while read line; do
- echo "$lvlc: " "$line"
- done
- fi
-}
-
-## @brief Logs message at TRACE level (6)
-#
-# @param msg Message.
-# @retval 0 It's always returned, even if logging failed.
-dtrace() {
- set +x
- dlog 6 "$@"
- [ -n "$debug" ] && set -x || :
-}
-
-## @brief Logs message at DEBUG level (5)
-#
-# @param msg Message.
-# @retval 0 It's always returned, even if logging failed.
-ddebug() {
-# set +x
- dlog 5 "$@"
-# [ -n "$debug" ] && set -x || :
-}
-
-## @brief Logs message at INFO level (4)
-#
-# @param msg Message.
-# @retval 0 It's always returned, even if logging failed.
-dinfo() {
- set +x
- dlog 4 "$@"
- [ -n "$debug" ] && set -x || :
-}
-
-## @brief Logs message at WARN level (3)
-#
-# @param msg Message.
-# @retval 0 It's always returned, even if logging failed.
-dwarn() {
- set +x
- dlog 3 "$@"
- [ -n "$debug" ] && set -x || :
-}
-
-## @brief Logs message at ERROR level (2)
-#
-# @param msg Message.
-# @retval 0 It's always returned, even if logging failed.
-derror() {
-# set +x
- dlog 2 "$@"
-# [ -n "$debug" ] && set -x || :
-}
-
-## @brief Logs message at FATAL level (1)
-#
-# @param msg Message.
-# @retval 0 It's always returned, even if logging failed.
-dfatal() {
- set +x
- dlog 1 "$@"
- [ -n "$debug" ] && set -x || :
-}
-
-
-# Generic substring function. If $2 is in $1, return 0.
-strstr() { [ "${1#*$2*}" != "$1" ]; }
-
-# normalize_path <path>
-# Prints the normalized path, where it removes any duplicated
-# and trailing slashes.
-# Example:
-# $ normalize_path ///test/test//
-# /test/test
-normalize_path() {
- shopt -q -s extglob
- set -- "${1//+(\/)//}"
- shopt -q -u extglob
- echo "${1%/}"
-}
-
-# convert_abs_rel <from> <to>
-# Prints the relative path, when creating a symlink to <to> from <from>.
-# Example:
-# $ convert_abs_rel /usr/bin/test /bin/test-2
-# ../../bin/test-2
-# $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
-convert_abs_rel() {
- local __current __absolute __abssize __cursize __newpath
- local -i __i __level
-
- set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
-
- # corner case #1 - self looping link
- [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
-
- # corner case #2 - own dir link
- [[ "${1%/*}" == "$2" ]] && { echo "."; return; }
-
- IFS="/" __current=($1)
- IFS="/" __absolute=($2)
-
- __abssize=${#__absolute[@]}
- __cursize=${#__current[@]}
-
- while [[ ${__absolute[__level]} == ${__current[__level]} ]]
- do
- (( __level++ ))
- if (( __level > __abssize || __level > __cursize ))
- then
- break
- fi
- done
-
- for ((__i = __level; __i < __cursize-1; __i++))
- do
- if ((__i > __level))
- then
- __newpath=$__newpath"/"
- fi
- __newpath=$__newpath".."
- done
-
- for ((__i = __level; __i < __abssize; __i++))
- do
- if [[ -n $__newpath ]]
- then
- __newpath=$__newpath"/"
- fi
- __newpath=$__newpath${__absolute[__i]}
- done
-
- echo "$__newpath"
-}
-
-
-# Install a directory, keeping symlinks as on the original system.
-# Example: if /lib points to /lib64 on the host, "inst_dir /lib/file"
-# will create ${initdir}/lib64, ${initdir}/lib64/file,
-# and a symlink ${initdir}/lib -> lib64.
-inst_dir() {
- [[ -e ${initdir}/"$1" ]] && return 0 # already there
-
- local _dir="$1" _part="${1%/*}" _file
- while [[ "$_part" != "${_part%/*}" ]] && ! [[ -e "${initdir}/${_part}" ]]; do
- _dir="$_part $_dir"
- _part=${_part%/*}
- done
-
- # iterate over parent directories
- for _file in $_dir; do
- [[ -e "${initdir}/$_file" ]] && continue
- if [[ -L $_file ]]; then
- inst_symlink "$_file"
- else
- # create directory
- mkdir -m 0755 -p "${initdir}/$_file" || return 1
- [[ -e "$_file" ]] && chmod --reference="$_file" "${initdir}/$_file"
- chmod u+w "${initdir}/$_file"
- fi
- done
-}
-
-# $1 = file to copy to ramdisk
-# $2 (optional) Name for the file on the ramdisk
-# Location of the image dir is assumed to be $initdir
-# We never overwrite the target if it exists.
-inst_simple() {
- [[ -f "$1" ]] || return 1
- strstr "$1" "/" || return 1
-
- local _src=$1 target="${2:-$1}"
- if ! [[ -d ${initdir}/$target ]]; then
- [[ -e ${initdir}/$target ]] && return 0
- [[ -L ${initdir}/$target ]] && return 0
- [[ -d "${initdir}/${target%/*}" ]] || inst_dir "${target%/*}"
- fi
- # install checksum files also
- if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
- inst "${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
- fi
- ddebug "Installing $_src"
- cp --sparse=always -pfL "$_src" "${initdir}/$target"
-}
-
-# find symlinks linked to given library file
-# $1 = library file
-# Function searches for symlinks by stripping version numbers appended to
-# library filename, checks if it points to the same target and finally
-# prints the list of symlinks to stdout.
-#
-# Example:
-# rev_lib_symlinks libfoo.so.8.1
-# output: libfoo.so.8 libfoo.so
-# (Only if libfoo.so.8 and libfoo.so exists on host system.)
-rev_lib_symlinks() {
- [[ ! $1 ]] && return 0
-
- local fn="$1" orig="$(readlink -f "$1")" links=''
-
- [[ ${fn} =~ .*\.so\..* ]] || return 1
-
- until [[ ${fn##*.} == so ]]; do
- fn="${fn%.*}"
- [[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}"
- done
-
- echo "${links}"
-}
-
-# Same as above, but specialized to handle dynamic libraries.
-# It handles making symlinks according to how the original library
-# is referenced.
-inst_library() {
- local _src="$1" _dest=${2:-$1} _lib _reallib _symlink
- strstr "$1" "/" || return 1
- [[ -e $initdir/$_dest ]] && return 0
- if [[ -L $_src ]]; then
- # install checksum files also
- if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
- inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac"
- fi
- _reallib=$(readlink -f "$_src")
- inst_simple "$_reallib" "$_reallib"
- inst_dir "${_dest%/*}"
- [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
- ln -sfn $(convert_abs_rel "${_dest}" "${_reallib}") "${initdir}/${_dest}"
- else
- inst_simple "$_src" "$_dest"
- fi
-
- # Create additional symlinks. See rev_symlinks description.
- for _symlink in $(rev_lib_symlinks $_src) $(rev_lib_symlinks $_reallib); do
- [[ ! -e $initdir/$_symlink ]] && {
- ddebug "Creating extra symlink: $_symlink"
- inst_symlink $_symlink
- }
- done
-}
-
-# find a binary. If we were not passed the full path directly,
-# search in the usual places to find the binary.
-find_binary() {
- if [[ -z ${1##/*} ]]; then
- if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then
- echo $1
- return 0
- fi
- fi
-
- type -P $1
-}
-
-# Same as above, but specialized to install binary executables.
-# Install binary executable, and all shared library dependencies, if any.
-inst_binary() {
- local _bin _target
- _bin=$(find_binary "$1") || return 1
- _target=${2:-$_bin}
- [[ -e $initdir/$_target ]] && return 0
- [[ -L $_bin ]] && inst_symlink $_bin $_target && return 0
- local _file _line
- local _so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
- # I love bash!
- LC_ALL=C ldd "$_bin" 2>/dev/null | while read _line; do
- [[ $_line = 'not a dynamic executable' ]] && break
-
- if [[ $_line =~ $_so_regex ]]; then
- _file=${BASH_REMATCH[1]}
- [[ -e ${initdir}/$_file ]] && continue
- inst_library "$_file"
- continue
- fi
-
- if [[ $_line =~ not\ found ]]; then
- dfatal "Missing a shared library required by $_bin."
- dfatal "Run \"ldd $_bin\" to find out what it is."
- dfatal "$_line"
- dfatal "dracut cannot create an initrd."
- exit 1
- fi
- done
- inst_simple "$_bin" "$_target"
-}
-
-# same as above, except for shell scripts.
-# If your shell script does not start with shebang, it is not a shell script.
-inst_script() {
- local _bin
- _bin=$(find_binary "$1") || return 1
- shift
- local _line _shebang_regex
- read -r -n 80 _line <"$_bin"
- # If debug is set, clean unprintable chars to prevent messing up the term
- [[ $debug ]] && _line=$(echo -n "$_line" | tr -c -d '[:print:][:space:]')
- _shebang_regex='(#! *)(/[^ ]+).*'
- [[ $_line =~ $_shebang_regex ]] || return 1
- inst "${BASH_REMATCH[2]}" && inst_simple "$_bin" "$@"
-}
-
-# same as above, but specialized for symlinks
-inst_symlink() {
- local _src=$1 _target=${2:-$1} _realsrc
- strstr "$1" "/" || return 1
- [[ -L $1 ]] || return 1
- [[ -L $initdir/$_target ]] && return 0
- _realsrc=$(readlink -f "$_src")
- if ! [[ -e $initdir/$_realsrc ]]; then
- if [[ -d $_realsrc ]]; then
- inst_dir "$_realsrc"
- else
- inst "$_realsrc"
- fi
- fi
- [[ ! -e $initdir/${_target%/*} ]] && inst_dir "${_target%/*}"
- [[ -d ${_target%/*} ]] && _target=$(readlink -f ${_target%/*})/${_target##*/}
- ln -sfn $(convert_abs_rel "${_target}" "${_realsrc}") "$initdir/$_target"
-}
-
-# attempt to install any programs specified in a udev rule
-inst_rule_programs() {
- local _prog _bin
-
- if grep -qE 'PROGRAM==?"[^ "]+' "$1"; then
- for _prog in $(grep -E 'PROGRAM==?"[^ "]+' "$1" | sed -r 's/.*PROGRAM==?"([^ "]+).*/\1/'); do
- if [ -x /lib/udev/$_prog ]; then
- _bin=/lib/udev/$_prog
- else
- _bin=$(find_binary "$_prog") || {
- dinfo "Skipping program $_prog using in udev rule $(basename $1) as it cannot be found"
- continue;
- }
- fi
-
- #dinfo "Installing $_bin due to it's use in the udev rule $(basename $1)"
- dracut_install "$_bin"
- done
- fi
-}
-
-# udev rules always get installed in the same place, so
-# create a function to install them to make life simpler.
-inst_rules() {
- local _target=/etc/udev/rules.d _rule _found
-
- inst_dir "/lib/udev/rules.d"
- inst_dir "$_target"
- for _rule in "$@"; do
- if [ "${rule#/}" = "$rule" ]; then
- for r in /lib/udev/rules.d /etc/udev/rules.d; do
- if [[ -f $r/$_rule ]]; then
- _found="$r/$_rule"
- inst_simple "$_found"
- inst_rule_programs "$_found"
- fi
- done
- fi
- for r in '' ./ $dracutbasedir/rules.d/; do
- if [[ -f ${r}$_rule ]]; then
- _found="${r}$_rule"
- inst_simple "$_found" "$_target/${_found##*/}"
- inst_rule_programs "$_found"
- fi
- done
- [[ $_found ]] || dinfo "Skipping udev rule: $_rule"
- done
-}
-
-# general purpose installation function
-# Same args as above.
-inst() {
- local _x
-
- case $# in
- 1) ;;
- 2) [[ ! $initdir && -d $2 ]] && export initdir=$2
- [[ $initdir = $2 ]] && set $1;;
- 3) [[ -z $initdir ]] && export initdir=$2
- set $1 $3;;
- *) dfatal "inst only takes 1 or 2 or 3 arguments"
- exit 1;;
- esac
- for _x in inst_symlink inst_script inst_binary inst_simple; do
- $_x "$@" && return 0
- done
- return 1
-}
-
-# install any of listed files
-#
-# If first argument is '-d' and second some destination path, first accessible
-# source is installed into this path, otherwise it will installed in the same
-# path as source. If none of listed files was installed, function return 1.
-# On first successful installation it returns with 0 status.
-#
-# Example:
-#
-# inst_any -d /bin/foo /bin/bar /bin/baz
-#
-# Lets assume that /bin/baz exists, so it will be installed as /bin/foo in
-# initramfs.
-inst_any() {
- local to f
-
- [[ $1 = '-d' ]] && to="$2" && shift 2
-
- for f in "$@"; do
- if [[ -e $f ]]; then
- [[ $to ]] && inst "$f" "$to" && return 0
- inst "$f" && return 0
- fi
- done
-
- return 1
-}
-
-# dracut_install [-o ] <file> [<file> ... ]
-# Install <file> to the initramfs image
-# -o optionally install the <file> and don't fail, if it is not there
-dracut_install() {
- local _optional=no
- if [[ $1 = '-o' ]]; then
- _optional=yes
- shift
- fi
- while (($# > 0)); do
- if ! inst "$1" ; then
- if [[ $_optional = yes ]]; then
- dinfo "Skipping program $1 as it cannot be found and is" \
- "flagged to be optional"
- else
- dfatal "Failed to install $1"
- exit 1
- fi
- fi
- shift
- done
-}
-
-# Install a single kernel module along with any firmware it may require.
-# $1 = full path to kernel module to install
-install_kmod_with_fw() {
- # no need to go further if the module is already installed
-
- [[ -e "${initdir}/lib/modules/$KERNEL_VER/${1##*/lib/modules/$KERNEL_VER/}" ]] \
- && return 0
-
- [[ -e "$initdir/.kernelmodseen/${1##*/}" ]] && return 0
-
- if [[ $omit_drivers ]]; then
- local _kmod=${1##*/}
- _kmod=${_kmod%.ko}
- _kmod=${_kmod/-/_}
- if [[ "$_kmod" =~ $omit_drivers ]]; then
- dinfo "Omitting driver $_kmod"
- return 1
- fi
- if [[ "${1##*/lib/modules/$KERNEL_VER/}" =~ $omit_drivers ]]; then
- dinfo "Omitting driver $_kmod"
- return 1
- fi
- fi
-
- [ -d "$initdir/.kernelmodseen" ] && \
- > "$initdir/.kernelmodseen/${1##*/}"
-
- inst_simple "$1" "/lib/modules/$KERNEL_VER/${1##*/lib/modules/$KERNEL_VER/}" \
- || return $?
-
- local _modname=${1##*/} _fwdir _found _fw
- _modname=${_modname%.ko*}
- for _fw in $(modinfo -k $KERNEL_VER -F firmware $1 2>/dev/null); do
- _found=''
- for _fwdir in $fw_dir; do
- if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then
- inst_simple "$_fwdir/$_fw" "/lib/firmware/$_fw"
- _found=yes
- fi
- done
- if [[ $_found != yes ]]; then
- if ! grep -qe "\<${_modname//-/_}\>" /proc/modules; then
- dinfo "Possible missing firmware \"${_fw}\" for kernel module" \
- "\"${_modname}.ko\""
- else
- dwarn "Possible missing firmware \"${_fw}\" for kernel module" \
- "\"${_modname}.ko\""
- fi
- fi
- done
- return 0
-}
-
-# Do something with all the dependencies of a kernel module.
-# Note that kernel modules depend on themselves using the technique we use
-# $1 = function to call for each dependency we find
-# It will be passed the full path to the found kernel module
-# $2 = module to get dependencies for
-# rest of args = arguments to modprobe
-# _fderr specifies FD passed from surrounding scope
-for_each_kmod_dep() {
- local _func=$1 _kmod=$2 _cmd _modpath _options _found=0
- shift 2
- modprobe "$@" --ignore-install --show-depends $_kmod 2>&${_fderr} | (
- while read _cmd _modpath _options; do
- [[ $_cmd = insmod ]] || continue
- $_func ${_modpath} || exit $?
- _found=1
- done
- [[ $_found -eq 0 ]] && exit 1
- exit 0
- )
-}
-
-# filter kernel modules to install certain modules that meet specific
-# requirements.
-# $1 = search only in subdirectory of /kernel/$1
-# $2 = function to call with module name to filter.
-# This function will be passed the full path to the module to test.
-# The behavior of this function can vary depending on whether $hostonly is set.
-# If it is, we will only look at modules that are already in memory.
-# If it is not, we will look at all kernel modules
-# This function returns the full filenames of modules that match $1
-filter_kernel_modules_by_path () (
- local _modname _filtercmd
- if ! [[ $hostonly ]]; then
- _filtercmd='find "$KERNEL_MODS/kernel/$1" "$KERNEL_MODS/extra"'
- _filtercmd+=' "$KERNEL_MODS/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
- _filtercmd+=' -o -name "*.ko.xz"'
- _filtercmd+=' 2>/dev/null'
- else
- _filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
- _filtercmd+='-k $KERNEL_VER 2>/dev/null'
- fi
- for _modname in $(eval $_filtercmd); do
- case $_modname in
- *.ko) "$2" "$_modname" && echo "$_modname";;
- *.ko.gz) gzip -dc "$_modname" > $initdir/$$.ko
- $2 $initdir/$$.ko && echo "$_modname"
- rm -f $initdir/$$.ko
- ;;
- *.ko.xz) xz -dc "$_modname" > $initdir/$$.ko
- $2 $initdir/$$.ko && echo "$_modname"
- rm -f $initdir/$$.ko
- ;;
- esac
- done
-)
-find_kernel_modules_by_path () (
- if ! [[ $hostonly ]]; then
- find "$KERNEL_MODS/kernel/$1" "$KERNEL_MODS/extra" "$KERNEL_MODS/weak-updates" \
- -name "*.ko" -o -name "*.ko.gz" -o -name "*.ko.xz" 2>/dev/null
- else
- cut -d " " -f 1 </proc/modules \
- | xargs modinfo -F filename -k $KERNEL_VER 2>/dev/null
- fi
-)
-
-filter_kernel_modules () {
- filter_kernel_modules_by_path drivers "$1"
-}
-
-find_kernel_modules () {
- find_kernel_modules_by_path drivers
-}
-
-# instmods [-c] <kernel module> [<kernel module> ... ]
-# instmods [-c] <kernel subsystem>
-# install kernel modules along with all their dependencies.
-# <kernel subsystem> can be e.g. "=block" or "=drivers/usb/storage"
-instmods() {
- [[ $no_kernel = yes ]] && return
- # called [sub]functions inherit _fderr
- local _fderr=9
- local _check=no
- if [[ $1 = '-c' ]]; then
- _check=yes
- shift
- fi
-
- function inst1mod() {
- local _ret=0 _mod="$1"
- case $_mod in
- =*)
- if [ -f $KERNEL_MODS/modules.${_mod#=} ]; then
- ( [[ "$_mpargs" ]] && echo $_mpargs
- cat "${KERNEL_MODS}/modules.${_mod#=}" ) \
- | instmods
- else
- ( [[ "$_mpargs" ]] && echo $_mpargs
- find "$KERNEL_MODS" -path "*/${_mod#=}/*" -printf '%f\n' ) \
- | instmods
- fi
- ;;
- --*) _mpargs+=" $_mod" ;;
- i2o_scsi) return ;; # Do not load this diagnostic-only module
- *)
- _mod=${_mod##*/}
- # if we are already installed, skip this module and go on
- # to the next one.
- [[ -f "$initdir/.kernelmodseen/${_mod%.ko}.ko" ]] && return
-
- if [[ $omit_drivers ]] && [[ "$1" =~ $omit_drivers ]]; then
- dinfo "Omitting driver ${_mod##$KERNEL_MODS}"
- return
- fi
- # If we are building a host-specific initramfs and this
- # module is not already loaded, move on to the next one.
- [[ $hostonly ]] && ! grep -qe "\<${_mod//-/_}\>" /proc/modules \
- && ! echo $add_drivers | grep -qe "\<${_mod}\>" \
- && return
-
- # We use '-d' option in modprobe only if modules prefix path
- # differs from default '/'. This allows us to use Dracut with
- # old version of modprobe which doesn't have '-d' option.
- local _moddirname=${KERNEL_MODS%%/lib/modules/*}
- [[ -n ${_moddirname} ]] && _moddirname="-d ${_moddirname}/"
-
- # ok, load the module, all its dependencies, and any firmware
- # it may require
- for_each_kmod_dep install_kmod_with_fw $_mod \
- --set-version $KERNEL_VER ${_moddirname} $_mpargs
- ((_ret+=$?))
- ;;
- esac
- return $_ret
- }
-
- function instmods_1() {
- local _mod _mpargs
- if (($# == 0)); then # filenames from stdin
- while read _mod; do
- inst1mod "${_mod%.ko*}" || {
- if [ "$_check" = "yes" ]; then
- dfatal "Failed to install $_mod"
- return 1
- fi
- }
- done
- fi
- while (($# > 0)); do # filenames as arguments
- inst1mod ${1%.ko*} || {
- if [ "$_check" = "yes" ]; then
- dfatal "Failed to install $1"
- return 1
- fi
- }
- shift
- done
- return 0
- }
-
- local _ret _filter_not_found='FATAL: Module .* not found.'
- set -o pipefail
- # Capture all stderr from modprobe to _fderr. We could use {var}>...
- # redirections, but that would make dracut require bash4 at least.
- eval "( instmods_1 \"\$@\" ) ${_fderr}>&1" \
- | while read line; do [[ "$line" =~ $_filter_not_found ]] && echo $line || echo $line >&2 ;done | derror
- _ret=$?
- set +o pipefail
- return $_ret
-}
-
-# inst_libdir_file [-n <pattern>] <file> [<file>...]
-# Install a <file> located on a lib directory to the initramfs image
-# -n <pattern> install non-matching files
-inst_libdir_file() {
- if [[ "$1" == "-n" ]]; then
- local _pattern=$1
- shift 2
- for _dir in $libdirs; do
- for _i in "$@"; do
- for _f in "$_dir"/$_i; do
- [[ "$_i" =~ $_pattern ]] || continue
- [[ -e "$_i" ]] && dracut_install "$_i"
- done
- done
- done
- else
- for _dir in $libdirs; do
- for _i in "$@"; do
- for _f in "$_dir"/$_i; do
- [[ -e "$_f" ]] && dracut_install "$_f"
- done
- done
- done
- fi
-}
-
-check_nspawn() {
- [[ -d /sys/fs/cgroup/systemd ]]
-}
-
-
-do_test() {
- if [[ $UID != "0" ]]; then
- echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2
- exit 0
- fi
-
-# Detect lib paths
- [[ $libdir ]] || for libdir in /lib64 /lib; do
- [[ -d $libdir ]] && libdirs+=" $libdir" && break
- done
-
- [[ $usrlibdir ]] || for usrlibdir in /usr/lib64 /usr/lib; do
- [[ -d $usrlibdir ]] && libdirs+=" $usrlibdir" && break
- done
-
- import_testdir
- import_initdir
-
- while (($# > 0)); do
- case $1 in
- --run)
- echo "TEST RUN: $TEST_DESCRIPTION"
- test_run
- ret=$?
- if [ $ret -eq 0 ]; then
- echo "TEST RUN: $TEST_DESCRIPTION [OK]"
- else
- echo "TEST RUN: $TEST_DESCRIPTION [FAILED]"
- fi
- exit $ret;;
- --setup)
- echo "TEST SETUP: $TEST_DESCRIPTION"
- test_setup
- exit $?;;
- --clean)
- echo "TEST CLEANUP: $TEST_DESCRIPTION"
- test_cleanup
- rm -fr "$TESTDIR"
- rm -f .testdir
- exit $?;;
- --all)
- echo -n "TEST: $TEST_DESCRIPTION ";
- (
- test_setup && test_run
- ret=$?
- test_cleanup
- rm -fr "$TESTDIR"
- rm -f .testdir
- exit $ret
- ) </dev/null >test.log 2>&1
- ret=$?
- if [ $ret -eq 0 ]; then
- rm test.log
- echo "[OK]"
- else
- echo "[FAILED]"
- echo "see $(pwd)/test.log"
- fi
- exit $ret;;
- *) break ;;
- esac
- shift
- done
-}
diff --git a/test/testsuite.target b/test/testsuite.target
deleted file mode 100644
index 1a7e5b371a..0000000000
--- a/test/testsuite.target
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Testsuite target
-Requires=multi-user.target
-After=multi-user.target
-Conflicts=rescue.target
-AllowIsolate=yes
diff --git a/test/timers.target b/test/timers.target
deleted file mode 120000
index 576d47fed7..0000000000
--- a/test/timers.target
+++ /dev/null
@@ -1 +0,0 @@
-../units/timers.target \ No newline at end of file
diff --git a/test/udev-test.pl b/test/udev-test.pl
deleted file mode 100755
index 64d7f93444..0000000000
--- a/test/udev-test.pl
+++ /dev/null
@@ -1,1545 +0,0 @@
-#!/usr/bin/perl
-
-# udev test
-#
-# Provides automated testing of the udev binary.
-# The whole test is self contained in this file, except the matching sysfs tree.
-# Simply extend the @tests array, to add a new test variant.
-#
-# Every test is driven by its own temporary config file.
-# This program prepares the environment, creates the config and calls udev.
-#
-# udev parses the rules, looks at the provided sysfs and
-# first creates and then removes the device node.
-# After creation and removal the result is checked against the
-# expected value and the result is printed.
-#
-# Copyright (C) 2004-2012 Kay Sievers <kay@vrfy.org>
-# Copyright (C) 2004 Leann Ogasawara <ogasawara@osdl.org>
-
-use warnings;
-use strict;
-
-my $udev_bin = "./test-udev";
-my $valgrind = 0;
-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";
-my $udev_rules = "$udev_rules_dir/udev-test.rules";
-my $EXIT_TEST_SKIP = 77;
-
-my @tests = (
- {
- desc => "no rules",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "sda" ,
- exp_rem_error => "yes",
- rules => <<EOF
-#
-EOF
- },
- {
- desc => "label test of scsi disc",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "boot_disk" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "label test of scsi disc",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "boot_disk" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "label test of scsi disc",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "boot_disk" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "label test of scsi partition",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
-EOF
- },
- {
- desc => "label test of pattern match",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="?ATA", SYMLINK+="boot_disk%n-1"
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA?", SYMLINK+="boot_disk%n-2"
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="A??", SYMLINK+="boot_disk%n"
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATAS", SYMLINK+="boot_disk%n-3"
-EOF
- },
- {
- desc => "label test of multiple sysfs files",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS X ", SYMLINK+="boot_diskX%n"
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", SYMLINK+="boot_disk%n"
-EOF
- },
- {
- desc => "label test of max sysfs files (skip invalid rule)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", ATTRS{queue_depth}=="32", SYMLINK+="boot_diskXX%n"
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", SYMLINK+="boot_disk%n"
-EOF
- },
- {
- desc => "catch device by *",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
- rules => <<EOF
-KERNEL=="ttyACM*", SYMLINK+="modem/%n"
-EOF
- },
- {
- desc => "catch device by * - take 2",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
- rules => <<EOF
-KERNEL=="*ACM1", SYMLINK+="bad"
-KERNEL=="*ACM0", SYMLINK+="modem/%n"
-EOF
- },
- {
- desc => "catch device by ?",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
- rules => <<EOF
-KERNEL=="ttyACM??*", SYMLINK+="modem/%n-1"
-KERNEL=="ttyACM??", SYMLINK+="modem/%n-2"
-KERNEL=="ttyACM?", SYMLINK+="modem/%n"
-EOF
- },
- {
- desc => "catch device by character class",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
- rules => <<EOF
-KERNEL=="ttyACM[A-Z]*", SYMLINK+="modem/%n-1"
-KERNEL=="ttyACM?[0-9]", SYMLINK+="modem/%n-2"
-KERNEL=="ttyACM[0-9]*", SYMLINK+="modem/%n"
-EOF
- },
- {
- desc => "replace kernel name",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
- rules => <<EOF
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "Handle comment lines in config file (and replace kernel name)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
- rules => <<EOF
-# this is a comment
-KERNEL=="ttyACM0", SYMLINK+="modem"
-
-EOF
- },
- {
- desc => "Handle comment lines in config file with whitespace (and replace kernel name)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
- rules => <<EOF
- # this is a comment with whitespace before the comment
-KERNEL=="ttyACM0", SYMLINK+="modem"
-
-EOF
- },
- {
- desc => "Handle whitespace only lines (and replace kernel name)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "whitespace" ,
- rules => <<EOF
-
-
-
- # this is a comment with whitespace before the comment
-KERNEL=="ttyACM0", SYMLINK+="whitespace"
-
-
-
-EOF
- },
- {
- desc => "Handle empty lines in config file (and replace kernel name)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
- rules => <<EOF
-
-KERNEL=="ttyACM0", SYMLINK+="modem"
-
-EOF
- },
- {
- desc => "Handle backslashed multi lines in config file (and replace kernel name)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
- rules => <<EOF
-KERNEL=="ttyACM0", \\
-SYMLINK+="modem"
-
-EOF
- },
- {
- desc => "preserve backslashes, if they are not for a newline",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "aaa",
- rules => <<EOF
-KERNEL=="ttyACM0", PROGRAM=="/bin/echo -e \\101", RESULT=="A", SYMLINK+="aaa"
-EOF
- },
- {
- desc => "Handle stupid backslashed multi lines in config file (and replace kernel name)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
- rules => <<EOF
-
-#
-\\
-
-\\
-
-#\\
-
-KERNEL=="ttyACM0", \\
- SYMLINK+="modem"
-
-EOF
- },
- {
- desc => "subdirectory handling",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "sub/direct/ory/modem" ,
- rules => <<EOF
-KERNEL=="ttyACM0", SYMLINK+="sub/direct/ory/modem"
-EOF
- },
- {
- desc => "parent device name match of scsi partition",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "first_disk5" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="first_disk%n"
-EOF
- },
- {
- desc => "test substitution chars",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="Major:%M:minor:%m:kernelnumber:%n:id:%b"
-EOF
- },
- {
- desc => "import of shell-value returned from program",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node12345678",
- rules => <<EOF
-SUBSYSTEMS=="scsi", IMPORT{program}="/bin/echo -e \' TEST_KEY=12345678\\n TEST_key2=98765\'", SYMLINK+="node\$env{TEST_KEY}"
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "sustitution of sysfs value (%s{file})",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "disk-ATA-sda" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="disk-%s{vendor}-%k"
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "program result substitution",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "special-device-5" ,
- not_exp_name => "not" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="-special-*", SYMLINK+="not"
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-*", SYMLINK+="%c-%n"
-EOF
- },
- {
- desc => "program result substitution (newline removal)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "newline_removed" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo test", RESULT=="test", SYMLINK+="newline_removed"
-EOF
- },
- {
- desc => "program result substitution",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "test-0:0:0:0" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n test-%b", RESULT=="test-0:0*", SYMLINK+="%c"
-EOF
- },
- {
- desc => "program with lots of arguments",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "foo9" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="%c{7}"
-EOF
- },
- {
- desc => "program with subshell",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "bar9" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed s/foo9/bar9/'", KERNEL=="sda5", SYMLINK+="%c{7}"
-EOF
- },
- {
- desc => "program arguments combined with apostrophes",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "foo7" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n 'foo3 foo4' 'foo5 foo6 foo7 foo8'", KERNEL=="sda5", SYMLINK+="%c{5}"
-EOF
- },
- {
- desc => "characters before the %c{N} substitution",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "my-foo9" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="my-%c{7}"
-EOF
- },
- {
- desc => "substitute the second to last argument",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "my-foo8" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="my-%c{6}"
-EOF
- },
- {
- desc => "test substitution by variable name",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="Major:\$major-minor:\$minor-kernelnumber:\$number-id:\$id"
-EOF
- },
- {
- desc => "test substitution by variable name 2",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="Major:\$major-minor:%m-kernelnumber:\$number-id:\$id"
-EOF
- },
- {
- desc => "test substitution by variable name 3",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "850:0:0:05" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="%M%m%b%n"
-EOF
- },
- {
- desc => "test substitution by variable name 4",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "855" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="\$major\$minor\$number"
-EOF
- },
- {
- desc => "test substitution by variable name 5",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "8550:0:0:0" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="\$major%m%n\$id"
-EOF
- },
- {
- desc => "non matching SUBSYSTEMS for device with no parent",
- devpath => "/devices/virtual/tty/console",
- exp_name => "TTY",
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo", RESULT=="foo", SYMLINK+="foo"
-KERNEL=="console", SYMLINK+="TTY"
-EOF
- },
- {
- desc => "non matching SUBSYSTEMS",
- devpath => "/devices/virtual/tty/console",
- exp_name => "TTY" ,
- rules => <<EOF
-SUBSYSTEMS=="foo", ATTRS{dev}=="5:1", SYMLINK+="foo"
-KERNEL=="console", SYMLINK+="TTY"
-EOF
- },
- {
- desc => "ATTRS match",
- devpath => "/devices/virtual/tty/console",
- exp_name => "foo" ,
- rules => <<EOF
-KERNEL=="console", SYMLINK+="TTY"
-ATTRS{dev}=="5:1", SYMLINK+="foo"
-EOF
- },
- {
- desc => "ATTR (empty file)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "empty" ,
- rules => <<EOF
-KERNEL=="sda", ATTR{test_empty_file}=="?*", SYMLINK+="something"
-KERNEL=="sda", ATTR{test_empty_file}!="", SYMLINK+="not-empty"
-KERNEL=="sda", ATTR{test_empty_file}=="", SYMLINK+="empty"
-KERNEL=="sda", ATTR{test_empty_file}!="?*", SYMLINK+="not-something"
-EOF
- },
- {
- desc => "ATTR (non-existent file)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "non-existent" ,
- rules => <<EOF
-KERNEL=="sda", ATTR{nofile}=="?*", SYMLINK+="something"
-KERNEL=="sda", ATTR{nofile}!="", SYMLINK+="not-empty"
-KERNEL=="sda", ATTR{nofile}=="", SYMLINK+="empty"
-KERNEL=="sda", ATTR{nofile}!="?*", SYMLINK+="not-something"
-KERNEL=="sda", TEST!="nofile", SYMLINK+="non-existent"
-KERNEL=="sda", SYMLINK+="wrong"
-EOF
- },
- {
- desc => "program and bus type match",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "scsi-0:0:0:0" ,
- rules => <<EOF
-SUBSYSTEMS=="usb", PROGRAM=="/bin/echo -n usb-%b", SYMLINK+="%c"
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n scsi-%b", SYMLINK+="%c"
-SUBSYSTEMS=="foo", PROGRAM=="/bin/echo -n foo-%b", SYMLINK+="%c"
-EOF
- },
- {
- desc => "sysfs parent hierarchy",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
- rules => <<EOF
-ATTRS{idProduct}=="007b", SYMLINK+="modem"
-EOF
- },
- {
- desc => "name test with ! in the name",
- devpath => "/devices/virtual/block/fake!blockdev0",
- exp_name => "is/a/fake/blockdev0" ,
- rules => <<EOF
-SUBSYSTEMS=="scsi", SYMLINK+="is/not/a/%k"
-SUBSYSTEM=="block", SYMLINK+="is/a/%k"
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "name test with ! in the name, but no matching rule",
- devpath => "/devices/virtual/block/fake!blockdev0",
- exp_name => "fake/blockdev0" ,
- exp_rem_error => "yes",
- rules => <<EOF
-KERNEL=="ttyACM0", SYMLINK+="modem"
-EOF
- },
- {
- desc => "KERNELS rule",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "scsi-0:0:0:0",
- rules => <<EOF
-SUBSYSTEMS=="usb", KERNELS=="0:0:0:0", SYMLINK+="not-scsi"
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:1", SYMLINK+="no-match"
-SUBSYSTEMS=="scsi", KERNELS==":0", SYMLINK+="short-id"
-SUBSYSTEMS=="scsi", KERNELS=="/0:0:0:0", SYMLINK+="no-match"
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="scsi-0:0:0:0"
-EOF
- },
- {
- desc => "KERNELS wildcard all",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "scsi-0:0:0:0",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="*:1", SYMLINK+="no-match"
-SUBSYSTEMS=="scsi", KERNELS=="*:0:1", SYMLINK+="no-match"
-SUBSYSTEMS=="scsi", KERNELS=="*:0:0:1", SYMLINK+="no-match"
-SUBSYSTEMS=="scsi", KERNEL=="0:0:0:0", SYMLINK+="before"
-SUBSYSTEMS=="scsi", KERNELS=="*", SYMLINK+="scsi-0:0:0:0"
-EOF
- },
- {
- desc => "KERNELS wildcard partial",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "scsi-0:0:0:0",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="before"
-SUBSYSTEMS=="scsi", KERNELS=="*:0", SYMLINK+="scsi-0:0:0:0"
-EOF
- },
- {
- desc => "KERNELS wildcard partial 2",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "scsi-0:0:0:0",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="before"
-SUBSYSTEMS=="scsi", KERNELS=="*:0:0:0", SYMLINK+="scsi-0:0:0:0"
-EOF
- },
- {
- desc => "substitute attr with link target value (first match)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "driver-is-sd",
- rules => <<EOF
-SUBSYSTEMS=="scsi", SYMLINK+="driver-is-\$attr{driver}"
-EOF
- },
- {
- desc => "substitute attr with link target value (currently selected device)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "driver-is-ahci",
- rules => <<EOF
-SUBSYSTEMS=="pci", SYMLINK+="driver-is-\$attr{driver}"
-EOF
- },
- {
- desc => "ignore ATTRS attribute whitespace",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "ignored",
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE", SYMLINK+="ignored"
-EOF
- },
- {
- desc => "do not ignore ATTRS attribute whitespace",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "matched-with-space",
- rules => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE ", SYMLINK+="wrong-to-ignore"
-SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE ", SYMLINK+="matched-with-space"
-EOF
- },
- {
- desc => "permissions USER=bad GROUP=name",
- devpath => "/devices/virtual/tty/tty33",
- exp_name => "tty33",
- exp_perms => "0:0:0600",
- rules => <<EOF
-KERNEL=="tty33", OWNER="bad", GROUP="name"
-EOF
- },
- {
- desc => "permissions OWNER=1",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_perms => "1::0600",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="1"
-EOF
- },
- {
- desc => "permissions GROUP=1",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_perms => ":1:0660",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", GROUP="1"
-EOF
- },
- {
- desc => "textual user id",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_perms => "nobody::0600",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="nobody"
-EOF
- },
- {
- desc => "textual group id",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_perms => ":daemon:0660",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", GROUP="daemon"
-EOF
- },
- {
- desc => "textual user/group id",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_perms => "root:mail:0660",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="root", GROUP="mail"
-EOF
- },
- {
- desc => "permissions MODE=0777",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_perms => "::0777",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", MODE="0777"
-EOF
- },
- {
- desc => "permissions OWNER=1 GROUP=1 MODE=0777",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_perms => "1:1:0777",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="1", GROUP="1", MODE="0777"
-EOF
- },
- {
- desc => "permissions OWNER to 1",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "ttyACM0",
- exp_perms => "1::",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", OWNER="1"
-EOF
- },
- {
- desc => "permissions GROUP to 1",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "ttyACM0",
- exp_perms => ":1:0660",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", GROUP="1"
-EOF
- },
- {
- desc => "permissions MODE to 0060",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "ttyACM0",
- exp_perms => "::0060",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", MODE="0060"
-EOF
- },
- {
- desc => "permissions OWNER, GROUP, MODE",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "ttyACM0",
- exp_perms => "1:1:0777",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", OWNER="1", GROUP="1", MODE="0777"
-EOF
- },
- {
- desc => "permissions only rule",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "ttyACM0",
- exp_perms => "1:1:0777",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", OWNER="1", GROUP="1", MODE="0777"
-KERNEL=="ttyUSX[0-9]*", OWNER="2", GROUP="2", MODE="0444"
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n"
-EOF
- },
- {
- desc => "multiple permissions only rule",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "ttyACM0",
- exp_perms => "1:1:0777",
- rules => <<EOF
-SUBSYSTEM=="tty", OWNER="1"
-SUBSYSTEM=="tty", GROUP="1"
-SUBSYSTEM=="tty", MODE="0777"
-KERNEL=="ttyUSX[0-9]*", OWNER="2", GROUP="2", MODE="0444"
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n"
-EOF
- },
- {
- desc => "permissions only rule with override at SYMLINK+ rule",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "ttyACM0",
- exp_perms => "1:2:0777",
- rules => <<EOF
-SUBSYSTEM=="tty", OWNER="1"
-SUBSYSTEM=="tty", GROUP="1"
-SUBSYSTEM=="tty", MODE="0777"
-KERNEL=="ttyUSX[0-9]*", OWNER="2", GROUP="2", MODE="0444"
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", GROUP="2"
-EOF
- },
- {
- desc => "major/minor number test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- exp_majorminor => "8:0",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node"
-EOF
- },
- {
- desc => "big major number test",
- devpath => "/devices/virtual/misc/misc-fake1",
- exp_name => "node",
- exp_majorminor => "4095:1",
- rules => <<EOF
-KERNEL=="misc-fake1", SYMLINK+="node"
-EOF
- },
- {
- desc => "big major and big minor number test",
- devpath => "/devices/virtual/misc/misc-fake89999",
- exp_name => "node",
- exp_majorminor => "4095:89999",
- rules => <<EOF
-KERNEL=="misc-fake89999", SYMLINK+="node"
-EOF
- },
- {
- desc => "multiple symlinks with format char",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "symlink2-ttyACM0",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK="symlink1-%n symlink2-%k symlink3-%b"
-EOF
- },
- {
- desc => "multiple symlinks with a lot of s p a c e s",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "one",
- not_exp_name => " ",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK=" one two "
-EOF
- },
- {
- desc => "symlink creation (same directory)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem0",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK="modem%n"
-EOF
- },
- {
- desc => "multiple symlinks",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "second-0" ,
- rules => <<EOF
-KERNEL=="ttyACM0", SYMLINK="first-%n second-%n third-%n"
-EOF
- },
- {
- desc => "symlink name '.'",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => ".",
- exp_add_error => "yes",
- exp_rem_error => "yes",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="."
-EOF
- },
- {
- desc => "symlink node to itself",
- devpath => "/devices/virtual/tty/tty0",
- exp_name => "link",
- exp_add_error => "yes",
- exp_rem_error => "yes",
- option => "clean",
- rules => <<EOF
-KERNEL=="tty0", SYMLINK+="tty0"
-EOF
- },
- {
- desc => "symlink %n substitution",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "symlink0",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK+="symlink%n"
-EOF
- },
- {
- desc => "symlink %k substitution",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "symlink-ttyACM0",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK+="symlink-%k"
-EOF
- },
- {
- desc => "symlink %M:%m substitution",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "major-166:0",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK+="major-%M:%m"
-EOF
- },
- {
- desc => "symlink %b substitution",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "symlink-0:0:0:0",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="symlink-%b"
-EOF
- },
- {
- desc => "symlink %c substitution",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "test",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo test", SYMLINK+="%c"
-EOF
- },
- {
- desc => "symlink %c{N} substitution",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "test",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo symlink test this", SYMLINK+="%c{2}"
-EOF
- },
- {
- desc => "symlink %c{N+} substitution",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "this",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo symlink test this", SYMLINK+="%c{2+}"
-EOF
- },
- {
- desc => "symlink only rule with %c{N+}",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "test",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/bin/echo link test this" SYMLINK+="%c{2+}"
-EOF
- },
- {
- desc => "symlink %s{filename} substitution",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "166:0",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="%s{dev}"
-EOF
- },
- {
- desc => "program result substitution (numbered part of)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "link1",
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2", RESULT=="node *", SYMLINK+="%c{2} %c{3}"
-EOF
- },
- {
- desc => "program result substitution (numbered part of+)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "link4",
- rules => <<EOF
-SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT=="node *", SYMLINK+="%c{2+}"
-EOF
- },
- {
- desc => "SUBSYSTEM match test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="should_not_match", SUBSYSTEM=="vc"
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", SUBSYSTEM=="block"
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="should_not_match2", SUBSYSTEM=="vc"
-EOF
- },
- {
- desc => "DRIVERS match test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="should_not_match", DRIVERS=="sd-wrong"
-SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", DRIVERS=="sd"
-EOF
- },
- {
- desc => "devnode substitution test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/usr/bin/test -b %N" SYMLINK+="node"
-EOF
- },
- {
- desc => "parent node name substitution test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "sda-part-1",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="%P-part-1"
-EOF
- },
- {
- desc => "udev_root substitution",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "start-/dev-end",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="start-%r-end"
-EOF
- },
- {
- desc => "last_rule option",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "last",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="last", OPTIONS="last_rule"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="very-last"
-EOF
- },
- {
- desc => "negation KERNEL!=",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "match",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL!="sda1", SYMLINK+="matches-but-is-negated"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
-SUBSYSTEMS=="scsi", KERNEL!="xsda1", SYMLINK+="match"
-EOF
- },
- {
- desc => "negation SUBSYSTEM!=",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "not-anything",
- rules => <<EOF
-SUBSYSTEMS=="scsi", SUBSYSTEM=="block", KERNEL!="sda1", SYMLINK+="matches-but-is-negated"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
-SUBSYSTEMS=="scsi", SUBSYSTEM!="anything", SYMLINK+="not-anything"
-EOF
- },
- {
- desc => "negation PROGRAM!= exit code",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "nonzero-program",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
-KERNEL=="sda1", PROGRAM!="/bin/false", SYMLINK+="nonzero-program"
-EOF
- },
- {
- desc => "ENV{} test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "true",
- rules => <<EOF
-ENV{ENV_KEY_TEST}="test"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="go", SYMLINK+="wrong"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="test", SYMLINK+="true"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="bad", SYMLINK+="bad"
-EOF
- },
- {
- desc => "ENV{} test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "true",
- rules => <<EOF
-ENV{ENV_KEY_TEST}="test"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="go", SYMLINK+="wrong"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="yes", ENV{ACTION}=="add", ENV{DEVPATH}=="*/block/sda/sdax1", SYMLINK+="no"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="test", ENV{ACTION}=="add", ENV{DEVPATH}=="*/block/sda/sda1", SYMLINK+="true"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="bad", SYMLINK+="bad"
-EOF
- },
- {
- desc => "ENV{} test (assign)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "true",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="true"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="yes", SYMLINK+="no"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="true", SYMLINK+="true"
-EOF
- },
- {
- desc => "ENV{} test (assign 2 times)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "true",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="true"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="absolutely-\$env{ASSIGN}"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="yes", SYMLINK+="no"
-SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="absolutely-true", SYMLINK+="true"
-EOF
- },
- {
- desc => "ENV{} test (assign2)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "part",
- rules => <<EOF
-SUBSYSTEM=="block", KERNEL=="*[0-9]", ENV{PARTITION}="true", ENV{MAINDEVICE}="false"
-SUBSYSTEM=="block", KERNEL=="*[!0-9]", ENV{PARTITION}="false", ENV{MAINDEVICE}="true"
-ENV{MAINDEVICE}=="true", SYMLINK+="disk"
-SUBSYSTEM=="block", SYMLINK+="before"
-ENV{PARTITION}=="true", SYMLINK+="part"
-EOF
- },
- {
- desc => "untrusted string sanitize",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "sane",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e name; (/usr/bin/badprogram)", RESULT=="name_ _/usr/bin/badprogram_", SYMLINK+="sane"
-EOF
- },
- {
- desc => "untrusted string sanitize (don't replace utf8)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "uber",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xc3\\xbcber" RESULT=="\xc3\xbcber", SYMLINK+="uber"
-EOF
- },
- {
- desc => "untrusted string sanitize (replace invalid utf8)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "replaced",
- rules => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xef\\xe8garbage", RESULT=="__garbage", SYMLINK+="replaced"
-EOF
- },
- {
- desc => "read sysfs value from parent device",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "serial-354172020305000",
- rules => <<EOF
-KERNEL=="ttyACM*", ATTRS{serial}=="?*", SYMLINK+="serial-%s{serial}"
-EOF
- },
- {
- desc => "match against empty key string",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "ok",
- rules => <<EOF
-KERNEL=="sda", ATTRS{nothing}!="", SYMLINK+="not-1-ok"
-KERNEL=="sda", ATTRS{nothing}=="", SYMLINK+="not-2-ok"
-KERNEL=="sda", ATTRS{vendor}!="", SYMLINK+="ok"
-KERNEL=="sda", ATTRS{vendor}=="", SYMLINK+="not-3-ok"
-EOF
- },
- {
- desc => "check ACTION value",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "ok",
- rules => <<EOF
-ACTION=="unknown", KERNEL=="sda", SYMLINK+="unknown-not-ok"
-ACTION=="add", KERNEL=="sda", SYMLINK+="ok"
-EOF
- },
- {
- desc => "final assignment",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "ok",
- exp_perms => "root:tty:0640",
- rules => <<EOF
-KERNEL=="sda", GROUP:="tty"
-KERNEL=="sda", GROUP="not-ok", MODE="0640", SYMLINK+="ok"
-EOF
- },
- {
- desc => "final assignment 2",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "ok",
- exp_perms => "root:tty:0640",
- rules => <<EOF
-KERNEL=="sda", GROUP:="tty"
-SUBSYSTEM=="block", MODE:="640"
-KERNEL=="sda", GROUP="not-ok", MODE="0666", SYMLINK+="ok"
-EOF
- },
- {
- desc => "env substitution",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "node-add-me",
- rules => <<EOF
-KERNEL=="sda", MODE="0666", SYMLINK+="node-\$env{ACTION}-me"
-EOF
- },
- {
- desc => "reset list to current value",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "three",
- not_exp_name => "two",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="one"
-KERNEL=="ttyACM[0-9]*", SYMLINK+="two"
-KERNEL=="ttyACM[0-9]*", SYMLINK="three"
-EOF
- },
- {
- desc => "test empty SYMLINK+ (empty override)",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "right",
- not_exp_name => "wrong",
- rules => <<EOF
-KERNEL=="ttyACM[0-9]*", SYMLINK+="wrong"
-KERNEL=="ttyACM[0-9]*", SYMLINK=""
-KERNEL=="ttyACM[0-9]*", SYMLINK+="right"
-EOF
- },
- {
- desc => "test multi matches",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "right",
- rules => <<EOF
-KERNEL=="ttyACM*", SYMLINK+="before"
-KERNEL=="ttyACM*|nothing", SYMLINK+="right"
-EOF
- },
- {
- desc => "test multi matches 2",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "right",
- rules => <<EOF
-KERNEL=="dontknow*|*nothing", SYMLINK+="nomatch"
-KERNEL=="ttyACM*", SYMLINK+="before"
-KERNEL=="dontknow*|ttyACM*|nothing*", SYMLINK+="right"
-EOF
- },
- {
- desc => "test multi matches 3",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "right",
- rules => <<EOF
-KERNEL=="dontknow|nothing", SYMLINK+="nomatch"
-KERNEL=="dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong1"
-KERNEL=="X|attyACM0|dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong2"
-KERNEL=="dontknow|ttyACM0|nothing", SYMLINK+="right"
-EOF
- },
- {
- desc => "test multi matches 4",
- devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "right",
- rules => <<EOF
-KERNEL=="dontknow|nothing", SYMLINK+="nomatch"
-KERNEL=="dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong1"
-KERNEL=="X|attyACM0|dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong2"
-KERNEL=="all|dontknow|ttyACM0", SYMLINK+="right"
-KERNEL=="ttyACM0a|nothing", SYMLINK+="wrong3"
-EOF
- },
- {
- desc => "IMPORT parent test sequence 1/2 (keep)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "parent",
- option => "keep",
- rules => <<EOF
-KERNEL=="sda", IMPORT{program}="/bin/echo -e \'PARENT_KEY=parent_right\\nWRONG_PARENT_KEY=parent_wrong'"
-KERNEL=="sda", SYMLINK+="parent"
-EOF
- },
- {
- desc => "IMPORT parent test sequence 2/2 (keep)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "parentenv-parent_right",
- option => "clean",
- rules => <<EOF
-KERNEL=="sda1", IMPORT{parent}="PARENT*", SYMLINK+="parentenv-\$env{PARENT_KEY}\$env{WRONG_PARENT_KEY}"
-EOF
- },
- {
- desc => "GOTO test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "right",
- rules => <<EOF
-KERNEL=="sda1", GOTO="TEST"
-KERNEL=="sda1", SYMLINK+="wrong"
-KERNEL=="sda1", GOTO="BAD"
-KERNEL=="sda1", SYMLINK+="", LABEL="NO"
-KERNEL=="sda1", SYMLINK+="right", LABEL="TEST", GOTO="end"
-KERNEL=="sda1", SYMLINK+="wrong2", LABEL="BAD"
-LABEL="end"
-EOF
- },
- {
- desc => "GOTO label does not exist",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "right",
- rules => <<EOF
-KERNEL=="sda1", GOTO="does-not-exist"
-KERNEL=="sda1", SYMLINK+="right",
-LABEL="exists"
-EOF
- },
- {
- desc => "SYMLINK+ compare test",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "right",
- not_exp_name => "wrong",
- rules => <<EOF
-KERNEL=="sda1", SYMLINK+="link"
-KERNEL=="sda1", SYMLINK=="link*", SYMLINK+="right"
-KERNEL=="sda1", SYMLINK=="nolink*", SYMLINK+="wrong"
-EOF
- },
- {
- desc => "invalid key operation",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "yes",
- rules => <<EOF
-KERNEL="sda1", SYMLINK+="no"
-KERNEL=="sda1", SYMLINK+="yes"
-EOF
- },
- {
- desc => "operator chars in attribute",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "yes",
- rules => <<EOF
-KERNEL=="sda", ATTR{test:colon+plus}=="?*", SYMLINK+="yes"
-EOF
- },
- {
- desc => "overlong comment line",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "yes",
- rules => <<EOF
-# 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
- # 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-KERNEL=="sda1", SYMLINK+=="no"
-KERNEL=="sda1", SYMLINK+="yes"
-EOF
- },
- {
- desc => "magic subsys/kernel lookup",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "00:16:41:e2:8d:ff",
- rules => <<EOF
-KERNEL=="sda", SYMLINK+="\$attr{[net/eth0]address}"
-EOF
- },
- {
- desc => "TEST absolute path",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "there",
- rules => <<EOF
-TEST=="/etc/machine-id", SYMLINK+="there"
-TEST!="/etc/machine-id", SYMLINK+="notthere"
-EOF
- },
- {
- desc => "TEST subsys/kernel lookup",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "yes",
- rules => <<EOF
-KERNEL=="sda", TEST=="[net/eth0]", SYMLINK+="yes"
-EOF
- },
- {
- desc => "TEST relative path",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "relative",
- rules => <<EOF
-KERNEL=="sda", TEST=="size", SYMLINK+="relative"
-EOF
- },
- {
- desc => "TEST wildcard substitution (find queue/nr_requests)",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "found-subdir",
- rules => <<EOF
-KERNEL=="sda", TEST=="*/nr_requests", SYMLINK+="found-subdir"
-EOF
- },
- {
- desc => "TEST MODE=0000",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "sda",
- exp_perms => "0:0:0000",
- exp_rem_error => "yes",
- rules => <<EOF
-KERNEL=="sda", MODE="0000"
-EOF
- },
- {
- desc => "TEST PROGRAM feeds OWNER, GROUP, MODE",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "sda",
- exp_perms => "1:1:0400",
- exp_rem_error => "yes",
- rules => <<EOF
-KERNEL=="sda", MODE="666"
-KERNEL=="sda", PROGRAM=="/bin/echo 1 1 0400", OWNER="%c{1}", GROUP="%c{2}", MODE="%c{3}"
-EOF
- },
- {
- desc => "TEST PROGRAM feeds MODE with overflow",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "sda",
- exp_perms => "0:0:0440",
- exp_rem_error => "yes",
- rules => <<EOF
-KERNEL=="sda", MODE="440"
-KERNEL=="sda", PROGRAM=="/bin/echo 0 0 0400letsdoabuffferoverflow0123456789012345789012345678901234567890", OWNER="%c{1}", GROUP="%c{2}", MODE="%c{3}"
-EOF
- },
- {
- desc => "magic [subsys/sysname] attribute substitution",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "sda-8741C4G-end",
- exp_perms => "0:0:0600",
- rules => <<EOF
-KERNEL=="sda", PROGRAM="/bin/true create-envp"
-KERNEL=="sda", ENV{TESTENV}="change-envp"
-KERNEL=="sda", SYMLINK+="%k-%s{[dmi/id]product_name}-end"
-EOF
- },
- {
- desc => "builtin path_id",
- devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0",
- rules => <<EOF
-KERNEL=="sda", IMPORT{builtin}="path_id"
-KERNEL=="sda", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/\$env{ID_PATH}"
-EOF
- },
-);
-
-sub udev {
- my ($action, $devpath, $rules) = @_;
-
- # create temporary rules
- system("mkdir", "-p", "$udev_rules_dir");
- open CONF, ">$udev_rules" || die "unable to create rules file: $udev_rules";
- print CONF $$rules;
- close CONF;
-
- if ($valgrind > 0) {
- system("$udev_bin_valgrind $action $devpath");
- } elsif ($gdb > 0) {
- system("$udev_bin_gdb $action $devpath");
- } else {
- system("$udev_bin", "$action", "$devpath");
- }
-}
-
-my $error = 0;
-
-sub permissions_test {
- my($rules, $uid, $gid, $mode) = @_;
-
- my $wrong = 0;
- my $userid;
- my $groupid;
-
- $rules->{exp_perms} =~ m/^(.*):(.*):(.*)$/;
- if ($1 ne "") {
- if (defined(getpwnam($1))) {
- $userid = int(getpwnam($1));
- } else {
- $userid = $1;
- }
- if ($uid != $userid) { $wrong = 1; }
- }
- if ($2 ne "") {
- if (defined(getgrnam($2))) {
- $groupid = int(getgrnam($2));
- } else {
- $groupid = $2;
- }
- if ($gid != $groupid) { $wrong = 1; }
- }
- if ($3 ne "") {
- if (($mode & 07777) != oct($3)) { $wrong = 1; };
- }
- if ($wrong == 0) {
- print "permissions: ok\n";
- } else {
- printf " expected permissions are: %s:%s:%#o\n", $1, $2, oct($3);
- printf " created permissions are : %i:%i:%#o\n", $uid, $gid, $mode & 07777;
- print "permissions: error\n";
- $error++;
- sleep(1);
- }
-}
-
-sub major_minor_test {
- my($rules, $rdev) = @_;
-
- my $major = ($rdev >> 8) & 0xfff;
- my $minor = ($rdev & 0xff) | (($rdev >> 12) & 0xfff00);
- my $wrong = 0;
-
- $rules->{exp_majorminor} =~ m/^(.*):(.*)$/;
- if ($1 ne "") {
- if ($major != $1) { $wrong = 1; };
- }
- if ($2 ne "") {
- if ($minor != $2) { $wrong = 1; };
- }
- if ($wrong == 0) {
- print "major:minor: ok\n";
- } else {
- printf " expected major:minor is: %i:%i\n", $1, $2;
- printf " created major:minor is : %i:%i\n", $major, $minor;
- print "major:minor: error\n";
- $error++;
- sleep(1);
- }
-}
-
-sub udev_setup {
- system("rm", "-rf", "$udev_dev");
- mkdir($udev_dev) || die "unable to create udev_dev: $udev_dev\n";
- # setting group and mode of udev_dev ensures the tests work
- # even if the parent directory has setgid bit enabled.
- chown (0, 0, $udev_dev) || die "unable to chown $udev_dev\n";
- chmod (0755, $udev_dev) || die "unable to chmod $udev_dev\n";
-
- system("rm", "-rf", "$udev_run");
-}
-
-sub run_test {
- my ($rules, $number) = @_;
-
- print "TEST $number: $rules->{desc}\n";
- print "device \'$rules->{devpath}\' expecting node/link \'$rules->{exp_name}\'\n";
-
- udev("add", $rules->{devpath}, \$rules->{rules});
- if (defined($rules->{not_exp_name})) {
- if ((-e "$udev_dev/$rules->{not_exp_name}") ||
- (-l "$udev_dev/$rules->{not_exp_name}")) {
- print "nonexistent: error \'$rules->{not_exp_name}\' not expected to be there\n";
- $error++;
- sleep(1);
- }
- }
-
- if ((-e "$udev_dev/$rules->{exp_name}") ||
- (-l "$udev_dev/$rules->{exp_name}")) {
-
- my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
- $atime, $mtime, $ctime, $blksize, $blocks) = stat("$udev_dev/$rules->{exp_name}");
-
- if (defined($rules->{exp_perms})) {
- permissions_test($rules, $uid, $gid, $mode);
- }
- if (defined($rules->{exp_majorminor})) {
- major_minor_test($rules, $rdev);
- }
- print "add: ok\n";
- } else {
- print "add: error";
- if ($rules->{exp_add_error}) {
- print " as expected\n";
- } else {
- print "\n";
- system("tree", "$udev_dev");
- print "\n";
- $error++;
- sleep(1);
- }
- }
-
- if (defined($rules->{option}) && $rules->{option} eq "keep") {
- print "\n\n";
- return;
- }
-
- udev("remove", $rules->{devpath}, \$rules->{rules});
- if ((-e "$udev_dev/$rules->{exp_name}") ||
- (-l "$udev_dev/$rules->{exp_name}")) {
- print "remove: error";
- if ($rules->{exp_rem_error}) {
- print " as expected\n";
- } else {
- print "\n";
- system("tree", "$udev_dev");
- print "\n";
- $error++;
- sleep(1);
- }
- } else {
- print "remove: ok\n";
- }
-
- print "\n";
-
- if (defined($rules->{option}) && $rules->{option} eq "clean") {
- udev_setup();
- }
-
-}
-
-# only run if we have root permissions
-# due to mknod restrictions
-if (!($<==0)) {
- print "Must have root permissions to run properly.\n";
- exit;
-}
-
-# skip the test when running in a container
-system("systemd-detect-virt", "-c", "-q");
-if ($? >> 8 == 0) {
- print "Running in a container, skipping the test.\n";
- exit($EXIT_TEST_SKIP);
-}
-
-udev_setup();
-
-my $test_num = 1;
-my @list;
-
-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);
- }
-}
-
-if ($list[0]) {
- foreach my $arg (@list) {
- if (defined($tests[$arg-1]->{desc})) {
- print "udev-test will run test number $arg:\n\n";
- run_test($tests[$arg-1], $arg);
- } else {
- print "test does not exist.\n";
- }
- }
-} else {
- # test all
- print "\nudev-test will run ".($#tests + 1)." tests:\n\n";
-
- foreach my $rules (@tests) {
- run_test($rules, $test_num);
- $test_num++;
- }
-}
-
-print "$error errors occurred\n\n";
-
-# cleanup
-system("rm", "-rf", "$udev_dev");
-system("rm", "-rf", "$udev_run");
-
-if ($error > 0) {
- exit(1);
-}
-exit(0);
diff --git a/test/unstoppable.service b/test/unstoppable.service
deleted file mode 100644
index 24fb0a25e1..0000000000
--- a/test/unstoppable.service
+++ /dev/null
@@ -1,5 +0,0 @@
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/bin/echo 'I'm unstoppable!'
-ExecStop=/bin/systemctl start --no-block unstoppable.service