]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test case for fdstore dumping logic, and systemd-notify --fd=
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Mar 2023 16:28:15 +0000 (18:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 29 Mar 2023 17:09:10 +0000 (19:09 +0200)
test/units/testsuite-80.sh

index 43647a707ff4a57060ab5d2cf66eba8395320e4f..0072133cd4e1ca4adc274aea26fe9c1dca86a92f 100755 (executable)
@@ -48,5 +48,32 @@ assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "all"
 
 rm /tmp/syncfifo1 /tmp/syncfifo2
 
+MYSCRIPT="/tmp/myscript$RANDOM.sh"
+cat >> "$MYSCRIPT" <<'EOF'
+#!/usr/bin/env bash
+set -eux
+set -o pipefail
+N="/tmp/$RANDOM"
+echo $RANDOM > "$N"
+systemd-notify --fd=4 --fdname=quux --pid=parent 4< "$N"
+rm "$N"
+systemd-notify --ready
+exec sleep infinity
+EOF
+
+chmod +x "$MYSCRIPT"
+
+MYUNIT="myunit$RANDOM.service"
+systemd-run -u "$MYUNIT" -p Type=notify -p StandardOutput=journal+console -p StandardError=journal+console -p FileDescriptorStoreMax=7 "$MYSCRIPT"
+
+test "$(systemd-analyze fdstore "$MYUNIT" | wc -l)" -eq 2
+systemd-analyze fdstore "$MYUNIT" --json=short
+systemd-analyze fdstore "$MYUNIT" --json=short | grep -P -q '\[{"fdname":"quux","type":.*,"devno":\[.*\],"inode":.*,"rdevno":null,"path":"/tmp/.*","flags":"ro"}\]'
+
+systemctl stop "$MYUNIT"
+rm "$MYSCRIPT"
+
 touch /testok
 rm /failed
+
+exit 0