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.
add Asan for C files.
show failing verifications in red.
  • Loading branch information
rurban committed Dec 15, 2024
1 parent da9db5f commit 6d2221b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,11 @@ 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} -DDEBUG -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 @@ -624,7 +623,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
7 changes: 1 addition & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,7 @@ 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
#define GX_VFY 0x87FA3129
#endif
{ gxhash64_test, 64, GX_VFY, "gxhash64", "gxHash, 64-bit, AES-only, unportable", GOOD, {} },
{ gxhash64_test, 64, 0x9189E456, "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 6d2221b

Please sign in to comment.