[Lldb-commits] [lldb] [lldb][windows] do not use ConPTY in tests (PR #192657)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Sat Apr 18 06:19:39 PDT 2026
================
@@ -0,0 +1,77 @@
+"""
+Tests for Windows ConPTY (Pseudo Console) process I/O.
+
+These tests explicitly exercise the ConPTY path by clearing
+LLDB_LAUNCH_FLAG_USE_PIPES, which the test suite sets globally to avoid
+ConPTY VT-sequence pollution in unrelated tests.
+"""
+
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+# Must match main.c.
+_NUM_LINES = 500
+
+
+class ConPTYTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ TestBase.setUp(self)
+ # Clear LLDB_LAUNCH_FLAG_USE_PIPES so LLDB uses ConPTY instead of
+ # anonymous pipes. Restored in tearDown.
+ self._saved_pipes_flag = os.environ.pop("LLDB_LAUNCH_FLAG_USE_PIPES", None)
+
+ def tearDown(self):
+ if self._saved_pipes_flag is not None:
+ os.environ["LLDB_LAUNCH_FLAG_USE_PIPES"] = self._saved_pipes_flag
+ TestBase.tearDown(self)
+
+ def _run_to_exit(self, mode):
+ """Build, launch with *mode* as argv[1], run to exit, return stdout."""
+ self.build()
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ process = target.LaunchSimple(
+ [mode], None, self.get_process_working_directory()
+ )
+ self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
+
+ self.assertState(process.GetState(), lldb.eStateExited)
----------------
charles-zablit wrote:
I added `self.dbg.SetAsync(False)` to make sure that we are in synchronous mode.
I also tested adding a 2s `sleep` in the test target to slow down the debuggee on purpose. It does not seem to race.
https://github.com/llvm/llvm-project/pull/192657
More information about the lldb-commits
mailing list