From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31993 invoked by alias); 19 May 2017 06:29:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 31977 invoked by uid 89); 19 May 2017 06:29:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=excl, fd, D*pobox.com X-HELO: sasl.smtp.pobox.com Received: from pb-smtp1.pobox.com (HELO sasl.smtp.pobox.com) (64.147.108.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 May 2017 06:29:22 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 45035771C7; Fri, 19 May 2017 02:29:24 -0400 (EDT) Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 3B8B2771C6; Fri, 19 May 2017 02:29:24 -0400 (EDT) Received: from localhost.localdomain (unknown [76.215.41.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 5FE36771C3; Fri, 19 May 2017 02:29:23 -0400 (EDT) From: Daniel Santos To: Mike Stump , gcc-patches Cc: Rainer Orth , Bernd Edlinger Subject: [PATCH 1/2] [testsuite] Move non-standard parallelization support into new lib and fix flaw Date: Fri, 19 May 2017 06:29:00 -0000 Message-Id: <20170519063418.7836-1-daniel.santos@pobox.com> In-Reply-To: <3c867dc8-7d4a-ae82-c875-d03ff6d88776@pobox.com> References: <3c867dc8-7d4a-ae82-c875-d03ff6d88776@pobox.com> X-Pobox-Relay-ID: 7FC9C650-3C5C-11E7-87F6-EFB41968708C-06139138!pb-smtp1.pobox.com X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg01515.txt.bz2 This fixes a flaw in my parallelization code that caused it to fail when GCC_RUNTEST_PARALLELIZE_DIR wasn't set. It worked fine with make -j1, but failed with just make. As there could be other tests that might need to do their own paralellization, I'm moving the that code into it's own file under gcc/testsuite/lib. Signed-off-by: Daniel Santos --- .../gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp | 48 ++++-------- gcc/testsuite/lib/parallelize.exp | 88 ++++++++++++++++++++++ 2 files changed, 103 insertions(+), 33 deletions(-) create mode 100644 gcc/testsuite/lib/parallelize.exp diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp index e317af9bd85..77c40dbf349 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp +++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp @@ -30,13 +30,11 @@ if { (![istarget x86_64-*-*] && ![istarget i?86-*-*]) return } -global GCC_RUNTEST_PARALLELIZE_DIR - load_lib gcc-dg.exp +load_lib parallelize.exp proc runtest_ms_sysv { cflags generator_args } { - global GCC_UNDER_TEST HOSTCXX HOSTCXXFLAGS tmpdir srcdir subdir \ - parallel_dir next_test + global GCC_UNDER_TEST HOSTCXX HOSTCXXFLAGS tmpdir srcdir subdir set objdir "$tmpdir/ms-sysv" set generator "$tmpdir/ms-sysv-generate.exe" @@ -46,22 +44,6 @@ proc runtest_ms_sysv { cflags generator_args } { set ms_sysv_exe "$objdir/ms-sysv.exe" set status 0 set warn_flags "-Wall" - set this_test $next_test - incr next_test - - # Do parallelization here - if [catch {set fd [open "$parallel_dir/$this_test" \ - [list RDWR CREAT EXCL]]} ] { - if { [lindex $::errorCode 1] eq "EEXIST" } then { - # Another job is running this test - return - } else { - error "Failed to open $parallel_dir/$this_test: $::errorCode" - set status 1 - } - } else { - close $fd - } # Detect when hard frame pointers are enabled (or required) so we know not # to generate bp clobbers. @@ -73,9 +55,17 @@ proc runtest_ms_sysv { cflags generator_args } { set descr "$subdir CFLAGS=\"$cflags\" generator_args=\"$generator_args\"" verbose "$tmpdir: Running test $descr" 1 - # Cleanup any previous test in objdir - file delete -force $objdir - file mkdir $objdir + set status [parallel-should-run-test] + + if { $status == 1 } then { + return + } + + if { $status == 0 } then { + # Cleanup any previous test in objdir + file delete -force $objdir + file mkdir $objdir + } # Build the generator (only needs to be done once). set src "$srcdir/$subdir/gen.cc" @@ -148,16 +138,8 @@ proc runtest_ms_sysv { cflags generator_args } { } dg-init - -# Setup parallelization -set next_test 0 -set parallel_dir "$env(GCC_RUNTEST_PARALLELIZE_DIR)/abi-ms-sysv" -file mkdir "$env(GCC_RUNTEST_PARALLELIZE_DIR)" -file mkdir "$parallel_dir" - -if { ![file isdirectory "$parallel_dir"] } then { - error "Failed to create directory $parallel_dir: $::errorCode" - return +if { [parallel-init "ms2sysv"] != 0 } then { + return; } set gen_opts "-p0-5" diff --git a/gcc/testsuite/lib/parallelize.exp b/gcc/testsuite/lib/parallelize.exp new file mode 100644 index 00000000000..346a06f0fa0 --- /dev/null +++ b/gcc/testsuite/lib/parallelize.exp @@ -0,0 +1,88 @@ +# Functions for parallelizing tests that cannot use the standard dg-run, +# dg-runtest or gcc-dg-runtest for some reason. +# +# Copyright (C) 2017 Free Software Foundation, Inc. +# Contributed by Daniel Santos +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Under Section 7 of GPL version 3, you are granted additional +# permissions described in the GCC Runtime Library Exception, version +# 3.1, as published by the Free Software Foundation. +# +# You should have received a copy of the GNU General Public License and +# a copy of the GCC Runtime Library Exception along with this program; +# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +# . + +set is_parallel_build 0 +set parallel_next_test 0 +set parallel_dir "" + +# Setup parallelization directory and variables. +# +# Returns 0 upon success, -1 on failure. +proc parallel-init { uid } { + global is_parallel_build parallel_dir parallel_parallel_next_test env + + if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR) ] } { + set gcc_pardir "$env(GCC_RUNTEST_PARALLELIZE_DIR)" + set is_parallel_build 1 + set parallel_dir "${gcc_pardir}/${uid}" + if [catch {file mkdir "$gcc_pardir"}] { + if { [lindex $::errorCode 1] ne "EEXIST" } { + error "Failed to create directory $gcc_pardir: $::errorCode" + return -1 + } + } + if [catch {file mkdir "$parallel_dir"}] { + if { [lindex $::errorCode 1] ne "EEXIST" } { + error "Failed to create directory $parallel_dir: $::errorCode" + return -1 + } + } + } + return 0 +} + +# Test if a test should be run on by this job or not. +# +# Returns: +# 0 if the test should be run by this job +# 1 if it should not, +# -1 upon error. +proc parallel-should-run-test {} { + global is_parallel_build parallel_dir parallel_next_test + + # Not a parallel build + if { $is_parallel_build != 1 } { + return 0 + } + + set this_test $parallel_next_test + incr parallel_next_test + + if [catch {set fd [open "$parallel_dir/$this_test" \ + [list RDWR CREAT EXCL]]} ] { + if { [lindex $::errorCode 1] eq "EEXIST" } then { + # Another job is running this test + return 1 + } else { + error "Failed to open $parallel_dir/$this_test: $::errorCode" + return -1 + } + } else { + close $fd + return 0 + } +} -- 2.11.0