Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Add one gtest-style test. Test Plan: run on bot Reviewers: samsonov Reviewed By: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7287 llvm-svn: 227639
- Loading branch information
Showing
6 changed files
with
101 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "FuzzerInternal.h" | ||
#include "gtest/gtest.h" | ||
#include <set> | ||
|
||
// For now, have TestOneInput just to make it link. | ||
// Later we may want to make unittests that actually call TestOneInput. | ||
extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { | ||
abort(); | ||
} | ||
|
||
TEST(Fuzzer, CrossOver) { | ||
using namespace fuzzer; | ||
Unit A({0, 1, 2}), B({5, 6, 7}); | ||
Unit C; | ||
Unit Expected[] = { | ||
{ 0 }, | ||
{ 0, 1 }, | ||
{ 0, 5 }, | ||
{ 0, 1, 2 }, | ||
{ 0, 1, 5 }, | ||
{ 0, 5, 1 }, | ||
{ 0, 5, 6 }, | ||
{ 0, 1, 2, 5 }, | ||
{ 0, 1, 5, 2 }, | ||
{ 0, 1, 5, 6 }, | ||
{ 0, 5, 1, 2 }, | ||
{ 0, 5, 1, 6 }, | ||
{ 0, 5, 6, 1 }, | ||
{ 0, 5, 6, 7 }, | ||
{ 0, 1, 2, 5, 6 }, | ||
{ 0, 1, 5, 2, 6 }, | ||
{ 0, 1, 5, 6, 2 }, | ||
{ 0, 1, 5, 6, 7 }, | ||
{ 0, 5, 1, 2, 6 }, | ||
{ 0, 5, 1, 6, 2 }, | ||
{ 0, 5, 1, 6, 7 }, | ||
{ 0, 5, 6, 1, 2 }, | ||
{ 0, 5, 6, 1, 7 }, | ||
{ 0, 5, 6, 7, 1 }, | ||
{ 0, 1, 2, 5, 6, 7 }, | ||
{ 0, 1, 5, 2, 6, 7 }, | ||
{ 0, 1, 5, 6, 2, 7 }, | ||
{ 0, 1, 5, 6, 7, 2 }, | ||
{ 0, 5, 1, 2, 6, 7 }, | ||
{ 0, 5, 1, 6, 2, 7 }, | ||
{ 0, 5, 1, 6, 7, 2 }, | ||
{ 0, 5, 6, 1, 2, 7 }, | ||
{ 0, 5, 6, 1, 7, 2 }, | ||
{ 0, 5, 6, 7, 1, 2 } | ||
}; | ||
for (size_t Len = 1; Len < 8; Len++) { | ||
std::set<Unit> FoundUnits, ExpectedUnitsWitThisLength; | ||
for (int Iter = 0; Iter < 3000; Iter++) { | ||
CrossOver(A, B, &C, Len); | ||
FoundUnits.insert(C); | ||
} | ||
for (const Unit &U : Expected) | ||
if (U.size() <= Len) | ||
ExpectedUnitsWitThisLength.insert(U); | ||
EXPECT_EQ(ExpectedUnitsWitThisLength, FoundUnits); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import lit.formats | ||
|
||
config.name = "LLVMFuzzer-Unittest" | ||
print config.test_exec_root | ||
config.test_format = lit.formats.GoogleTest(".", "Unittest") | ||
config.suffixes = [] | ||
config.test_source_root = config.test_exec_root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@" | ||
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/unit/lit.cfg") |