tests: allow disabling threading when debugging tests
with `-threads 1`
This commit is contained in:
parent
88a9cb6bb4
commit
c5efefd4b7
|
|
@ -13,6 +13,13 @@ static std::unique_ptr<tbb::global_control> tbbGlobalControl;
|
|||
|
||||
void configureTBB(int maxthreads, bool lowPriority)
|
||||
{
|
||||
if (tbbGlobalControl) {
|
||||
logging::print("ignoring multiple configureTBB calls\n");
|
||||
// only allow calling once per process, so we can disable threading in test_main.cc
|
||||
// and further attempts to re-enable it will be ignored
|
||||
return;
|
||||
}
|
||||
|
||||
tbbGlobalControl = std::unique_ptr<tbb::global_control>();
|
||||
|
||||
if (maxthreads > 0) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include <doctest/doctest.h>
|
||||
|
||||
#include <common/log.hh>
|
||||
#include <common/threads.hh>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
|
@ -10,6 +11,14 @@ int main(int argc, char **argv)
|
|||
// writing console colors within test case output breaks doctest/CLion integration
|
||||
logging::enable_color_codes = false;
|
||||
|
||||
// parse "-threads 1"
|
||||
for (int i = 1; i < argc - 1; ++i) {
|
||||
if (!strcmp("-threads", argv[i])) {
|
||||
configureTBB(atoi(argv[i + 1]), false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
doctest::Context context;
|
||||
|
||||
context.applyCommandLine(argc, argv);
|
||||
|
|
|
|||
Loading…
Reference in New Issue