Skip to content

Commit

Permalink
Merge pull request #3847 from Mytherin/expandossfuzz
Browse files Browse the repository at this point in the history
Expand oss-fuzz tests to run queries and check for internal errors
  • Loading branch information
Mytherin committed Jun 14, 2022
2 parents 383ab64 + c05242b commit cdfb9f9
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test/ossfuzz/parse_fuzz_test.cpp
@@ -1,10 +1,25 @@
#include "duckdb/parser/parser.hpp"
#include "duckdb.hpp"
#include "duckdb/common/string_util.hpp"
#include <string>
#include <unordered_set>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
std::string input(reinterpret_cast<const char *>(data), size);
duckdb::Parser parser;
duckdb::DuckDB db(nullptr);
duckdb::Connection con(db);

std::unordered_set<std::string> internal_error_messages = {"Unoptimized Result differs from original result!",
"INTERNAL"};
con.Query("PRAGMA enable_verification");
try {
parser.ParseQuery(input);
auto result = con.Query(input);
if (!result->success) {
for (auto &internal_error : internal_error_messages) {
if (duckdb::StringUtil::Contains(result->error, internal_error)) {
return 1;
}
}
}
} catch (std::exception &e) {
}
return 0;
Expand Down

0 comments on commit cdfb9f9

Please sign in to comment.