From: Frantisek Sumsal Date: Fri, 22 Dec 2023 13:09:58 +0000 (+0100) Subject: test: slightly extend uid0's coverage X-Git-Tag: v256-rc1~1406^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7de211891658a3f74c4afefdf4083d1ef3f10249;p=thirdparty%2Fsystemd.git test: slightly extend uid0's coverage --- diff --git a/test/units/testsuite-74.run.sh b/test/units/testsuite-74.run.sh index 1b4daf8bf48..69907d4f385 100755 --- a/test/units/testsuite-74.run.sh +++ b/test/units/testsuite-74.run.sh @@ -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"