[gdb/testsuite] Prepare nodebug exec in gdb.base/cvexpr.exp

When running test-case gdb.base/cvexpr.exp with target board unix/-bad, I get:
...
gdb compile failed, gcc: error: unrecognized command line option '-bad'
ERROR: tcl error sourcing src/gdb/testsuite/gdb.base/cvexpr.exp.
ERROR: can't read "use_gdb_stub": no such variable
...

This is triggered in a part of the test that claims to require no debug
information, but uses the exec containing either dwarf or ctf.

Fix this by preparing another executable compiled with nodebug, and using
that one instead.

Also use with_test_prefix to mark the nodebug part, such that we have:
...
gdb compile failed, gcc: error: unrecognized command line option '-bad'
UNTESTED: gdb.base/cvexpr.exp: dwarf: failed to prepare
gdb compile failed, gcc: error: unrecognized command line option '-bad'
UNTESTED: gdb.base/cvexpr.exp: nodebug: failed to prepare
...

Tested on x86_64-linux.
This commit is contained in:
Tom de Vries
2021-09-30 19:07:48 +02:00
parent 85d74f2936
commit dc412de5e9

View File

@ -509,14 +509,20 @@ foreach testspec $specs {
} }
# These tests don't rely on the debug format. # These tests don't rely on the debug format.
gdb_test "ptype _Atomic int" "type = _Atomic int" with_test_prefix nodebug {
gdb_test "ptype int * restrict" "type = int \\* restrict" if { [prepare_for_testing "failed to prepare" $binfile $srcfile {nodebug}] } {
return 0
}
# C++ does not have "restrict". gdb_test "ptype _Atomic int" "type = _Atomic int"
gdb_test_no_output "set lang c++" gdb_test "ptype int * restrict" "type = int \\* restrict"
with_test_prefix c++ {
gdb_test "ptype int * restrict" "A syntax error in expression.*"
# There is a GCC extension for __restrict__, though. # C++ does not have "restrict".
gdb_test "ptype int * __restrict__" "type = int \\* __restrict__" gdb_test_no_output "set lang c++"
with_test_prefix c++ {
gdb_test "ptype int * restrict" "A syntax error in expression.*"
# There is a GCC extension for __restrict__, though.
gdb_test "ptype int * __restrict__" "type = int \\* __restrict__"
}
} }