Skip to content

Commit

Permalink
tests: Set test concurrency in the CMake cache
Browse files Browse the repository at this point in the history
By using a CMake cache variable, it allows developers to easily change
the default of 2 with CMake via

    ./test.py -c 4

or

    cmake -DSeastar_UNIT_TEST_SMP=4 .
  • Loading branch information
Jesse Haber-Kucharsky committed Jan 24, 2019
1 parent 8338148 commit 821ad54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
parser.add_argument('--mode', choices=seastar_cmake.SUPPORTED_MODES, help="Run only tests for given build mode")
parser.add_argument('--timeout', action="store",default="300",type=int, help="timeout value for test execution")
parser.add_argument('--jenkins', action="store",help="jenkins output file prefix")
parser.add_argument('--smp', '-c', action="store",default='2',type=int,help="Number of threads for multi-core tests")
parser.add_argument('--verbose', '-v', action = 'store_true', default = False,
help = 'Verbose reporting')
args = parser.parse_args()
Expand All @@ -44,6 +45,7 @@ def run_tests(mode):
TRANSLATED_CMAKE_ARGS = [
tr(args.timeout, 'TEST_TIMEOUT'),
tr(args.fast, 'EXECUTE_ONLY_FAST_TESTS'),
tr(args.smp, 'UNIT_TEST_SMP'),
tr(args.jenkins, 'JENKINS', value_when_none=''),
]

Expand Down
11 changes: 7 additions & 4 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
# Logical target for all unit tests.
add_custom_target (unit_tests)

set (Seastar_UNIT_TEST_SMP
2
CACHE
STRING
"Run unit tests with this many cores.")

#
# Define a new unit test with the given name.
#
Expand Down Expand Up @@ -61,9 +67,6 @@ function (seastar_add_test name)
BOOST
CUSTOM)

# Run all Seastar tests on two cores by default.
set (num_cores 2)

cmake_parse_arguments (parsed_args
""
"WORKING_DIRECTORY;KIND"
Expand Down Expand Up @@ -97,7 +100,7 @@ function (seastar_add_test name)
list (APPEND args ${jenkins_args})
endif ()

list (APPEND args -- -c ${num_cores})
list (APPEND args -- -c ${Seastar_UNIT_TEST_SMP})
list (APPEND args ${parsed_args_RUN_ARGS})
elseif (parsed_args_KIND STREQUAL "BOOST")
set (args "")
Expand Down

0 comments on commit 821ad54

Please sign in to comment.