aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-01-27 10:31:47 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-01-28 10:05:33 +0000
commit47918cca26dac0c38196148ce09e0936c70c1bf5 (patch)
treee217a02d263b8a9f75ff17af50993a3b95c2cc56
parent24cf63899bf363c761c344a47dae037fbba8d643 (diff)
downloadgdb-47918cca26dac0c38196148ce09e0936c70c1bf5.zip
gdb-47918cca26dac0c38196148ce09e0936c70c1bf5.tar.gz
gdb-47918cca26dac0c38196148ce09e0936c70c1bf5.tar.bz2
gdb/testsuite: unset XDG_CONFIG_HOME
Since this commit: commit 64aaad6349d2b2c45063a5383f877ce9a3a0c354 Date: Fri Sep 25 14:50:56 2020 +0100 gdb: use get_standard_config_dir when looking for .gdbinit GDB has been checking for ${XDG_CONFIG_HOME}/gdb/gdbinit on startup. Most tests pass -nx to GDB to block loading of gdbinit files, but there are a few tests (e.g. gdb.base/gdbinit-history.exp) that don't use -nx and instead setup a fake HOME directory containing a gdbinit file. However, since the above commit, if XDG_CONFIG_HOME is set then once -nx is no longer being passed GDB will load any gdbinit file it finds in that directory, which could cause the test to fail. As a concrete example: $ mkdir -p fake_xdg_config_home/gdb/ $ cat <<EOF >fake_xdg_config_home/gdb/gdbinit echo goodbye\n quit EOF $ export XDG_CONFIG_HOME=$PWD/fake_xdg_config_home $ make check-gdb TESTS="gdb.base/gdbinit-history.exp" Should result in the test failing. The solution I propose is to unset XDG_CONFIG_HOME in default_gdb_init, we already unset a bunch of environment variables in this proc. gdb/testsuite/ChangeLog: * lib/gdb.exp (default_gdb_init): Unset XDG_CONFIG_HOME.
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/lib/gdb.exp7
2 files changed, 11 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ddb8f8b..b752e6d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * lib/gdb.exp (default_gdb_init): Unset XDG_CONFIG_HOME.
+
2021-01-28 Tom de Vries <tdevries@suse.de>
* gdb.ada/out_of_line_in_inlined.exp: Use gdb_breakpoint.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 2a952c6..53ac9f1 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5241,6 +5241,13 @@ proc default_gdb_init { test_file_name } {
unset -nocomplain ::env(GDBHISTFILE)
unset -nocomplain ::env(GDBHISTSIZE)
+ # Ensure that XDG_CONFIG_HOME is not set. Some tests setup a fake
+ # home directory in order to test loading settings from gdbinit.
+ # If XDG_CONFIG_HOME is set then GDB will load a gdbinit from
+ # there (if one is present) rather than the home directory setup
+ # in the test.
+ unset -nocomplain ::env(XDG_CONFIG_HOME)
+
# Initialize GDB's pty with a fixed size, to make sure we avoid pagination
# during startup. See "man expect" for details about stty_init.
global stty_init