Fuzz test not recognized with quickstart with cmake
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 137
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 22
Description
Hello! I am following the Quickstart with CMake guide provided here: https://github.com/google/fuzztest/blob/main/doc/quickstart-cmake.md and am having some trouble getting the simple fuzz test to be recognized.
My CMakeLists.txt looks as follows (pretty much copy paste from the quickstart guide, except for some minor directory changes since the quickstart guide specifies to create a directory called “first_fuzz”):
cmake_minimum_required(VERSION 3.19)
project(first_fuzz_project)
```
# GoogleTest requires at least C++17
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(fuzztest)
enable_testing()
include(GoogleTest)
fuzztest_setup_fuzzing_flags()
add_executable(
first_fuzz_test
first_fuzz/first_fuzz_test.cc
)
# If you have other dependencies than FuzzTest, link them:
# target_link_libraries(first_fuzz_test PRIVATE other_deps)
link_fuzztest(first_fuzz_test)
gtest_discover_tests(first_fuzz_test)
```
In the new directory (first_fuzz) that I created, I added the test [first_fuzz_test.cc](http://first_fuzz_test.cc/) file with the content specified in the quickstart guide:
```
#include "fuzztest/fuzztest.h"
#include "gtest/gtest.h"
TEST(MyTestSuite, OnePlustTwoIsTwoPlusOne) {
EXPECT_EQ(1 + 2, 2 + 1);
}
void IntegerAdditionCommutes(int a, int b) {
EXPECT_EQ(a + b, b + a);
}
FUZZ_TEST(MyTestSuite, IntegerAdditionCommutes);
```
I then built the program with the specified cmake flags:
```shell
$ CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=RelWithDebug -DFUZZTEST_FUZZING_MODE=on ..
$ cmake --build .
```
The build succeeds without any errors and I am able to run the unit tests without any issue. When trying to run the fuzz test, the binary reports containing coverage but there are no tests that are recognized:
```shell
$ ./first_fuzz_test --fuzz=MyTestSuite.IntegerAdditionCommutes
```
[.] Sanitizer coverage enabled. Counter map size: 35469, Cmp map size: 262144
No FUZZ_TEST matches the name: MyTestSuite.IntegerAdditionCommutes
Valid tests:
Just for documentation purposes, I am using Apple clang++ version 14.0.3 on a 2019 Intel Macbook Pro with cmake version 3.26.4.
Is there something missing in the quickstart cmake guide that I am forgetting? Any additional guidance would be helpful, thanks in advance!
Contributor guide
Assessment
This issue has not been assessed yet.