From 965ba98bc0b86407df7e873c38e83709e0673db4 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Mon, 9 Sep 2024 15:29:37 -0400 Subject: [PATCH] fix(ci): thread sanitizer should actually run multi-threaded --- .github/workflows/linux.yml | 2 +- meson.options | 1 + src/iguana/tests/iguana_test.cc | 2 +- src/iguana/tests/meson.build | 6 +++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2140651b..84e80c32 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -38,7 +38,7 @@ jobs: { "id": "coverage", "CC": "gcc", "CXX": "g++", "opts": "-Dbuildtype=release -Dz_require_root=true -Db_coverage=true" }, { "id": "documentation", "CC": "gcc", "CXX": "g++", "opts": "-Dbuildtype=release -Dz_require_root=true -Dinstall_documentation=true" }, { "id": "address-sanitizer", "CC": "clang", "CXX": "clang++", "opts": "-Dbuildtype=debug -Dz_require_root=true -Db_sanitize=address -Db_lundef=false -Db_pie=true" }, - { "id": "thread-sanitizer", "CC": "clang", "CXX": "clang++", "opts": "-Dbuildtype=debug -Dz_require_root=true -Db_sanitize=thread -Db_lundef=false -Db_pie=true" }, + { "id": "thread-sanitizer", "CC": "clang", "CXX": "clang++", "opts": "-Dbuildtype=debug -Dz_require_root=true -Db_sanitize=thread -Db_lundef=false -Db_pie=true -Dtest_multithreading=4" }, { "id": "undefined-sanitizer", "CC": "clang", "CXX": "clang++", "opts": "-Dbuildtype=debug -Dz_require_root=true -Db_sanitize=undefined -Db_lundef=false -Db_pie=true" }, { "id": "leak-sanitizer", "CC": "clang", "CXX": "clang++", "opts": "-Dbuildtype=debug -Dz_require_root=true -Db_sanitize=leak -Db_lundef=false -Db_pie=true" }, { "id": "noROOT", "CC": "gcc", "CXX": "g++", "opts": "-Dbuildtype=release -Dz_require_root=false" }, diff --git a/meson.options b/meson.options index de851cf0..555ea7cd 100644 --- a/meson.options +++ b/meson.options @@ -11,6 +11,7 @@ option('test_data_file', type: 'string', value: '', description: ' option('test_num_events', type: 'string', value: '10', description: 'Number of events from `test_data_file` to test') option('test_output_dir', type: 'string', value: '', description: 'Output directory for tests. Must be an absolute path. If unspecified, tests will still run, but will not produce output files.') option('test_validator_all_stats', type: 'boolean', value: false, description: 'If true, use all statistics for validators, rather than `test_num_events`') +option('test_multithreading', type: 'integer', value: -1, description: 'if < 0, run single threaded, otherwise run tests with this many threads (use 0 for hardware max)') # expert options: the defaults should be reasonable for a local installation; different values may be preferred for installation in common areas option('z_install_envfile', type: 'boolean', value: true, description: 'Install a sourceable environment variable file') diff --git a/src/iguana/tests/iguana_test.cc b/src/iguana/tests/iguana_test.cc index 83431b53..8ed6e7ee 100644 --- a/src/iguana/tests/iguana_test.cc +++ b/src/iguana/tests/iguana_test.cc @@ -137,7 +137,7 @@ int main(int argc, char** argv) // parse option arguments int opt; - while((opt = getopt(argc, argv, "hf:n:a:b:p:t:o:v|")) != -1) { + while((opt = getopt(argc, argv, "hf:n:a:b:p:t:j:o:v|")) != -1) { switch(opt) { case 'h': return UsageOptions(2); diff --git a/src/iguana/tests/meson.build b/src/iguana/tests/meson.build index 57b78898..dce8265e 100644 --- a/src/iguana/tests/meson.build +++ b/src/iguana/tests/meson.build @@ -41,7 +41,11 @@ foreach algo : algo_dict 'algorithm-' + test_name_algo, test_exe, suite: [ 'algorithm' ], - args: test_args + [ '-n', '0' ],#get_option('test_num_events') ], + args: test_args + [ + '-n', get_option('test_num_events'), + '-j', get_option('test_multithreading').to_string(), + ], + is_parallel: get_option('test_multithreading') < 0, # don't parallelize these tests if `test_multithreading >= 0` env: project_test_env, timeout: 0, )