aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-04-11 18:05:40 -0400
committerJack Lloyd <[email protected]>2018-04-11 18:05:40 -0400
commit87c697920206ac7ab0f757d3ec0c5550defd2517 (patch)
tree61da156f5a2c4bf65de38f93cb432adc1f233f1c
parentc6a90da3f5a43411c6cd5a481b4af6a2b301cc11 (diff)
Fix the botan-test --verbose flag, which did nothing
It used to do something, then I broke it.
-rw-r--r--src/tests/main.cpp1
-rw-r--r--src/tests/test_dl_group.cpp2
-rw-r--r--src/tests/test_ffi.cpp2
-rw-r--r--src/tests/test_ocsp.cpp2
-rw-r--r--src/tests/test_runner.cpp3
-rw-r--r--src/tests/test_tests.cpp2
-rw-r--r--src/tests/tests.cpp8
-rw-r--r--src/tests/tests.h32
-rw-r--r--src/tests/unit_ecdsa.cpp2
9 files changed, 30 insertions, 24 deletions
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index 0e0360783..ef1a16ba7 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -81,6 +81,7 @@ int main(int argc, char* argv[])
parser.get_arg("provider"),
parser.get_arg("drbg-seed"),
parser.get_arg_sz("test-runs"),
+ parser.flag_set("verbose"),
parser.flag_set("log-success"),
parser.flag_set("run-online-tests"),
parser.flag_set("run-long-tests"),
diff --git a/src/tests/test_dl_group.cpp b/src/tests/test_dl_group.cpp
index 064cb2221..64a59f22c 100644
--- a/src/tests/test_dl_group.cpp
+++ b/src/tests/test_dl_group.cpp
@@ -44,7 +44,7 @@ class DL_Group_Tests final : public Test
"DL_Group uninitialized",
[]() { Botan::DL_Group dl; dl.get_p(); });
- if(Test::no_avoid_undefined_behavior())
+ if(Test::options().undefined_behavior_allowed())
{
result.test_throws("Bad generator param",
"Invalid argument DL_Group unknown PrimeType",
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp
index d5627a45f..b1c117dcc 100644
--- a/src/tests/test_ffi.cpp
+++ b/src/tests/test_ffi.cpp
@@ -842,7 +842,7 @@ class FFI_Unit_Tests final : public Test
// delete of null is ok/ignored
TEST_FFI_RC(0, botan_hash_destroy, (nullptr));
- if(Test::no_avoid_undefined_behavior())
+ if(Test::options().undefined_behavior_allowed())
{
// Confirm that botan_x_destroy checks the argument type
botan_mp_t mp;
diff --git a/src/tests/test_ocsp.cpp b/src/tests/test_ocsp.cpp
index 4b344891e..3b681e193 100644
--- a/src/tests/test_ocsp.cpp
+++ b/src/tests/test_ocsp.cpp
@@ -228,7 +228,7 @@ class OCSP_Tests final : public Test
results.push_back(test_response_verification_softfail());
#if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS)
- if(Test::run_online_tests())
+ if(Test::options().run_online_tests())
{
results.push_back(test_online_request());
}
diff --git a/src/tests/test_runner.cpp b/src/tests/test_runner.cpp
index 2816d386d..849c1a8a9 100644
--- a/src/tests/test_runner.cpp
+++ b/src/tests/test_runner.cpp
@@ -208,8 +208,7 @@ std::string report_out(const std::vector<Botan_Tests::Test::Result>& results,
for(auto const& result : combined)
{
- const bool verbose = false;
- out << result.second.result_string(verbose);
+ out << result.second.result_string();
tests_failed += result.second.tests_failed();
tests_ran += result.second.tests_run();
}
diff --git a/src/tests/test_tests.cpp b/src/tests/test_tests.cpp
index 52db0679a..3a52b85b9 100644
--- a/src/tests/test_tests.cpp
+++ b/src/tests/test_tests.cpp
@@ -188,7 +188,7 @@ class Test_Tests final : public Test
if(test_result.tests_failed() > 0)
{
result.test_success("Got expected failure for " + what);
- const std::string result_str = test_result.result_string(true);
+ const std::string result_str = test_result.result_string();
result.confirm("result string contains FAIL",
result_str.find("FAIL") != std::string::npos);
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index e51496ab9..beb7e770d 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -141,7 +141,7 @@ bool Test::Result::test_throws(const std::string& what, const std::string& expec
bool Test::Result::test_success(const std::string& note)
{
- if(Test::log_success())
+ if(Test::options().log_success())
{
test_note(note);
}
@@ -165,7 +165,7 @@ bool Test::Result::test_failure(const std::string& err)
{
m_fail_log.push_back(err);
- if(m_who != "Failing Test" && Test::abort_on_first_fail())
+ if(Test::options().abort_on_first_fail() && m_who != "Failing Test")
{
std::abort();
}
@@ -415,8 +415,10 @@ std::string Test::format_time(uint64_t ns)
return o.str();
}
-std::string Test::Result::result_string(bool verbose) const
+std::string Test::Result::result_string() const
{
+ const bool verbose = Test::options().verbose();
+
if(tests_run() == 0 && !verbose)
{
return "";
diff --git a/src/tests/tests.h b/src/tests/tests.h
index c3affb6ef..87ea16379 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -58,22 +58,24 @@ class Test_Options
const std::string& provider,
const std::string& drbg_seed,
size_t test_runs,
+ bool verbose,
bool log_success,
bool run_online_tests,
bool run_long_tests,
bool abort_on_first_fail,
- bool no_avoid_undefined) :
+ bool undefined_behavior_allowed) :
m_requested_tests(requested_tests),
m_data_dir(data_dir),
m_pkcs11_lib(pkcs11_lib),
m_provider(provider),
m_drbg_seed(drbg_seed),
m_test_runs(test_runs),
+ m_verbose(verbose),
m_log_success(log_success),
m_run_online_tests(run_online_tests),
m_run_long_tests(run_long_tests),
m_abort_on_first_fail(abort_on_first_fail),
- m_no_avoid_undefined(no_avoid_undefined)
+ m_undefined_behavior_allowed(undefined_behavior_allowed)
{}
const std::vector<std::string>& requested_tests() const
@@ -97,12 +99,14 @@ class Test_Options
bool abort_on_first_fail() const { return m_abort_on_first_fail; }
- bool no_avoid_undefined_behavior() const
+ bool verbose() const { return m_verbose; }
+
+ bool undefined_behavior_allowed() const
{
#if defined(BOTAN_HAS_SANITIZER_UNDEFINED)
- return m_no_avoid_undefined;
+ return m_undefined_behavior_allowed;
#else
- BOTAN_UNUSED(m_no_avoid_undefined);
+ BOTAN_UNUSED(m_undefined_behavior_allowed);
return true;
#endif
}
@@ -114,11 +118,12 @@ class Test_Options
std::string m_provider;
std::string m_drbg_seed;
size_t m_test_runs;
+ bool m_verbose;
bool m_log_success;
bool m_run_online_tests;
bool m_run_long_tests;
bool m_abort_on_first_fail;
- bool m_no_avoid_undefined;
+ bool m_undefined_behavior_allowed;
};
/*
@@ -161,7 +166,8 @@ class Test
{
return m_who;
}
- std::string result_string(bool verbose) const;
+
+ std::string result_string() const;
static Result Failure(const std::string& who,
const std::string& what)
@@ -474,13 +480,11 @@ class Test
static void set_test_rng(std::unique_ptr<Botan::RandomNumberGenerator> rng);
- static bool no_avoid_undefined_behavior() { return m_opts.no_avoid_undefined_behavior(); }
- static bool log_success() { return m_opts.log_success(); }
- static bool run_online_tests() { return m_opts.run_online_tests(); }
- static bool run_long_tests() { return m_opts.run_long_tests(); }
- static bool abort_on_first_fail() { return m_opts.abort_on_first_fail(); }
- static const std::string& data_dir() { return m_opts.data_dir(); }
- static const std::string& pkcs11_lib() { return m_opts.pkcs11_lib(); }
+ static const Test_Options& options() { return m_opts; }
+
+ static bool run_long_tests() { return options().run_long_tests(); }
+ static const std::string& data_dir() { return options().data_dir(); }
+ static const std::string& pkcs11_lib() { return options().pkcs11_lib(); }
static std::string temp_file_name(const std::string& basename);
diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp
index e21d4764c..260eb8571 100644
--- a/src/tests/unit_ecdsa.cpp
+++ b/src/tests/unit_ecdsa.cpp
@@ -299,7 +299,7 @@ Test::Result test_encoding_options()
result.test_eq("Hybrid point same size as uncompressed",
enc_uncompressed.size(), enc_hybrid.size());
- if(Test::no_avoid_undefined_behavior())
+ if(Test::options().undefined_behavior_allowed())
{
auto invalid_format = static_cast<Botan::PointGFp::Compression_Type>(99);