public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Make gdb.base/index-cache.exp work with readnow board (PR 24669)
Date: Sun, 16 Jun 2019 13:59:00 -0000	[thread overview]
Message-ID: <20190616135953.27513.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=399aaebd1a5e9e3971758396bd0c5c3ec5ae2386

commit 399aaebd1a5e9e3971758396bd0c5c3ec5ae2386
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Sun Jun 16 09:07:16 2019 -0400

    Make gdb.base/index-cache.exp work with readnow board (PR 24669)
    
    The gdb.base/index-cache.exp test fails with the readnow board:
    
      $ make check TESTS="gdb.base/index-cache.exp" RUNTESTFLAGS="--target_board=readnow"
      FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
      FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there
      FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: check index-cache stats
      FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats
    
    The problem is similar to what was fixed in
    
      5a56d6a65f84 ("[gdb/testsuite] Fix index-cache.exp with cc-with-{gdb-index,debug-names}")
    
    In that commit, gdb.base/index-cache.exp was modified to account for the
    fact that the index cache is not used when the binary already has an
    embedded index.
    
    The same situation happens when GDB is started with the -readnow flag:
    it bypasses indices and partial symbols.  So this patch updates the test
    to also expect the index cache not to be used if -readnow is present in
    $GDBFLAGS,
    
    gdb/testsuite/ChangeLog:
    
    	PR gdb/24669
    	* gdb.base/index-cache.exp (uses_readnow,
    	expecting_index_cache_use): Define global variable.
    	(test_cache_enabled_miss, test_cache_enabled_hit): Use
    	expecting_index_cache_use.

Diff:
---
 gdb/testsuite/ChangeLog                |  8 ++++++
 gdb/testsuite/gdb.base/index-cache.exp | 49 ++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2efadd1..0330301 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-16  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	PR gdb/24669
+	* gdb.base/index-cache.exp (uses_readnow,
+	expecting_index_cache_use): Define global variable.
+	(test_cache_enabled_miss, test_cache_enabled_hit): Use
+	expecting_index_cache_use.
+
 2019-06-16  Bernhard Heckel  <bernhard.heckel@intel.com>
 	    Andrew Burgess  <andrew.burgess@embecosm.com>
 
diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp
index b76a02b..075dffe 100644
--- a/gdb/testsuite/gdb.base/index-cache.exp
+++ b/gdb/testsuite/gdb.base/index-cache.exp
@@ -22,7 +22,14 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
     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:
@@ -124,12 +131,13 @@ proc_with_prefix test_cache_disabled { cache_dir } {
     }
 }
 
-# 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
 
@@ -137,10 +145,10 @@ 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]]
-	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}]]
@@ -151,29 +159,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]
-	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 {}
@@ -185,10 +194,10 @@ 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"
 
-	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
 	}
     }
 }


                 reply	other threads:[~2019-06-16 13:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190616135953.27513.qmail@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).