[5/6] gdb.base/foll-fork.exp: use foreach_with_prefix to handle prefixes

Message ID 20210910205402.3853607-5-simon.marchi@efficios.com
State New
Headers show
Series
  • [1/6] gdb.base/foll-fork.exp: remove DUPLICATEs
Related show

Commit Message

Lancelot SIX via Gdb-patches Sept. 10, 2021, 8:54 p.m.
No behavior change in the test expected, other than in the test names.

Change-Id: I111137483858ab0f23138439f2930009779a2b3d
---
 gdb/testsuite/gdb.base/foll-fork.exp | 165 +++++++++++++--------------
 1 file changed, 81 insertions(+), 84 deletions(-)

-- 
2.33.0

Patch

diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp
index 3b90bb2e785..3a0cc2fe456 100644
--- a/gdb/testsuite/gdb.base/foll-fork.exp
+++ b/gdb/testsuite/gdb.base/foll-fork.exp
@@ -79,109 +79,106 @@  proc_with_prefix test_follow_fork { follow-fork-mode detach-on-fork cmd } {
     global srcfile
     global testfile
 
-    with_test_prefix "follow ${follow-fork-mode}, detach ${detach-on-fork}, command \"$cmd\"" {
-
-	# Start a new debugger session each time so defaults are legitimate.
-	if { ![setup] } {
-	    return
-	}
+    # Start a new debugger session each time so defaults are legitimate.
+    if { ![setup] } {
+	return
+    }
 
-	# The "Detaching..." and "Attaching..." messages may be hidden by
-	# default.
-	gdb_test_no_output "set verbose"
+    # The "Detaching..." and "Attaching..." messages may be hidden by
+    # default.
+    gdb_test_no_output "set verbose"
 
-	# Set follow-fork-mode if we aren't using the default.
-	if {${follow-fork-mode} == "default"} {
-	    set follow-fork-mode "parent"
-	} else {
-	    gdb_test_no_output "set follow-fork ${follow-fork-mode}"
-	}
+    # Set follow-fork-mode if we aren't using the default.
+    if {${follow-fork-mode} == "default"} {
+	set follow-fork-mode "parent"
+    } else {
+	gdb_test_no_output "set follow-fork ${follow-fork-mode}"
+    }
 
-	gdb_test "show follow-fork" \
-	"Debugger response to a program call of fork or vfork is \"${follow-fork-mode}\"."
+    gdb_test "show follow-fork" \
+    "Debugger response to a program call of fork or vfork is \"${follow-fork-mode}\"."
 
-	# Set detach-on-fork mode if we aren't using the default.
-	if {${detach-on-fork} == "default"} {
-	    set detach-on-fork "on"
-	} else {
-	    gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
-	}
+    # Set detach-on-fork mode if we aren't using the default.
+    if {${detach-on-fork} == "default"} {
+	set detach-on-fork "on"
+    } else {
+	gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
+    }
 
-	gdb_test "show detach-on-fork" \
-		 "Whether gdb will detach.* fork is ${detach-on-fork}."
+    gdb_test "show detach-on-fork" \
+	     "Whether gdb will detach.* fork is ${detach-on-fork}."
 
-	# Set a breakpoint after the fork if we aren't single-stepping
-	# past the fork.
-	if {$cmd == "continue"} {
-	    set bp_after_fork [gdb_get_line_number "set breakpoint here"]
-	    gdb_test "break ${srcfile}:$bp_after_fork" \
-		     "Breakpoint.*, line $bp_after_fork.*" \
-		     "set breakpoint after fork"
-	}
+    # Set a breakpoint after the fork if we aren't single-stepping
+    # past the fork.
+    if {$cmd == "continue"} {
+	set bp_after_fork [gdb_get_line_number "set breakpoint here"]
+	gdb_test "break ${srcfile}:$bp_after_fork" \
+		 "Breakpoint.*, line $bp_after_fork.*" \
+		 "set breakpoint after fork"
+    }
 
-	# Set up the output we expect to see after we run.
-	set expected_re ""
-	if {${follow-fork-mode} == "child"} {
-	    set expected_re "\\\[Attaching after.* fork to.*"
-	    if {${detach-on-fork} == "on"} {
-		append expected_re "\\\[Detaching after fork from .*"
-	    }
-	    append expected_re "set breakpoint here.*"
-	} elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
-	    set expected_re "\\\[Detaching after fork from .*set breakpoint here.*"
-	} else {
-	    set expected_re ".*set breakpoint here.*"
+    # Set up the output we expect to see after we run.
+    set expected_re ""
+    if {${follow-fork-mode} == "child"} {
+	set expected_re "\\\[Attaching after.* fork to.*"
+	if {${detach-on-fork} == "on"} {
+	    append expected_re "\\\[Detaching after fork from .*"
 	}
+	append expected_re "set breakpoint here.*"
+    } elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
+	set expected_re "\\\[Detaching after fork from .*set breakpoint here.*"
+    } else {
+	set expected_re ".*set breakpoint here.*"
+    }
 
-	# Test running past and following the fork, using the parameters
-	# set above.
-	gdb_test $cmd $expected_re "$cmd past fork"
+    # Test running past and following the fork, using the parameters
+    # set above.
+    gdb_test $cmd $expected_re "$cmd past fork"
 
-	# Check that we have the inferiors arranged correctly after 
-	# following the fork.
-	set resume_unfollowed 0
-	if {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
+    # Check that we have the inferiors arranged correctly after
+    # following the fork.
+    set resume_unfollowed 0
+    if {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
 
-	    # Follow parent / detach child: the only inferior is the parent.
-	    gdb_test "info inferiors" "\\* 1 .* process.*"
+	# Follow parent / detach child: the only inferior is the parent.
+	gdb_test "info inferiors" "\\* 1 .* process.*"
 
-	} elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "off"} {
+    } elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "off"} {
 
-	    # Follow parent / keep child: two inferiors under debug, the
-	    # parent is the current inferior.
-	    gdb_test "info inferiors" "\\* 1 .*process.* 2 .*process.*"
+	# Follow parent / keep child: two inferiors under debug, the
+	# parent is the current inferior.
+	gdb_test "info inferiors" "\\* 1 .*process.* 2 .*process.*"
 
-	    gdb_test "inferior 2" "Switching to inferior 2 .*"
-	    set resume_unfollowed 1
+	gdb_test "inferior 2" "Switching to inferior 2 .*"
+	set resume_unfollowed 1
 
-	} elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "on"} {
+    } elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "on"} {
 
-	    # Follow child / detach parent: the child is under debug and is
-	    # the current inferior.  The parent is listed but is not under
-	    # debug.
-	    gdb_test "info inferiors" " 1 .*<null>.*\\* 2 .*process.*"
+	# Follow child / detach parent: the child is under debug and is
+	# the current inferior.  The parent is listed but is not under
+	# debug.
+	gdb_test "info inferiors" " 1 .*<null>.*\\* 2 .*process.*"
 
-	} elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "off"} {
+    } elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "off"} {
 
-	    # Follow child / keep parent: two inferiors under debug, the
-	    # child is the current inferior.
-	    gdb_test "info inferiors" " 1 .*process.*\\* 2 .*process.*"
+	# Follow child / keep parent: two inferiors under debug, the
+	# child is the current inferior.
+	gdb_test "info inferiors" " 1 .*process.*\\* 2 .*process.*"
 
-	    gdb_test "inferior 1" "Switching to inferior 1 .*"
-	    set resume_unfollowed 1
-	}
+	gdb_test "inferior 1" "Switching to inferior 1 .*"
+	set resume_unfollowed 1
+    }
 
-	if {$resume_unfollowed == 1} {
-	    if {$cmd == "next 2"} {
+    if {$resume_unfollowed == 1} {
+	if {$cmd == "next 2"} {
 
-		gdb_continue_to_end "continue unfollowed inferior to end"
+	    gdb_continue_to_end "continue unfollowed inferior to end"
 
-	    } elseif {$cmd == "continue"} {
+	} elseif {$cmd == "continue"} {
 
-		gdb_continue_to_breakpoint \
-		    "continue unfollowed inferior to bp" \
-		    ".* set breakpoint here.*"
-	    }
+	    gdb_continue_to_breakpoint \
+		"continue unfollowed inferior to bp" \
+		".* set breakpoint here.*"
 	}
     }
 }
@@ -395,14 +392,14 @@  if { ![check_fork_catchpoints] } {
 # The first loop should be sufficient to test the defaults.  There
 # is no need to test using the defaults in other permutations (e.g.
 # "default" "on", "parent" "default", etc.).
-foreach cmd {"next 2" "continue"} {
+foreach_with_prefix cmd {"next 2" "continue"} {
     test_follow_fork "default" "default" $cmd
 }
 
 # Now test all explicit permutations.
-foreach follow-fork-mode {"parent" "child"} {
-    foreach detach-on-fork {"on" "off"} {
-	foreach cmd {"next 2" "continue"} {
+foreach_with_prefix follow-fork-mode {"parent" "child"} {
+    foreach_with_prefix detach-on-fork {"on" "off"} {
+	foreach_with_prefix cmd {"next 2" "continue"} {
 	    test_follow_fork ${follow-fork-mode} ${detach-on-fork} $cmd
 	}
     }