Skip to content

Commit 87526e0

Browse files
Enable a coarse-grained prallelism when running regression test jobs via Makefiles
Previously, the makefiles ran the regression test target sequentially, regardless of any -jN option passed to make. In this commit, an extra 'test-batch' target is added which enables running the same regression tests, but with each top-level test directory run as a seperate target. To avoid horribly interleaved output from parallel test jobs, GNU parallel is used to execute the test jobs. This provides line bufferering, such that output from each job is prefixed with a job number. This matches the behaviour of ctest used in the CMake based builds.
1 parent fdba57c commit 87526e0

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

.travis.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
- libwww-perl
6363
- g++-5
6464
- libubsan0
65+
- parallel
6566
before_install:
6667
- mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc
6768
# env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer"
@@ -76,7 +77,7 @@ jobs:
7677
compiler: gcc
7778
cache: ccache
7879
before_install:
79-
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache
80+
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache parallel
8081
- export PATH=$PATH:/usr/local/opt/ccache/libexec
8182
env: COMPILER="ccache g++"
8283

@@ -87,7 +88,7 @@ jobs:
8788
compiler: clang
8889
cache: ccache
8990
before_install:
90-
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache
91+
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache parallel
9192
- export PATH=$PATH:/usr/local/opt/ccache/libexec
9293
env:
9394
- COMPILER="ccache clang++"
@@ -132,6 +133,7 @@ jobs:
132133
- clang-3.7
133134
- libstdc++-5-dev
134135
- libubsan0
136+
- parallel
135137
before_install:
136138
- mkdir bin ; ln -s /usr/bin/clang-3.7 bin/gcc
137139
- export CCACHE_CPP2=yes
@@ -258,7 +260,7 @@ install:
258260

259261
script:
260262
- if [ -e bin/gcc ] ; then export PATH=$PWD/bin:$PATH ; fi ;
261-
- env UBSAN_OPTIONS=print_stacktrace=1 make -C regression test "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j2
263+
- env UBSAN_OPTIONS=print_stacktrace=1 make -C regression test-parallel "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j2 JOBS=2
262264
- make -C unit "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j2
263265
- make -C unit test
264266

regression/Makefile

+31-6
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,40 @@ DIRS = ansi-c \
2020
test-script \
2121
# Empty last line
2222

23-
# Check for the existence of $dir. Tests under goto-gcc cannot be run on
24-
# Windows, so appveyor.yml unlinks the entire directory under Windows.
23+
# Tests under goto-gcc cannot be run on Windows, so appveyor.yml unlinks
24+
# the entire directory under Windows. This variable will contain the list
25+
# of directories that actually exist on the current platform.
26+
PLATFORM_DIRS = $(wildcard $(DIRS))
27+
28+
# Run all test directories in sequence
29+
.PHONY: test
2530
test:
26-
@for dir in $(DIRS); do \
27-
if [ -d "$$dir" ]; then \
28-
$(MAKE) -C "$$dir" test || exit 1; \
29-
fi; \
31+
@for dir in $(PLATFORM_DIRS); do \
32+
$(MAKE) "$$dir" || exit 1; \
3033
done;
3134

35+
# Pattern to execute a single test suite directory
36+
.PHONY: $(PLATFORM_DIRS)
37+
$(PLATFORM_DIRS):
38+
@echo "Running $@..." ;
39+
$(MAKE) -C "$@" test || exit 1;
40+
41+
# Run all test directories using GNU Parallel
42+
.PHONY: test-parallel
43+
.NOTPARALLEL: test-parallel
44+
test-parallel:
45+
@echo "Building with $(JOBS) jobs"
46+
parallel \
47+
--halt soon,fail=1 \
48+
--tag \
49+
--tagstring '{#}:' \
50+
--linebuffer \
51+
--jobs $(JOBS) \
52+
$(MAKE) "{}" \
53+
::: $(PLATFORM_DIRS)
54+
55+
56+
.PHONY: clean
3257
clean:
3358
@for dir in *; do \
3459
if [ -d "$$dir" ]; then \

0 commit comments

Comments
 (0)