diff options
| author | Leitwolf | 2026-10-30 00:06:27 +0300 |
|---|---|---|
| committer | GitHub | 2026-10-30 00:06:27 +0300 |
| commit | 471756b77331fa1ab77bc94e6aae228baef903e0 (patch) | |
| tree | 3af5223ff664544d15eaf20a10eccdf3465d9958 /fuzzing | |
| parent | 1d48419b7ef642917ebf7dfd16c3bc1b3050d8f1 (diff) | |
| parent | 0b4b57a0688f2943f4c797c20d68d533cf70fd15 (diff) | |
| download | catch3-471756b77331fa1ab77bc94e6aae228baef903e0.tar.gz | |
Merge pull request #20 from Progmasoft/feature/catch3-json
Read the options of a project from catch3.json
Diffstat (limited to 'fuzzing')
| -rw-r--r-- | fuzzing/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | fuzzing/Progmasoft/fuzz_ProjectConfig.cpp | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/fuzzing/CMakeLists.txt b/fuzzing/CMakeLists.txt index 05591520..c5b71e9c 100644 --- a/fuzzing/CMakeLists.txt +++ b/fuzzing/CMakeLists.txt @@ -20,7 +20,7 @@ foreach(fuzzer TestSpecParser) endforeach() # Progmasoft's fuzzers live apart, under their own license header. -foreach(fuzzer RunnerJson RunnerOptions) +foreach(fuzzer ProjectConfig RunnerJson RunnerOptions) add_executable(fuzz_${fuzzer} Progmasoft/fuzz_${fuzzer}.cpp) target_link_libraries(fuzz_${fuzzer} PRIVATE fuzzhelper) endforeach() diff --git a/fuzzing/Progmasoft/fuzz_ProjectConfig.cpp b/fuzzing/Progmasoft/fuzz_ProjectConfig.cpp new file mode 100644 index 00000000..0c43f550 --- /dev/null +++ b/fuzzing/Progmasoft/fuzz_ProjectConfig.cpp @@ -0,0 +1,30 @@ +// Copyright (c) 2026 Progmasoft. +// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1 + +// The text of a catch3.json. Reading it must give options or an error, never +// crash, and the worker arguments derived from the options must parse again. + +#include <Progmasoft/Runner/Options.hpp> +#include <Progmasoft/Runner/ProjectConfig.hpp> + +#include <cstdint> +#include <cstdlib> +#include <string_view> + +extern "C" int +LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) +{ + namespace Runner = Progmasoft::Catch3::Runner; + const std::string_view text{reinterpret_cast<const char *>(data), size}; + auto options = Runner::ApplyProjectConfig(text, "project", "catch3.json"); + if (options) + { + const auto worker = + Runner::ParseOptions(Runner::WorkerArguments(*options)); + if (!worker) + { + std::abort(); + } + } + return 0; +} |