srctree

Robin Linden parent b11eb898 500f3661
archive/test: Set up fuzz testing

inlinesplit
archive/BUILD added: 54, removed: 5, total 49
@@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bzl:copts.bzl", "HASTUR_COPTS")
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test")
load("//bzl:copts.bzl", "HASTUR_COPTS", "HASTUR_FUZZ_PLATFORMS")
 
cc_library(
name = "archive",
@@ -27,4 +28,16 @@ cc_library(
":archive",
"//etest",
],
) for src in glob(["*_test.cpp"])]
) for src in glob(
include = ["*_test.cpp"],
exclude = ["*_fuzz_test.cpp"],
)]
 
[cc_fuzz_test(
name = src[:-4],
size = "small",
srcs = [src],
copts = HASTUR_COPTS,
target_compatible_with = HASTUR_FUZZ_PLATFORMS,
deps = [":archive"],
) for src in glob(["*_fuzz_test.cpp"])]
 
filename was Deleted added: 54, removed: 5, total 49
@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "archive/zlib.h"
 
#include <stddef.h> // NOLINT
#include <stdint.h> // NOLINT
#include <string_view>
#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::string_view input{reinterpret_cast<char const *>(data), size};
std::ignore = archive::zlib_decode(input, archive::ZlibMode::Gzip);
return 0;
}
 
filename was Deleted added: 54, removed: 5, total 49
@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "archive/zlib.h"
 
#include <stddef.h> // NOLINT
#include <stdint.h> // NOLINT
#include <string_view>
#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::string_view input{reinterpret_cast<char const *>(data), size};
std::ignore = archive::zlib_decode(input, archive::ZlibMode::Zlib);
return 0;
}