From 56977661a8509232a8307e8eab2e0b8636af3b43 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 12 Apr 2019 15:36:43 +0000 Subject: Proposal to silent, when wished, some "false positives" when using sanitizers. --- src/scripts/ubsan-blacklist.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/scripts/ubsan-blacklist.txt (limited to 'src') diff --git a/src/scripts/ubsan-blacklist.txt b/src/scripts/ubsan-blacklist.txt new file mode 100644 index 000000000..c9d310a50 --- /dev/null +++ b/src/scripts/ubsan-blacklist.txt @@ -0,0 +1,2 @@ +src:*dl_group.cpp +src:*ecc_key.cpp -- cgit v1.2.3 From f136bdf46b706980cf73ec7d9d3aa3c54089d392 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 12 Apr 2019 21:26:14 +0100 Subject: Using preprocessor for the tests --- src/scripts/ubsan-blacklist.txt | 2 -- src/tests/main.cpp | 3 +-- src/tests/test_dl_group.cpp | 17 ++++++++--------- src/tests/test_ffi.cpp | 15 +++++++-------- src/tests/tests.h | 17 ++--------------- src/tests/unit_ecdsa.cpp | 13 ++++++------- 6 files changed, 24 insertions(+), 43 deletions(-) delete mode 100644 src/scripts/ubsan-blacklist.txt (limited to 'src') 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(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(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(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(mp))); + TEST_FFI_RC(0, botan_mp_destroy, (mp)); +#endif std::set 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 m_requested_tests; std::set 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(99); +#if !defined(BOTAN_HAS_SANITIZER_UNDEFINED) + auto invalid_format = static_cast(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; } -- cgit v1.2.3