]>
Commit | Line | Data |
---|---|---|
8eab7668 | 1 | #!/bin/bash |
8eab7668 PW |
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 | |
10 | mkdir -p $TESTDIR/root | |
11 | mount ${LOOPDEV}p1 $TESTDIR/root | |
12 | ||
13 | # Create what will eventually be our root filesystem onto an overlay | |
14 | ( | |
15 | LOG_LEVEL=5 | |
16 | eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) | |
17 | ||
18 | setup_basic_environment | |
19 | ||
20 | # Set up the services. | |
21 | cat >$initdir/etc/systemd/system/specifier-j-wants.service << EOF | |
22 | [Unit] | |
23 | Description=Wants with percent-j specifier | |
24 | Wants=specifier-j-depends-%j.service | |
25 | After=specifier-j-depends-%j.service | |
26 | ||
27 | [Service] | |
28 | Type=oneshot | |
29 | ExecStart=test -f /tmp/test-specifier-j-%j | |
30 | ExecStart=/bin/sh -c 'echo OK > /testok' | |
31 | EOF | |
32 | cat >$initdir/etc/systemd/system/specifier-j-depends-wants.service << EOF | |
33 | [Unit] | |
34 | Description=Dependent service for percent-j specifier | |
35 | ||
36 | [Service] | |
37 | Type=oneshot | |
38 | ExecStart=touch /tmp/test-specifier-j-wants | |
39 | EOF | |
40 | cat >$initdir/etc/systemd/system/testsuite.service << EOF | |
41 | [Unit] | |
42 | Description=Testsuite: Ensure %j Wants directives work | |
43 | Wants=specifier-j-wants.service | |
44 | After=specifier-j-wants.service | |
45 | ||
46 | [Service] | |
47 | Type=oneshot | |
48 | ExecStart=/bin/true | |
49 | EOF | |
50 | ||
51 | setup_testsuite | |
52 | ) || return 1 | |
53 | setup_nspawn_root | |
54 | ||
55 | # mask some services that we do not want to run in these tests | |
56 | ln -s /dev/null $initdir/etc/systemd/system/systemd-hwdb-update.service | |
57 | ln -s /dev/null $initdir/etc/systemd/system/systemd-journal-catalog-update.service | |
58 | ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.service | |
59 | ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket | |
60 | ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service | |
61 | ||
62 | ddebug "umount $TESTDIR/root" | |
63 | umount $TESTDIR/root | |
64 | } | |
65 | ||
66 | do_test "$@" |