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