This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] testsuite: Fix save-trace.exp writing outside standard output directory


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

commit 266b65b33e23c916e5e698d24c37f65d90645a19
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Tue Feb 16 09:00:50 2016 -0500

    testsuite: Fix save-trace.exp writing outside standard output directory
    
    In save-trace.exp, we want to test loading of a tracepoint definition
    file with a relative path (I am not sure why in fact).  We currently use
    "savetrace-relative.tr", which ends up directly in testsuite/.  If we
    use [standard_output_file] on that path, it becomes absolute.  I decided
    to just replace [pwd] with . (a dot) in the path given by
    standard_output_file to make it relative.  However, this trick only
    works because [pwd] is a prefix of the standard output directory.  So I
    added a check to verify that precondition.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.trace/save-trace.exp: Change relative path to be in the
    	standard output directory.

Diff:
---
 gdb/testsuite/ChangeLog                |  5 +++++
 gdb/testsuite/gdb.trace/save-trace.exp | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a62d358..5c663ef 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-16  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* gdb.trace/save-trace.exp: Change relative path to be in the
+	standard output directory.
+
 2016-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	* gdb.arch/i386-prologue.c: Add missing prototypes.
diff --git a/gdb/testsuite/gdb.trace/save-trace.exp b/gdb/testsuite/gdb.trace/save-trace.exp
index 7c897bb..a70ad54 100644
--- a/gdb/testsuite/gdb.trace/save-trace.exp
+++ b/gdb/testsuite/gdb.trace/save-trace.exp
@@ -151,7 +151,18 @@ proc do_save_load_test { save_path } {
 gdb_verify_tracepoints "verify trace setup"
 
 with_test_prefix "relative" {
-    do_save_load_test "savetrace-relative.tr"
+    set filepath [standard_output_file "savetrace-relative.tr"]
+
+    # This only works because the pwd is a prefix of the standard output
+    # directory.  If this assumption becomes false, then this test needs to be
+    # changed (the relative path from [pwd] to the standard output directory
+    # will become a bit more complicated to compute).
+    if {[string first [pwd] $filepath] != 0} {
+	error "[pwd] is not a prefix of $filepath."
+    }
+
+    set filepath [string map "[pwd] ." $filepath]
+    do_save_load_test "$filepath"
 }
 
 with_test_prefix "absolute" {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]