Coverage Report

Created: 2026-11-12 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/WasmEdge/lib/driver/instantiateTool.cpp
Line
Count
Source
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright The WasmEdge Authors
3
4
#include "common/filesystem.h"
5
#include "common/spdlog.h"
6
#include "driver/tool.h"
7
#include "vm/vm.h"
8
9
#include <cstdlib>
10
#include <string_view>
11
12
using namespace std::literals;
13
14
namespace WasmEdge {
15
namespace Driver {
16
17
0
int InstantiateTool(struct DriverToolOptions &Opt) noexcept {
18
0
  std::ios::sync_with_stdio(false);
19
20
0
  Configure Conf = createConfigure(Opt);
21
22
0
  setMemoryPageLimit(Opt, Conf);
23
24
0
  Conf.addHostRegistration(HostRegistration::Wasi);
25
26
0
  const auto InputPath = getInputPath(Opt);
27
0
  if (!InputPath) {
28
0
    return EXIT_FAILURE;
29
0
  }
30
31
0
  VM::VM VM(Conf);
32
33
0
  if (!registerLinkedModules(Opt, VM)) {
34
0
    return EXIT_FAILURE;
35
0
  }
36
37
0
  if (auto Result = VM.loadWasm(u8string(*InputPath)); !Result) {
38
0
    return EXIT_FAILURE;
39
0
  }
40
0
  if (auto Result = VM.validate(); !Result) {
41
0
    return EXIT_FAILURE;
42
0
  }
43
0
  if (auto Result = VM.instantiate(); !Result) {
44
0
    return EXIT_FAILURE;
45
0
  }
46
47
0
  spdlog::info("Instantiation succeeded."sv);
48
  return EXIT_SUCCESS;
49
0
}
50
51
} // namespace Driver
52
} // namespace WasmEdge