Coverage Report

Created: 2026-06-30 06:10

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