/src/WasmEdge/lib/driver/fuzzTool.cpp
Line | Count | Source |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: Copyright The WasmEdge Authors |
3 | | |
4 | | #ifdef WASMEDGE_BUILD_FUZZING |
5 | | #include "driver/fuzzTool.h" |
6 | | #include "common/configure.h" |
7 | | #include "common/spdlog.h" |
8 | | #include "driver/compiler.h" |
9 | | |
10 | | #include <string_view> |
11 | | |
12 | | namespace WasmEdge { |
13 | | namespace Driver { |
14 | | |
15 | 9.37k | int FuzzTool(const uint8_t *Data, size_t Size) noexcept { |
16 | 9.37k | using namespace std::literals; |
17 | 9.37k | std::ios::sync_with_stdio(false); |
18 | 9.37k | spdlog::set_level(spdlog::level::critical); |
19 | | |
20 | 9.37k | Configure Conf; |
21 | 9.37k | Conf.getRuntimeConfigure().setRunMode(WasmEdge::RunMode::Interpreter); |
22 | 9.37k | return compileModule(Conf, Span<const uint8_t>(Data, Size), "/dev/null"sv); |
23 | 9.37k | } |
24 | | |
25 | | } // namespace Driver |
26 | | } // namespace WasmEdge |
27 | | #endif |