-
Notifications
You must be signed in to change notification settings - Fork 76
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
#include <string> in fuzztest.h not found #657
Comments
can you paste the command that is failing? you mentioned your project is in
C, which makes me think that you are compiling with clang and not clang++.
<string> is a C++ header and won't be found by clang automatically.
Markus
…On Mon, Oct 23, 2023, 12:56 marvi3 ***@***.***> wrote:
Hello,
I am sorry, but I am running into a problem when building a project with
cmake and fuzztest.
My project is a make c project but I have changed it to a simple cmake
project using the provided guide about cmake projects.
I basically have a *.c and a *.h file and would like to build them with
fuzztest.
CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(fuzztest)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(fuzztest)
enable_testing()
include(GoogleTest)
fuzztest_setup_fuzzing_flags()
add_compile_definitions(-DMJS_MAIN -DMJS_EXPOSE_PRIVATE -DCS_ENABLE_STDIO -DMJS_ENABLE_DEBUG -DCS_MMAP -DMJS_MODULE_LINES)
add_executable(
mjs_fuzztest
mjs_fuzz/mjs.c
mjs_fuzz/mjs.h
)
link_fuzztest(mjs_fuzztest)
gtest_discover_tests(mjs_fuzztest)
However when I run cmake --build . as described I get the following error:
[ 40%] Building C object CMakeFiles/mjs_fuzztest.dir/mjs.c.o In file included from src/mjs_main.c:13: /home/kali/SUT/mjsFuzzTest/fuzztest/fuzztest/fuzztest.h:18:10: fatal error: 'string' file not found #include <string>
However when I run the example from the cmake file, the
first_fuzz_test.cc, everything works like a charme.
How is it possible, that clang can not find the string header?
I hope to get some suggestion, what I might be doing wrong.
—
Reply to this email directly, view it on GitHub
<#657>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABDETCIQ2BLIXMJNUI2DEKDYA2OTBAVCNFSM6AAAAAA6MMJ4SGVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE2TONRQGIZTGNY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hello Markus, I run the following commands: CC=clang-16 CXX=clang++-16 cmake -DCMAKE_BUILD_TYPE=RelWithDebug -DFUZZTEST_FUZZING_MODE=on ..
cmake --build . Does that mean I can not test c programms with fuzztest out of the box? Best wishes, |
You should be able to FuzzTest C code. C++ is largely a superset of C so
you should be OK. Maybe you could put the FuzzTests in a C++ file and link
in your C code when you build everything with clang++.
…On Mon, Oct 23, 2023, 13:43 marvi3 ***@***.***> wrote:
Hello Markus,
thanks for the quick reply. That is utterly stupid of me. I did not even
think about c not having strings and was just all the time wondering what
was going on and what I did wrong.
I run the following commands:
CC=clang-16 CXX=clang++-16 cmake -DCMAKE_BUILD_TYPE=RelWithDebug -DFUZZTEST_FUZZING_MODE=on ..
cmake --build .
Does that mean I can not test c programms with fuzztest out of the box?
Best wishes,
marvi3
—
Reply to this email directly, view it on GitHub
<#657 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABDETCPN5POCNLYDYR6YSIDYA2UCJAVCNFSM6AAAAAA6MMJ4SGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZVG4YDCNBTGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
As Markus suggested, put your fuzz tests in a C++ file. Include your C header file with C language linkage: extern "C" {
#include "my/c/header.h"
}
// Call your C functions from fuzz tests. Then you should be good! |
Thank you a lot for your reply and help. By the way I think I forgot to tell which SUT I want to build with FuzzTest: I am getting a lot of error code that I do not get when building the program originally. Some errors seem to be connected with makros that try to get expanded:
But even when I have fixed them I get this error that I can't seem to fix without breaking other things:
This assertion fail also does not happen when I build the program on it's own. |
When I fix all other problems I am left with an error: fuzztest/./fuzztest/internal/domains/arbitrary_impl.h:63:3: error: static assertion failed due to requirement 'foobar<char *>::value': => Type not supported yet. Consider filing an issue.
static_assert(foobar<T>::value, So I simply commented this assertion out and then it throws the following error. So it seems like there is a problem with the value_type. I looked a bit in issues and found issue #176 where it is talked about no longer explicitly defining value_type and the change removed the value_type from InRegexImpl::DomainBase. fuzztest/./fuzztest/internal/type_support.h:42:1: error: no type named 'value_type' in 'fuzztest::internal::ArbitraryImpl<char *>' using value_type_t = typename Domain::value_type; I am sorry to bother you guys with my problems but I really do not know how to continue anymore. |
Looks like you're trying to instantiate Can you paste the fuzz test somewhere and share a link? |
Hello,
I am sorry, but I am running into a problem when building a project with cmake and fuzztest.
My project is a make c project but I have changed it to a simple cmake project using the provided guide about cmake projects.
I basically have a *.c and a *.h file and would like to build them with fuzztest.
CMakeLists.txt
However when I run
cmake --build .
as described I get the following error:However when I run the example from the cmake file, the first_fuzz_test.cc, everything works like a charme.
How is it possible, that clang can not find the string header?
I hope to get some suggestion, what I might be doing wrong.
The text was updated successfully, but these errors were encountered: