From 1df88991a323f72afa224112c4d9e527f40c0d03 Mon Sep 17 00:00:00 2001 From: Khaled Yakdan Date: Mon, 25 Mar 2024 07:58:36 +0100 Subject: [PATCH] Exclude unit tests from fuzzing builds Needed to exclude unrelated GTest source files and headers from the coverage report --- src/explore_me/complex_checks_test.cpp | 6 +++++- src/explore_me/simple_checks_test.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/explore_me/complex_checks_test.cpp b/src/explore_me/complex_checks_test.cpp index aea3746..81ad008 100644 --- a/src/explore_me/complex_checks_test.cpp +++ b/src/explore_me/complex_checks_test.cpp @@ -1,9 +1,11 @@ #include #include -#include #include "explore_me.h" +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +#include + TEST(ExploreComplexChecksTests, DeveloperTest) { EXPECT_NO_THROW(ExploreComplexChecks(0, 10, "Developer")); } @@ -12,6 +14,8 @@ TEST(ExploreComplexChecksTests, MaintainerTest) { EXPECT_NO_THROW(ExploreComplexChecks(20, -10, "Maintainer")); } +#endif + FUZZ_TEST(const uint8_t *data, size_t size) { FuzzedDataProvider fdp(data, size); long a = fdp.ConsumeIntegral(); diff --git a/src/explore_me/simple_checks_test.cpp b/src/explore_me/simple_checks_test.cpp index af2fcfa..2819401 100644 --- a/src/explore_me/simple_checks_test.cpp +++ b/src/explore_me/simple_checks_test.cpp @@ -1,9 +1,11 @@ #include #include -#include #include "explore_me.h" +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +#include + TEST(ExploreSimpleChecksTests, DeveloperTest) { EXPECT_NO_THROW(ExploreSimpleChecks(0, 10, "Developer")); } @@ -12,6 +14,8 @@ TEST(ExploreSimpleChecksTests, MaintainerTest) { EXPECT_NO_THROW(ExploreSimpleChecks(20, -10, "Maintainer")); } +#endif + FUZZ_TEST(const uint8_t *data, size_t size) { FuzzedDataProvider fdp(data, size); int a = fdp.ConsumeIntegral();