diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6ed13e62f0..0cf889d75fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,4 +124,4 @@ jobs: - name: tests env: CTEST_OUTPUT_ON_FAILURE: ON - run: make release-test -j3 + run: make release-test-ci -j3 diff --git a/Makefile b/Makefile index 928942721f4..a4519158307 100644 --- a/Makefile +++ b/Makefile @@ -98,6 +98,10 @@ release-test: mkdir -p $(builddir)/release cd $(builddir)/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release $(topdir) && $(MAKE) && $(MAKE) test +release-test-ci: + mkdir -p $(builddir)/release + cd $(builddir)/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release -D BUILD_SHARED_LIBS=ON $(topdir) && $(MAKE) && MONERO_PARALLEL_TEST_JOBS=nproc $(topdir)/tests/run-tests-parallel.sh + release-all: mkdir -p $(builddir)/release cd $(builddir)/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release $(topdir) && $(MAKE) diff --git a/tests/run-tests-parallel.sh b/tests/run-tests-parallel.sh new file mode 100755 index 00000000000..c574dfa3706 --- /dev/null +++ b/tests/run-tests-parallel.sh @@ -0,0 +1,68 @@ +#!/bin/bash -e + +# Copyright (c) 2014-2021, The Monero Project +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are +# permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be +# used to endorse or promote products derived from this software without specific +# prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# The parallelism celing can be controlled with MONERO_PARALLEL_TEST_JOBS env variable, +# for example: +# +# MONERO_PARALLEL_TEST_JOBS=1 tests/run-tests-parallel.sh +# MONERO_PARALLEL_TEST_JOBS=nproc tests/run-tests-parallel.sh +# +# The minimum between the ceiling and a currently selected reasonable number of threads is used in the end. +# The reasonable number is selected as a number, that delivers the solution in the shortest time. + +NUM_PROC_MAX_REASONABLE=2 # This might be increased, once the core_tests are divided into many more independent pieces or simply sped up +TESTS_EXCLUDED_REGEX="unit_tests|functional_tests_rpc" # These tests collide with core_tests + +if [ -z $MONERO_PARALLEL_TEST_JOBS ]; then + echo "No parallelism ceiling selected. Using nproc." + MONERO_PARALLEL_TEST_JOBS=$(nproc) +else + if [ "$MONERO_PARALLEL_TEST_JOBS" == "nproc" ]; then + MONERO_PARALLEL_TEST_JOBS=$(nproc) + fi + echo "Parallelism ceiling selected. Using $MONERO_PARALLEL_TEST_JOBS jobs." +fi + + +min() { + RET=$(($1 < $2 ? $1 : $2)) + echo $RET +} + +NUM_PROC_FINAL=$(min $NUM_PROC_MAX_REASONABLE $MONERO_PARALLEL_TEST_JOBS) +echo "Job number ceiling is $MONERO_PARALLEL_TEST_JOBS and the reasonable maximum is currently $NUM_PROC_MAX_REASONABLE." +echo "Using the minimum of the two, so $NUM_PROC_FINAL jobs." + +# Run the excluded tests first, then everything but excluded. +# In the current situation, the excluded tests are the most probable and quickest to fail, giving an early feedback. +time \ +ctest -j"${NUM_PROC_FINAL}" -R "${TESTS_EXCLUDED_REGEX}" && \ +ctest -j"${NUM_PROC_FINAL}" -E "${TESTS_EXCLUDED_REGEX}" +