From 3e488d8ccd0fb25d9c2d33feceb9eac3e336c1b0 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 20 May 2025 11:10:29 +0200 Subject: [PATCH] [gdb/testsuite] Fix gdb.dwarf2/dw-form-strx-out-of-bounds.exp with make-check-all.sh I forgot to run test-case gdb.dwarf2/dw-form-strx-out-of-bounds.exp with make-check-all.sh, and consequently failed to notice that it fails with for instance target board fission-dwp. The test-case does: ... source $srcdir/$subdir/dw-form-strx.exp.tcl ... and in that tcl file, prepare_for_testing fails, so a -1 is returned, but that is ignored by the source command. Fix this by using require, but rather that testing the result of the source command, communicate success by setting a global variable prepare_for_testing_done. Likewise in gdb.dwarf2/dw-form-strx.exp. Also, the test-case gdb.dwarf2/dw-form-strx-out-of-bounds.exp fails for target board readnow, because the DWARF error occurs during a different command than expected. Fix this by just skipping the test-case in that case. Tested on x86_64-linux. Reported-by: Simon Marchi Approved-By: Tom Tromey --- gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp | 6 ++++++ gdb/testsuite/gdb.dwarf2/dw-form-strx.exp | 2 ++ gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp index f2123fa7e07..cb24b19a131 100644 --- a/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp @@ -18,7 +18,13 @@ # Out of bounds index. set int_str_idx 1 +# With readnow, the dwarf error is printed during the file command, so skip +# the test. +require !readnow + +set prepare_for_testing_done 0 source $srcdir/$subdir/dw-form-strx.exp.tcl +require {expr $prepare_for_testing_done == 1} set re_dwarf_error \ [string_list_to_regexp \ diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp index 9b62edfee0b..3f739c4adea 100644 --- a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp @@ -18,6 +18,8 @@ # Correct index. set int_str_idx 0 +set prepare_for_testing_done 0 source $srcdir/$subdir/dw-form-strx.exp.tcl +require {expr $prepare_for_testing_done == 1} gdb_test "ptype global_var" "type = int" diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl index 15cfe276f96..d69b517f2e7 100644 --- a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl @@ -56,5 +56,9 @@ Dwarf::assemble $asm_file { if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile $asm_file] {nodebug}] } { - return -1 + return } + +# Let includers know prepare_for_testing was done, without having to check +# source return status. +set prepare_for_testing_done 1 -- 2.47.2