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.
This commit is contained in:
Tim Schumacher 2023-05-22 23:14:37 +02:00 committed by Andreas Kling
parent 38a553e1ce
commit faa08ef1a1
Notes: sideshowbarker 2024-07-17 23:00:03 +09:00
2 changed files with 29 additions and 80 deletions

View file

@ -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")

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
* Copyright (c) 2023, Tim Schumacher <timschumi@gmx.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -36,86 +37,6 @@
ENUMERATE_TARGETS(__ENUMERATE_TARGET)
#undef __ENUMERATE_TARGET
#define LLVMFuzzerTestOneInput TestBMPLoader
#include <Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestELF
#include <Meta/Lagom/Fuzzers/FuzzELF.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestGemini
#include <Meta/Lagom/Fuzzers/FuzzGemini.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestGIFLoader
#include <Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestHttpRequest
#include <Meta/Lagom/Fuzzers/FuzzHttpRequest.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestICOLoader
#include <Meta/Lagom/Fuzzers/FuzzICOLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestJPEGLoader
#include <Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestJs
#include <Meta/Lagom/Fuzzers/FuzzJs.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestMarkdown
#include <Meta/Lagom/Fuzzers/FuzzMarkdown.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestPBMLoader
#include <Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestPGMLoader
#include <Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestPNGLoader
#include <Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestPPMLoader
#include <Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestQOILoader
#include <Meta/Lagom/Fuzzers/FuzzQOILoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestTGALoader
#include <Meta/Lagom/Fuzzers/FuzzTGALoader.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestRegexECMA262
#include <Meta/Lagom/Fuzzers/FuzzRegexECMA262.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestRegexPosixExtended
#include <Meta/Lagom/Fuzzers/FuzzRegexPosixExtended.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestShell
#include <Meta/Lagom/Fuzzers/FuzzShell.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestTTF
#include <Meta/Lagom/Fuzzers/FuzzTTF.cpp>
#undef LLVMFuzzerTestOneInput
#define LLVMFuzzerTestOneInput TestURL
#include <Meta/Lagom/Fuzzers/FuzzURL.cpp>
#undef LLVMFuzzerTestOneInput
static auto parse_target_name(StringView name)
{
if (name == "list"sv) {