]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add a test for #31384
authorDavid Tardon <dtardon@redhat.com>
Fri, 16 Feb 2024 15:22:05 +0000 (16:22 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 19 Feb 2024 16:45:19 +0000 (16:45 +0000)
test/test-functions
test/units/testsuite-23.utmp.sh [new file with mode: 0755]

index a3bb4abc00bb199925054355d2ef6e581d361704..f99d177e2fe3c11f0d701d02be7dac6b75c86c76 100644 (file)
@@ -256,6 +256,7 @@ BASICTOOLS=(
     useradd
     userdel
     wc
+    whoami
     xargs
     xzcat
 )
diff --git a/test/units/testsuite-23.utmp.sh b/test/units/testsuite-23.utmp.sh
new file mode 100755 (executable)
index 0000000..4f84315
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+set -eux
+set -o pipefail
+
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
+USER="test-23-utmp"
+
+cleanup() {
+    userdel "$USER"
+}
+
+trap cleanup EXIT
+useradd "$USER"
+
+assert_eq "$(systemd-run -qP -p UtmpIdentifier=test -p UtmpMode=user -p User=$USER whoami)" "$USER"
+assert_eq "$(systemd-run -qP -p UtmpIdentifier=test -p UtmpMode=user whoami)" "$(whoami)"