Coverage Report

Created: 2026-09-28 06:22

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 = std::filesystem::absolute(u8path(Opt.SoName.value()));
25
26
  // Create VM and get WASI module instance.
27
0
  VM::VM VM(Conf);
28
29
  // Load, validate, WASM or Component.
30
0
  if (auto Result = VM.loadWasm(u8string(InputPath)); !Result) {
31
0
    return EXIT_FAILURE;
32
0
  }
33
34
0
  if (auto Result = VM.validate(); !Result) {
35
0
    return EXIT_FAILURE;
36
0
  }
37
38
0
  spdlog::info("Validation succeeded."sv);
39
  return EXIT_SUCCESS;
40
0
}
41
} // namespace Driver
42
} // namespace WasmEdge