test: slightly extend uid0's coverage

This commit is contained in:
Frantisek Sumsal
2023-12-22 14:09:58 +01:00
parent a6fb61be77
commit 7de2118916

View File

@@ -230,6 +230,15 @@ assert_eq "$A" "$B"
# Check that invoking the tool under the uid0 alias name works
uid0 ls /
assert_eq "$(uid0 echo foo)" "foo"
# Check if we set some expected environment variables
for arg in "" "--user=root" "--user=testuser"; do
assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_USER')" "$USER"
assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_UID')" "$(id -u "$USER")"
assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_GID')" "$(id -u "$USER")"
done
# Let's chain a couple of uid0 calls together, for fun
readarray -t cmdline < <(printf "%.0suid0\n" {0..31})
assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"
umount /proc/version
rm "$V"