gdb.base/foll-fork.exp: accept "info breakpoints" output in any order
authorSimon Marchi <simon.marchi@polymtl.ca>
Tue, 28 Sep 2021 17:22:53 +0000 (13:22 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 28 Sep 2021 23:30:41 +0000 (19:30 -0400)
The test currently requires the "inf 1" breakpoint to be before the "inf
2" breakpoint.  This is not always the case:

    info breakpoints 2
    Num     Type           Disp Enb Address            What
    2       breakpoint     keep y   <MULTIPLE>
    2.1                         y   0x0000555555554730 in callee at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/foll-fork.c:9 inf 2
    2.2                         y   0x0000555555554730 in callee at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/foll-fork.c:9 inf 1
    (gdb) FAIL: gdb.base/foll-fork.exp: follow-fork-mode=parent: detach-on-fork=off: cmd=next 2: test_follow_fork: info breakpoints

Since add_location_to_breakpoint uses only the address as a criterion to
sort locations, the order of locations at the same address is not
stable: it will depend on the insertion order.  Here, the insertion
order comes from the order of SALs when creating the breakpoint, which
can vary from machine to machine.  While it would be more user-friendly
to have a more stable order for printed breakpoint locations, it doesn't
really matter for this test, and it would be hard to define an order
that will be the same everywhere, all the time.

So, loosen the regexp to accept "inf 1" and "inf 2" in any order.

Co-Authored-By: Pedro Alves <pedro@palves.net>
Change-Id: I5ada2e0c6ad0669e0d161bfb6b767229c0970d16

gdb/testsuite/gdb.base/foll-fork.exp

index 7f9e1cf87c6a657a8ccc5945cd414d5e216cc027..d6d32f63121b705e612bbec3112a26475b426190 100644 (file)
@@ -193,10 +193,17 @@ proc_with_prefix test_follow_fork { follow-fork-mode detach-on-fork cmd } {
                pass $gdb_test_name
            }
        }
+
+       set any {[^\r\n]+}
+
+       set loc1_inf1 "$bpnum\\.1 $any inf 1"
+       set loc1_inf2 "$bpnum\\.1 $any inf 2"
+
+       set loc2_inf1 "$bpnum\\.2 $any inf 1"
+       set loc2_inf2 "$bpnum\\.2 $any inf 2"
+
        gdb_test "info breakpoints $bpnum" \
-           [multi_line \
-               "$bpnum\\.1 .* inf 1" \
-               "$bpnum\\.2 .* inf 2"] \
+           "($loc1_inf1\r\n$loc2_inf2|$loc1_inf2\r\n$loc2_inf1)" \
            "info breakpoints"
     }
 }