diff mbox

gdb: use foreach_with_prefix in gdb.base/break-interp.exp

Message ID 20200306223218.20320-1-simon.marchi@efficios.com
State New
Headers show

Commit Message

Simon Marchi March 6, 2020, 10:32 p.m. UTC
Use foreach_with_prefix, instead of foreach and with_test_prefix
separately.  Since allows removing some indentation levels, and formats
the test names a bit nicer, in my opinion (or at least, it's more
consistent with the rest of the testsuite):

    - PASS: gdb.base/break-interp.exp: LDprelinkNOdebugNO: BINprelinkNOdebugNOpieNO: INNER: core: set verbose on
    + PASS: gdb.base/break-interp.exp: ldprelink=NO: ldsepdebug=NO: binprelink=NO: binsepdebug=NO: binpie=NO: INNER: set verbose on

Note: this patch is better viewed with "git show -w" to ignore
whitespace changes.

gdb/testsuite/ChangeLog:

	* gdb.base/break-interp.exp: Use foreach_with_prefix.
---
 gdb/testsuite/gdb.base/break-interp.exp | 270 ++++++++++++------------
 1 file changed, 133 insertions(+), 137 deletions(-)
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index 6f1af0e5b184..4dabf49aae2f 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -530,8 +530,8 @@  proc test_ld {file ifmain trynosym displacement} {
 # Create separate binaries for each testcase - to make the possible reported
 # problem reproducible after the whole test run finishes.
 
-foreach ldprelink {NO YES} {
-    foreach ldsepdebug {NO IN SEP} {
+foreach_with_prefix ldprelink {NO YES} {
+    foreach_with_prefix ldsepdebug {NO IN SEP} {
 	# Skip running the ldsepdebug test if we do not have system separate
 	# debug info available.
 	if {$interp_system_debug == "" && $ldsepdebug == "SEP"} {
@@ -554,164 +554,160 @@  foreach ldprelink {NO YES} {
 	# possibly unprelinked ld.so to test all the combinations for GDB.
 	set interp_saved ${interp}-saved
 
-	with_test_prefix "$ldname" {
-	    if {$ldsepdebug == "NO"} {
-		file_copy $interp_system $interp
-		# Never call strip-debug before unprelink:
-		# prelink: ...: Section .note.gnu.build-id created after prelinking
-		if ![prelinkNO $interp] {
-		    continue
-		}
-		strip_debug $interp
-	    } elseif {$ldsepdebug == "IN" && $interp_system_debug == ""} {
-		file_copy $interp_system $interp
-	    } elseif {$ldsepdebug == "IN" && $interp_system_debug != ""} {
-		file_copy $interp_system $interp
-		file_copy $interp_system_debug "${interp}.debug"
-		# eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
-		if {![prelinkNO $interp] || ![prelinkNO "${interp}.debug"]} {
-		    continue
-		}
-		set test "eu-unstrip unprelinked:[file tail $interp_system] + [file tail $interp_system_debug] to [file tail $interp]"
-		set command "exec eu-unstrip -o $interp $interp ${interp}.debug"
-		verbose -log "command is $command"
-		if [catch $command] {
-		    setup_xfail *-*-*
-		    fail $test
-		    continue
-		} else {
-		    pass $test
-		}
-	    } elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} {
-		file_copy $interp_system $interp
-		# eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
-		if ![prelinkNO $interp] {
-		    continue
-		}
-		gdb_gnu_strip_debug $interp
-	    } elseif {$ldsepdebug == "SEP" && $interp_system_debug != ""} {
-		file_copy $interp_system $interp
-		file_copy $interp_system_debug "${interp}.debug"
-	    }
-
-	    if {$ldsepdebug == "SEP"} {
-		if ![prelinkNO "${interp}.debug"] {
-		    continue
-		}
-	    } else {
-		file delete "${interp}.debug"
+	if {$ldsepdebug == "NO"} {
+	    file_copy $interp_system $interp
+	    # Never call strip-debug before unprelink:
+	    # prelink: ...: Section .note.gnu.build-id created after prelinking
+	    if ![prelinkNO $interp] {
+		continue
 	    }
-
-	    if ![prelink$ldprelink $interp "$interp, second time"] {
+	    strip_debug $interp
+	} elseif {$ldsepdebug == "IN" && $interp_system_debug == ""} {
+	    file_copy $interp_system $interp
+	} elseif {$ldsepdebug == "IN" && $interp_system_debug != ""} {
+	    file_copy $interp_system $interp
+	    file_copy $interp_system_debug "${interp}.debug"
+	    # eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
+	    if {![prelinkNO $interp] || ![prelinkNO "${interp}.debug"]} {
 		continue
 	    }
-
-	    if {$ldprelink == "NO"} {
-		set displacement "NONZERO"
+	    set test "eu-unstrip unprelinked:[file tail $interp_system] + [file tail $interp_system_debug] to [file tail $interp]"
+	    set command "exec eu-unstrip -o $interp $interp ${interp}.debug"
+	    verbose -log "command is $command"
+	    if [catch $command] {
+		setup_xfail *-*-*
+		fail $test
+		continue
 	    } else {
-		# x86* kernel loads prelinked PIE binary at its
-		# prelinked address but ppc* kernel loads it at a
-		# random address.  prelink normally skips PIE binaries
-		# during the system scan.
-		set displacement "PRESENT"
+		pass $test
 	    }
-	    test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
+	} elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} {
+	    file_copy $interp_system $interp
+	    # eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
+	    if ![prelinkNO $interp] {
+		continue
+	    }
+	    gdb_gnu_strip_debug $interp
+	} elseif {$ldsepdebug == "SEP" && $interp_system_debug != ""} {
+	    file_copy $interp_system $interp
+	    file_copy $interp_system_debug "${interp}.debug"
+	}
 
-	    if ![file_copy $interp $interp_saved] {
+	if {$ldsepdebug == "SEP"} {
+	    if ![prelinkNO "${interp}.debug"] {
 		continue
 	    }
+	} else {
+	    file delete "${interp}.debug"
+	}
 
-	    foreach binprelink {NO YES} {
-		foreach binsepdebug {NO IN SEP} {
-		    # "ATTACH" is like "YES" but it is modified during
-		    # run.  It cannot be used for problem
-		    # reproducibility after the testcase ends.
-		    foreach binpie {NO YES ATTACH} {
-			# This combination is not possible, non-PIE (fixed address)
-			# binary cannot be prelinked to any (other) address.
-			if {$binprelink == "YES" && $binpie == "NO"} {
-			    continue
-			}
+	if ![prelink$ldprelink $interp "$interp, second time"] {
+	    continue
+	}
 
-			set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
-			set exec $binprefix-$binname
+	if {$ldprelink == "NO"} {
+	    set displacement "NONZERO"
+	} else {
+	    # x86* kernel loads prelinked PIE binary at its
+	    # prelinked address but ppc* kernel loads it at a
+	    # random address.  prelink normally skips PIE binaries
+	    # during the system scan.
+	    set displacement "PRESENT"
+	}
+	test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
 
-			with_test_prefix "$binname" {
-			    set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
-			    if {$binsepdebug != "NO"} {
-				lappend opts {debug}
-			    }
-			    if {$binpie != "NO"} {
-				lappend opts {pie}
-			    } else {
-				# Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled.
-				lappend opts {nopie}
-			    }
+	if ![file_copy $interp $interp_saved] {
+	    continue
+	}
 
-			    set dir ${exec}.d
-			    set relink_args [build_executable_own_libs ${test}.exp [file tail $exec] $srcfile $opts $interp $dir]
-			    if {$relink_args == ""} {
-				continue
-			    }
+	foreach_with_prefix binprelink {NO YES} {
+	    foreach_with_prefix binsepdebug {NO IN SEP} {
+		# "ATTACH" is like "YES" but it is modified during
+		# run.  It cannot be used for problem
+		# reproducibility after the testcase ends.
+		foreach_with_prefix binpie {NO YES ATTACH} {
+		    # This combination is not possible, non-PIE (fixed address)
+		    # binary cannot be prelinked to any (other) address.
+		    if {$binprelink == "YES" && $binpie == "NO"} {
+			continue
+		    }
 
-			    if {$binsepdebug == "SEP"} {
-				gdb_gnu_strip_debug $exec
-			    }
+		    set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
+		    set exec $binprefix-$binname
 
-			    if {$binpie == "NO"} {
-				set displacement "NONE"
-			    } elseif {$binprelink == "NO"} {
-				set displacement "NONZERO"
+		    set opts "ldflags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
+		    if {$binsepdebug != "NO"} {
+			lappend opts {debug}
+		    }
+		    if {$binpie != "NO"} {
+			lappend opts {pie}
+		    } else {
+			# Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled.
+			lappend opts {nopie}
+		    }
+
+		    set dir ${exec}.d
+		    set relink_args [build_executable_own_libs ${test}.exp [file tail $exec] $srcfile $opts $interp $dir]
+		    if {$relink_args == ""} {
+			continue
+		    }
+
+		    if {$binsepdebug == "SEP"} {
+			gdb_gnu_strip_debug $exec
+		    }
+
+		    if {$binpie == "NO"} {
+			set displacement "NONE"
+		    } elseif {$binprelink == "NO"} {
+			set displacement "NONZERO"
+		    } else {
+			# x86* kernel loads prelinked PIE binary at its prelinked
+			# address but ppc* kernel loads it at a random address.
+			# prelink normally skips PIE binaries during the system scan.
+			set displacement "PRESENT"
+		    }
+
+		    if {[prelink$binprelink $relink_args [file tail $exec]]
+			&& [file_copy $interp_saved $interp]} {
+			# In order to make test names unique wrap the core of this if block
+			# with a test prefix.  Some of the tests performed in the if
+			# condition are repeated within this body.
+			with_test_prefix "INNER" {
+			    if {$binpie != "ATTACH"} {
+				test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
 			    } else {
-				# x86* kernel loads prelinked PIE binary at its prelinked
-				# address but ppc* kernel loads it at a random address.
-				# prelink normally skips PIE binaries during the system scan.
-				set displacement "PRESENT"
-			    }
+				# If the file has been randomly prelinked it must be
+				# "NONZERO".  We could see "ZERO" only if it was unprelinked
+				# and it is now running at the same address - which is 0 but
+				# executable can never run at address 0.
 
-			    if {[prelink$binprelink $relink_args [file tail $exec]]
-				&& [file_copy $interp_saved $interp]} {
-				# In order to make test names unique wrap the core of this if block
-				# with a test prefix.  Some of the tests performed in the if
-				# condition are repeated within this body.
-				with_test_prefix "INNER" {
-				    if {$binpie != "ATTACH"} {
-					test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
-				    } else {
-					# If the file has been randomly prelinked it must be
-					# "NONZERO".  We could see "ZERO" only if it was unprelinked
-					# and it is now running at the same address - which is 0 but
-					# executable can never run at address 0.
-
-					set displacement "NONZERO"
-					test_attach $exec $displacement $relink_args
-
-					# ATTACH means that executables and libraries have been
-					# modified after they have been run.  They cannot be reused
-					# for problem reproducibility after the testcase ends in
-					# the ATTACH case.  Therefore they are rather deleted not
-					# to confuse after the run finishes.
-					set exec_debug [system_debug_get $exec]
-					if {$exec_debug != ""} {
-					    # `file delete [glob "${exec_debug}*"]' does not work.
-					    foreach f [glob "${exec_debug}*"] {
-						file delete $f
-					    }
-					}
-					file delete -force $dir
-					# `file delete [glob "${exec}*"]' does not work.
-					foreach f [glob "${exec}*"] {
-					    file delete $f
-					}
+				set displacement "NONZERO"
+				test_attach $exec $displacement $relink_args
+
+				# ATTACH means that executables and libraries have been
+				# modified after they have been run.  They cannot be reused
+				# for problem reproducibility after the testcase ends in
+				# the ATTACH case.  Therefore they are rather deleted not
+				# to confuse after the run finishes.
+				set exec_debug [system_debug_get $exec]
+				if {$exec_debug != ""} {
+				    # `file delete [glob "${exec_debug}*"]' does not work.
+				    foreach f [glob "${exec_debug}*"] {
+					file delete $f
 				    }
 				}
+				file delete -force $dir
+				# `file delete [glob "${exec}*"]' does not work.
+				foreach f [glob "${exec}*"] {
+				    file delete $f
+				}
 			    }
 			}
 		    }
 		}
 	    }
-
-	    file delete $interp_saved
 	}
+
+	file delete $interp_saved
     }
 }