1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

testsuite-77: Fix race condition

Use a socket unit to make sure the socket exists before we start
the client that accesses it.
This commit is contained in:
Daan De Meyer 2023-01-18 16:31:35 +01:00 committed by Luca Boccassi
parent 41d125614c
commit 78d774bab4
7 changed files with 18 additions and 22 deletions

View File

@ -1,7 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-77-OPENFILE
[Service]
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=simple

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
echo "Socket" | nc -lkU /tmp/test.sock

View File

@ -0,0 +1,6 @@
[Unit]
Description=TEST-77-OPENFILE server socket
[Socket]
ListenStream=/tmp/test.sock
Accept=yes

View File

@ -0,0 +1,7 @@
[Unit]
Description=TEST-77-OPENFILE server
[Service]
ExecStart=echo "Socket"
StandardInput=socket
StandardOutput=socket

View File

@ -1,9 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-77-OPENFILE
[Service]
OpenFile=/tmp/test.sock:socket:read-only
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View File

@ -16,8 +16,11 @@ read -r -u 4 text
assert_eq "$text" "File"
# Test for socket
systemctl start testsuite-77-netcat.service
systemctl start testsuite-77-socket.service
systemctl start testsuite-77-server.socket
systemd-run -p OpenFile=/tmp/test.sock:socket:read-only \
--wait \
--pipe \
/usr/lib/systemd/tests/testdata/units/testsuite-77-client.sh
# Tests for D-Bus
diff <(systemctl show -p OpenFile testsuite-77) - <<EOF