return
}
+# The index cache won't be used in certain circumstances, for which we must
+# account in this test:
+#
+# - the binary already has an index section
+# - we use the -readnow switch
set has_index_section [exec_has_index_section $binfile]
+set uses_readnow [expr [string first "-readnow" $GDBFLAGS] != -1]
+set expecting_index_cache_use [expr !$has_index_section && !$uses_readnow]
# List the files in DIR on the host (where GDB-under-test runs).
# Return a list of two elements:
}
}
-# 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
+# Test a cache miss. We expect to have at least one file in the cache if the
+# index cache is going to be used (see expecting_index_cache_use) and a cache
+# miss in the stats. If the cache is not going to be used, we expect to have
+# no files and no cache hits nor misses.
proc_with_prefix test_cache_enabled_miss { cache_dir } {
- global testfile has_index_section
+ global testfile expecting_index_cache_use
lassign [ls_host $cache_dir] ret files_before
lassign [ls_host $cache_dir] ret files_after
set nfiles_created [expr [llength $files_after] - [llength $files_before]]
- if { $has_index_section } {
- gdb_assert "$nfiles_created == 0" "no file was created"
- } else {
+ if { $expecting_index_cache_use } {
gdb_assert "$nfiles_created > 0" "at least one file was created"
+ } else {
+ gdb_assert "$nfiles_created == 0" "no file was created"
}
set build_id [get_build_id [standard_output_file ${testfile}]]
set expected_created_file [list "${build_id}.gdb-index"]
set found_idx [lsearch -exact $files_after $expected_created_file]
- if { $has_index_section } {
- gdb_assert "$found_idx == -1" "no index cache file generated"
- } else {
+ if { $expecting_index_cache_use } {
gdb_assert "$found_idx >= 0" "expected file is there"
+ } else {
+ gdb_assert "$found_idx == -1" "no index cache file generated"
}
remote_exec host rm "-f $cache_dir/$expected_created_file"
- if { $has_index_section } {
- check_cache_stats 0 0
- } else {
+ if { $expecting_index_cache_use } {
check_cache_stats 0 1
+ } else {
+ check_cache_stats 0 0
}
}
}
-# 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
+# Test a cache hit. We should have at least one file in the cache if the index
+# cache is going to be used (see expecting_index_cache_use) and a cache hit in
+# the stats. If the cache is not going to be used, we expect to have no files
+# and no cache hits nor misses.
proc_with_prefix test_cache_enabled_hit { cache_dir } {
- global has_index_section
+ global expecting_index_cache_use
# Just to populate the cache.
run_test_with_flags $cache_dir on {}
set nfiles_created [expr [llength $files_after] - [llength $files_before]]
gdb_assert "$nfiles_created == 0" "no files were created"
- if { $has_index_section } {
- check_cache_stats 0 0
- } else {
+ if { $expecting_index_cache_use } {
check_cache_stats 1 0
+ } else {
+ check_cache_stats 0 0
}
}
}