[testsuite] gdb.base/dlmopen: Fix test name and use gdb_attach
authorLancelot SIX <lancelot.six@amd.com>
Fri, 4 Nov 2022 15:36:21 +0000 (15:36 +0000)
committerLancelot SIX <lancelot.six@amd.com>
Fri, 4 Nov 2022 16:18:27 +0000 (16:18 +0000)
One test name in gdb.base/dlmopen.exp changes from run to run
since it includes a process id:

    PASS: gdb.base/dlmopen.exp: attach 3442682

This is not convenient do diff gdb.sum files to compare test runs.

Fix by using gdb_attach helper function to handle attaching to the
process as it produce a constant test name.

While at it also check gdb_attach's return value to only run the
rest of the test if the attach was successful.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/testsuite/gdb.base/dlmopen.exp

index a80db75f9ac7b58e4a7ef32dca963af054a295de..31f74008f10cc371863cd6355861a9800aed44f1 100644 (file)
@@ -159,7 +159,9 @@ set test_spawn_id [spawn_wait_for_attach $binfile]
 set testpid [spawn_id_get_pid $test_spawn_id]
 
 # Attach.
-gdb_test "attach $testpid" "Attaching to program.*, process $testpid.*"
+if { ![gdb_attach $testpid] } {
+    return
+}
 
 with_test_prefix "attach" {
     # Remove the pause.  We no longer need it.