[gdb/testsuite] Fix gdb.dwarf2/gdb-add-index-symlink.exp
authorTom de Vries <tdevries@suse.de>
Mon, 11 Oct 2021 10:21:00 +0000 (12:21 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 11 Oct 2021 10:21:00 +0000 (12:21 +0200)
The test-case gdb.dwarf2/gdb-add-index-symlink.exp interpretes a failure to
add an index as a failure to add an index for a symlink:
...
if { [ensure_gdb_index $symlink] == -1 } {
    fail "Unable to call gdb-add-index with a symlink to a symfile"
    return -1
}
...

However, it's possible that the gdb-add-index also fails with a regular
file.  Add a check for that situation.

Tested on x86_64-linux.

gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp

index eaeddec0250e01e330c949e156dd20143ad1d693..74c558ad231dad88af6d7cc46534062bca8bae97 100644 (file)
@@ -22,6 +22,19 @@ if {![dwarf2_support]} {
 
 standard_testfile main.c
 
+# First check whether we can actually handle the non-symlink case.
+with_test_prefix non-symlink {
+    if { [prepare_for_testing "failed to prepare" "${testfile}" \
+             [list ${srcfile}]] } {
+       return -1
+    }
+
+    if { [ensure_gdb_index $binfile] == -1 } {
+       return -1
+    }
+}
+
+# Regenerate exec without index.
 if { [prepare_for_testing "failed to prepare" "${testfile}" \
          [list ${srcfile}]] } {
     return -1