public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb/testsuite: unset XDG_CONFIG_HOME
Date: Wed, 27 Jan 2021 13:27:45 +0000	[thread overview]
Message-ID: <20210127132745.4061609-1-andrew.burgess@embecosm.com> (raw)

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.
---
 gdb/testsuite/ChangeLog   | 4 ++++
 gdb/testsuite/lib/gdb.exp | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 2a952c6146f..53ac9f1408c 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
-- 
2.25.4


             reply	other threads:[~2021-01-27 13:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 13:27 Andrew Burgess [this message]
2021-01-27 20:51 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210127132745.4061609-1-andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).