Bug 1754025 [wpt PR 32729] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / tools / fuzzing / registry / FuzzerRegistry.h
blob5976ddc5b601f0086608ce5b992fa01557028021
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * * This Source Code Form is subject to the terms of the Mozilla Public
3 * * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef _FuzzerRegistry_h__
7 #define _FuzzerRegistry_h__
9 #include <cstdint>
10 #include <map>
11 #include <string>
12 #include <utility>
14 #include "mozilla/Attributes.h"
15 #include "mozilla/Types.h"
17 typedef int (*FuzzerInitFunc)(int*, char***);
18 typedef int (*FuzzerTestingFunc)(const uint8_t*, size_t);
20 typedef int (*LibFuzzerDriver)(int*, char***, FuzzerTestingFunc);
22 namespace mozilla {
24 typedef std::pair<FuzzerInitFunc, FuzzerTestingFunc> FuzzerFunctions;
26 class FuzzerRegistry {
27 public:
28 MOZ_EXPORT static FuzzerRegistry& getInstance();
29 MOZ_EXPORT void registerModule(std::string moduleName,
30 FuzzerInitFunc initFunc,
31 FuzzerTestingFunc testingFunc);
32 MOZ_EXPORT FuzzerFunctions getModuleFunctions(std::string& moduleName);
34 FuzzerRegistry(FuzzerRegistry const&) = delete;
35 void operator=(FuzzerRegistry const&) = delete;
37 private:
38 FuzzerRegistry(){};
39 std::map<std::string, FuzzerFunctions> moduleMap;
42 } // namespace mozilla
44 #endif // _FuzzerRegistry_h__