This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix gdb.base/gdbinit-history.exp when HISTSIZE is set in the environment


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=84204ed7c0ccaa790dff8e124e710277d9a8abc9

commit 84204ed7c0ccaa790dff8e124e710277d9a8abc9
Author: Pedro Alves <palves@redhat.com>
Date:   Tue May 19 10:47:27 2015 +0100

    Fix gdb.base/gdbinit-history.exp when HISTSIZE is set in the environment
    
    Some buildslaves are showing that this test is failing.  E.g.,:
    
     https://sourceware.org/ml/gdb-testers/2015-q2/msg04164.html
    
    The issue is that HISTSIZE is set to 1000 in the environment that runs
    the tests (that's the default in Fedora, set in /etc/profile).
    
    We can trivially reproduce it with:
    
     $ HISTSIZE=1000 make check RUNTESTFLAGS="gdbinit-history.exp"
     (...)
     Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/gdbinit-history.exp ...
     FAIL: gdb.base/gdbinit-history.exp: show history size
     FAIL: gdb.base/gdbinit-history.exp: show history size
     FAIL: gdb.base/gdbinit-history.exp: show commands
    
    gdb.log shows:
     ...
     (gdb) set height 0
     (gdb) set width 0
     (gdb) show history size
     The size of the command history is 1000.
     (gdb) FAIL: gdb.base/gdbinit-history.exp: show history size
    
    gdb/testsuite/ChangeLog:
    2015-05-19  Pedro Alves  <palves@redhat.com>
    
    	* gdb.base/gdbinit-history.exp (test_gdbinit_history_setting):
    	Save the whole env array instead of just HOME.  Unset HISTSIZE in
    	the environment while testing.  Restore whole environment
    	afterwards.

Diff:
---
 gdb/testsuite/ChangeLog                    |  7 +++++++
 gdb/testsuite/gdb.base/gdbinit-history.exp | 12 ++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9b446af..a74ac52 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-19  Pedro Alves  <palves@redhat.com>
+
+	* gdb.base/gdbinit-history.exp (test_gdbinit_history_setting):
+	Save the whole env array instead of just HOME.  Unset HISTSIZE in
+	the environment while testing.  Restore whole environment
+	afterwards.
+
 2015-05-16  Doug Evans  <xdje42@gmail.com>
 
 	* gdb.guile/scm-ports.c: New file.
diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp
index 474680a..aba15b4 100644
--- a/gdb/testsuite/gdb.base/gdbinit-history.exp
+++ b/gdb/testsuite/gdb.base/gdbinit-history.exp
@@ -27,8 +27,15 @@ proc test_gdbinit_history_setting { home size } {
     global srcdir
     global subdir
 
-    set old_home $env(HOME)
+    array set old_env [array get env]
+
     set env(HOME) "$srcdir/$subdir/$home"
+
+    # The HISTSIZE environment variable takes precedence over whatever
+    # history size is set in .gdbinit.  Make sure the former is not
+    # set.
+    unset -nocomplain env(HISTSIZE)
+
     set saved_internal_gdbflags $INTERNAL_GDBFLAGS
     set INTERNAL_GDBFLAGS [string map {"-nx" ""} $INTERNAL_GDBFLAGS]
 
@@ -44,7 +51,8 @@ proc test_gdbinit_history_setting { home size } {
     }
 
     set INTERNAL_GDBFLAGS $saved_internal_gdbflags
-    set $env(HOME) $old_home
+
+    array set env [array get old_env]
 }
 
 test_gdbinit_history_setting "gdbinit-history/unlimited" "unlimited"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]