aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Carlier <[email protected]>2019-04-12 21:26:14 +0100
committerDavid Carlier <[email protected]>2019-04-12 22:12:42 +0100
commitf136bdf46b706980cf73ec7d9d3aa3c54089d392 (patch)
treedfe0435342f838882191f2857c5aba641eedaad0
parent56977661a8509232a8307e8eab2e0b8636af3b43 (diff)
Using preprocessor for the tests
-rw-r--r--src/scripts/ubsan-blacklist.txt2
-rw-r--r--src/tests/main.cpp3
-rw-r--r--src/tests/test_dl_group.cpp17
-rw-r--r--src/tests/test_ffi.cpp15
-rw-r--r--src/tests/tests.h17
-rw-r--r--src/tests/unit_ecdsa.cpp13
6 files changed, 24 insertions, 43 deletions
diff --git a/src/scripts/ubsan-blacklist.txt b/src/scripts/ubsan-blacklist.txt
deleted file mode 100644
index c9d310a50..000000000
--- a/src/scripts/ubsan-blacklist.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-src:*dl_group.cpp
-src:*ecc_key.cpp
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index 3cf7526f0..fa158c6c5 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -96,8 +96,7 @@ int main(int argc, char* argv[])
parser.flag_set("log-success"),
parser.flag_set("run-online-tests"),
parser.flag_set("run-long-tests"),
- parser.flag_set("abort-on-first-fail"),
- parser.flag_set("no-avoid-undefined"));
+ parser.flag_set("abort-on-first-fail"));
#if defined(BOTAN_HAS_OPENSSL)
if(opts.provider().empty() || opts.provider() == "openssl")
diff --git a/src/tests/test_dl_group.cpp b/src/tests/test_dl_group.cpp
index 159454b3f..df5aaa8ce 100644
--- a/src/tests/test_dl_group.cpp
+++ b/src/tests/test_dl_group.cpp
@@ -44,15 +44,14 @@ class DL_Group_Tests final : public Test
"DL_Group uninitialized",
[]() { Botan::DL_Group dl; dl.get_p(); });
- if(Test::options().undefined_behavior_allowed())
- {
- result.test_throws("Bad generator param",
- "DL_Group unknown PrimeType",
- []() {
- auto invalid_type = static_cast<Botan::DL_Group::PrimeType>(9);
- Botan::DL_Group dl(Test::rng(), invalid_type, 1024);
- });
- }
+#if !defined(BOTAN_HAS_SANITIZER_UNDEFINED)
+ result.test_throws("Bad generator param",
+ "DL_Group unknown PrimeType",
+ []() {
+ auto invalid_type = static_cast<Botan::DL_Group::PrimeType>(9);
+ Botan::DL_Group dl(Test::rng(), invalid_type, 1024);
+ });
+#endif
return result;
}
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp
index de429bde9..696a70377 100644
--- a/src/tests/test_ffi.cpp
+++ b/src/tests/test_ffi.cpp
@@ -1103,14 +1103,13 @@ class FFI_Unit_Tests final : public Test
// delete of null is ok/ignored
TEST_FFI_RC(0, botan_hash_destroy, (nullptr));
- if(Test::options().undefined_behavior_allowed())
- {
- // Confirm that botan_x_destroy checks the argument type
- botan_mp_t mp;
- botan_mp_init(&mp);
- TEST_FFI_RC(BOTAN_FFI_ERROR_INVALID_OBJECT, botan_hash_destroy, (reinterpret_cast<botan_hash_t>(mp)));
- TEST_FFI_RC(0, botan_mp_destroy, (mp));
- }
+#if !defined(BOTAN_HAS_SANITIZER_UNDEFINED)
+ // Confirm that botan_x_destroy checks the argument type
+ botan_mp_t mp;
+ botan_mp_init(&mp);
+ TEST_FFI_RC(BOTAN_FFI_ERROR_INVALID_OBJECT, botan_hash_destroy, (reinterpret_cast<botan_hash_t>(mp)));
+ TEST_FFI_RC(0, botan_mp_destroy, (mp));
+#endif
std::set<std::string> errors;
for(int i = -100; i != 50; ++i)
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 267026f35..f496c3cfb 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -65,8 +65,7 @@ class Test_Options
bool log_success,
bool run_online_tests,
bool run_long_tests,
- bool abort_on_first_fail,
- bool undefined_behavior_allowed) :
+ bool abort_on_first_fail) :
m_requested_tests(requested_tests),
m_skip_tests(skip_tests.begin(), skip_tests.end()),
m_data_dir(data_dir),
@@ -79,8 +78,7 @@ class Test_Options
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_undefined_behavior_allowed(undefined_behavior_allowed)
+ m_abort_on_first_fail(abort_on_first_fail)
{
}
@@ -112,16 +110,6 @@ class Test_Options
bool verbose() const { return m_verbose; }
- bool undefined_behavior_allowed() const
- {
-#if defined(BOTAN_HAS_SANITIZER_UNDEFINED)
- return m_undefined_behavior_allowed;
-#else
- BOTAN_UNUSED(m_undefined_behavior_allowed);
- return true;
-#endif
- }
-
private:
std::vector<std::string> m_requested_tests;
std::set<std::string> m_skip_tests;
@@ -136,7 +124,6 @@ class Test_Options
bool m_run_online_tests;
bool m_run_long_tests;
bool m_abort_on_first_fail;
- bool m_undefined_behavior_allowed;
};
/*
diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp
index 88c3a4d05..d87d54f5e 100644
--- a/src/tests/unit_ecdsa.cpp
+++ b/src/tests/unit_ecdsa.cpp
@@ -299,14 +299,13 @@ Test::Result test_encoding_options()
result.test_eq("Hybrid point same size as uncompressed",
enc_uncompressed.size(), enc_hybrid.size());
- if(Test::options().undefined_behavior_allowed())
- {
- auto invalid_format = static_cast<Botan::PointGFp::Compression_Type>(99);
+#if !defined(BOTAN_HAS_SANITIZER_UNDEFINED)
+ auto invalid_format = static_cast<Botan::PointGFp::Compression_Type>(99);
- result.test_throws("Invalid point format throws",
- "Invalid point encoding for EC_PublicKey",
- [&] { key.set_point_encoding(invalid_format); });
- }
+ result.test_throws("Invalid point format throws",
+ "Invalid point encoding for EC_PublicKey",
+ [&] { key.set_point_encoding(invalid_format); });
+#endif
return result;
}