]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-28-PERCENTJ-WANTEDBY/test.sh
Merge pull request #13080 from keszybz/firstboot-fixes
[thirdparty/systemd.git] / test / TEST-28-PERCENTJ-WANTEDBY / test.sh
1 #!/bin/bash
2 set -e
3 TEST_DESCRIPTION="Ensure %j Wants directives work"
4 RUN_IN_UNPRIVILEGED_CONTAINER=yes
5
6 . $TEST_BASE_DIR/test-functions
7
8 test_setup() {
9 create_empty_image_rootdir
10
11 # Create what will eventually be our root filesystem onto an overlay
12 (
13 LOG_LEVEL=5
14 eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
15
16 setup_basic_environment
17
18 # Set up the services.
19 cat >$initdir/etc/systemd/system/specifier-j-wants.service << EOF
20 [Unit]
21 Description=Wants with percent-j specifier
22 Wants=specifier-j-depends-%j.service
23 After=specifier-j-depends-%j.service
24
25 [Service]
26 Type=oneshot
27 ExecStart=test -f /tmp/test-specifier-j-%j
28 ExecStart=/bin/sh -c 'echo OK > /testok'
29 EOF
30 cat >$initdir/etc/systemd/system/specifier-j-depends-wants.service << EOF
31 [Unit]
32 Description=Dependent service for percent-j specifier
33
34 [Service]
35 Type=oneshot
36 ExecStart=touch /tmp/test-specifier-j-wants
37 EOF
38 cat >$initdir/etc/systemd/system/testsuite.service << EOF
39 [Unit]
40 Description=Testsuite: Ensure %j Wants directives work
41 Wants=specifier-j-wants.service
42 After=specifier-j-wants.service
43
44 [Service]
45 Type=oneshot
46 ExecStart=/bin/true
47 EOF
48
49 setup_testsuite
50 )
51 setup_nspawn_root
52
53 # mask some services that we do not want to run in these tests
54 ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service
55 ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service
56 ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service
57 ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
58 ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service
59 }
60
61 do_test "$@"