From 82a48eb1db49139ea5b46375d80676e7c0737096 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 24 Sep 2025 18:01:20 +0200 Subject: [PATCH] test: add simple test case for mute-console service --- test/units/TEST-74-AUX-UTILS.mute-console.sh | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 test/units/TEST-74-AUX-UTILS.mute-console.sh diff --git a/test/units/TEST-74-AUX-UTILS.mute-console.sh b/test/units/TEST-74-AUX-UTILS.mute-console.sh new file mode 100755 index 0000000000..e15be1ef32 --- /dev/null +++ b/test/units/TEST-74-AUX-UTILS.mute-console.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux +set -o pipefail + +if ! command -v systemd-mute-console >/dev/null; then + echo "systemd-mute-console is not installed, skipping the test" + exit 0 +fi + +PID="$(systemd-notify --fork -- systemd-mute-console)" +sleep .5 +kill "$PID" +unset PID + +(! systemd-mute-console --kernel=no --pid1=no) + +PID="$(systemd-notify --fork -- systemd-mute-console --kernel=yes --pid1=yes)" +sleep .5 +kill "$PID" +unset PID + +varlinkctl introspect "$(which systemd-mute-console)" + +PID="$(systemd-notify --fork -- varlinkctl call -E "$(which systemd-mute-console)" io.systemd.MuteConsole.Mute '{}')" +sleep .5 +kill "$PID" +unset PID + +PID="$(systemd-notify --fork -- varlinkctl call -E "$(which systemd-mute-console)" io.systemd.MuteConsole.Mute '{"pid1":true, "kernel":true}')" +sleep .5 +kill "$PID" +unset PID + +varlinkctl introspect /run/systemd/io.systemd.MuteConsole + +PID="$(systemd-notify --fork -- varlinkctl call -E /run/systemd/io.systemd.MuteConsole io.systemd.MuteConsole.Mute '{}')" +sleep .5 +kill "$PID" +unset PID