File: parse_fuzz_test.cpp

package info (click to toggle)
duckdb 1.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 558
file content (26 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#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::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 {
		auto result = con.Query(input);
		if (result->HasError()) {
			for (auto &internal_error : internal_error_messages) {
				if (duckdb::StringUtil::Contains(result->GetError(), internal_error)) {
					return 1;
				}
			}
		}
	} catch (std::exception &e) {
	}
	return 0;
}