On 07/28/2016 11:26 PM, Joseph Myers wrote:
> On Mon, 18 Jul 2016, Martin Liška wrote:
> 
>> Well, I can imaging a guard which will test whether 
>> "$objdir/../../params.options" file exits, and if so, then the tests are 
>> executed? Is it acceptable approach?
> 
> The correct way to test for build-tree testing is [info exists 
> TESTING_IN_BUILD_TREE].  When testing outside the build tree, you should 
> not assume anything about directories outside of the test and source 
> directories, meaning you should not test for existence of paths in 
> $objdir/../ in that case.

Thank you for the hint, I'm attaching patch.

> 
> (The preferable approach is to factor out the code generating this file so 
> it can be run from the testsuite.  Then you don't need to distinguish 
> build-tree and other testing at all.)
> 

That would be the best approach, but I've got quite limited experience with 
DejaGNU,
I would postpone it and write it on my TODO list.

May I install the suggested patch?
Martin
>From 71b4f52b348098314c2b2351bcd7dbd72e051ec4 Mon Sep 17 00:00:00 2001
From: marxin <mli...@suse.cz>
Date: Mon, 1 Aug 2016 13:59:34 +0200
Subject: [PATCH] Use TESTING_IN_BUILD_TREE in params.exp

gcc/testsuite/ChangeLog:

2016-08-01  Martin Liska  <mli...@suse.cz>

	* gcc.dg/params/params.exp: Replace file exists with
	TESTING_IN_BUILD_TREE.
---
 gcc/testsuite/gcc.dg/params/params.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/params/params.exp b/gcc/testsuite/gcc.dg/params/params.exp
index 47f5af5..2eb797e 100644
--- a/gcc/testsuite/gcc.dg/params/params.exp
+++ b/gcc/testsuite/gcc.dg/params/params.exp
@@ -32,7 +32,7 @@ proc param_run_test { param_name param_value } {
 }
 
 set options_file "$objdir/../../params.options"
-if { [file exists $options_file] == 0 } {
+if { [info exists TESTING_IN_BUILD_TREE] == 0 } {
   return
 }
 
-- 
2.9.2

Reply via email to