Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [pushed 0/3] [gdb/testsuite] Add some tui test-cases
@ 2026-10-16 15:28 Tom de Vries
  2026-10-16 15:28 ` [pushed 1/3] [gdb/testsuite] Handle non-existing testfile in find_core_file Tom de Vries
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom de Vries @ 2026-10-16 15:28 UTC (permalink / raw)
  To: gdb-patches

I came across commit a4f8f290270 ("gdb/tui: disable tui mode when an assert
triggers"), and noticed that there are no test-cases that exercise this
scenario.

This series contains three patches.

The last two each add one such test-case.  I've confirmed that the test-cases
fail if commit a4f8f290270 is reverted.

The first is a trivial fix in proc find_core_file, that is required for the
second patch.

Tested on x86_64-linux.

Tom de Vries (3):
  [gdb/testsuite] Handle non-existing testfile in find_core_file
  [gdb/testsuite] Add gdb.tui/fatal.exp
  [gdb/testsuite] Add gdb.tui/internal-error.exp

 gdb/testsuite/gdb.tui/fatal.exp          | 71 ++++++++++++++++++++++++
 gdb/testsuite/gdb.tui/internal-error.exp | 59 ++++++++++++++++++++
 gdb/testsuite/lib/gdb.exp                |  4 +-
 3 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.tui/fatal.exp
 create mode 100644 gdb/testsuite/gdb.tui/internal-error.exp


base-commit: d5482742b2e597b2db086b0588a90feb22d10f68
-- 
2.51.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pushed 1/3] [gdb/testsuite] Handle non-existing testfile in find_core_file
  2026-10-16 15:28 [pushed 0/3] [gdb/testsuite] Add some tui test-cases Tom de Vries
@ 2026-10-16 15:28 ` Tom de Vries
  2026-10-16 15:28 ` [pushed 2/3] [gdb/testsuite] Add gdb.tui/fatal.exp Tom de Vries
  2026-10-16 15:28 ` [pushed 3/3] [gdb/testsuite] Add gdb.tui/internal-error.exp Tom de Vries
  2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-10-16 15:28 UTC (permalink / raw)
  To: gdb-patches

Proc find_core_file assumes that variable testfile exists.

The variable doesn't exist when not using standard_testfile.

Fix this by checking if it exists in find_core_file.
---
 gdb/testsuite/lib/gdb.exp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a77063b0bf0..dca32750fbf 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -10303,7 +10303,9 @@ proc find_core_file {pid} {
     } elseif {$pid != -1} {
 	lappend files core.$pid
     }
-    lappend files ${::testfile}.core
+    if {[info exists ::testfile]} {
+	lappend files ${::testfile}.core
+    }
     lappend files core
 
     foreach file $files {
-- 
2.51.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pushed 2/3] [gdb/testsuite] Add gdb.tui/fatal.exp
  2026-10-16 15:28 [pushed 0/3] [gdb/testsuite] Add some tui test-cases Tom de Vries
  2026-10-16 15:28 ` [pushed 1/3] [gdb/testsuite] Handle non-existing testfile in find_core_file Tom de Vries
@ 2026-10-16 15:28 ` Tom de Vries
  2026-10-16 15:28 ` [pushed 3/3] [gdb/testsuite] Add gdb.tui/internal-error.exp Tom de Vries
  2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-10-16 15:28 UTC (permalink / raw)
  To: gdb-patches

Add test-case gdb.tui/fatal.exp, a test-case for the handle_fatal_signal part
of commit a4f8f290270 ("gdb/tui: disable tui mode when an assert triggers").
---
 gdb/testsuite/gdb.tui/fatal.exp | 71 +++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 gdb/testsuite/gdb.tui/fatal.exp

diff --git a/gdb/testsuite/gdb.tui/fatal.exp b/gdb/testsuite/gdb.tui/fatal.exp
new file mode 100644
index 00000000000..3caf55ec4c3
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/fatal.exp
@@ -0,0 +1,71 @@
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check handling of abort in TUI.
+
+tuiterm_env
+require allow_tui_tests
+
+# This test-case produces a core file.  Let's not do that remotely.
+require {!isremote host}
+
+# Check that we're able to use SIGABRT.
+require {remote_kill_spawn_id_p host SIGABRT}
+
+Term::clean_restart 24 80
+
+set have_backtrace_on_fatal_signal 0
+gdb_test_multiple "maint set backtrace-on-fatal-signal on" "" {
+    -re -wrap "support for this feature is not compiled into GDB" {
+    }
+    -re -wrap "^" {
+	set have_backtrace_on_fatal_signal 1
+    }
+}
+require {expr {$have_backtrace_on_fatal_signal}}
+
+# Get the GDB core into the output directory, so that it
+# doesn't count as unexpected core in gdb.sum.
+set dir [standard_output_file ""]
+gdb_test "cd $dir" "Working directory .*" \
+    "cd to test directory"
+
+require Term::enter_tui
+
+set gdb_pid [exp_pid -i $::gdb_spawn_id]
+
+kill_gdb SIGABRT
+
+set re_msg_line \
+    [string_to_regexp \
+	 "This is a bug, please report it."]
+set re_msg \
+    [multi_line \
+	 "" \
+	 $re_msg_line]
+gdb_assert \
+    {[Term::wait_for_region_contents 0 0 80 24 $re_msg]} \
+    "saw message"
+
+set seen_eof 0
+gdb_expect {
+    eof {
+	set seen_eof 1
+	remove_core $gdb_pid
+	gdb_exit_cleanup
+    }
+}
+
+gdb_assert {$seen_eof} "aborted"
-- 
2.51.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pushed 3/3] [gdb/testsuite] Add gdb.tui/internal-error.exp
  2026-10-16 15:28 [pushed 0/3] [gdb/testsuite] Add some tui test-cases Tom de Vries
  2026-10-16 15:28 ` [pushed 1/3] [gdb/testsuite] Handle non-existing testfile in find_core_file Tom de Vries
  2026-10-16 15:28 ` [pushed 2/3] [gdb/testsuite] Add gdb.tui/fatal.exp Tom de Vries
@ 2026-10-16 15:28 ` Tom de Vries
  2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-10-16 15:28 UTC (permalink / raw)
  To: gdb-patches

Add test-case gdb.tui/internal-error.exp, a test-case for the
internal_vproblem part of commit a4f8f290270 ("gdb/tui: disable tui mode when
an assert triggers").
---
 gdb/testsuite/gdb.tui/internal-error.exp | 59 ++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 gdb/testsuite/gdb.tui/internal-error.exp

diff --git a/gdb/testsuite/gdb.tui/internal-error.exp b/gdb/testsuite/gdb.tui/internal-error.exp
new file mode 100644
index 00000000000..5d827f7adaa
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/internal-error.exp
@@ -0,0 +1,59 @@
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check handling of internal-error in TUI.
+
+tuiterm_env
+
+require allow_tui_tests
+
+foreach_with_prefix quit {yes no} {
+    Term::clean_restart 24 80
+
+    gdb_test_no_output "maint set internal-error corefile no"
+    gdb_test_no_output "maint set internal-error quit $quit"
+
+    require Term::enter_tui
+
+    send_gdb "maint internal-error\n"
+    set re_msg_line \
+	[string_to_regexp \
+	     "This is a bug, please report it."]
+    set re_msg \
+	[multi_line \
+	     "" \
+	     $re_msg_line]
+    gdb_assert \
+	{[Term::wait_for_region_contents 0 0 80 24 $re_msg]} \
+	"saw message"
+
+    if {$quit == "yes"} {
+	set seen_eof 0
+	gdb_expect {
+	    eof {
+		set seen_eof 1
+		gdb_exit_cleanup
+	    }
+	}
+
+	gdb_assert {$seen_eof} "exited"
+    } else {
+	gdb_assert {[Term::wait_for ""]} "got prompt"
+	gdb_assert {[Term::command "print 1"]} "responsive prompt"
+	send_gdb "info win\n"
+	set re_no_tui [string_to_regexp "The TUI is not active."]
+	gdb_assert {[Term::wait_for $re_no_tui]} "TUI disabled"
+    }
+}
-- 
2.51.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-16 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 15:28 [pushed 0/3] [gdb/testsuite] Add some tui test-cases Tom de Vries
2026-10-16 15:28 ` [pushed 1/3] [gdb/testsuite] Handle non-existing testfile in find_core_file Tom de Vries
2026-10-16 15:28 ` [pushed 2/3] [gdb/testsuite] Add gdb.tui/fatal.exp Tom de Vries
2026-10-16 15:28 ` [pushed 3/3] [gdb/testsuite] Add gdb.tui/internal-error.exp Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox