[Lldb-commits] [lldb] d4083a2 - [lldb] Fix flakyness in TestQemuLaunch.test_stdio_redirect
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 7 05:19:56 PST 2021
Author: Pavel Labath
Date: 2021-12-07T14:19:44+01:00
New Revision: d4083a296ac828440604574e7a9fac70ede96d66
URL: https://github.com/llvm/llvm-project/commit/d4083a296ac828440604574e7a9fac70ede96d66
DIFF: https://github.com/llvm/llvm-project/commit/d4083a296ac828440604574e7a9fac70ede96d66.diff
LOG: [lldb] Fix flakyness in TestQemuLaunch.test_stdio_redirect
The test was flaky because it was trying to read from the (redirected)
stdout file before the data was been flushed to it. This would not be a
problem for a "normal" debug session, but since here the emulator and
the target binary coexist in the same process (and this is true both for
real qemu and our fake implementation), there
is a window of time between the stub returning an exit packet (which is
the event that the test is waiting for) and the process really exiting
(which is when the normal flushing happens).
This patch adds an explicit flush to work around this. Theoretically,
it's possible that real code could run into this issue as well, but such
a use case is not very likely. If we wanted to fix this for real, we
could add some code which waits for the host process to terminate (in
addition to receiving the termination packet), but this is somewhat
complicated by the fact that this code lives in the gdb-remote process
plugin.
Added:
Modified:
lldb/test/API/qemu/qemu.py
Removed:
################################################################################
diff --git a/lldb/test/API/qemu/qemu.py b/lldb/test/API/qemu/qemu.py
index eca85f8ac99b9..4b94c7689657e 100755
--- a/lldb/test/API/qemu/qemu.py
+++ b/lldb/test/API/qemu/qemu.py
@@ -35,8 +35,10 @@ def cont(self):
json.dump(self._state, f)
elif action == "stdout":
sys.stdout.write(data)
+ sys.stdout.flush()
elif action == "stderr":
sys.stderr.write(data)
+ sys.stderr.flush()
elif action == "stdin":
self._state[data] = sys.stdin.readline()
else:
More information about the lldb-commits
mailing list