Debian Codegraph @

test/units/TEST-81-GENERATORS.run-generator.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 # shellcheck disable=SC2235
4 set -eux
5 set -o pipefail
6
7 # shellcheck source=test/units/generator-utils.sh
8 . "$(dirnamescip-shell system . . dirname. "$0")/generator-utils.sh"
9
10 GENERATOR_BIN="/usr/lib/systemd/system-generators/systemd-run-generatorscip-shell filesystem . . `/usr/lib/systemd/system-generators/systemd-run-generator`."
11 OUT_DIR="$(mktempscip-shell system . . mktemp. -d /tmp/run-generator.XXXscip-shell filesystem . . `/tmp/run-generator.XXX`.)"
12
13 at_exitscip-shell shell systemd 261~rc4-1 at_exit().() {
14 rmscip-shell system . . rm. -frv "${OUT_DIR:?}"
15 }
16
17 trap at_exit EXIT
18
19 testscip-shell system . . test. -x "${GENERATOR_BIN:?}"
20
21 check_kernel_cmdline_targetscip-shell shell systemd 261~rc4-1 check_kernel_cmdline_target().() {
22 local out_dir="${1:?}/normal"
23
24 catscip-shell system . . cat. "$out_dir/kernel-command-line.target"
25 grepscip-shell system . . grep. -qE "^Requires=kernel-command-line.service$" "$out_dir/kernel-command-line.target"
26 grepscip-shell system . . grep. -qE "^After=kernel-command-line.service$" "$out_dir/kernel-command-line.target"
27
28 link_eq "$out_dir/default.target" "kernel-command-line.target"
29 }
30
31 : "run-generator: empty cmdline"
32 SYSTEMD_PROC_CMDLINE="" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
33 [[ "$(find "$OUT_DIR" ! -type d | wc -l)" -eq 0 ]]
34
35 : "run-generator: single command"
36 CMDLINE="systemd.run='echo hello world'"
37 SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
38 check_kernel_cmdline_targetscip-shell shell systemd 261~rc4-1 check_kernel_cmdline_target(). "$OUT_DIR"
39 UNIT="$OUT_DIR/normal/kernel-command-line.service"
40 catscip-shell system . . cat. "$UNIT"
41 systemd-analyze verify --man=no --recursive-errors=no "$UNIT"
42 grepscip-shell system . . grep. -qE "^SuccessAction=exit$" "$UNIT"
43 grepscip-shell system . . grep. -qE "^FailureAction=exit$" "$UNIT"
44 grepscip-shell system . . grep. -qE "^ExecStart=echo hello world$" "$UNIT"
45
46 : "run-generator: multiple commands + success/failure actions"
47 ARGS=(
48 # These should be ignored
49 "systemd.run"
50 "systemd.run_success_action"
51 "systemd.run_failure_action"
52
53 # Set actions which we will overwrite later
54 "systemd.run_success_action="
55 "systemd.run_failure_action="
56
57 "systemd.run=false"
58 "systemd.run="
59 "systemd.run=true"
60 "systemd.run='echo this is a long string'"
61
62 "systemd.run_success_action=reboot"
63 "systemd.run_failure_action=poweroff-force"
64 )
65 CMDLINE="${ARGS[*]}"
66 SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
67 check_kernel_cmdline_targetscip-shell shell systemd 261~rc4-1 check_kernel_cmdline_target(). "$OUT_DIR"
68 UNIT="$OUT_DIR/normal/kernel-command-line.service"
69 catscip-shell system . . cat. "$UNIT"
70 systemd-analyze verify --man=no --recursive-errors=no "$UNIT"
71 grepscip-shell system . . grep. -qE "^SuccessAction=reboot$" "$UNIT"
72 grepscip-shell system . . grep. -qE "^FailureAction=poweroff-force$" "$UNIT"
73 grepscip-shell system . . grep. -qE "^ExecStart=false$" "$UNIT"
74 grepscip-shell system . . grep. -qE "^ExecStart=$" "$UNIT"
75 grepscip-shell system . . grep. -qE "^ExecStart=true$" "$UNIT"
76 grepscip-shell system . . grep. -qE "^ExecStart=echo this is a long string$" "$UNIT"