Skip to content

Commit

Permalink
Enable AddressSanitizer on CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Anderson committed Jun 28, 2021
1 parent 7b85edc commit 2d9659a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Autocoders/Python/test/interface1/UserSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Fw::SerializeStatus UserSerializer::serialize(Fw::SerializeBufferBase& buffer) c

Fw::SerializeStatus UserSerializer::deserialize(Fw::SerializeBufferBase& buffer) {
NATIVE_UINT_TYPE serSize = sizeof(m_struct);
return buffer.deserialize((U8*)&m_struct,serSize);
Fw::SerializeStatus stat = buffer.deserialize((U8*)&m_struct,serSize);
FW_ASSERT(serSize == sizeof(m_struct));
return stat;
}


Expand Down
3 changes: 2 additions & 1 deletion Autocoders/Python/test/serialize_user/UserSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Fw::SerializeStatus UserSerializer::serialize(Fw::SerializeBufferBase& buffer) c

Fw::SerializeStatus UserSerializer::deserialize(Fw::SerializeBufferBase& buffer) {
NATIVE_UINT_TYPE serSize = sizeof(m_struct);
return buffer.deserialize((U8*)&m_struct,serSize);
Fw::SerializeStatus stat = buffer.deserialize((U8*)&m_struct,serSize);
FW_ASSERT(serSize == sizeof(m_struct));
return stat;
}


Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ set(FPRIME_PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Root path of F p
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-unused-parameter")

# For this testing cmake project, enable ASAN, a runtime memory sanitizer, on all unit tests
set (CMAKE_C_FLAGS_TESTING "${CMAKE_C_FLAGS_TESTING} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_CXX_FLAGS_TESTING "${CMAKE_CXX_FLAGS_TESTING} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_LINKER_FLAGS_TESTING "${CMAKE_LINKER_FLAGS_TESTING} -fno-omit-frame-pointer -fsanitize=address")

# Include the build for F prime.
include("${CMAKE_CURRENT_LIST_DIR}/cmake/FPrime.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/FPrime-Code.cmake")
4 changes: 2 additions & 2 deletions cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ endif()
SET(CMAKE_CXX_FLAGS_RELEASE "-std=c++03" CACHE STRING "C++ flags." FORCE)
SET(CMAKE_C_FLAGS_RELEASE "-std=c99" CACHE STRING "C flags." FORCE)
# Raise C++ standard to C++11 while unit testing to support googletest
SET(CMAKE_CXX_FLAGS_TESTING "-std=c++11 -g -DBUILD_UT -DPROTECTED=public -DPRIVATE=public -DSTATIC= -fprofile-arcs -ftest-coverage"
SET(CMAKE_CXX_FLAGS_TESTING "${CMAKE_CXX_FLAGS_TESTING} -std=c++11 -g -DBUILD_UT -DPROTECTED=public -DPRIVATE=public -DSTATIC= -fprofile-arcs -ftest-coverage"
CACHE STRING "Testing C++ flags." FORCE)
SET(CMAKE_C_FLAGS_TESTING "-std=c99 -g -DBUILD_UT -DPROTECTED=public -DPRIVATE=public -DSTATIC= -fprofile-arcs -ftest-coverage"
SET(CMAKE_C_FLAGS_TESTING "${CMAKE_C_FLAGS_TESTING} -std=c99 -g -DBUILD_UT -DPROTECTED=public -DPRIVATE=public -DSTATIC= -fprofile-arcs -ftest-coverage"
CACHE STRING "Testing C flags." FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_TESTING "" CACHE STRING "Testing linker flags." FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_TESTING "" CACHE STRING "Testing linker flags." FORCE)
Expand Down

0 comments on commit 2d9659a

Please sign in to comment.