Skip to content

Commit 241b88f

Browse files
committed
tests: prevent unexpected message combining
If the qrexec daemon is slow enough, it is possible for the standard output of the service to be sent as one message instead of two. Prevent this by waiting for the first message to be received before sending the service's standard input. This also requires that the test service be changed to read its input after producing the output from the wait-for-session script.
1 parent 223361b commit 241b88f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

qrexec/tests/socket/daemon.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,10 @@ def test_run_dom0_service_wait_for_session(self):
759759
"rpc",
760760
"qubes.Service",
761761
"""\
762-
#!/bin/sh
763-
read input
764-
cat {}
765-
echo "arg: $1, remote domain: $QREXEC_REMOTE_DOMAIN, input: $input"
762+
#!/bin/sh
763+
cat {}
764+
read input
765+
echo "arg: $1, remote domain: $QREXEC_REMOTE_DOMAIN, input: $input"
766766
""".format(
767767
log
768768
),
@@ -774,16 +774,16 @@ def test_run_dom0_service_wait_for_session(self):
774774

775775
cmd = "QUBESRPC qubes.Service+arg src_domain name src_domain"
776776
source = self.connect_service_request(cmd)
777+
self.assertEqual(source.recv_message(), (
778+
qrexec.MSG_DATA_STDOUT,
779+
b"wait for session: remote domain: src_domain\n",
780+
))
777781

778782
source.send_message(qrexec.MSG_DATA_STDIN, b"stdin data\n")
779783
source.send_message(qrexec.MSG_DATA_STDIN, b"")
780784
self.assertEqual(
781785
source.recv_all_messages(),
782786
[
783-
(
784-
qrexec.MSG_DATA_STDOUT,
785-
b"wait for session: remote domain: src_domain\n",
786-
),
787787
(
788788
qrexec.MSG_DATA_STDOUT,
789789
b"arg: arg, remote domain: src_domain, "

0 commit comments

Comments
 (0)