]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-28-PERCENTJ-WANTEDBY/test.sh
test: add function to reduce copied setup boilerplate
[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 mask_supporting_services
18
19 # Set up the services.
20 cat >$initdir/etc/systemd/system/specifier-j-wants.service << EOF
21 [Unit]
22 Description=Wants with percent-j specifier
23 Wants=specifier-j-depends-%j.service
24 After=specifier-j-depends-%j.service
25
26 [Service]
27 Type=oneshot
28 ExecStart=test -f /tmp/test-specifier-j-%j
29 ExecStart=/bin/sh -c 'echo OK > /testok'
30 EOF
31 cat >$initdir/etc/systemd/system/specifier-j-depends-wants.service << EOF
32 [Unit]
33 Description=Dependent service for percent-j specifier
34
35 [Service]
36 Type=oneshot
37 ExecStart=touch /tmp/test-specifier-j-wants
38 EOF
39 cat >$initdir/etc/systemd/system/testsuite.service << EOF
40 [Unit]
41 Description=Testsuite: Ensure %j Wants directives work
42 Wants=specifier-j-wants.service
43 After=specifier-j-wants.service
44
45 [Service]
46 Type=oneshot
47 ExecStart=/bin/true
48 EOF
49
50 setup_testsuite
51 )
52
53 setup_nspawn_root
54 }
55
56 do_test "$@"