]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-28-PERCENTJ-WANTEDBY/test.sh
test-network: change default sleep time of start_networkd()
[thirdparty/systemd.git] / test / TEST-28-PERCENTJ-WANTEDBY / test.sh
CommitLineData
8eab7668 1#!/bin/bash
8eab7668
PW
2set -e
3TEST_DESCRIPTION="Ensure %j Wants directives work"
4RUN_IN_UNPRIVILEGED_CONTAINER=yes
5
6. $TEST_BASE_DIR/test-functions
7
8test_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]
23Description=Wants with percent-j specifier
24Wants=specifier-j-depends-%j.service
25After=specifier-j-depends-%j.service
26
27[Service]
28Type=oneshot
29ExecStart=test -f /tmp/test-specifier-j-%j
30ExecStart=/bin/sh -c 'echo OK > /testok'
31EOF
32 cat >$initdir/etc/systemd/system/specifier-j-depends-wants.service << EOF
33[Unit]
34Description=Dependent service for percent-j specifier
35
36[Service]
37Type=oneshot
38ExecStart=touch /tmp/test-specifier-j-wants
39EOF
40 cat >$initdir/etc/systemd/system/testsuite.service << EOF
41[Unit]
42Description=Testsuite: Ensure %j Wants directives work
43Wants=specifier-j-wants.service
44After=specifier-j-wants.service
45
46[Service]
47Type=oneshot
48ExecStart=/bin/true
49EOF
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
66do_test "$@"