Skip to content

Commit

Permalink
verifyall.sh also Debug
Browse files Browse the repository at this point in the history
this shows all ubsan violations.
fix gxhash verification values for Debug.
add Asan for C files.
show failing verifications in red.
  • Loading branch information
rurban committed Dec 15, 2024
1 parent da9db5f commit fae6e9b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
24 changes: 14 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ if(NOT CMAKE_BUILD_TYPE)
CACHE STRING "Choose the type of build, options are: Debug Release
RelWithDebInfo MinSizeRel Asan." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")

include(CheckTypeSize)
check_type_size(__int64 __INT64)
Expand Down Expand Up @@ -214,12 +214,9 @@ if(CMAKE_COMPILER_IS_GNUCC
set(CRC_PCLMUL_SRC crc32-pclmul_asm.S)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined -DHAVE_ASAN -DHAVE_UBSAN")
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined -DHAVE_ASAN -DHAVE_UBSAN"
"${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -fno-omit-frame-pointer -fsanitize=address,undefined -DHAVE_ASAN -DHAVE_UBSAN"
)
set(CMAKE_LINKER_FLAGS_DEBUG
"${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined"
Expand Down Expand Up @@ -271,6 +268,7 @@ if(AES_TRUE)
set(AES_FOUND
true
CACHE BOOL "AES-NI available")
message(STATUS "AES-NI available")
else(AES_TRUE)
set(AES_FOUND
false
Expand All @@ -281,15 +279,18 @@ if(CLMUL_TRUE)
set(CLMUL_FOUND
true
CACHE BOOL "CLMUL available")
message(STATUS "CLMUL available")
else()
set(CLMUL_FOUND
false
CACHE BOOL "CLMUL not available")
message(STATUS "CLMUL not available")
endif()
if(SHA_TRUE)
set(SHA_FOUND
true
CACHE BOOL "SHA-NI available")
message(STATUS "SHA-NI available")
else(SHA_TRUE)
set(SHA_FOUND
false
Expand All @@ -300,6 +301,7 @@ if(AVX2_TRUE)
set(AVX2_FOUND
true
CACHE BOOL "AVX2 available")
message(STATUS "AVX2 available")
else(AVX2_TRUE)
set(AVX2_FOUND
false
Expand All @@ -310,6 +312,7 @@ if(AVX512F_TRUE)
set(AVX512F_FOUND
true
CACHE BOOL "AVX512F available")
message(STATUS "AVX512F available")
else(AVX512F_TRUE)
set(AVX512F_FOUND
false
Expand All @@ -320,6 +323,7 @@ if(AVX512VL_TRUE)
set(AVX512VL_FOUND
true
CACHE BOOL "AVX512VL available")
message(STATUS "AVX512VL available")
else(AVX512VL_TRUE)
set(AVX512VL_FOUND
false
Expand Down Expand Up @@ -624,7 +628,7 @@ set_source_files_properties(

if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
# PMP breaks Debug build
if(NOT (CMAKE_BUILD_TYPE STREQUAL "asan"))
if(NOT (CMAKE_BUILD_TYPE STREQUAL "Asan"))
set(PMPML_SRC PMP_Multilinear.cpp PMP_Multilinear_64.cpp
PMP_Multilinear_test.cpp)
endif()
Expand Down
4 changes: 2 additions & 2 deletions KeysetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ bool VerificationTest ( HashInfo* info, bool verbose )
return true;
} else {
if (verbose)
printf("Verification value 0x%08X ....... FAIL! (Expected 0x%08X)\n",
printf("Verification value 0x%08X ....... \x1b[31mFAIL!\x1b[39m (Expected 0x%08X)\n",
verification, expected);
return false;
}
} else {
if (!expected) {
if (verbose)
printf("Verification value 0x%08X ....... INSECURE (should not be 0)\n",
printf("Verification value 0x%08X ....... \x1b[31mINSECURE\x1b[39m (should not be 0)\n",
verification);
return true;
} else {
Expand Down
8 changes: 4 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,12 @@ HashInfo g_hashes[] =
{ farmhash128_c_test, 128, FARM128_VERIF,"farmhash128_c", "farmhash128_with_seed (C99)", GOOD, {} },
#endif
#ifdef HAVE_AESNI
#ifdef _MSC_VER
#define GX_VFY 0x9189E456
#else
#if defined __linux && defined GITHUB_ACTIONS
#define GX_VFY 0x87FA3129
#else
#define GX_VFY 0x9189E456
#endif
{ gxhash64_test, 64, GX_VFY, "gxhash64", "gxHash, 64-bit, AES-only, unportable", GOOD, {} },
{ gxhash64_test, 64, GX_VFY, "gxhash64", "gxHash, 64-bit, AES-only, unportable", GOOD, {} },
#endif
{ xxHash64_test, 64, 0x024B7CF4, "xxHash64", "xxHash, 64-bit", GOOD, {} },
#if 0
Expand Down
9 changes: 7 additions & 2 deletions verifyall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
set -e
echo build 64bit
make -j4 -C build && build/SMHasher --verbose --test=VerifyAll
echo build32 32bit
make -j4 -C build32 && build32/SMHasher --verbose --test=VerifyAll
if test -d build32; then
echo build32 32bit
make -j4 -C build32 && build32/SMHasher --verbose --test=VerifyAll
fi
echo build-debug with asan
test -d build-debug || cmake -S . -B build-debug -DCMAKE_RELEASE_TYPE=Debug
make -j4 -C build-debug && build-debug/SMHasher --verbose --test=VerifyAll

0 comments on commit fae6e9b

Please sign in to comment.