summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2023-05-22 23:14:37 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-23 06:11:33 +0200
commitfaa08ef1a1e8a34de517e7ede66369b12dbfb111 (patch)
tree71008b07ab6b446ffe2a398a360917596fe26332 /Userland
parent38a553e1cea5f19d1783f7c14249ee9731d21689 (diff)
downloadserenity-faa08ef1a1e8a34de517e7ede66369b12dbfb111.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Utilities/CMakeLists.txt28
-rw-r--r--Userland/Utilities/test-fuzz.cpp81
2 files changed, 29 insertions, 80 deletions
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 <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) {