public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] testsuite: Make standard_temp_file use invocation-specific directories
  2016-02-15 20:24 [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory Simon Marchi
@ 2016-02-15 20:24 ` Simon Marchi
  2016-02-15 23:46   ` Pedro Alves
  2016-02-15 23:45 ` [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory Pedro Alves
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2016-02-15 20:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Just like standard_output_file, standard_temp_file should use multiple
directories to make the tests parallel-safe.  However,
standard_temp_file is sometimes called in some procedures that are not
test-specific.  For example, gdb_init uses it, but is called once before
all test files are ran.  Therefore, we can't organize it in a
temp/gdb.subdir/testname layout, like standard_output_file.

Because it's just meant for temporary files that don't really need to be
inspected after the test, we can just put them in a directory based on
the runtest pid.  There is always a single exp file being executed by a
particular runtest invocation at any given time, so it should be safe.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (standard_temp_file): Return a path specific to
	the runtest invocation.
---
 gdb/testsuite/lib/gdb.exp | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1fb05c4..a77bce4 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4339,13 +4339,12 @@ proc standard_output_file {basename} {
 # Return the name of a file in our standard temporary directory.
 
 proc standard_temp_file {basename} {
-    global objdir GDB_PARALLEL
-
-    if {[info exists GDB_PARALLEL]} {
-	return [make_gdb_parallel_path temp $basename]
-    } else {
-	return $basename
-    }
+    # Since a particular runtest invocation is only executing a single test
+    # file at any given time, we can use the runtest pid to build the
+    # path of the temp directory.
+    set dir [make_gdb_parallel_path temp [pid]]
+    file mkdir $dir
+    return [file join $dir $basename]
 }
 
 # Set 'testfile', 'srcfile', and 'binfile'.
-- 
2.5.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory
@ 2016-02-15 20:24 Simon Marchi
  2016-02-15 20:24 ` [PATCH 2/2] testsuite: Make standard_temp_file use invocation-specific directories Simon Marchi
  2016-02-15 23:45 ` [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory Pedro Alves
  0 siblings, 2 replies; 5+ messages in thread
From: Simon Marchi @ 2016-02-15 20:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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.
---
 gdb/testsuite/gdb.trace/save-trace.exp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.trace/save-trace.exp b/gdb/testsuite/gdb.trace/save-trace.exp
index 7c897bb..3819034 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 work 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" {
-- 
2.5.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory
  2016-02-15 20:24 [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory Simon Marchi
  2016-02-15 20:24 ` [PATCH 2/2] testsuite: Make standard_temp_file use invocation-specific directories Simon Marchi
@ 2016-02-15 23:45 ` Pedro Alves
  2016-02-16 14:02   ` Simon Marchi
  1 sibling, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2016-02-15 23:45 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 02/15/2016 08:24 PM, Simon Marchi wrote:

> gdb/testsuite/ChangeLog:
> 
> 	* gdb.trace/save-trace.exp: Change relative path to be in the
> 	standard output directory.

OK.

> +    # This only work because the pwd is a prefix of the standard output

"This only works"

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] testsuite: Make standard_temp_file use invocation-specific directories
  2016-02-15 20:24 ` [PATCH 2/2] testsuite: Make standard_temp_file use invocation-specific directories Simon Marchi
@ 2016-02-15 23:46   ` Pedro Alves
  0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2016-02-15 23:46 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 02/15/2016 08:24 PM, Simon Marchi wrote:

> gdb/testsuite/ChangeLog:
> 
> 	* lib/gdb.exp (standard_temp_file): Return a path specific to
> 	the runtest invocation.

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory
  2016-02-15 23:45 ` [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory Pedro Alves
@ 2016-02-16 14:02   ` Simon Marchi
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2016-02-16 14:02 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 16-02-15 06:44 PM, Pedro Alves wrote:
> On 02/15/2016 08:24 PM, Simon Marchi wrote:
> 
>> gdb/testsuite/ChangeLog:
>>
>> 	* gdb.trace/save-trace.exp: Change relative path to be in the
>> 	standard output directory.
> 
> OK.
> 
>> +    # This only work because the pwd is a prefix of the standard output
> 
> "This only works"
> 
> Thanks,
> Pedro Alves
> 

Both patches are pushed, with the typo in this one fixed.

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-16 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-15 20:24 [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory Simon Marchi
2016-02-15 20:24 ` [PATCH 2/2] testsuite: Make standard_temp_file use invocation-specific directories Simon Marchi
2016-02-15 23:46   ` Pedro Alves
2016-02-15 23:45 ` [PATCH 1/2] testsuite: Fix save-trace.exp writing outside standard output directory Pedro Alves
2016-02-16 14:02   ` Simon Marchi

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).