]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.base/index-cache.exp
[gdb/testsuite] Fix index-cache.exp with cc-with-{gdb-index,debug-names}
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / index-cache.exp
index 4e583abf013fbad552757205951e816abeadf3ed..5baba843607bc648518d296239bec620f916b4b0 100644 (file)
@@ -22,6 +22,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
     return
 }
 
+set has_index_section [exec_has_index_section $binfile]
+
 # List the files in DIR on the host (where GDB-under-test runs).
 # Return a list of two elements:
 #   - 0 on success, -1 on failure
@@ -122,10 +124,12 @@ proc_with_prefix test_cache_disabled { cache_dir } {
     }
 }
 
-# Test with the cache enabled, we expect to have exactly one file created.
+# Test with the cache enabled, we expect to have:
+# - exactly one file created, in case of no index section
+# - no file created, in case of an index section
 
 proc_with_prefix test_cache_enabled_miss { cache_dir } {
-    global testfile
+    global testfile has_index_section
 
     lassign [ls_host $cache_dir] ret files_before
 
@@ -133,7 +137,11 @@ proc_with_prefix test_cache_enabled_miss { cache_dir } {
 
        lassign [ls_host $cache_dir] ret files_after
        set nfiles_created [expr [llength $files_after] - [llength $files_before]]
-       gdb_assert "$nfiles_created > 0" "at least one file was created"
+       if { $has_index_section } {
+           gdb_assert "$nfiles_created == 0" "no file was created"
+       } else {
+           gdb_assert "$nfiles_created > 0" "at least one file was created"
+       }
 
        set build_id [get_build_id  [standard_output_file ${testfile}]]
        if { $build_id == "" } {
@@ -143,19 +151,30 @@ proc_with_prefix test_cache_enabled_miss { cache_dir } {
 
        set expected_created_file [list "${build_id}.gdb-index"]
        set found_idx [lsearch -exact $files_after $expected_created_file]
-       gdb_assert "$found_idx >= 0" "expected file is there"
+       if { $has_index_section } {
+           gdb_assert "$found_idx == -1" "no index cache file generated"
+       } else {
+           gdb_assert "$found_idx >= 0" "expected file is there"
+       }
 
        remote_exec host rm "-f $cache_dir/$expected_created_file"
 
-       check_cache_stats 0 1
+       if { $has_index_section } {
+           check_cache_stats 0 0
+       } else {
+           check_cache_stats 0 1
+       }
     }
 }
 
 
-# Test with the cache enabled, this time we should have one file (the
-# same), but one cache read hit.
+# Test with the cache enabled, this time we should have:
+# - one file (the same), but one cache read hit, in case of no index section
+# - no file, no cache hit, in case an an index section
 
 proc_with_prefix test_cache_enabled_hit { cache_dir } {
+    global has_index_section
+
     # Just to populate the cache.
     run_test_with_flags $cache_dir on {}
 
@@ -166,7 +185,11 @@ proc_with_prefix test_cache_enabled_hit { cache_dir } {
        set nfiles_created [expr [llength $files_after] - [llength $files_before]]
        gdb_assert "$nfiles_created == 0" "no files were created"
 
-       check_cache_stats 1 0
+       if { $has_index_section } {
+           check_cache_stats 0 0
+       } else {
+           check_cache_stats 1 0
+       }
     }
 }