[binutils-gdb] [gdb/testsuite] Make gdb.dwarf2/dwzbuildid.exp more robust

Tom de Vries vries@sourceware.org
Fri Sep 8 10:27:27 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9c5bc1bd1399c11427deec1f8de6c537ab249087

commit 9c5bc1bd1399c11427deec1f8de6c537ab249087
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Sep 8 12:27:02 2023 +0200

    [gdb/testsuite] Make gdb.dwarf2/dwzbuildid.exp more robust
    
    I ran test-case gdb.dwarf2/dwzbuildid.exp with target board cc-with-gdb-index,
    and noticed that compilation failure for one exec prohibited testing of all
    execs.
    
    Fix this by restructuring the test-case, such that we have:
    ...
    PASS: gdb.dwarf2/dwzbuildid.exp: testname=ok: set debug-file-directory
    PASS: gdb.dwarf2/dwzbuildid.exp: testname=ok: print the_int
    UNSUPPORTED: gdb.dwarf2/dwzbuildid.exp: testname=mismatch: compilation failed
    UNSUPPORTED: gdb.dwarf2/dwzbuildid.exp: testname=fallback: compilation failed
    ...
    
    Tested on x86_64-linux.

Diff:
---
 gdb/testsuite/gdb.dwarf2/dwzbuildid.exp | 70 ++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
index 81cefc60dfc..76e3a7d6e42 100644
--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
@@ -134,46 +134,46 @@ for {set i 2} {$i <= 8} {incr i} {
 # Copy a file into the .build-id place for the "fallback" test.
 file copy -force -- ${binfile}8.o $basedir/$ok_prefix/$ok_suffix2.debug
 
-# Link the executables.
-if {[gdb_compile [list ${binfile}1.o ${binfile}2.o] ${binfile}-ok \
-	 executable {}] != ""} {
-    return -1
-}
-
-if {[gdb_compile [list ${binfile}1.o ${binfile}4.o] ${binfile}-mismatch \
-	 executable {quiet}] != ""} {
-    return -1
-}
+proc do_test {} {
+    clean_restart
 
-if {[gdb_compile [list ${binfile}1.o ${binfile}6.o] ${binfile}-fallback \
-	 executable {}] != ""} {
-    return -1
-}
+    gdb_test_no_output "set debug-file-directory $::debugdir" \
+	"set debug-file-directory"
 
+    gdb_load ${::binfile}-${::testname}
 
-foreach testname {ok mismatch fallback} {
-    with_test_prefix $testname {
-	clean_restart
+    if { $::testname == "mismatch" && [readnow] } {
+	# Main is found in the minimal symbols.  When using readnow, a
+	# failure to read the dwarf also causes the minimal symbols to be
+	# unavailable.
+	# Setup a kfail for "FAIL: gdb_breakpoint: set breakpoint at main".
+	setup_kfail "symtab/26797" *-*-*
+    }
+    if {![runto_main]} {
+	return
+    }
 
-	gdb_test_no_output "set debug-file-directory $debugdir" \
-	    "set debug-file-directory"
+    if {$::testname == "mismatch"} {
+	gdb_test "print the_int" \
+	    "(No symbol table is loaded|No symbol \"the_int\" in current context).*"
+    } else {
+	gdb_test "print the_int" " = 99"
+    }
+}
 
-	gdb_load ${binfile}-${testname}
+foreach_with_prefix testname { ok mismatch fallback } {
+    if { $testname == "ok" } {
+	set objs [list ${binfile}1.o ${binfile}2.o]
+    } elseif { $testname == "mismatch" } {
+	set objs [list ${binfile}1.o ${binfile}4.o]
+    } elseif { $testname == "fallback" } {
+	set objs [list ${binfile}1.o ${binfile}6.o]
+    }
 
-	if { $testname == "mismatch" && [readnow] } {
-	    # Main is found in the minimal symbols.  When using readnow, a
-	    # failure to read the dwarf also causes the minimal symbols to be
-	    # unavailable.
-	    # Setup a kfail for "FAIL: gdb_breakpoint: set breakpoint at main".
-	    setup_kfail "symtab/26797" *-*-*
-	}
-	if {[runto_main]} {
-	    if {$testname == "mismatch"} {
-		gdb_test "print the_int" \
-		    "(No symbol table is loaded|No symbol \"the_int\" in current context).*"
-	    } else {
-		gdb_test "print the_int" " = 99"
-	    }
-	}
+    if {[gdb_compile $objs ${binfile}-$testname executable {quiet}] != ""} {
+	unsupported "compilation failed"
+	continue
     }
+
+    do_test
 }


More information about the Gdb-cvs mailing list