diff options
author | Jack Lloyd <[email protected]> | 2018-12-31 11:19:07 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-31 11:19:07 -0500 |
commit | 089e9887c9730fcb888561e1d63eae610cf0f6b4 (patch) | |
tree | ace64a9e71349fc46535f1533fb87a93a30c1323 /src/tests | |
parent | e6a8664c7b644225d7ee7f81e9e5c2800c69355b (diff) |
Add ability to skip a few named tests
This is sometimes useful when debugging
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/main.cpp | 3 | ||||
-rw-r--r-- | src/tests/test_runner.cpp | 18 | ||||
-rw-r--r-- | src/tests/tests.h | 9 |
3 files changed, 26 insertions, 4 deletions
diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 180daf1d4..995510ec7 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -60,7 +60,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 " + "--log-success --abort-on-first-fail --no-avoid-undefined --skip-tests= " "--run-long-tests --run-online-tests --test-runs=1 --drbg-seed= " "*suites"; @@ -76,6 +76,7 @@ int main(int argc, char* argv[]) const Botan_Tests::Test_Options opts( parser.get_arg_list("suites"), + parser.get_arg_list("skip-tests"), parser.get_arg_or("data-dir", "src/tests/data"), parser.get_arg("pkcs11-lib"), parser.get_arg("provider"), diff --git a/src/tests/test_runner.cpp b/src/tests/test_runner.cpp index e7862e90d..e346e9afa 100644 --- a/src/tests/test_runner.cpp +++ b/src/tests/test_runner.cpp @@ -91,6 +91,7 @@ class Testsuite_RNG final : public Botan::RandomNumberGenerator int Test_Runner::run(const Test_Options& opts) { std::vector<std::string> req = opts.requested_tests(); + const std::set<std::string> to_skip = opts.skip_tests(); if(req.empty()) { @@ -99,10 +100,18 @@ int Test_Runner::run(const Test_Options& opts) run the "essentials" to smoke test, then everything else in alphabetical order. */ - req = {"block", "stream", "hash", "mac", "modes", "aead", - "kdf", "pbkdf", "hmac_drbg", "util" + + std::vector<std::string> default_first = { + "block", "stream", "hash", "mac", "modes", "aead", + "kdf", "pbkdf", "hmac_drbg", "util" }; + for(auto s : default_first) + { + if(to_skip.count(s) == 0) + req.push_back(s); + } + std::set<std::string> all_others = Botan_Tests::Test::registered_tests(); if(opts.pkcs11_lib().empty()) @@ -126,6 +135,11 @@ int Test_Runner::run(const Test_Options& opts) all_others.erase(f); } + for(const std::string& f : to_skip) + { + all_others.erase(f); + } + req.insert(req.end(), all_others.begin(), all_others.end()); } else if(req.size() == 1 && req.at(0) == "pkcs11") diff --git a/src/tests/tests.h b/src/tests/tests.h index 02e1380c5..93e972900 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -54,6 +54,7 @@ class Test_Options Test_Options() = default; Test_Options(const std::vector<std::string>& requested_tests, + const std::vector<std::string>& skip_tests, const std::string& data_dir, const std::string& pkcs11_lib, const std::string& provider, @@ -66,6 +67,7 @@ class Test_Options bool abort_on_first_fail, bool undefined_behavior_allowed) : m_requested_tests(requested_tests), + m_skip_tests(skip_tests.begin(), skip_tests.end()), m_data_dir(data_dir), m_pkcs11_lib(pkcs11_lib), m_provider(provider), @@ -77,11 +79,15 @@ class Test_Options m_run_long_tests(run_long_tests), m_abort_on_first_fail(abort_on_first_fail), m_undefined_behavior_allowed(undefined_behavior_allowed) - {} + { + } const std::vector<std::string>& requested_tests() const { return m_requested_tests; } + const std::set<std::string>& skip_tests() const + { return m_skip_tests; } + const std::string& data_dir() const { return m_data_dir; } const std::string& pkcs11_lib() const { return m_pkcs11_lib; } @@ -114,6 +120,7 @@ class Test_Options private: std::vector<std::string> m_requested_tests; + std::set<std::string> m_skip_tests; std::string m_data_dir; std::string m_pkcs11_lib; std::string m_provider; |