Skip to content

Commit

Permalink
Merge pull request #9 from DNedic/tests/add_sanitizers_and_fortify
Browse files Browse the repository at this point in the history
tests: Add sanitizers to tests
  • Loading branch information
DNedic authored Nov 3, 2023
2 parents b2a8c13 + eb745b3 commit 078db39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ add_executable(tests
# Required in order to test the std::span API as well
target_compile_features(tests PRIVATE cxx_std_20)

target_compile_options(tests
PRIVATE
-fno-omit-frame-pointer # For nicer stack traces with sanitizers
-fsanitize=address
-fsanitize=signed-integer-overflow
-fsanitize=bounds
)

target_link_options(tests
PRIVATE
-fsanitize=address
-fsanitize=signed-integer-overflow
-fsanitize=bounds
)

target_link_libraries(tests
PRIVATE
${PROJECT_NAME}
Expand Down
6 changes: 3 additions & 3 deletions tests/spsc/ring_buf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TEST_CASE("Get free after a wrapping write", "[rb_get_free_wrapped]") {
rb.Skip(sizeof(test_data) / sizeof(test_data[0]));

const float test_data2[900] = {3.1416F};
rb.Write(test_data, sizeof(test_data2) / sizeof(test_data2[0]));
rb.Write(test_data2, sizeof(test_data2) / sizeof(test_data2[0]));

/* After a wrapping write */
REQUIRE(rb.GetFree() ==
Expand Down Expand Up @@ -78,8 +78,8 @@ TEST_CASE("Get available after a wrapping write",

rb.Skip(sizeof(test_data) / sizeof(test_data[0]));

const float test_data2[900] = {3.1416F};
rb.Write(test_data, sizeof(test_data2) / sizeof(test_data2[0]));
const double test_data2[900] = {3.1416F};
rb.Write(test_data2, sizeof(test_data2) / sizeof(test_data2[0]));

/* After a wrapping write */
REQUIRE(rb.GetAvailable() == sizeof(test_data2) / sizeof(test_data2[0]));
Expand Down

0 comments on commit 078db39

Please sign in to comment.