1#!/usr/bin/env bash
2# SPDX-License-Identifier: LGPL-2.1-or-later
3set -eux
4set -o pipefail
5
6systemd-analyze log-level debug
7systemd-analyze log-target console
8
9systemd-run --wait --unit=test27-one \
10            -p StandardOutput=file:/tmp/stdout \
11            -p StandardError=file:/tmp/stderr \
12            -p Type=exec \
13            sh -c 'echo x ; echo y >&2'
14cmp /tmp/stdout <<EOF
15x
16EOF
17cmp /tmp/stderr <<EOF
18y
19EOF
20
21systemd-run --wait --unit=test27-two \
22            -p StandardOutput=file:/tmp/stdout \
23            -p StandardError=file:/tmp/stderr \
24            -p Type=exec \
25            sh -c 'echo z ; echo a >&2'
26cmp /tmp/stdout <<EOF
27z
28EOF
29cmp /tmp/stderr <<EOF
30a
31EOF
32
33systemd-run --wait --unit=test27-three \
34            -p StandardOutput=append:/tmp/stdout \
35            -p StandardError=append:/tmp/stderr \
36            -p Type=exec \
37            sh -c 'echo b ; echo c >&2'
38cmp /tmp/stdout <<EOF
39z
40b
41EOF
42cmp /tmp/stderr <<EOF
43a
44c
45EOF
46
47systemd-run --wait --unit=test27-four \
48            -p StandardOutput=truncate:/tmp/stdout \
49            -p StandardError=truncate:/tmp/stderr \
50            -p Type=exec \
51            sh -c 'echo a ; echo b >&2'
52cmp /tmp/stdout <<EOF
53a
54EOF
55cmp /tmp/stderr <<EOF
56b
57EOF
58
59systemd-analyze log-level info
60
61echo OK >/testok
62
63exit 0
64