From: Lennart Poettering Date: Fri, 25 Oct 2024 07:29:38 +0000 (+0200) Subject: ci: add some basic testing of the new --pty and --pipe switches X-Git-Tag: v257-rc1~141^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F34891%2Fhead;p=thirdparty%2Fsystemd.git ci: add some basic testing of the new --pty and --pipe switches --- diff --git a/test/units/TEST-74-AUX-UTILS.run.sh b/test/units/TEST-74-AUX-UTILS.run.sh index 3ef9c88d792..903ddde70ef 100755 --- a/test/units/TEST-74-AUX-UTILS.run.sh +++ b/test/units/TEST-74-AUX-UTILS.run.sh @@ -261,4 +261,14 @@ if [[ -e /usr/lib/pam.d/systemd-run0 ]] || [[ -e /etc/pam.d/systemd-run0 ]]; the assert_eq "$(run0 -D / pwd)" "/" assert_eq "$(run0 --user=testuser pwd)" "/home/testuser" assert_eq "$(run0 -D / --user=testuser pwd)" "/" + + # Verify that all combinations of --pty/--pipe come to the sam results + assert_eq "$(run0 echo -n foo)" "foo" + assert_eq "$(run0 --pty echo -n foo)" "foo" + assert_eq "$(run0 --pipe echo -n foo)" "foo" + assert_eq "$(run0 --pipe --pty echo -n foo)" "foo" + + # Validate when we invoke run0 without a tty, that depending on --pty it either allocates a tty or not + assert_neq "$(run0 --pty tty < /dev/null)" "not a tty" + assert_eq "$(run0 --pipe tty < /dev/null)" "not a tty" fi diff --git a/test/units/util.sh b/test/units/util.sh index 80ae8ffc5b5..51e0ad1ec0e 100755 --- a/test/units/util.sh +++ b/test/units/util.sh @@ -39,6 +39,15 @@ assert_eq() {( fi )} +assert_neq() {( + set +ex + + if [[ "${1?}" = "${2?}" ]]; then + echo "FAIL: not expected: '$2' actual: '$1'" >&2 + exit 1 + fi +)} + assert_le() {( set +ex