[PATCH v2 08/16] Make inferior/GDB share terminal in tests that exercise GDB/inferior reading same input

Pedro Alves pedro@palves.net
Mon Jun 14 21:24:02 GMT 2021


Some testcases exercise some aspect that only makes sense when GDB and
the inferior are sharing the same terminal, meaning GDB and the
inferior are reading from the same input file.

This commit makes sure that continues to be tested even after GDB
changed to put inferiors in their own session/terminal by default, by
issuing "tty /dev/tty".  The tests would fail otherwise.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

	* gdb.base/annota-input-while-running.exp: Issue "tty /dev/tty"
	before starting program.
	* gdb.base/continue-all-already-running.exp: Likewise.
	* gdb.base/infcall-input.exp: Likewise.

Change-Id: Ia5f9061bf28a5e780194aa75b37b6058de0614ee
---
 .../gdb.base/annota-input-while-running.exp          |  4 ++++
 .../gdb.base/continue-all-already-running.exp        |  3 +++
 gdb/testsuite/gdb.base/infcall-input.exp             | 12 +++++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/annota-input-while-running.exp b/gdb/testsuite/gdb.base/annota-input-while-running.exp
index 389cb644517..912565806e8 100644
--- a/gdb/testsuite/gdb.base/annota-input-while-running.exp
+++ b/gdb/testsuite/gdb.base/annota-input-while-running.exp
@@ -22,6 +22,10 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug] == -1} {
     return -1
 }
 
+# This testcase only makes sense when GDB and the inferior are reading
+# from the same input file (aka sharing the terminal's input buffer).
+gdb_test_no_output "tty /dev/tty"
+
 # Because runto_main doesn't know how to handle the prompt with annotations,
 # run to main before we set the annotation level.
 if ![runto_main] then {
diff --git a/gdb/testsuite/gdb.base/continue-all-already-running.exp b/gdb/testsuite/gdb.base/continue-all-already-running.exp
index de84897c766..caff93ab425 100644
--- a/gdb/testsuite/gdb.base/continue-all-already-running.exp
+++ b/gdb/testsuite/gdb.base/continue-all-already-running.exp
@@ -20,6 +20,9 @@ standard_testfile
 
 save_vars { GDBFLAGS } {
     set GDBFLAGS "$GDBFLAGS -ex \"set non-stop on\""
+    # This test only makes sense when GDB and the inferior are reading
+    # from the same input file / sharing the terminal.
+    append GDBFLAGS " -ex \"tty /dev/tty\""
     if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } {
 	return -1
     }
diff --git a/gdb/testsuite/gdb.base/infcall-input.exp b/gdb/testsuite/gdb.base/infcall-input.exp
index fec0eb2a4d8..87bd049e139 100644
--- a/gdb/testsuite/gdb.base/infcall-input.exp
+++ b/gdb/testsuite/gdb.base/infcall-input.exp
@@ -23,10 +23,20 @@ if [target_info exists gdb,cannot_call_functions] {
     continue
 }
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
+if {[build_executable "failed to compile" $testfile $srcfile debug]} {
     return -1
 }
 
+save_vars { GDBFLAGS } {
+    # This test only makes sense when GDB and the inferior are reading
+    # from the same input file / sharing the terminal.  If we instead
+    # let GDB put the inferior in its own session, then while the
+    # inferior is running in the foreground, input would be redirected
+    # to the inferior, and GDB would never see that input.
+    append GDBFLAGS " -ex \"tty /dev/tty\""
+    clean_restart $binfile
+}
+
 if ![runto_main] then {
     fail "couldn't run to main"
     return -1
-- 
2.26.2



More information about the Gdb-patches mailing list