gdb/testsuite: Installed-GDB testing & data-directory
authorPedro Alves <pedro@palves.net>
Fri, 18 Mar 2022 12:39:55 +0000 (12:39 +0000)
committerPedro Alves <pedro@palves.net>
Mon, 21 Mar 2022 11:59:40 +0000 (11:59 +0000)
commit9170b70c41064a0ba197dc7e2d6ecb940d2272bb
treeab02120ef7e23e7ab53bcde1eebf427d7cf1ec3c
parenta58b0053f4c4b4f0089f3985a41d0deac4c59ea4
gdb/testsuite: Installed-GDB testing & data-directory

In testsuite/README, we suggest that you can run the testsuite against
some other GDB binary by using:

    make check RUNTESTFLAGS=GDB=/usr/bin/gdb

However, that example isn't fully correct, because with that command
line, the testsuite will still pass

  -data-directory=[pwd]/../data-directory

to /usr/bin/gdb, like e.g.:

  ...
  builtin_spawn /usr/bin/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory -iex set height 0 -iex set width 0
  ...

while if you're testing an installed GDB (the system GDB being the
most usual scenario), then you should normally let it use its own
configured directory, not the just-built GDB's data directory.

This commit improves the status quo with the following two changes:

 - if the user specifies GDB on the command line, then by default,
   don't start GDB with the -data-directory command line option.
   I.e., let the tested GDB use its own configured data directory.

 - let the user override the data directory, via a new
   GDB_DATA_DIRECTORY global.  This replaces the existing
   BUILD_DATA_DIRECTORY variable in testsuite/lib/gdb.exp, which
   wasn't overridable, and was a bit misnamed for the new purpose.

So after this, the following commands I believe behave intuitively:

 # Test the non-installed GDB in some build dir:

    make check \
      RUNTESTFLAGS="GDB=/path/to/other/build/gdb \
                    GDB_DATA_DIRECTORY=/path/to/other/build/gdb/data-directory"

 # Test the GDB installed in some prefix:

    make check \
      RUNTESTFLAGS="GDB=/opt/gdb/bin/gdb"

 # Test the built GDB with some alternative data directory, e.g., the
   system GDB's data directory:

    make check \
      RUNTESTFLAGS="GDB_DATA_DIRECTORY=/usr/share/gdb"

Change-Id: Icdc21c85219155d9564a9900961997e6624b78fb
gdb/testsuite/README
gdb/testsuite/lib/gdb.exp