Skip to content

Commit b59a9d6

Browse files
author
Le Yao
committed
Fix symbol link error when testing runtime
Add wamr runtime to testing, passed Signed-off-by: Le Yao <le.yao@intel.com>
1 parent d06e7f9 commit b59a9d6

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

include/proxy-wasm/wamr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121

2222
namespace proxy_wasm {
2323

24-
std::unique_ptr<WasmVm> createWAMRVm();
24+
std::unique_ptr<WasmVm> createWamrVm();
2525

2626
} // namespace proxy_wasm

src/wamr/wamr.cc

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ class Wamr : public WasmVm {
5555
public:
5656
Wamr() {}
5757

58-
std::string_view runtime() override { return "webassembly micro runtime"; }
58+
std::string_view runtime() override { return "wamr"; }
5959
std::string_view getPrecompiledSectionName() override { return ""; }
6060

61-
Cloneable cloneable() override { return Cloneable::NotCloneable; }
62-
std::unique_ptr<WasmVm> clone() override { return nullptr; };
61+
Cloneable cloneable() override {
62+
return Cloneable::CompiledBytecode;
63+
;
64+
}
65+
std::unique_ptr<WasmVm> clone() override;
6366

6467
AbiVersion getAbiVersion() override;
6568
std::string_view getCustomSection(std::string_view name) override;
@@ -153,6 +156,21 @@ bool Wamr::load(const std::string &code, bool allow_precompiled) {
153156
return module_ != nullptr;
154157
}
155158

159+
std::unique_ptr<WasmVm> Wamr::clone() {
160+
assert(module_ != nullptr);
161+
162+
auto clone = std::make_unique<Wamr>();
163+
164+
clone->integration().reset(integration()->clone());
165+
166+
clone->store_ = wasm_store_new(engine());
167+
168+
WasmByteVec stripped;
169+
clone->module_ =
170+
wasm_module_new(store_.get(), getStrippedSource(&stripped) ? stripped.get() : source_.get());
171+
return clone;
172+
}
173+
156174
// TODO(mathetake): move to proxy_wasm::common::*
157175
bool Wamr::getStrippedSource(WasmByteVec *out) {
158176
std::vector<byte_t> stripped;

test/utility.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ std::vector<std::string> getRuntimes() {
2626
#endif
2727
#if defined(WASM_WASMTIME)
2828
"wasmtime",
29+
#endif
30+
#if defined(WASM_WAMR)
31+
"wamr",
2932
#endif
3033
""
3134
};

test/utility.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#if defined(WASM_WASMTIME)
3333
#include "include/proxy-wasm/wasmtime.h"
3434
#endif
35-
#if defined(WASM_WASMTIME)
35+
#if defined(WASM_WAMR)
3636
#include "include/proxy-wasm/wamr.h"
3737
#endif
3838

@@ -79,6 +79,10 @@ class TestVM : public testing::TestWithParam<std::string> {
7979
#if defined(WASM_WASMTIME)
8080
} else if (runtime_ == "wasmtime") {
8181
vm_ = proxy_wasm::createWasmtimeVm();
82+
#endif
83+
#if defined(WASM_WAMR)
84+
} else if (runtime_ == "wamr") {
85+
vm_ = proxy_wasm::createWamrVm();
8286
#endif
8387
}
8488
vm_->integration().reset(integration_);

0 commit comments

Comments
 (0)