]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ci: add some basic testing of the new --pty and --pipe switches 34891/head
authorLennart Poettering <lennart@poettering.net>
Fri, 25 Oct 2024 07:29:38 +0000 (09:29 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 25 Oct 2024 12:14:26 +0000 (14:14 +0200)
test/units/TEST-74-AUX-UTILS.run.sh
test/units/util.sh

index 3ef9c88d7923c75f11ac6157dd58b1970e9a05ff..903ddde70efc31db15e4639b5014de8f997fc9dd 100755 (executable)
@@ -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
index 80ae8ffc5b5168d4e61e36c035463805dd95349f..51e0ad1ec0e322985a02c40cfdb8c8c495ce52d2 100755 (executable)
@@ -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