From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96983 invoked by alias); 12 Feb 2016 21:02:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 96970 invoked by uid 89); 12 Feb 2016 21:02:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=sk:wrong_f, UD:wrong_frame_bt_full.exp, UD:tr, Saved X-HELO: usplmg21.ericsson.net Received: from usplmg21.ericsson.net (HELO usplmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 12 Feb 2016 21:01:51 +0000 Received: from EUSAAHC001.ericsson.se (Unknown_Domain [147.117.188.75]) by usplmg21.ericsson.net (Symantec Mail Security) with SMTP id D2.5E.32102.5284EB65; Fri, 12 Feb 2016 22:01:25 +0100 (CET) Received: from elxcz23q12-y4.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 12 Feb 2016 16:01:47 -0500 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] testsuite: Fix some tests that write outside of the standard output/temp directories Date: Fri, 12 Feb 2016 21:02:00 -0000 Message-ID: <1455310904-12076-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00436.txt.bz2 I used the GDB_INOTIFY feature to find those. These should be all obvious changes, except for standard_temp_file and save-trace.exp. I changed standard_temp_file the same way we changed standard_output_file (to always return a test file-specific directory). However, standard_temp_file is sometimes called when gdb_test_file_name is not set, such as in gdb_init. In that case, it returns the base temp directory. When running in parallel, I guess it means there is still a chance of conflict between parallel test invocations. I don't think I am making things worst than before though, since it was already the case. 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 it, it becomes absolute. I decided to just replace [pwd] with . (a dot) in that path to make it relative. It wouldn't work if the [pwd] was not a prefix of the standard output directory though. So I added a check to verify that precondition. gdb/testsuite/ChangeLog: * gdb.base/wrong_frame_bt_full.exp: Use standard_output_file to define object file path. * gdb.btrace/gcore.exp: Use standard_output_file to define core file path. * gdb.trace/save-trace.exp: Change relative path to be in the standard output directory. * lib/gdb.exp (standard_temp_file): Return a testfile-specific path when possible. * lib/opencl.exp (gdb_compile_opencl_hostapp): Use standard_output_file to define binfile. --- gdb/testsuite/gdb.base/wrong_frame_bt_full.exp | 5 +++-- gdb/testsuite/gdb.btrace/gcore.exp | 3 ++- gdb/testsuite/gdb.trace/save-trace.exp | 13 ++++++++++++- gdb/testsuite/lib/gdb.exp | 15 +++++++++++---- gdb/testsuite/lib/opencl.exp | 2 +- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp index a763470..cc4d879 100644 --- a/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp +++ b/gdb/testsuite/gdb.base/wrong_frame_bt_full.exp @@ -23,16 +23,17 @@ set main_testfile wrong_frame_bt_full-main set opaque_testfile wrong_frame_bt_full-opaque +set opaque_objfile [standard_output_file "$opaque_testfile.o"] if {[gdb_compile "${srcdir}/${subdir}/$opaque_testfile.c" \ - $opaque_testfile.o \ + $opaque_objfile \ object {}] != ""} { untested "failed to compile $opaque_testfile.c" return -1 } if {[gdb_compile \ - [list ${srcdir}/${subdir}/$main_testfile.c $opaque_testfile.o] \ + [list ${srcdir}/${subdir}/$main_testfile.c $opaque_objfile] \ [standard_output_file ${main_testfile}] \ executable {debug}] != ""} { untested "failed to build $main_testfile" diff --git a/gdb/testsuite/gdb.btrace/gcore.exp b/gdb/testsuite/gdb.btrace/gcore.exp index dead9c9..3eef2a1 100644 --- a/gdb/testsuite/gdb.btrace/gcore.exp +++ b/gdb/testsuite/gdb.btrace/gcore.exp @@ -38,4 +38,5 @@ gdb_test "next" ".*main\.3.*" gdb_test "record goto begin" ".*main\.2.*" # generate a core file - this used to assert -gdb_test "generate-core-file core" "Saved corefile core" +set corefile [standard_output_file core] +gdb_test "generate-core-file $corefile" "Saved corefile $corefile" 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" { diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 1fb05c4..861fe5d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4339,13 +4339,20 @@ 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 + global objdir subdir gdb_test_file_name + + # gdb_test_file_name may not be set, if we are not executing something + # specific to a test file (e.g. gdb_init). In that case, return the base + # temp directory. - if {[info exists GDB_PARALLEL]} { - return [make_gdb_parallel_path temp $basename] + if [info exists gdb_test_file_name] { + set dir [make_gdb_parallel_path temp $subdir $gdb_test_file_name] } else { - return $basename + set dir [make_gdb_parallel_path temp] } + + file mkdir $dir + return [file join $dir $basename] } # Set 'testfile', 'srcfile', and 'binfile'. diff --git a/gdb/testsuite/lib/opencl.exp b/gdb/testsuite/lib/opencl.exp index 11f3194..2feed8b 100644 --- a/gdb/testsuite/lib/opencl.exp +++ b/gdb/testsuite/lib/opencl.exp @@ -21,7 +21,7 @@ proc gdb_compile_opencl_hostapp {clsource executable options} { global srcdir objdir subdir set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c" - set binfile ${objdir}/${subdir}/${executable} + set binfile [standard_output_file ${executable}] set compile_flags [concat additional_flags=-I${srcdir}/lib/ additional_flags=-DCL_SOURCE=$clsource] set options_opencl [concat {debug} $compile_flags $options [list libs=-lOpenCL]] return [gdb_compile ${src} ${binfile} "executable" ${options_opencl}] -- 2.5.1