TEST-74-AUX-UTILS: add tests for 'run0 -D'

This commit is contained in:
John A. Leuenhagen
2024-10-15 18:59:44 +09:00
committed by Yu Watanabe
parent 0054a2acc3
commit 4ca75488d9
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -211,6 +211,7 @@ BASICTOOLS=(
ping
pkill
ps
pwd
readlink
realpath
rev
+12
View File
@@ -246,4 +246,16 @@ if [[ -e /usr/lib/pam.d/systemd-run0 ]] || [[ -e /etc/pam.d/systemd-run0 ]]; the
# Let's chain a couple of run0 calls together, for fun
readarray -t cmdline < <(printf "%.0srun0\n" {0..31})
assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"
# Tests for working directory, especially for specifying "/" (see PR #34771).
cd /
assert_eq "$(run0 pwd)" "/"
assert_eq "$(run0 -D /tmp pwd)" "/tmp"
assert_eq "$(run0 --user=testuser pwd)" "/home/testuser"
assert_eq "$(run0 -D /tmp --user=testuser pwd)" "/tmp"
cd /tmp
assert_eq "$(run0 pwd)" "/tmp"
assert_eq "$(run0 -D / pwd)" "/"
assert_eq "$(run0 --user=testuser pwd)" "/home/testuser"
assert_eq "$(run0 -D / --user=testuser pwd)" "/"
fi