b961095
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
b961095
b961095
Jan Kratochvil 22d1e60
Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.base/readline-overflow.exp
b961095
===================================================================
Jan Kratochvil 22d1e60
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 22d1e60
+++ gdb-7.10.90.20160211/gdb/testsuite/gdb.base/readline-overflow.exp	2016-02-15 23:30:29.191677414 +0100
Jan Kratochvil 22d1e60
@@ -0,0 +1,126 @@
b961095
+# Copyright 2006 Free Software Foundation, Inc.
b961095
+
b961095
+# This program is free software; you can redistribute it and/or modify
b961095
+# it under the terms of the GNU General Public License as published by
b961095
+# the Free Software Foundation; either version 2 of the License, or
b961095
+# (at your option) any later version.
b961095
+# 
b961095
+# This program is distributed in the hope that it will be useful,
b961095
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b961095
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b961095
+# GNU General Public License for more details.
b961095
+# 
b961095
+# You should have received a copy of the GNU General Public License
b961095
+# along with this program; if not, write to the Free Software
b961095
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
b961095
+
b961095
+# Please email any bugs, comments, and/or additions to this file to:
b961095
+# bug-gdb@prep.ai.mit.edu
b961095
+
b961095
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>
b961095
+
b961095
+# This file is part of the gdb testsuite.
b961095
+
b961095
+#
b961095
+# Tests for readline buffer overflow.
b961095
+#
b961095
+
b961095
+if $tracelevel {
b961095
+  strace $tracelevel
b961095
+}
b961095
+
b961095
+# Don't let a .inputrc file or an existing setting of INPUTRC mess up
b961095
+# the test results.  Even if /dev/null doesn't exist on the particular
b961095
+# platform, the readline library will use the default setting just by
b961095
+# failing to open the file.  OTOH, opening /dev/null successfully will
b961095
+# also result in the default settings being used since nothing will be
b961095
+# read from this file.
b961095
+global env
b961095
+if [info exists env(INPUTRC)] {
b961095
+    set old_inputrc $env(INPUTRC)
b961095
+}
b961095
+set env(INPUTRC) "/dev/null"
b961095
+
b961095
+set oldtimeout1 $timeout
b961095
+set timeout 600
b961095
+
b961095
+if [info exists env(GDBHISTFILE)] {
b961095
+    set old_gdbhistfile $env(GDBHISTFILE)
b961095
+}
b961095
+if [info exists env(HISTSIZE)] {
b961095
+    set old_histsize $env(HISTSIZE)
b961095
+}
b961095
+set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
b961095
+set env(HISTSIZE) "10"
b961095
+
b961095
+gdb_exit
b961095
+gdb_start
b961095
+gdb_reinitialize_dir $srcdir/$subdir
b961095
+
b961095
+
b961095
+set width 11
b961095
+gdb_test "set width $width" \
b961095
+         "" \
b961095
+         "Setting width to $width."
b961095
+#gdb_test "set height 1" \
b961095
+#         "" \
b961095
+#         "Setting height to 1."
b961095
+send_gdb "run X"
b961095
+set i 0
b961095
+# It crashes using `set width 7' on `set total 3560'.
b961095
+# Sometimes it corrupts screen on `set width 7'.
b961095
+# Bugreport used `set total 130001':
b961095
+# 	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
b961095
+# Check also `timeout' above.
b961095
+set total 4200
b961095
+gdb_expect {
b961095
+	-re X {
b961095
+		incr i
b961095
+		if {$i <= $total} {
b961095
+			send_gdb "X"
b961095
+			exp_continue
b961095
+		}
b961095
+	}
b961095
+	-re "\[ \b\r\n\]" {
b961095
+		exp_continue
b961095
+	}
b961095
+	eof {
b961095
+		fail "gdb sending total $total characters"
b961095
+		note "Failed after sending $i characters, reason: EOF"
b961095
+		gdb_clear_suppressed
b961095
+	}
b961095
+	timeout {
b961095
+		fail "gdb sending total $total characters"
b961095
+		note "Failed after sending $i characters (timeout $timeout), reason: TIMEOUT"
b961095
+		gdb_clear_suppressed
b961095
+	}
b961095
+	default {
b961095
+		fail "gdb sending total $total characters"
b961095
+		note "Failed after sending $i characters, reason: 0=\[$expect_out(0,string)\] buffer=\[$expect_out(buffer)\]"
b961095
+		gdb_clear_suppressed
b961095
+	}
b961095
+}
Jan Kratochvil 22d1e60
+send_gdb "\r"
Jan Kratochvil 22d1e60
+gdb_test "" \
b961095
+         "No executable file specified..*" \
b961095
+         "All the characters transferred"
b961095
+
b961095
+
b961095
+# Restore globals modified in this test...
b961095
+if [info exists old_inputrc] {
b961095
+    set env(INPUTRC) $old_inputrc
b961095
+} else {
b961095
+    unset env(INPUTRC)
b961095
+}
b961095
+if [info exists old_gdbhistfile] {
b961095
+    set env(GDBHISTFILE) $old_gdbhistfile
b961095
+} else {
b961095
+    unset env(GDBHISTFILE)
b961095
+}
b961095
+if [info exists old_histsize] {
b961095
+    set env(HISTSIZE) $old_histsize
b961095
+} else {
b961095
+    unset env(HISTSIZE)
b961095
+}
b961095
+set timeout $oldtimeout1
b961095
+