Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GCC for unit test mode #1393

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/cmake_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -yq \
ccache clang cmake ninja-build libprotobuf-dev protobuf-compiler
ccache clang gcc g++ cmake ninja-build libprotobuf-dev protobuf-compiler
- name: Restore latest cache
uses: actions/cache/restore@v4
with:
Expand All @@ -65,7 +65,7 @@ jobs:
-D CMAKE_BUILD_TYPE=RelWithDebug \
-D FUZZTEST_REPO_BRANCH="${{ github.head_ref || github.ref_name }}" \
&& cmake --build build_codelab -j $(nproc)
- name: Run all tests in default mode
- name: Run all tests in default mode with clang
if: matrix.mode == 'default'
run: |
CC=clang CXX=clang++ cmake \
Expand All @@ -78,6 +78,20 @@ jobs:
-D FUZZTEST_BUILD_TESTING=on \
&& cmake --build build -j $(nproc) \
&& ctest --test-dir build -j $(nproc) --output-on-failure
- name: Run all tests in default mode with gcc
if: matrix.mode == 'default'
run: |
CC=gcc CXX=g++ cmake \
-S . \
-B build \
-G Ninja \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_BUILD_TYPE=RelWithDebug \
-D FUZZTEST_BUILD_TESTING=on \
&& cmake --build build -j $(nproc)
# TODO: Rewrite helper `PrintValue` to obtain same output under clang and gcc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aleksisch, just wanted to check if you are planning to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aleksisch, just wanted to check if you are planning to do this.

Yes, I'll investigate it

# && ctest --test-dir build -j $(nproc) --output-on-failure
- name: Run end-to-end tests in fuzzing mode
if: matrix.mode == 'fuzzing'
run: |
Expand Down
6 changes: 4 additions & 2 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")
if (NOT COMPILER_GCC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")
endif()

### Libraries

Expand Down
8 changes: 6 additions & 2 deletions fuzztest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ include_directories(${PARENT_DIR})

add_subdirectory(grammars)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")

if (NOT COMPILER_GCC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0")
endif()


fuzztest_cc_library(
NAME
Expand Down
Loading