diff --git a/test/extensions/access_loggers/wasm/config_test.cc b/test/extensions/access_loggers/wasm/config_test.cc index 1f55eaa5bc214..ea4425810622a 100644 --- a/test/extensions/access_loggers/wasm/config_test.cc +++ b/test/extensions/access_loggers/wasm/config_test.cc @@ -32,10 +32,12 @@ class TestFactoryContext : public NiceMock {}; +class WasmAccessLogConfigTest + : public testing::TestWithParam> {}; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmAccessLogConfigTest, - Envoy::Extensions::Common::Wasm::runtime_values); + Envoy::Extensions::Common::Wasm::runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); TEST_P(WasmAccessLogConfigTest, CreateWasmFromEmpty) { auto factory = @@ -56,12 +58,6 @@ TEST_P(WasmAccessLogConfigTest, CreateWasmFromEmpty) { } TEST_P(WasmAccessLogConfigTest, CreateWasmFromWASM) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif auto factory = Registry::FactoryRegistry::getFactory( "envoy.access_loggers.wasm"); @@ -69,9 +65,9 @@ TEST_P(WasmAccessLogConfigTest, CreateWasmFromWASM) { envoy::extensions::access_loggers::wasm::v3::WasmAccessLog config; config.mutable_config()->mutable_vm_config()->set_runtime( - absl::StrCat("envoy.wasm.runtime.", GetParam())); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam()))); std::string code; - if (GetParam() != "null") { + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/access_loggers/wasm/test_data/test_cpp.wasm")); } else { diff --git a/test/extensions/bootstrap/wasm/config_test.cc b/test/extensions/bootstrap/wasm/config_test.cc index 70c747c86f1fd..8f8b32ac48ff4 100644 --- a/test/extensions/bootstrap/wasm/config_test.cc +++ b/test/extensions/bootstrap/wasm/config_test.cc @@ -21,12 +21,12 @@ namespace Wasm { using Extensions::Bootstrap::Wasm::WasmServicePtr; -class WasmFactoryTest : public testing::TestWithParam { +class WasmFactoryTest : public testing::TestWithParam> { protected: WasmFactoryTest() { config_.mutable_config()->mutable_vm_config()->set_runtime( - absl::StrCat("envoy.wasm.runtime.", GetParam())); - if (GetParam() != "null") { + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam()))); + if (std::get<0>(GetParam()) != "null") { config_.mutable_config()->mutable_vm_config()->mutable_code()->mutable_local()->set_filename( TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/start_cpp.wasm")); @@ -69,15 +69,10 @@ class WasmFactoryTest : public testing::TestWithParam { }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmFactoryTest, - Envoy::Extensions::Common::Wasm::runtime_values); + Envoy::Extensions::Common::Wasm::runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); TEST_P(WasmFactoryTest, CreateWasmFromWasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif auto factory = std::make_unique(); auto empty_config = factory->createEmptyConfigProto(); @@ -90,12 +85,6 @@ TEST_P(WasmFactoryTest, CreateWasmFromWasm) { } TEST_P(WasmFactoryTest, CreateWasmFromWasmPerThread) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif config_.set_singleton(false); initializeWithConfig(config_); @@ -105,13 +94,7 @@ TEST_P(WasmFactoryTest, CreateWasmFromWasmPerThread) { } TEST_P(WasmFactoryTest, MissingImport) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } config_.mutable_config()->mutable_vm_config()->mutable_code()->mutable_local()->set_filename( @@ -122,12 +105,6 @@ TEST_P(WasmFactoryTest, MissingImport) { } TEST_P(WasmFactoryTest, UnspecifiedRuntime) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif config_.mutable_config()->mutable_vm_config()->set_runtime(""); EXPECT_THROW_WITH_REGEX( @@ -136,12 +113,6 @@ TEST_P(WasmFactoryTest, UnspecifiedRuntime) { } TEST_P(WasmFactoryTest, UnknownRuntime) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif config_.mutable_config()->mutable_vm_config()->set_runtime("envoy.wasm.runtime.invalid"); EXPECT_THROW_WITH_MESSAGE(initializeWithConfig(config_), Extensions::Common::Wasm::WasmException, @@ -149,12 +120,6 @@ TEST_P(WasmFactoryTest, UnknownRuntime) { } TEST_P(WasmFactoryTest, StartFailed) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif ProtobufWkt::StringValue plugin_configuration; plugin_configuration.set_value("bad"); config_.mutable_config()->mutable_vm_config()->mutable_configuration()->PackFrom( @@ -165,12 +130,6 @@ TEST_P(WasmFactoryTest, StartFailed) { } TEST_P(WasmFactoryTest, StartFailedOpen) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif ProtobufWkt::StringValue plugin_configuration; plugin_configuration.set_value("bad"); config_.mutable_config()->mutable_vm_config()->mutable_configuration()->PackFrom( @@ -182,12 +141,6 @@ TEST_P(WasmFactoryTest, StartFailedOpen) { } TEST_P(WasmFactoryTest, ConfigureFailed) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif ProtobufWkt::StringValue plugin_configuration; plugin_configuration.set_value("bad"); config_.mutable_config()->mutable_configuration()->PackFrom(plugin_configuration); diff --git a/test/extensions/bootstrap/wasm/wasm_integration_test.cc b/test/extensions/bootstrap/wasm/wasm_integration_test.cc index afebbfd345550..08eb4691b4716 100644 --- a/test/extensions/bootstrap/wasm/wasm_integration_test.cc +++ b/test/extensions/bootstrap/wasm/wasm_integration_test.cc @@ -10,7 +10,8 @@ namespace Extensions { namespace Wasm { namespace { -class WasmIntegrationTest : public HttpIntegrationTest, public testing::TestWithParam { +class WasmIntegrationTest : public HttpIntegrationTest, + public testing::TestWithParam> { public: WasmIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, Network::Address::IpVersion::v4) {} @@ -58,7 +59,7 @@ name: envoy.filters.http.wasm local: filename: {} )EOF", - GetParam(), httpwasm)); + std::get<0>(GetParam()), httpwasm)); HttpIntegrationTest::initialize(); } @@ -68,17 +69,11 @@ name: envoy.filters.http.wasm }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmIntegrationTest, - Envoy::Extensions::Common::Wasm::sandbox_runtime_values, + Envoy::Extensions::Common::Wasm::sandbox_runtime_and_cpp_values, Envoy::Extensions::Common::Wasm::wasmTestParamsToString); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WasmIntegrationTest); TEST_P(WasmIntegrationTest, FilterMakesCallInConfigureTime) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif initialize(); ASSERT_TRUE(fake_upstreams_.back()->waitForHttpConnection(*dispatcher_, wasm_connection_)); diff --git a/test/extensions/bootstrap/wasm/wasm_test.cc b/test/extensions/bootstrap/wasm/wasm_test.cc index 7427b158988ae..0d9e895445de8 100644 --- a/test/extensions/bootstrap/wasm/wasm_test.cc +++ b/test/extensions/bootstrap/wasm/wasm_test.cc @@ -85,21 +85,24 @@ class WasmTestBase { std::shared_ptr wasm_; }; -class WasmTest : public WasmTestBase, public testing::TestWithParam { +class WasmTest : public WasmTestBase, + public testing::TestWithParam> { public: - void createWasm() { WasmTestBase::createWasm(GetParam()); } + void createWasm() { WasmTestBase::createWasm(std::get<0>(GetParam())); } }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmTest, - Envoy::Extensions::Common::Wasm::sandbox_runtime_values); + Envoy::Extensions::Common::Wasm::sandbox_runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WasmTest); -class WasmNullTest : public WasmTestBase, public testing::TestWithParam { +class WasmNullTest : public WasmTestBase, + public testing::TestWithParam> { public: void createWasm() { - WasmTestBase::createWasm(GetParam()); + WasmTestBase::createWasm(std::get<0>(GetParam())); const auto code = - GetParam() != "null" + std::get<0>(GetParam()) != "null" ? TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/stats_cpp.wasm")) : "WasmStatsCpp"; @@ -109,7 +112,8 @@ class WasmNullTest : public WasmTestBase, public testing::TestWithParam> { @@ -130,8 +134,7 @@ class WasmTestMatrix : public WasmTestBase, }; INSTANTIATE_TEST_SUITE_P(RuntimesAndLanguages, WasmTestMatrix, - testing::Combine(Envoy::Extensions::Common::Wasm::sandbox_runtime_values, - Envoy::Extensions::Common::Wasm::language_values)); + Envoy::Extensions::Common::Wasm::sandbox_runtime_and_language_values); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WasmTestMatrix); TEST_P(WasmTestMatrix, LoggingWithEnvVars) { @@ -170,12 +173,6 @@ TEST_P(WasmTestMatrix, LoggingWithEnvVars) { } TEST_P(WasmTest, BadSignature) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/bad_signature_cpp.wasm")); @@ -186,12 +183,6 @@ TEST_P(WasmTest, BadSignature) { } TEST_P(WasmTest, Segv) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm")); @@ -205,12 +196,6 @@ TEST_P(WasmTest, Segv) { } TEST_P(WasmTest, DivByZero) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm")); @@ -224,12 +209,6 @@ TEST_P(WasmTest, DivByZero) { } TEST_P(WasmTest, IntrinsicGlobals) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/emscripten_cpp.wasm")); @@ -249,12 +228,6 @@ TEST_P(WasmTest, IntrinsicGlobals) { // change this behavior by providing non-trapping instructions, but in the mean time we support the // default Emscripten behavior. TEST_P(WasmTest, Asm2Wasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/asm2wasm_cpp.wasm")); @@ -267,12 +240,6 @@ TEST_P(WasmTest, Asm2Wasm) { } TEST_P(WasmNullTest, Stats) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); auto context = static_cast(wasm_->start(plugin_)); @@ -292,12 +259,6 @@ TEST_P(WasmNullTest, Stats) { } TEST_P(WasmNullTest, StatsHigherLevel) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); auto context = static_cast(wasm_->start(plugin_)); @@ -323,12 +284,6 @@ TEST_P(WasmNullTest, StatsHigherLevel) { } TEST_P(WasmNullTest, StatsHighLevel) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif createWasm(); auto context = static_cast(wasm_->start(plugin_)); diff --git a/test/extensions/common/wasm/wasm_runtime.cc b/test/extensions/common/wasm/wasm_runtime.cc index 0251fbb7880b9..db5ecc6e400b0 100644 --- a/test/extensions/common/wasm/wasm_runtime.cc +++ b/test/extensions/common/wasm/wasm_runtime.cc @@ -5,12 +5,6 @@ namespace Extensions { namespace Common { namespace Wasm { -std::vector runtimes() { - std::vector runtimes = sandboxRuntimes(); - runtimes.push_back("null"); - return runtimes; -} - std::vector sandboxRuntimes() { std::vector runtimes; #if defined(PROXY_WASM_HAS_RUNTIME_V8) @@ -28,29 +22,35 @@ std::vector sandboxRuntimes() { return runtimes; } -std::vector languages() { +std::vector languages(bool cpp_only) { std::vector languages; #if defined(__x86_64__) // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. languages.push_back("cpp"); #endif - languages.push_back("rust"); + if (!cpp_only) { + languages.push_back("rust"); + } return languages; } -std::vector> runtimesAndLanguages() { +std::vector> wasmTestMatrix(bool include_nullvm, + bool cpp_only) { std::vector> values; for (const auto& runtime : sandboxRuntimes()) { - for (const auto& language : languages()) { + for (const auto& language : languages(cpp_only)) { values.push_back(std::make_tuple(runtime, language)); } } - values.push_back(std::make_tuple("null", "cpp")); + if (include_nullvm) { + values.push_back(std::make_tuple("null", "cpp")); + } return values; } -std::string wasmTestParamsToString(const ::testing::TestParamInfo& p) { - return p.param; +std::string +wasmTestParamsToString(const ::testing::TestParamInfo>& p) { + return std::get<0>(p.param) + "_" + std::get<1>(p.param); } } // namespace Wasm diff --git a/test/extensions/common/wasm/wasm_runtime.h b/test/extensions/common/wasm/wasm_runtime.h index 7a1b365e3fbc9..1db6344e5ec2c 100644 --- a/test/extensions/common/wasm/wasm_runtime.h +++ b/test/extensions/common/wasm/wasm_runtime.h @@ -7,24 +7,17 @@ namespace Extensions { namespace Common { namespace Wasm { -// All Wasm runtimes. -std::vector runtimes(); +// Testable runtime and language combinations. +std::vector> wasmTestMatrix(bool include_nullvm, + bool cpp_only); -// All sandboxed Wasm runtimes. -std::vector sandboxRuntimes(); +inline auto runtime_and_cpp_values = testing::ValuesIn(wasmTestMatrix(true, true)); +inline auto sandbox_runtime_and_cpp_values = testing::ValuesIn(wasmTestMatrix(false, true)); +inline auto runtime_and_language_values = testing::ValuesIn(wasmTestMatrix(true, false)); +inline auto sandbox_runtime_and_language_values = testing::ValuesIn(wasmTestMatrix(false, false)); -// All programming languages used in Wasm tests. -std::vector languages(); - -// Testable runtime and language combinations -std::vector> runtimesAndLanguages(); - -inline auto runtime_values = testing::ValuesIn(runtimes()); -inline auto sandbox_runtime_values = testing::ValuesIn(sandboxRuntimes()); -inline auto language_values = testing::ValuesIn(languages()); -inline auto runtime_and_language_values = testing::ValuesIn(runtimesAndLanguages()); - -std::string wasmTestParamsToString(const ::testing::TestParamInfo& p); +std::string +wasmTestParamsToString(const ::testing::TestParamInfo>& p); } // namespace Wasm } // namespace Common diff --git a/test/extensions/common/wasm/wasm_test.cc b/test/extensions/common/wasm/wasm_test.cc index cd3b9be7b1681..ff7398083d9eb 100644 --- a/test/extensions/common/wasm/wasm_test.cc +++ b/test/extensions/common/wasm/wasm_test.cc @@ -80,7 +80,7 @@ class TestContext : public ::Envoy::Extensions::Common::Wasm::Context { MOCK_METHOD(void, log_, (spdlog::level::level_enum level, absl::string_view message)); }; -class WasmCommonTest : public testing::TestWithParam { +class WasmCommonTest : public testing::TestWithParam> { public: void SetUp() override { // NOLINT(readability-identifier-naming) Logger::Registry::getLog(Logger::Id::wasm).set_level(spdlog::level::debug); @@ -88,7 +88,9 @@ class WasmCommonTest : public testing::TestWithParam { } }; -INSTANTIATE_TEST_SUITE_P(Runtimes, WasmCommonTest, Envoy::Extensions::Common::Wasm::runtime_values); +INSTANTIATE_TEST_SUITE_P(Runtimes, WasmCommonTest, + Envoy::Extensions::Common::Wasm::runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); TEST_P(WasmCommonTest, WasmFailState) { Stats::IsolatedStoreImpl stats_store; @@ -166,16 +168,12 @@ TEST_P(WasmCommonTest, Logging) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); plugin_config.mutable_configuration()->set_value(plugin_configuration); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -221,7 +219,7 @@ TEST_P(WasmCommonTest, Logging) { auto root_context = static_cast(wasm_weak.lock()->start(plugin)); EXPECT_EQ(root_context->getConfiguration(), "logging"); - if (GetParam() != "null") { + if (std::get<0>(GetParam()) != "null") { EXPECT_TRUE(root_context->validateConfiguration("", plugin)); } wasm_weak.lock()->configure(root_context, plugin); @@ -237,13 +235,7 @@ TEST_P(WasmCommonTest, Logging) { } TEST_P(WasmCommonTest, BadSignature) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() != "v8") { + if (std::get<0>(GetParam()) != "v8") { return; } Stats::IsolatedStoreImpl stats_store; @@ -258,7 +250,7 @@ TEST_P(WasmCommonTest, BadSignature) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); auto plugin = std::make_shared( plugin_config, envoy::config::core::v3::TrafficDirection::UNSPECIFIED, local_info, nullptr); auto vm_key = proxy_wasm::makeVmKey("", "", code); @@ -271,13 +263,7 @@ TEST_P(WasmCommonTest, BadSignature) { } TEST_P(WasmCommonTest, Segv) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() != "v8") { + if (std::get<0>(GetParam()) != "v8") { return; } Stats::IsolatedStoreImpl stats_store; @@ -293,7 +279,7 @@ TEST_P(WasmCommonTest, Segv) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); auto plugin = std::make_shared( plugin_config, envoy::config::core::v3::TrafficDirection::UNSPECIFIED, local_info, nullptr); @@ -320,13 +306,7 @@ TEST_P(WasmCommonTest, Segv) { } TEST_P(WasmCommonTest, DivByZero) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() != "v8") { + if (std::get<0>(GetParam()) != "v8") { return; } Stats::IsolatedStoreImpl stats_store; @@ -339,7 +319,7 @@ TEST_P(WasmCommonTest, DivByZero) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( @@ -374,15 +354,11 @@ TEST_P(WasmCommonTest, IntrinsicGlobals) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -420,15 +396,11 @@ TEST_P(WasmCommonTest, Utilities) { auto vm_configuration = "utilities"; envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -466,7 +438,7 @@ TEST_P(WasmCommonTest, Utilities) { const_buffer.set(static_cast(buffer_impl.get())); string_buffer.set("contents"); std::string data("contents"); - if (GetParam() != "null") { + if (std::get<0>(GetParam()) != "null") { EXPECT_EQ(WasmResult::InvalidMemoryAccess, buffer.copyTo(wasm.get(), 0, 1 << 30 /* length too long */, 0, 0)); EXPECT_EQ(WasmResult::InvalidMemoryAccess, @@ -493,15 +465,11 @@ TEST_P(WasmCommonTest, Stats) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -544,7 +512,7 @@ TEST_P(WasmCommonTest, Foreign) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); auto plugin = std::make_shared( @@ -553,11 +521,7 @@ TEST_P(WasmCommonTest, Foreign) { *api, cluster_manager, *dispatcher); EXPECT_NE(wasm, nullptr); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -588,7 +552,7 @@ TEST_P(WasmCommonTest, OnForeign) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); auto plugin = std::make_shared( @@ -598,11 +562,7 @@ TEST_P(WasmCommonTest, OnForeign) { *api, cluster_manager, *dispatcher); EXPECT_NE(wasm, nullptr); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -626,7 +586,7 @@ TEST_P(WasmCommonTest, OnForeign) { } TEST_P(WasmCommonTest, WASI) { - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { // This test has no meaning unless it is invoked by actual Wasm code return; } @@ -640,7 +600,7 @@ TEST_P(WasmCommonTest, WASI) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); auto plugin = std::make_shared( @@ -650,11 +610,7 @@ TEST_P(WasmCommonTest, WASI) { EXPECT_NE(wasm, nullptr); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -689,7 +645,7 @@ TEST_P(WasmCommonTest, VmCache) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); plugin_config.mutable_configuration()->set_value(plugin_configuration); @@ -703,16 +659,12 @@ TEST_P(WasmCommonTest, VmCache) { })); auto vm_config = plugin_config.mutable_vm_config(); - vm_config->set_runtime(absl::StrCat("envoy.wasm.runtime.", GetParam())); + vm_config->set_runtime(absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam()))); ProtobufWkt::StringValue vm_configuration_string; vm_configuration_string.set_value(vm_configuration); vm_config->mutable_configuration()->PackFrom(vm_configuration_string); std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); } else { @@ -775,13 +727,7 @@ TEST_P(WasmCommonTest, VmCache) { } TEST_P(WasmCommonTest, RemoteCode) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -806,12 +752,12 @@ TEST_P(WasmCommonTest, RemoteCode) { // test that the proto_config parameter is released after the factory is created envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); plugin_config.mutable_configuration()->set_value(plugin_configuration); auto vm_config = plugin_config.mutable_vm_config(); - vm_config->set_runtime(absl::StrCat("envoy.wasm.runtime.", GetParam())); + vm_config->set_runtime(absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam()))); ProtobufWkt::BytesValue vm_configuration_bytes; vm_configuration_bytes.set_value(vm_configuration); vm_config->mutable_configuration()->PackFrom(vm_configuration_bytes); @@ -895,13 +841,7 @@ TEST_P(WasmCommonTest, RemoteCode) { } TEST_P(WasmCommonTest, RemoteCodeMultipleRetry) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -919,7 +859,7 @@ TEST_P(WasmCommonTest, RemoteCodeMultipleRetry) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); plugin_config.mutable_configuration()->set_value(plugin_configuration); @@ -927,7 +867,7 @@ TEST_P(WasmCommonTest, RemoteCodeMultipleRetry) { absl::StrCat("{{ test_rundir }}/test/extensions/common/wasm/test_data/test_cpp.wasm"))); auto vm_config = plugin_config.mutable_vm_config(); - vm_config->set_runtime(absl::StrCat("envoy.wasm.runtime.", GetParam())); + vm_config->set_runtime(absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam()))); ProtobufWkt::StringValue vm_configuration_string; vm_configuration_string.set_value(vm_configuration); vm_config->mutable_configuration()->PackFrom(vm_configuration_string); @@ -1023,13 +963,7 @@ TEST_P(WasmCommonTest, RemoteCodeMultipleRetry) { // test that wasm imports/exports do not work when ABI restriction is enforced TEST_P(WasmCommonTest, RestrictCapabilities) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -1042,7 +976,7 @@ TEST_P(WasmCommonTest, RestrictCapabilities) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( @@ -1083,13 +1017,7 @@ TEST_P(WasmCommonTest, RestrictCapabilities) { // test with proxy_on_vm_start allowed, but proxy_log restricted TEST_P(WasmCommonTest, AllowOnVmStart) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -1102,7 +1030,7 @@ TEST_P(WasmCommonTest, AllowOnVmStart) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( @@ -1145,13 +1073,7 @@ TEST_P(WasmCommonTest, AllowOnVmStart) { // test with both proxy_on_vm_start and proxy_log allowed, but WASI restricted TEST_P(WasmCommonTest, AllowLog) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -1164,7 +1086,7 @@ TEST_P(WasmCommonTest, AllowLog) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( @@ -1204,13 +1126,7 @@ TEST_P(WasmCommonTest, AllowLog) { // test with both proxy_on_vm_start and fd_write allowed, but proxy_log restricted TEST_P(WasmCommonTest, AllowWASI) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -1223,7 +1139,7 @@ TEST_P(WasmCommonTest, AllowWASI) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( @@ -1263,13 +1179,7 @@ TEST_P(WasmCommonTest, AllowWASI) { // test a different callback besides proxy_on_vm_start TEST_P(WasmCommonTest, AllowOnContextCreate) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -1282,7 +1192,7 @@ TEST_P(WasmCommonTest, AllowOnContextCreate) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( @@ -1324,13 +1234,7 @@ TEST_P(WasmCommonTest, AllowOnContextCreate) { // test that a copy-constructed thread-local Wasm still enforces the same policy TEST_P(WasmCommonTest, ThreadLocalCopyRetainsEnforcement) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } Stats::IsolatedStoreImpl stats_store; @@ -1343,7 +1247,7 @@ TEST_P(WasmCommonTest, ThreadLocalCopyRetainsEnforcement) { envoy::extensions::wasm::v3::PluginConfig plugin_config; *plugin_config.mutable_vm_config()->mutable_runtime() = - absl::StrCat("envoy.wasm.runtime.", GetParam()); + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())); plugin_config.mutable_vm_config()->mutable_configuration()->set_value(vm_configuration); const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( @@ -1393,15 +1297,15 @@ TEST_P(WasmCommonTest, ThreadLocalCopyRetainsEnforcement) { thread_local_wasm->start(plugin); } -class WasmCommonContextTest - : public Common::Wasm::WasmTestBase> { +class WasmCommonContextTest : public Common::Wasm::WasmTestBase< + testing::TestWithParam>> { public: WasmCommonContextTest() = default; void setup(const std::string& code, std::string vm_configuration, std::string root_id = "") { setRootId(root_id); setVmConfiguration(vm_configuration); - setupBase(GetParam(), code, + setupBase(std::get<0>(GetParam()), code, [](Wasm* wasm, const std::shared_ptr& plugin) -> ContextBase* { return new TestContext(wasm, plugin); }); @@ -1420,15 +1324,11 @@ class WasmCommonContextTest }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmCommonContextTest, - Envoy::Extensions::Common::Wasm::runtime_values); + Envoy::Extensions::Common::Wasm::runtime_and_cpp_values); TEST_P(WasmCommonContextTest, OnDnsResolve) { std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(absl::StrCat( "{{ test_rundir }}/test/extensions/common/wasm/test_data/test_context_cpp.wasm"))); } else { @@ -1464,10 +1364,10 @@ TEST_P(WasmCommonContextTest, OnDnsResolve) { rootContext().onResolveDns(1 /* token */, Envoy::Network::DnsResolver::ResolutionStatus::Failure, {}); - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { rootContext().onTick(0); } - if (GetParam() == "v8") { + if (std::get<0>(GetParam()) == "v8") { rootContext().onQueueReady(0); } // Wait till the Wasm is destroyed and then the late callback should do nothing. @@ -1480,11 +1380,7 @@ TEST_P(WasmCommonContextTest, OnDnsResolve) { TEST_P(WasmCommonContextTest, EmptyContext) { std::string code; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(absl::StrCat( "{{ test_rundir }}/test/extensions/common/wasm/test_data/test_context_cpp.wasm"))); } else { diff --git a/test/extensions/filters/http/wasm/config_test.cc b/test/extensions/filters/http/wasm/config_test.cc index 5e4f66d6f375b..7a56307760222 100644 --- a/test/extensions/filters/http/wasm/config_test.cc +++ b/test/extensions/filters/http/wasm/config_test.cc @@ -30,7 +30,7 @@ namespace HttpFilters { namespace Wasm { class WasmFilterConfigTest : public Event::TestUsingSimulatedTime, - public testing::TestWithParam { + public testing::TestWithParam> { protected: WasmFilterConfigTest() : api_(Api::createApiForTest(stats_store_)) { ON_CALL(context_, api()).WillByDefault(ReturnRef(*api_)); @@ -65,22 +65,18 @@ class WasmFilterConfigTest : public Event::TestUsingSimulatedTime, }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmFilterConfigTest, - Envoy::Extensions::Common::Wasm::sandbox_runtime_values); + Envoy::Extensions::Common::Wasm::sandbox_runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WasmFilterConfigTest); TEST_P(WasmFilterConfigTest, JsonLoadFromFileWasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - const std::string json = TestEnvironment::substitute(absl::StrCat(R"EOF( + const std::string json = + TestEnvironment::substitute(absl::StrCat(R"EOF( { "config" : { "vm_config": { "runtime": "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(", + std::get<0>(GetParam()), R"EOF(", "configuration": { "@type": "type.googleapis.com/google.protobuf.StringValue", "value": "some configuration" @@ -107,17 +103,11 @@ TEST_P(WasmFilterConfigTest, JsonLoadFromFileWasm) { } TEST_P(WasmFilterConfigTest, YamlLoadFromFileWasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" configuration: "@type": "type.googleapis.com/google.protobuf.StringValue" value: "some configuration" @@ -156,18 +146,12 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromFileWasm) { } TEST_P(WasmFilterConfigTest, YamlLoadFromFileWasmFailOpenOk) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( config: fail_open: true vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" configuration: "@type": "type.googleapis.com/google.protobuf.StringValue" value: "some configuration" @@ -190,12 +174,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromFileWasmFailOpenOk) { } TEST_P(WasmFilterConfigTest, YamlLoadInlineWasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); EXPECT_FALSE(code.empty()); @@ -203,7 +181,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadInlineWasm) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: { inline_bytes: ")EOF", Base64::encode(code.data(), code.size()), R"EOF(" } @@ -226,7 +204,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadInlineBadCode) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: inline_string: "bad code" @@ -240,12 +218,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadInlineBadCode) { } TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); const std::string sha256 = Hex::encode( @@ -254,7 +226,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasm) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -295,12 +267,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasm) { } TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailOnUncachedThenSucceed) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); const std::string sha256 = Hex::encode( @@ -310,7 +276,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailOnUncachedThenSucceed) { vm_config: nack_on_code_cache_miss: true runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -367,12 +333,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailOnUncachedThenSucceed) { } TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); const std::string sha256 = Hex::encode( @@ -382,7 +342,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) { vm_config: nack_on_code_cache_miss: true runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -499,12 +459,13 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) { // Case 5: flush the stale cache. const std::string sha256_2 = sha256 + "new"; - const std::string yaml2 = TestEnvironment::substitute(absl::StrCat(R"EOF( + const std::string yaml2 = + TestEnvironment::substitute(absl::StrCat(R"EOF( config: vm_config: nack_on_code_cache_miss: true runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -514,7 +475,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) { retry_policy: num_retries: 0 sha256: )EOF", - sha256_2)); + sha256_2)); envoy::extensions::filters::http::wasm::v3::Wasm proto_config2; TestUtility::loadFromYaml(yaml2, proto_config2); @@ -565,12 +526,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) { } TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteConnectionReset) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); const std::string sha256 = Hex::encode( @@ -579,7 +534,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteConnectionReset) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -613,12 +568,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteConnectionReset) { } TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessWith503) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); const std::string sha256 = Hex::encode( @@ -627,7 +576,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessWith503) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -664,12 +613,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessWith503) { } TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessIncorrectSha256) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); const std::string sha256 = Hex::encode( @@ -678,7 +621,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessIncorrectSha256) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -715,12 +658,6 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessIncorrectSha256) { } TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteMultipleRetries) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif initializeForRemote(); const std::string code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/http/wasm/test_data/test_cpp.wasm")); @@ -730,7 +667,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteMultipleRetries) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -801,7 +738,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessBadcode) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: @@ -871,7 +808,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteSuccessBadcodeFailOpen) { fail_open: true vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: remote: http_uri: diff --git a/test/extensions/filters/http/wasm/wasm_filter_test.cc b/test/extensions/filters/http/wasm/wasm_filter_test.cc index c5227d88a369b..daf77952f9e34 100644 --- a/test/extensions/filters/http/wasm/wasm_filter_test.cc +++ b/test/extensions/filters/http/wasm/wasm_filter_test.cc @@ -101,7 +101,8 @@ class WasmHttpFilterTest : public Common::Wasm::WasmHttpFilterTestBase< }; INSTANTIATE_TEST_SUITE_P(RuntimesAndLanguages, WasmHttpFilterTest, - Envoy::Extensions::Common::Wasm::runtime_and_language_values); + Envoy::Extensions::Common::Wasm::runtime_and_language_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); // Bad code in initial config. TEST_P(WasmHttpFilterTest, BadCode) { diff --git a/test/extensions/filters/network/wasm/config_test.cc b/test/extensions/filters/network/wasm/config_test.cc index 30b1c0ab7e66d..c686af0f7f506 100644 --- a/test/extensions/filters/network/wasm/config_test.cc +++ b/test/extensions/filters/network/wasm/config_test.cc @@ -22,7 +22,8 @@ namespace Extensions { namespace NetworkFilters { namespace Wasm { -class WasmNetworkFilterConfigTest : public testing::TestWithParam { +class WasmNetworkFilterConfigTest + : public testing::TestWithParam> { protected: WasmNetworkFilterConfigTest() : api_(Api::createApiForTest(stats_store_)) { ON_CALL(context_, api()).WillByDefault(ReturnRef(*api_)); @@ -57,23 +58,18 @@ class WasmNetworkFilterConfigTest : public testing::TestWithParam { }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmNetworkFilterConfigTest, - Envoy::Extensions::Common::Wasm::runtime_values); + Envoy::Extensions::Common::Wasm::runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); TEST_P(WasmNetworkFilterConfigTest, YamlLoadFromFileWasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: filename: "{{ test_rundir }}/test/extensions/filters/network/wasm/test_data/test_cpp.wasm" @@ -106,14 +102,8 @@ TEST_P(WasmNetworkFilterConfigTest, YamlLoadFromFileWasm) { } TEST_P(WasmNetworkFilterConfigTest, YamlLoadInlineWasm) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif const std::string code = - GetParam() != "null" + std::get<0>(GetParam()) != "null" ? TestEnvironment::readFileToStringForTest(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/filters/network/wasm/test_data/test_cpp.wasm")) : "NetworkTestCpp"; @@ -122,7 +112,7 @@ TEST_P(WasmNetworkFilterConfigTest, YamlLoadInlineWasm) { config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: { inline_bytes: ")EOF", Base64::encode(code.data(), code.size()), R"EOF(" } @@ -146,7 +136,7 @@ TEST_P(WasmNetworkFilterConfigTest, YamlLoadInlineBadCode) { name: "test" vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: { inline_string: "bad code" } )EOF"); @@ -166,7 +156,7 @@ TEST_P(WasmNetworkFilterConfigTest, YamlLoadInlineBadCodeFailOpenNackConfig) { fail_open: true vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: { inline_string: "bad code" } )EOF"); @@ -180,20 +170,14 @@ TEST_P(WasmNetworkFilterConfigTest, YamlLoadInlineBadCodeFailOpenNackConfig) { } TEST_P(WasmNetworkFilterConfigTest, FilterConfigFailClosed) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: filename: "{{ test_rundir }}/test/extensions/filters/network/wasm/test_data/test_cpp.wasm" @@ -209,13 +193,7 @@ TEST_P(WasmNetworkFilterConfigTest, FilterConfigFailClosed) { } TEST_P(WasmNetworkFilterConfigTest, FilterConfigFailOpen) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( @@ -223,7 +201,7 @@ TEST_P(WasmNetworkFilterConfigTest, FilterConfigFailOpen) { fail_open: true vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: filename: "{{ test_rundir }}/test/extensions/filters/network/wasm/test_data/test_cpp.wasm" @@ -237,20 +215,14 @@ TEST_P(WasmNetworkFilterConfigTest, FilterConfigFailOpen) { } TEST_P(WasmNetworkFilterConfigTest, FilterConfigCapabilitiesUnrestrictedByDefault) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: filename: "{{ test_rundir }}/test/extensions/filters/network/wasm/test_data/test_cpp.wasm" @@ -270,20 +242,14 @@ TEST_P(WasmNetworkFilterConfigTest, FilterConfigCapabilitiesUnrestrictedByDefaul } TEST_P(WasmNetworkFilterConfigTest, FilterConfigCapabilityRestriction) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: filename: "{{ test_rundir }}/test/extensions/filters/network/wasm/test_data/test_cpp.wasm" @@ -305,20 +271,14 @@ TEST_P(WasmNetworkFilterConfigTest, FilterConfigCapabilityRestriction) { } TEST_P(WasmNetworkFilterConfigTest, FilterConfigAllowOnVmStart) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif - if (GetParam() == "null") { + if (std::get<0>(GetParam()) == "null") { return; } const std::string yaml = TestEnvironment::substitute(absl::StrCat(R"EOF( config: vm_config: runtime: "envoy.wasm.runtime.)EOF", - GetParam(), R"EOF(" + std::get<0>(GetParam()), R"EOF(" code: local: filename: "{{ test_rundir }}/test/extensions/filters/network/wasm/test_data/test_cpp.wasm" diff --git a/test/extensions/filters/network/wasm/wasm_filter_test.cc b/test/extensions/filters/network/wasm/wasm_filter_test.cc index 472376c1c8be7..a04cff29793e5 100644 --- a/test/extensions/filters/network/wasm/wasm_filter_test.cc +++ b/test/extensions/filters/network/wasm/wasm_filter_test.cc @@ -91,7 +91,8 @@ class WasmNetworkFilterTest : public Extensions::Common::Wasm::WasmNetworkFilter }; INSTANTIATE_TEST_SUITE_P(RuntimesAndLanguages, WasmNetworkFilterTest, - Envoy::Extensions::Common::Wasm::runtime_and_language_values); + Envoy::Extensions::Common::Wasm::runtime_and_language_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); // Bad code in initial config. TEST_P(WasmNetworkFilterTest, BadCode) { diff --git a/test/extensions/stats_sinks/wasm/config_test.cc b/test/extensions/stats_sinks/wasm/config_test.cc index ac643ceb1229f..cb46b22b1c558 100644 --- a/test/extensions/stats_sinks/wasm/config_test.cc +++ b/test/extensions/stats_sinks/wasm/config_test.cc @@ -20,12 +20,12 @@ namespace Extensions { namespace StatSinks { namespace Wasm { -class WasmStatSinkConfigTest : public testing::TestWithParam { +class WasmStatSinkConfigTest : public testing::TestWithParam> { protected: WasmStatSinkConfigTest() { config_.mutable_config()->mutable_vm_config()->set_runtime( - absl::StrCat("envoy.wasm.runtime.", GetParam())); - if (GetParam() != "null") { + absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam()))); + if (std::get<0>(GetParam()) != "null") { config_.mutable_config()->mutable_vm_config()->mutable_code()->mutable_local()->set_filename( TestEnvironment::substitute( "{{ test_rundir " @@ -65,7 +65,8 @@ class WasmStatSinkConfigTest : public testing::TestWithParam { }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmStatSinkConfigTest, - Envoy::Extensions::Common::Wasm::runtime_values); + Envoy::Extensions::Common::Wasm::runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); TEST_P(WasmStatSinkConfigTest, CreateWasmFromEmpty) { envoy::extensions::stat_sinks::wasm::v3::Wasm config; @@ -81,12 +82,6 @@ TEST_P(WasmStatSinkConfigTest, CreateWasmFailOpen) { } TEST_P(WasmStatSinkConfigTest, CreateWasmFromWASM) { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - if (GetParam() != "null") { - return; - } -#endif initializeWithConfig(config_); EXPECT_NE(sink_, nullptr); diff --git a/test/extensions/stats_sinks/wasm/wasm_stat_sink_test.cc b/test/extensions/stats_sinks/wasm/wasm_stat_sink_test.cc index 1278a90e1ce36..8d0a36283ab91 100644 --- a/test/extensions/stats_sinks/wasm/wasm_stat_sink_test.cc +++ b/test/extensions/stats_sinks/wasm/wasm_stat_sink_test.cc @@ -31,14 +31,14 @@ class TestContext : public ::Envoy::Extensions::Common::Wasm::Context { MOCK_METHOD(void, log_, (spdlog::level::level_enum level, absl::string_view message)); }; -class WasmCommonContextTest - : public Common::Wasm::WasmTestBase> { +class WasmCommonContextTest : public Common::Wasm::WasmTestBase< + testing::TestWithParam>> { public: WasmCommonContextTest() = default; void setup(const std::string& code, std::string root_id = "") { setRootId(root_id); - setupBase(GetParam(), code, + setupBase(std::get<0>(GetParam()), code, [](Wasm* wasm, const std::shared_ptr& plugin) -> ContextBase* { return new TestContext(wasm, plugin); }); @@ -56,16 +56,13 @@ class WasmCommonContextTest }; INSTANTIATE_TEST_SUITE_P(Runtimes, WasmCommonContextTest, - Envoy::Extensions::Common::Wasm::runtime_values); + Envoy::Extensions::Common::Wasm::runtime_and_cpp_values, + Envoy::Extensions::Common::Wasm::wasmTestParamsToString); TEST_P(WasmCommonContextTest, OnStat) { std::string code; NiceMock snapshot_; - if (GetParam() != "null") { -#if !defined(__x86_64__) - // TODO(PiotrSikora): Emscripten ships binaries only for x86_64. - return; -#endif + if (std::get<0>(GetParam()) != "null") { code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(absl::StrCat( "{{ test_rundir }}/test/extensions/stats_sinks/wasm/test_data/test_context_cpp.wasm"))); } else {