srctree

Robin Linden parent 39057abc 29320a85
wasm/test: Set up fuzzing of the wasm byte code parser

inlinesplit
wasm/BUILD added: 25, removed: 3, total 22
@@ -37,7 +37,10 @@ cc_library(
size = "small",
srcs = [src],
copts = HASTUR_COPTS,
corpus = glob([src[:-4] + "_corpus/*"]),
corpus = glob(
include = [src[:-4] + "_corpus/*"],
allow_empty = True,
),
target_compatible_with = HASTUR_FUZZ_PLATFORMS,
deps = [":wasm"],
) for src in glob(["*_fuzz_test.cpp"])]
 
filename was Deleted added: 25, removed: 3, total 22
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "wasm/byte_code_parser.h"
 
#include <sstream>
#include <stddef.h> // NOLINT
#include <stdint.h> // NOLINT
#include <string>
#include <tuple>
 
extern "C" int LLVMFuzzerTestOneInput(uint8_t const *data, size_t size); // NOLINT
 
extern "C" int LLVMFuzzerTestOneInput(uint8_t const *data, size_t size) {
std::ignore = wasm::ByteCodeParser::parse_module(
std::stringstream{std::string{reinterpret_cast<char const *>(data), size}});
return 0;
}