From 6fb0c52295c21687a344d3ea8b076b64ebb43c95 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 25 Oct 2024 09:29:38 +0200 Subject: [PATCH] ci: add some basic testing of the new --pty and --pipe switches --- test/units/TEST-74-AUX-UTILS.run.sh | 10 ++++++++++ test/units/util.sh | 9 +++++++++ 2 files changed, 19 insertions(+) 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 -- 2.47.3