srctree

Robin Linden parent 73737ca4 40ada11d
img/qoi: Set up fuzz-testing

inlinesplit
img/BUILD added: 36, removed: 4, total 32
@@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "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 = "img",
@@ -44,7 +45,19 @@ extra_srcs = {
"//etest",
"@expected",
],
) 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 = [":img"],
) for src in glob(["*_fuzz_test.cpp"])]
 
cc_binary(
name = "img_example",
 
filename was Deleted added: 36, removed: 4, total 32
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "img/qoi.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 = img::Qoi::from( //
std::stringstream{std::string{reinterpret_cast<char const *>(data), size}});
return 0;
}