-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathwasm_runtime.cc
72 lines (64 loc) · 2.21 KB
/
wasm_runtime.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "test/extensions/common/wasm/wasm_runtime.h"
namespace Envoy {
namespace Extensions {
namespace Common {
namespace Wasm {
std::vector<std::string> sandboxRuntimes() {
std::vector<std::string> runtimes;
#if defined(PROXY_WASM_HAS_RUNTIME_V8)
runtimes.push_back("v8");
#endif
#if defined(PROXY_WASM_HAS_RUNTIME_WAMR)
runtimes.push_back("wamr");
#endif
#if defined(PROXY_WASM_HAS_RUNTIME_WASMTIME)
runtimes.push_back("wasmtime");
#endif
return runtimes;
}
std::vector<std::string> languages(bool cpp_only) {
std::vector<std::string> languages;
#if defined(__x86_64__)
// TODO(PiotrSikora): Emscripten ships binaries only for x86_64.
languages.push_back("cpp");
#endif
if (!cpp_only) {
languages.push_back("rust");
}
return languages;
}
std::vector<std::tuple<std::string, std::string>> wasmTestMatrix(bool include_nullvm,
bool cpp_only) {
std::vector<std::tuple<std::string, std::string>> values;
for (const auto& runtime : sandboxRuntimes()) {
for (const auto& language : languages(cpp_only)) {
values.push_back(std::make_tuple(runtime, language));
}
}
if (include_nullvm) {
values.push_back(std::make_tuple("null", "cpp"));
}
return values;
}
std::vector<std::tuple<std::string, std::string, bool>>
wasmDualFilterTestMatrix(bool include_nullvm, bool cpp_only) {
std::vector<std::tuple<std::string, std::string, bool>> values;
for (const auto& p : Envoy::Extensions::Common::Wasm::wasmTestMatrix(include_nullvm, cpp_only)) {
values.push_back(std::make_tuple(std::get<0>(p), std::get<1>(p), true));
values.push_back(std::make_tuple(std::get<0>(p), std::get<1>(p), false));
}
return values;
}
std::string
wasmTestParamsToString(const ::testing::TestParamInfo<std::tuple<std::string, std::string>>& p) {
return std::get<0>(p.param) + "_" + std::get<1>(p.param);
}
std::string wasmDualFilterTestParamsToString(
const ::testing::TestParamInfo<std::tuple<std::string, std::string, bool>>& p) {
return (std::get<2>(p.param) ? "downstream_" : "upstream_") + std::get<0>(p.param) + "_" +
std::get<1>(p.param);
}
} // namespace Wasm
} // namespace Common
} // namespace Extensions
} // namespace Envoy