RE: [PATCHv2 6/8] gdb/testsuite: expand gdb.base/foll-vfork.exp

Aktemur, Tankut Baris via Gdb-patches
2023-07-05T11:23:35Z

On Tuesday, July 4, 2023 5:23 PM, Andrew Burgess wrote:
> This commit provides tests for all of the bugs fixed in the previous
> four commits, this is achieved by expanding gdb.base/foll-vfork.exp to
> run with different configurations:
>
> * target-non-stop on/off
> * non-stop on/off
> * schedule-multiple on/off
>
> We don't test with schedule-multiple on if we are using a remote
> target, this is due to bug gdb/30574. I've added a link to that bug
> in this commit, but all this commit does is expose that bug, there's
> no fixes here.
>
> Some of the bugs fixed in the previous commits are very timing
> dependent, as such, they don't always show up. I've had more success
> when running this test on a very loaded machine -- I usually run ~8
> copies of the test in parallel, then the bugs would normally show up
> pretty quickly.
>
> Other than running the test in more configurations, I've not made any
> changes to what is actually being tested, other than in one place
> where, when testing with non-stop mode, GDB stops in a different
> inferior, as such I had to add a new 'inferior 2' call, this can be
> found in vfork_relations_in_info_inferiors.
>
> I have cleaned things up a little, for example, making use of
> proc_with_prefix to remove some with_test_prefix calls.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30574
> ---
> gdb/testsuite/gdb.base/foll-vfork.exp | 628 ++++++++++++--------------
> 1 file changed, 300 insertions(+), 328 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-
> vfork.exp
> index bdceff0f5de..be0715b05c0 100644
> --- a/gdb/testsuite/gdb.base/foll-vfork.exp
> +++ b/gdb/testsuite/gdb.base/foll-vfork.exp
> @@ -25,56 +25,52 @@ if {![istarget "*-linux*"]} {
> continue
> }
>
> -standard_testfile
> +standard_testfile .c -exit.c vforked-prog.c
>
> -set compile_options debug
> +set binfile $testfile
> +set binfile2 ${testfile}-exit
> +set binfile3 vforked-prog
>
> -if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} {
> +if {[build_executable "compile $binfile" $binfile $srcfile] == -1} {
> untested "failed to compile main testcase"
> return -1
> }
>
> -set testfile2 "vforked-prog"
> -set srcfile2 ${testfile2}.c
> +if {[build_executable "compile $binfile2" $binfile2 $srcfile2] == -1} {
> + untested "failed to compile main testcase"

A slightly different message can be used here, to distinguish it from the
case above. Also in the untested usage below.

> + return -1
> +}
>
> -if {[build_executable $testfile.exp $testfile2 $srcfile2 $compile_options] == -1} {
> - untested "failed to compile secondary testcase"
> +if {[build_executable "compile $binfile3" $binfile3 $srcfile3] == -1} {
> + untested "failed to compile main testcase"
> return -1
> }
>
...
> +proc_with_prefix vfork_child_follow_to_exit { binfile srcfile } {
> + setup_gdb $binfile $srcfile
> +
> + gdb_test_no_output "set follow-fork child"
> +
> + gdb_test_multiple "continue" "continue to child exit" {
> + -re -wrap "Couldn't get registers.*" {
> + # PR gdb/14766
> + fail $gdb_test_name

Since this is known, we can use a setup_kfail, I think.

> + }
> + -re -wrap "\\\[Attaching after.* vfork to.*\\\[Detaching vfork parent .* after
> child exit.*" {
> + pass $gdb_test_name
> + }
> + }
> +
> + # The parent has been detached; allow time for any output it might
> + # generate to arrive, so that output doesn't get confused with
> + # any gdb_expected debugger output from a subsequent testpoint.
> + #
> + exec sleep 1
> +}
> +
...
> +proc_with_prefix vfork_relations_in_info_inferiors { variant binfile srcfile
> non_stop } {
> + setup_gdb $binfile $srcfile
> +
> + gdb_test_no_output "set follow-fork child"
> +
> + gdb_test_multiple "next" "next over vfork" {
> + -re -wrap "\\\[Attaching after .* vfork to child.*if \\(pid == 0\\).*" {
> + pass $gdb_test_name
> + }
> + }
> +
> + if { $non_stop } {
> + gdb_test "inferior 2" ".*"
> + }
> +
> + gdb_test "info inferiors" \
> + ".*is vfork parent of inferior 2.*is vfork child of inferior 1" \
> + "info inferiors shows vfork parent/child relation"
> +
> + if { $variant == "exec" } {
> + set linenum [gdb_get_line_number "Hello from vforked-prog" ${::srcfile3}]
> + gdb_test_multiple "continue" "continue to bp" {
> + -re -wrap ".*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*"
> {
> + pass $gdb_test_name
> + }
> + }
> + } else {
> + gdb_test_multiple "continue" "continue to child exit" {
> + -re -wrap "exited normally.*" {
> + pass $gdb_test_name
> }

How about using gdb_continue_to_end instead of this gdb_test_multiple?

Thanks
-Baris

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928