From f7118b53a88602eb0e213a0603be820df181a520 Mon Sep 17 00:00:00 2001 From: Leonid Fedorov <79837786+mariadb-LeonidFedorov@users.noreply.github.com> Date: Thu, 2 Feb 2023 16:08:01 +0300 Subject: [PATCH] Turn on ASAN for unitests (#2719) Fix asan error on compression tests Fix warn of nonreturn function --- tests/CMakeLists.txt | 3 +++ tests/compression-tests.cpp | 2 +- utils/common/nullvaluemanip.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 647b4aeb1..a79261d59 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,7 @@ include_directories( ${ENGINE_COMMON_INCLUDES} ${ENGINE_BLOCKCACHE_INCLUDE} ${ENGINE_PRIMPROC_INCLUDE} ) +MY_CHECK_AND_SET_COMPILER_FLAG("-U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO) +MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=address -fsanitize-address-use-after-scope -fPIC") + if (WITH_UNITTESTS) cmake_policy(SET CMP0054 NEW) diff --git a/tests/compression-tests.cpp b/tests/compression-tests.cpp index 256b81f79..9b6523f01 100644 --- a/tests/compression-tests.cpp +++ b/tests/compression-tests.cpp @@ -59,7 +59,7 @@ TEST_F(CompressionTest, LZ4CanCompress) std::unique_ptr compressor(new compress::CompressInterfaceLZ4()); - size_t originalSize = originalData.size(); + size_t originalSize = originalData.size() + 1; size_t compressedSize = compressor->maxCompressedSize(originalSize); std::unique_ptr compressedData(new char[compressedSize]); std::memset(compressedData.get(), 0, compressedSize); diff --git a/utils/common/nullvaluemanip.cpp b/utils/common/nullvaluemanip.cpp index 76e373511..ff5836d2d 100644 --- a/utils/common/nullvaluemanip.cpp +++ b/utils/common/nullvaluemanip.cpp @@ -198,7 +198,7 @@ int64_t getSignedNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidt os << "getSignedNullValue(): got bad column type (" << t << "). Width=" << colWidth << endl; throw logic_error(os.str()); } - + return 0; } } // namespace utils