From: Daniel Santos <daniel.santos@pobox.com>
To: Mike Stump <mikestump@comcast.net>,
gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>,
Bernd Edlinger <bernd.edlinger@hotmail.de>
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 [thread overview]
Message-ID: <20170519063418.7836-1-daniel.santos@pobox.com> (raw)
In-Reply-To: <3c867dc8-7d4a-ae82-c875-d03ff6d88776@pobox.com>
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 <daniel.santos@pobox.com>
---
.../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 <daniel.santos@pobox.com>
+#
+# 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
+# <http://www.gnu.org/licenses/>.
+
+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
next prev parent reply other threads:[~2017-05-19 6:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 6:29 [PATCH 0/2] [testsuite] PR80759 Fix test breakages on i386-pc-solaris2.* Daniel Santos
2017-05-19 6:29 ` Daniel Santos [this message]
2017-05-19 6:50 ` [PATCH 2/2] [testsuite] PR 80759 Remove gas extensions from do-test.S, fix other problems Daniel Santos
2017-05-19 8:54 ` Rainer Orth
2017-05-20 0:38 ` Daniel Santos
2017-05-19 9:04 ` [PATCH 0/2] [testsuite] PR80759 Fix test breakages on i386-pc-solaris2.* Rainer Orth
2017-07-02 5:06 ` [PATCH v2 0/2] [testsuite, libgcc] PR80759 Fix FAILs on Solaris and Darwin Daniel Santos
2017-07-02 5:10 ` [PATCH 1/2] [testsuite] PR80759 fix tests " Daniel Santos
2017-07-02 5:10 ` [PATCH 2/2] [libgcc]: PR80759 fixes for Solaris & Darwin Daniel Santos
2017-07-17 16:11 ` PING: [PATCH v2 0/2] [testsuite, libgcc] PR80759 Fix FAILs on Solaris and Darwin Daniel Santos
2017-07-17 16:38 ` Mike Stump
2017-07-17 18:50 ` Uros Bizjak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170519063418.7836-1-daniel.santos@pobox.com \
--to=daniel.santos@pobox.com \
--cc=bernd.edlinger@hotmail.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=mikestump@comcast.net \
--cc=ro@CeBiTec.Uni-Bielefeld.DE \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).