binutils-gdb/gdb/testsuite/boards
Tom de Vries a02a90c114 [gdb/testsuite] Set sysroot earlier in local-board.exp
When running test-case gdb.base/batch-exit-status.exp for native, it passes.
But with target board cc-with-debug-names, we run into (added missing double
quotes for clarity):
...
builtin_spawn $build/gdb/testsuite/../../gdb/gdb -nw -nx \
  -data-directory $build/gdb/testsuite/../data-directory \
  -iex "set height 0" -iex "set width 0" -ex "set sysroot" -batch ""^M
: No such file or directory.^M
PASS: gdb.base/batch-exit-status.exp: \
  : No such file or directory\.: [lindex $result 2] == 0
FAIL: gdb.base/batch-exit-status.exp: \
  : No such file or directory\.: [lindex $result 3] == $expect_status
...

The difference between the passing and failing case is that with native we
have (leaving out set height/width for brevity):
...
$ gdb -batch ""; echo $?
: No such file or directory.
1
...
and with target board cc-with-debug-names:
...
$ gdb -ex "set sysroot" -batch ""; echo $?
: No such file or directory.
0
...

The difference is expected.  GDB returns the exit status of the last executed
command.  In the former case that's 'file ""', which fails.  In the latter case,
that's 'set sysroot', which succeeds.

Fix this by setting sysroot using -iex instead of -ex in local-board.exp, such
that we have the expected:
...
$ gdb -iex "set sysroot" -batch ""; echo $?
: No such file or directory.
1
...

Tested on x86_64-linux.
2021-09-12 11:30:06 +02:00
..
cc-with-debug-names.exp
cc-with-dwz-m.exp
cc-with-dwz.exp
cc-with-gdb-index.exp
cc-with-gnu-debuglink.exp [gdb/testsuite] Add target board cc-with-gnu-debuglink.exp 2021-05-21 18:11:12 +02:00
cc-with-tweaks.exp
debug-types.exp
dwarf4-gdb-index.exp
fission-dwp.exp
fission.exp
gdbserver-base.exp
gold-gdb-index.exp
gold.exp
local-board.exp [gdb/testsuite] Set sysroot earlier in local-board.exp 2021-09-12 11:30:06 +02:00
local-remote-host-native.exp
local-remote-host-notty.exp
local-remote-host.exp
native-extended-gdbserver.exp
native-gdbserver.exp
native-stdio-gdbserver.exp
readnow.exp
remote-gdbserver-on-localhost.exp
remote-stdio-gdbserver.exp
simavr.exp
stabs.exp
stdio-gdbserver-base.exp