Repository: randombit/botan
Pull request #2071 (2019-08-17 13:19:12)

Default to running the tests in threaded mode


Patch:
diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py
index bb59245f5..6f746edf3 100755
--- a/src/scripts/ci_build.py
+++ b/src/scripts/ci_build.py
@@ -50,8 +50,9 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro
     test_prefix = []
     test_cmd = [os.path.join(root_dir, 'botan-test')]
 
-    if target in ['shared', 'static', 'sanitizer', 'fuzzers', 'gcc4.8', 'cross-i386', 'bsi', 'nist']:
-        test_cmd += ['--test-threads=%d' % (get_concurrency())]
+    if target not in ['shared', 'static', 'sanitizer', 'fuzzers', 'gcc4.8', 'cross-i386', 'bsi', 'nist']:
+        # threads just slow down valgrind, qemu, etc
+        test_cmd += ['--test-threads=1']
 
     fast_tests = ['block', 'aead', 'hash', 'stream', 'mac', 'modes', 'kdf',
                   'hmac_drbg', 'hmac_drbg_unit',


Test patch:
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index fa158c6c5..b6f7c4188 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -61,7 +61,7 @@ int main(int argc, char* argv[])
       const std::string arg_spec =
          "botan-test --verbose --help --data-dir= --pkcs11-lib= --provider= "
          "--log-success --abort-on-first-fail --no-avoid-undefined --skip-tests= "
-         "--test-threads=1 --run-long-tests --run-online-tests --test-runs=1 --drbg-seed= "
+         "--test-threads=0 --run-long-tests --run-online-tests --test-runs=1 --drbg-seed= "
          "*suites";
 
       Botan_CLI::Argument_Parser parser(arg_spec);
@@ -74,15 +74,6 @@ int main(int argc, char* argv[])
          return 0;
          }
 
-#if defined(BOTAN_TARGET_OS_HAS_POSIX1) && defined(BOTAN_TARGET_OS_HAS_THREADS)
-      // The mlock pool becomes a major contention point when many
-      // threads are running.
-      if(parser.get_arg_sz("test-threads") != 1)
-         {
-         ::setenv("BOTAN_MLOCK_POOL_SIZE", "0", 1);
-         }
-#endif
-
       const Botan_Tests::Test_Options opts(
          parser.get_arg_list("suites"),
          parser.get_arg_list("skip-tests"),
diff --git a/src/tests/test_runner.cpp b/src/tests/test_runner.cpp
index 240ce93ca..d5f07e504 100644
--- a/src/tests/test_runner.cpp
+++ b/src/tests/test_runner.cpp
@@ -306,12 +306,11 @@ size_t Test_Runner::run_tests(const std::vector<std::string>& tests_to_run,
                               size_t tot_test_runs)
    {
    size_t tests_ran = 0, tests_failed = 0;
-
    const uint64_t start_time = Botan_Tests::Test::timestamp();
 
+#if defined(BOTAN_HAS_THREAD_UTILS) && defined(BOTAN_TARGET_OS_HAS_THREAD_LOCAL)
    if(test_threads != 1)
       {
-#if defined(BOTAN_HAS_THREAD_UTILS) && defined(BOTAN_TARGET_OS_HAS_THREAD_LOCAL)
       // If 0 then we let thread pool select the count
       Botan::Thread_Pool pool(test_threads);
 
@@ -336,9 +335,12 @@ size_t Test_Runner::run_tests(const std::vector<std::string>& tests_to_run,
       output() << test_summary(test_run, tot_test_runs, total_ns, tests_ran, tests_failed);
 
       return tests_failed;
-#else
-      output() << "Running tests in multiple threads not enabled in this build\n";
+      }
 #endif
+
+   if(test_threads > 1)
+      {
+      output() << "Running tests in multiple threads not enabled in this build\n";
       }
 
    for(auto const& test_name : tests_to_run)