Coverage Report

Created: 2026-11-12 06:35

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