From faa08ef1a1e8a34de517e7ede66369b12dbfb111 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 22 May 2023 23:14:37 +0200 Subject: test-fuzz: Don't include all fuzzers into the same .cpp file Instead, use the approach from BuggieBox to compile in the .cpp files separately. --- Userland/Utilities/CMakeLists.txt | 28 ++++++++++++++ Userland/Utilities/test-fuzz.cpp | 81 +-------------------------------------- 2 files changed, 29 insertions(+), 80 deletions(-) (limited to 'Userland') diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 19efb00005..c46e8938d7 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -158,3 +158,31 @@ target_link_libraries(zip PRIVATE LibArchive LibCompress LibCrypto LibFileSystem # FIXME: Link this file into headless-browser without compiling it again. target_sources(headless-browser PRIVATE "${SerenityOS_SOURCE_DIR}/Userland/Services/WebContent/WebDriverConnection.cpp") + +function (add_fuzzing_target name) + set(fuzz_source_file "${SerenityOS_SOURCE_DIR}/Meta/Lagom/Fuzzers/Fuzz${name}.cpp") + target_sources(test-fuzz PRIVATE "${fuzz_source_file}") + set_source_files_properties("${fuzz_source_file}" PROPERTIES COMPILE_DEFINITIONS "LLVMFuzzerTestOneInput=Test${name}") + set_source_files_properties("${fuzz_source_file}" PROPERTIES COMPILE_OPTIONS "-Wno-missing-declarations") +endfunction() + +add_fuzzing_target("BMPLoader") +add_fuzzing_target("ELF") +add_fuzzing_target("Gemini") +add_fuzzing_target("GIFLoader") +add_fuzzing_target("HttpRequest") +add_fuzzing_target("ICOLoader") +add_fuzzing_target("JPEGLoader") +add_fuzzing_target("Js") +add_fuzzing_target("Markdown") +add_fuzzing_target("PBMLoader") +add_fuzzing_target("PGMLoader") +add_fuzzing_target("PNGLoader") +add_fuzzing_target("PPMLoader") +add_fuzzing_target("QOILoader") +add_fuzzing_target("TGALoader") +add_fuzzing_target("RegexECMA262") +add_fuzzing_target("RegexPosixExtended") +add_fuzzing_target("Shell") +add_fuzzing_target("TTF") +add_fuzzing_target("URL") diff --git a/Userland/Utilities/test-fuzz.cpp b/Userland/Utilities/test-fuzz.cpp index bf0d6b8622..9ea825f56e 100644 --- a/Userland/Utilities/test-fuzz.cpp +++ b/Userland/Utilities/test-fuzz.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2021, Ben Wiederhake + * Copyright (c) 2023, Tim Schumacher * * SPDX-License-Identifier: BSD-2-Clause */ @@ -36,86 +37,6 @@ ENUMERATE_TARGETS(__ENUMERATE_TARGET) #undef __ENUMERATE_TARGET -#define LLVMFuzzerTestOneInput TestBMPLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestELF -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestGemini -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestGIFLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestHttpRequest -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestICOLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestJPEGLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestJs -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestMarkdown -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestPBMLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestPGMLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestPNGLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestPPMLoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestQOILoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestTGALoader -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestRegexECMA262 -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestRegexPosixExtended -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestShell -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestTTF -#include -#undef LLVMFuzzerTestOneInput - -#define LLVMFuzzerTestOneInput TestURL -#include -#undef LLVMFuzzerTestOneInput - static auto parse_target_name(StringView name) { if (name == "list"sv) { -- cgit v1.2.3