gdb/testsuite: Remove duplicates from gdb.base/realname-expand.exp
authorLancelot SIX <lsix@lancelotsix.com>
Fri, 19 Nov 2021 22:48:59 +0000 (22:48 +0000)
committerLancelot SIX <lsix@lancelotsix.com>
Fri, 7 Jan 2022 22:43:32 +0000 (22:43 +0000)
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/realname-expand.exp ...
    DUPLICATE: gdb.base/realname-expand.exp: set basenames-may-differ on

This is due to the fact that the test restarts GDB twice and each time
sets the basenames-may-differ setting.  This patch proposes to fix this
by not restarting GDB so the setting is maintained.  It just clears the
breakpoints between the two tests and updates the breakpoints number as
required.

This patch also perform some minor refactorings to improve visibility.

Tested on x86_64-linux.

gdb/testsuite/gdb.base/realname-expand.exp

index 63299cd5b5c2a40006d153ccb046344f6d30c788..b476ef876ef3dd4d0815b2a359789bf0712e2eaf 100644 (file)
@@ -40,10 +40,12 @@ clean_restart ${testfile}
 
 gdb_test_no_output "set basenames-may-differ on"
 
-gdb_test "rbreak realname-expand-real.c:func" "^rbreak realname-expand-real.c:func\r\nBreakpoint 1 at 0x\[0-9a-f\]+: file \[^\r\n\]*/realname-expand-link\\.c, line \[0-9\]+\\.\r\nvoid func\\(void\\);"
+gdb_test "rbreak realname-expand-real.c:func" \
+    [multi_line "" \
+               "Breakpoint 1 at $hex: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\." \
+               "void func\\(void\\);"]
 
-clean_restart ${testfile}
-
-gdb_test_no_output "set basenames-may-differ on"
+delete_breakpoints
 
-gdb_test "break realname-expand-real.c:func" "^break realname-expand-real.c:func\r\nBreakpoint 1 at 0x\[0-9a-f\]+: file \[^\r\n\]*/realname-expand-link\\.c, line \[0-9\]+\\."
+gdb_test "break realname-expand-real.c:func" \
+    "\r\nBreakpoint 2 at $hex: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\."