Libfuzzerize all examples

This commit is contained in:
Alex Groce 2018-07-30 21:31:41 -07:00
parent 3006e19817
commit c23e4e20b5
9 changed files with 72 additions and 2 deletions

View File

@ -16,6 +16,13 @@
add_executable(Crash Crash.cpp)
target_link_libraries(Crash deepstate)
if (BUILD_LIBFUZZER)
add_executable(Crash_LF Crash.cpp)
target_link_libraries(Crash_LF deepstate_LF)
target_link_libraries (Crash_LF "-fsanitize=fuzzer")
set_target_properties(Crash_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(OneOf OneOf.cpp)
target_link_libraries(OneOf deepstate)
@ -29,24 +36,73 @@ endif()
add_executable(Fixture Fixture.cpp)
target_link_libraries(Fixture deepstate)
if (BUILD_LIBFUZZER)
add_executable(Fixture_LF Fixture.cpp)
target_link_libraries(Fixture_LF deepstate_LF)
target_link_libraries (Fixture_LF "-fsanitize=fuzzer")
set_target_properties(Fixture_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(Primes Primes.cpp)
target_link_libraries(Primes deepstate)
if (BUILD_LIBFUZZER)
add_executable(Primes_LF Primes.cpp)
target_link_libraries(Primes_LF deepstate_LF)
target_link_libraries (Primes_LF "-fsanitize=fuzzer")
set_target_properties(Primes_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(Euler Euler.cpp)
target_link_libraries(Euler deepstate)
if (BUILD_LIBFUZZER)
add_executable(Euler_LF Euler.cpp)
target_link_libraries(Euler_LF deepstate_LF)
target_link_libraries (Euler_LF "-fsanitize=fuzzer")
set_target_properties(Euler_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(IntegerOverflow IntegerOverflow.cpp)
target_link_libraries(IntegerOverflow deepstate)
if (BUILD_LIBFUZZER)
add_executable(IntegerOverflow_LF IntegerOverflow.cpp)
target_link_libraries(IntegerOverflow_LF deepstate_LF)
target_link_libraries (IntegerOverflow_LF "-fsanitize=fuzzer")
set_target_properties(IntegerOverflow_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(IntegerArithmetic IntegerArithmetic.cpp)
target_link_libraries(IntegerArithmetic deepstate)
if (BUILD_LIBFUZZER)
add_executable(IntegerArithmetic_LF IntegerArithmetic.cpp)
target_link_libraries(IntegerArithmetic_LF deepstate_LF)
target_link_libraries (IntegerArithmetic_LF "-fsanitize=fuzzer")
set_target_properties(IntegerArithmetic_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(Lists Lists.cpp)
target_link_libraries(Lists deepstate)
if (BUILD_LIBFUZZER)
add_executable(Lists_LF Lists.cpp)
target_link_libraries(Lists_LF deepstate_LF)
target_link_libraries (Lists_LF "-fsanitize=fuzzer")
set_target_properties(Lists_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(StreamingAndFormatting StreamingAndFormatting.cpp)
target_link_libraries(StreamingAndFormatting deepstate)
if (BUILD_LIBFUZZER)
add_executable(StreamingAndFormatting_LF StreamingAndFormatting.cpp)
target_link_libraries(StreamingAndFormatting_LF deepstate_LF)
target_link_libraries (StreamingAndFormatting_LF "-fsanitize=fuzzer")
set_target_properties(StreamingAndFormatting_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
add_executable(Squares Squares.c)
target_link_libraries(Squares deepstate)
set_target_properties(Squares PROPERTIES COMPILE_DEFINITIONS "DEEPSTATE_TEST")

View File

@ -36,7 +36,9 @@ TEST(Crash, SegFault) {
ASSERT_EQ(x, x);
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif

View File

@ -39,7 +39,9 @@ TEST(Euler, SumsOfLikePowers) {
<< "^5 + " << d << "^5 = " << e << "^5";
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif

View File

@ -36,8 +36,9 @@ TEST_F(MyTest, Something) {
ASSUME_NE(x, 0);
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif

View File

@ -45,7 +45,9 @@ TEST(Arithmetic, InvertibleMultiplication_CanFail) {
});
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif

View File

@ -40,7 +40,9 @@ TEST(SignedInteger, MultiplicationOverflow) {
<< x << " squared overflowed.";
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif

View File

@ -31,7 +31,9 @@ TEST(Vector, DoubleReversal) {
});
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
DeepState_Run();
}
#endif

View File

@ -53,8 +53,9 @@ TEST(PrimePolynomial, OnlyGeneratesPrimes_NoStreaming) {
DeepState_Assert(IsPrime(Pump(poly)));
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif

View File

@ -40,7 +40,9 @@ TEST(Formatting, OverridePrintf) {
printf("hello again!");
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif