Improved the CMakeLists.txt just slightly. Provided a default, weak-attributed main function into libdeepstate so that tests don't need to define them. The weak attribute means that any main function defined by libfuzzer will be a strong symbol and take over, so there won't be a conflict. Adjusted examples accordingly to omit now redundant conditionally-compiled main functions, as that leaked out too many underlying details.

This commit is contained in:
Peter Goodman
2018-09-27 16:45:08 -07:00
parent 42b7068e2b
commit b1da5d6d48
12 changed files with 40 additions and 67 deletions
-7
View File
@@ -35,10 +35,3 @@ TEST(Crash, SegFault) {
ASSERT_EQ(x, x);
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif
-6
View File
@@ -39,9 +39,3 @@ TEST(Euler, SumsOfLikePowers) {
<< "^5 + " << d << "^5 = " << e << "^5";
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif
-7
View File
@@ -35,10 +35,3 @@ class MyTest : public deepstate::Test {
TEST_F(MyTest, Something) {
ASSUME_NE(x, 0);
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif
-7
View File
@@ -44,10 +44,3 @@ TEST(Arithmetic, InvertibleMultiplication_CanFail) {
<< x << " != (" << x << " / " << y << ") * " << y;
});
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif
+1 -7
View File
@@ -15,7 +15,7 @@
*/
#include <deepstate/DeepState.hpp>
#include <climits>
using namespace deepstate;
DEEPSTATE_NOINLINE int ident1(int x) {
@@ -40,9 +40,3 @@ TEST(SignedInteger, MultiplicationOverflow) {
<< x << " squared overflowed.";
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif
-7
View File
@@ -30,10 +30,3 @@ TEST(Vector, DoubleReversal) {
<< "Double reverse of vectors must be equal.";
});
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
DeepState_Run();
}
#endif
-7
View File
@@ -63,10 +63,3 @@ TEST(OneOfExample, ProduceSixtyOrHigher) {
<< x << " is >= 60: " << " did " << choices << " from " << start;
}
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif
-7
View File
@@ -52,10 +52,3 @@ TEST(PrimePolynomial, OnlyGeneratesPrimes_NoStreaming) {
DeepState_Assert(poly != (y * z));
DeepState_Assert(IsPrime(Pump(poly)));
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif
-6
View File
@@ -40,9 +40,3 @@ TEST(Formatting, OverridePrintf) {
printf("hello again!");
}
#ifndef LIBFUZZER
int main(int argc, char *argv[]) {
DeepState_InitOptions(argc, argv);
return DeepState_Run();
}
#endif