Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/tools/fuzzing/registry/FuzzerRegistry.h
Line
Count
Source
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/. */
5
6
#ifndef _FuzzerRegistry_h__
7
#define _FuzzerRegistry_h__
8
9
#include <cstdint>
10
#include <map>
11
#include <string>
12
#include <utility>
13
14
#include "mozilla/Attributes.h"
15
#include "mozilla/Types.h"
16
17
typedef int(*FuzzerInitFunc)(int*, char***);
18
typedef int(*FuzzerTestingFunc)(const uint8_t*, size_t);
19
20
typedef int(*LibFuzzerDriver)(int*, char***, FuzzerTestingFunc);
21
22
namespace mozilla {
23
24
typedef std::pair<FuzzerInitFunc, FuzzerTestingFunc> FuzzerFunctions;
25
26
class FuzzerRegistry {
27
    public:
28
        MOZ_EXPORT static FuzzerRegistry& getInstance();
29
        MOZ_EXPORT void registerModule(std::string moduleName, FuzzerInitFunc initFunc, FuzzerTestingFunc testingFunc);
30
        MOZ_EXPORT FuzzerFunctions getModuleFunctions(std::string& moduleName);
31
32
        FuzzerRegistry(FuzzerRegistry const&) = delete;
33
        void operator=(FuzzerRegistry const&) = delete;
34
35
    private:
36
3
        FuzzerRegistry() {};
37
        std::map<std::string, FuzzerFunctions> moduleMap;
38
};
39
40
} // namespace mozilla
41
42
43
#endif // _FuzzerRegistry_h__