diff --git a/test/common/buffer/owned_impl_test.cc b/test/common/buffer/owned_impl_test.cc index 6934fc63c2f4..bd06b3233da8 100644 --- a/test/common/buffer/owned_impl_test.cc +++ b/test/common/buffer/owned_impl_test.cc @@ -649,19 +649,24 @@ TEST_F(OwnedImplTest, ReserveZeroCommit) { slices[i].len_ = 0; } buf.commit(slices, allocated_slices); - int pipe_fds[2] = {0, 0}; - ASSERT_EQ(::pipe(pipe_fds), 0); + os_fd_t pipe_fds[2] = {0, 0}; + auto& os_sys_calls = Api::OsSysCallsSingleton::get(); +#ifdef WIN32 + ASSERT_EQ(os_sys_calls.socketpair(AF_INET, SOCK_STREAM, 0, pipe_fds).rc_, 0); +#else + ASSERT_EQ(pipe(pipe_fds), 0); +#endif Network::IoSocketHandleImpl io_handle(pipe_fds[0]); - ASSERT_EQ(::fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK), 0); - ASSERT_EQ(::fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK), 0); + ASSERT_EQ(os_sys_calls.setsocketblocking(pipe_fds[0], false).rc_, 0); + ASSERT_EQ(os_sys_calls.setsocketblocking(pipe_fds[1], false).rc_, 0); const uint32_t max_length = 1953; std::string data(max_length, 'e'); - const ssize_t rc = ::write(pipe_fds[1], data.data(), max_length); + const ssize_t rc = os_sys_calls.write(pipe_fds[1], data.data(), max_length).rc_; ASSERT_GT(rc, 0); const uint32_t previous_length = buf.length(); Api::IoCallUint64Result result = buf.read(io_handle, max_length); ASSERT_EQ(result.rc_, static_cast(rc)); - ASSERT_EQ(::close(pipe_fds[1]), 0); + ASSERT_EQ(os_sys_calls.close(pipe_fds[1]).rc_, 0); ASSERT_EQ(previous_length, buf.search(data.data(), rc, previous_length)); EXPECT_EQ("bbbbb", buf.toString().substr(0, 5)); expectSlices({{5, 0, 4056}, {1953, 2103, 4056}}, buf); @@ -672,19 +677,24 @@ TEST_F(OwnedImplTest, ReadReserveAndCommit) { Buffer::OwnedImpl buf; buf.add("bbbbb"); - int pipe_fds[2] = {0, 0}; - ASSERT_EQ(::pipe(pipe_fds), 0); + os_fd_t pipe_fds[2] = {0, 0}; + auto& os_sys_calls = Api::OsSysCallsSingleton::get(); +#ifdef WIN32 + ASSERT_EQ(os_sys_calls.socketpair(AF_INET, SOCK_STREAM, 0, pipe_fds).rc_, 0); +#else + ASSERT_EQ(pipe(pipe_fds), 0); +#endif Network::IoSocketHandleImpl io_handle(pipe_fds[0]); - ASSERT_EQ(::fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK), 0); - ASSERT_EQ(::fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK), 0); + ASSERT_EQ(os_sys_calls.setsocketblocking(pipe_fds[0], false).rc_, 0); + ASSERT_EQ(os_sys_calls.setsocketblocking(pipe_fds[1], false).rc_, 0); const uint32_t read_length = 32768; std::string data = "e"; - const ssize_t rc = ::write(pipe_fds[1], data.data(), data.size()); + const ssize_t rc = os_sys_calls.write(pipe_fds[1], data.data(), data.size()).rc_; ASSERT_GT(rc, 0); Api::IoCallUint64Result result = buf.read(io_handle, read_length); ASSERT_EQ(result.rc_, static_cast(rc)); - ASSERT_EQ(::close(pipe_fds[1]), 0); + ASSERT_EQ(os_sys_calls.close(pipe_fds[1]).rc_, 0); EXPECT_EQ("bbbbbe", buf.toString()); expectSlices({{6, 4050, 4056}}, buf); } diff --git a/test/common/buffer/watermark_buffer_test.cc b/test/common/buffer/watermark_buffer_test.cc index 1010e649843b..f5c13fa7e177 100644 --- a/test/common/buffer/watermark_buffer_test.cc +++ b/test/common/buffer/watermark_buffer_test.cc @@ -1,5 +1,6 @@ #include +#include "common/api/os_sys_calls_impl.h" #include "common/buffer/buffer_impl.h" #include "common/buffer/watermark_buffer.h" #include "common/network/io_socket_handle_impl.h" @@ -199,7 +200,12 @@ TEST_F(WatermarkBufferTest, MoveOneByte) { TEST_F(WatermarkBufferTest, WatermarkFdFunctions) { os_fd_t pipe_fds[2] = {0, 0}; +#ifdef WIN32 + auto& os_sys_calls = Api::OsSysCallsSingleton::get(); + ASSERT_EQ(0, os_sys_calls.socketpair(AF_INET, SOCK_STREAM, 0, pipe_fds).rc_); +#else ASSERT_EQ(0, pipe(pipe_fds)); +#endif buffer_.add(TEN_BYTES, 10); buffer_.add(TEN_BYTES, 10); diff --git a/test/common/grpc/BUILD b/test/common/grpc/BUILD index d790518e77bb..612f7f798b5b 100644 --- a/test/common/grpc/BUILD +++ b/test/common/grpc/BUILD @@ -161,6 +161,8 @@ envoy_cc_test_library( envoy_cc_test( name = "grpc_client_integration_test", srcs = ["grpc_client_integration_test.cc"], + # Fails on windows; Connection is terminated early testing BasicStream/IPv4_EnvoyGrpc + tags = ["fails_on_windows"], deps = [ ":grpc_client_integration_test_harness_lib", "//source/common/grpc:async_client_lib", diff --git a/test/common/http/BUILD b/test/common/http/BUILD index 5382d74c085c..91fc3ec75460 100644 --- a/test/common/http/BUILD +++ b/test/common/http/BUILD @@ -49,6 +49,8 @@ envoy_cc_test( envoy_cc_test( name = "codec_client_test", srcs = ["codec_client_test.cc"], + # IpVersions/CodecNetworkTest.SendData/IPv4: Test times out on Windows. + tags = ["fails_on_windows"], deps = [ ":common_lib", "//source/common/buffer:buffer_lib", diff --git a/test/common/http/http2/codec_impl_test.cc b/test/common/http/http2/codec_impl_test.cc index 8ad4de81ccd7..6ee56bf7234f 100644 --- a/test/common/http/http2/codec_impl_test.cc +++ b/test/common/http/http2/codec_impl_test.cc @@ -987,9 +987,6 @@ TEST_P(Http2CodecImplTest, WatermarkUnderEndStream) { response_encoder_->encodeHeaders(response_headers, true); } -class Http2CodecImplSettingsBasicTest : public Http2CodecImplTest {}; -TEST_P(Http2CodecImplSettingsBasicTest, ) {} - class Http2CodecImplStreamLimitTest : public Http2CodecImplTest {}; // Regression test for issue #3076. diff --git a/test/common/network/BUILD b/test/common/network/BUILD index 5c56a6262709..3f9b79c5e7a6 100644 --- a/test/common/network/BUILD +++ b/test/common/network/BUILD @@ -73,6 +73,8 @@ envoy_cc_test( envoy_cc_test( name = "connection_impl_test", srcs = ["connection_impl_test.cc"], + # Times out on Windows + tags = ["fails_on_windows"], deps = [ "//source/common/buffer:buffer_lib", "//source/common/common:empty_string", @@ -177,6 +179,8 @@ envoy_cc_test( envoy_cc_test( name = "listener_impl_test", srcs = ["listener_impl_test.cc"], + # Times out on Windows + tags = ["fails_on_windows"], deps = [ "//source/common/event:dispatcher_lib", "//source/common/network:address_lib", diff --git a/test/common/network/dns_impl_test.cc b/test/common/network/dns_impl_test.cc index d2f41dc1b4f2..38abf99b904a 100644 --- a/test/common/network/dns_impl_test.cc +++ b/test/common/network/dns_impl_test.cc @@ -1,13 +1,10 @@ -#include -#include -#include - #include #include #include #include #include +#include "envoy/common/platform.h" #include "envoy/config/core/v3/address.pb.h" #include "envoy/event/dispatcher.h" #include "envoy/network/address.h" @@ -34,6 +31,13 @@ #include "ares_dns.h" #include "gtest/gtest.h" +#if !defined(WIN32) +#include +#include +#else +#include "nameser.h" +#endif + using testing::_; using testing::Contains; using testing::InSequence; diff --git a/test/common/router/BUILD b/test/common/router/BUILD index 2ac9c91f26f3..c3cab9845d2c 100644 --- a/test/common/router/BUILD +++ b/test/common/router/BUILD @@ -221,6 +221,8 @@ envoy_cc_fuzz_test( name = "route_fuzz_test", srcs = ["route_fuzz_test.cc"], corpus = ":route_corpus", + # The corpus_from_config_impl currently does not work, the tests it runs do not pass + tags = ["skip_on_windows"], deps = [ ":route_fuzz_proto_cc_proto", "//source/common/router:config_lib", diff --git a/test/common/runtime/BUILD b/test/common/runtime/BUILD index c2cd9d5be4be..1df1476d4149 100644 --- a/test/common/runtime/BUILD +++ b/test/common/runtime/BUILD @@ -29,6 +29,8 @@ envoy_cc_test_library( envoy_cc_test( name = "runtime_protos_test", srcs = ["runtime_protos_test.cc"], + # Pass for the time being, test times out on windows + tags = ["fails_on_windows"], deps = [ "//source/common/runtime:runtime_lib", "//test/mocks/runtime:runtime_mocks", @@ -42,6 +44,9 @@ envoy_cc_test( name = "runtime_impl_test", srcs = ["runtime_impl_test.cc"], data = glob(["test_data/**"]) + ["filesystem_setup.sh"], + # Inexplicable failure promoting arguments to mock, see + # https://envoyproxy.slack.com/archives/CNAK09BSB/p1571946165007300 + tags = ["fails_on_windows"], deps = [ "//source/common/config:runtime_utility_lib", "//source/common/runtime:runtime_lib", diff --git a/test/common/signal/BUILD b/test/common/signal/BUILD index c29cfd2a56b3..746babe0fedf 100644 --- a/test/common/signal/BUILD +++ b/test/common/signal/BUILD @@ -11,7 +11,11 @@ envoy_package() envoy_cc_test( name = "signals_test", srcs = ["signals_test.cc"], - tags = ["backtrace"], + # Posix signal tests are irrelevant to Windows + tags = [ + "backtrace", + "skip_on_windows", + ], deps = [ "//source/common/signal:sigaction_lib", "//test/test_common:utility_lib", diff --git a/test/exe/BUILD b/test/exe/BUILD index 9c43e1b1ead8..7540aafa7525 100644 --- a/test/exe/BUILD +++ b/test/exe/BUILD @@ -17,6 +17,8 @@ envoy_sh_test( "//bazel:raw_build_id.ldscript", "//source/exe:envoy-static", ], + # The sh_test helper from Bazel does not work as expected, see: https://github.com/bazelbuild/bazel/issues/10959 + tags = ["fails_on_windows"], ) envoy_sh_test( @@ -24,8 +26,14 @@ envoy_sh_test( srcs = ["envoy_static_test.sh"], coverage = False, data = ["//source/exe:envoy-static"], + # For windows, we expect to use a .ps1 script that leverages dumpbin.exe, see: + # https://github.com/envoyproxy/envoy/pull/8280#pullrequestreview-290187328 + # The sh_test helper from Bazel does not work as expected, see: https://github.com/bazelbuild/bazel/issues/10959 # Sanitizers doesn't like statically linked lib(std)c++ and libgcc, skip this test in that context. - tags = ["no_san"], + tags = [ + "fails_on_windows", + "no_san", + ], ) envoy_sh_test( @@ -33,7 +41,11 @@ envoy_sh_test( srcs = ["pie_test.sh"], coverage = False, data = ["//source/exe:envoy-static"], - tags = ["nofips"], + # Since VS2015 or even earlier, link.exe defaults to PIE generation + tags = [ + "nofips", + "skip_on_windows", + ], ) envoy_sh_test( @@ -45,6 +57,8 @@ envoy_sh_test( "//bazel:raw_build_id.ldscript", "//source/exe:envoy-static", ], + # The sh_test helper from Bazel does not work as expected, see: https://github.com/bazelbuild/bazel/issues/10959 + tags = ["fails_on_windows"], ) envoy_cc_test( diff --git a/test/exe/main_common_test.cc b/test/exe/main_common_test.cc index ac625f349a07..78fe3aeebfcf 100644 --- a/test/exe/main_common_test.cc +++ b/test/exe/main_common_test.cc @@ -59,7 +59,12 @@ class MainCommonTest : public testing::TestWithParam uri_sans{"foo", "baz"}; const std::vector dns_sans; + const std::string subject = "subject"; EXPECT_CALL(*ssl, uriSanPeerCertificate()).WillRepeatedly(Return(uri_sans)); EXPECT_CALL(*ssl, dnsSansPeerCertificate()).WillRepeatedly(Return(dns_sans)); - EXPECT_CALL(*ssl, subjectPeerCertificate()).WillRepeatedly(ReturnRef("subject")); + EXPECT_CALL(*ssl, subjectPeerCertificate()).WillRepeatedly(ReturnRef(subject)); EXPECT_CALL(Const(conn), ssl()).WillRepeatedly(Return(ssl)); @@ -272,6 +273,7 @@ TEST(AuthenticatedMatcher, dnsSanPeerCertificate) { const std::vector uri_sans{"uri_foo"}; const std::vector dns_sans{"foo", "baz"}; + const std::string subject = "subject"; EXPECT_CALL(*ssl, uriSanPeerCertificate()).WillRepeatedly(Return(uri_sans)); EXPECT_CALL(Const(conn), ssl()).WillRepeatedly(Return(ssl)); @@ -279,7 +281,7 @@ TEST(AuthenticatedMatcher, dnsSanPeerCertificate) { EXPECT_CALL(*ssl, dnsSansPeerCertificate()).WillRepeatedly(Return(dns_sans)); EXPECT_CALL(Const(conn), ssl()).WillRepeatedly(Return(ssl)); - EXPECT_CALL(*ssl, subjectPeerCertificate()).WillRepeatedly(ReturnRef("subject")); + EXPECT_CALL(*ssl, subjectPeerCertificate()).WillRepeatedly(ReturnRef(subject)); // We should get check if any DNS SAN matches as URI SAN is not available. envoy::config::rbac::v3::Principal::Authenticated auth; @@ -374,9 +376,10 @@ TEST(PolicyMatcher, PolicyMatcher) { const std::vector uri_sans{"bar", "baz"}; const std::vector dns_sans; + const std::string subject = "subject"; EXPECT_CALL(*ssl, uriSanPeerCertificate()).Times(4).WillRepeatedly(Return(uri_sans)); EXPECT_CALL(*ssl, dnsSansPeerCertificate()).WillRepeatedly(Return(dns_sans)); - EXPECT_CALL(*ssl, subjectPeerCertificate()).WillRepeatedly(ReturnRef("subject")); + EXPECT_CALL(*ssl, subjectPeerCertificate()).WillRepeatedly(ReturnRef(subject)); EXPECT_CALL(Const(conn), ssl()).Times(2).WillRepeatedly(Return(ssl)); EXPECT_CALL(Const(info), downstreamLocalAddress()).Times(2).WillRepeatedly(ReturnRef(addr)); diff --git a/test/extensions/filters/listener/http_inspector/http_inspector_test.cc b/test/extensions/filters/listener/http_inspector/http_inspector_test.cc index b028974fcb8d..c55189470427 100644 --- a/test/extensions/filters/listener/http_inspector/http_inspector_test.cc +++ b/test/extensions/filters/listener/http_inspector/http_inspector_test.cc @@ -78,7 +78,7 @@ TEST_F(HttpInspectorTest, SkipHttpInspectForTLS) { TEST_F(HttpInspectorTest, InlineReadIoError) { init(/*include_inline_recv=*/false); EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([](int, void*, size_t, int) -> Api::SysCallSizeResult { + .WillOnce(Invoke([](os_fd_t, void*, size_t, int) -> Api::SysCallSizeResult { return Api::SysCallSizeResult{ssize_t(-1), 0}; })); EXPECT_CALL(dispatcher_, createFileEvent_(_, _, _, _)).Times(0); @@ -98,11 +98,12 @@ TEST_F(HttpInspectorTest, InlineReadInspectHttp10) { "a52df4a0-ed00-4a19-86a7-80e5049c6c84\r\nx-envoy-expected-rq-timeout-ms: " "15000\r\ncontent-length: 0\r\n\r\n"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); const std::vector alpn_protos{absl::string_view("http/1.0")}; EXPECT_CALL(dispatcher_, createFileEvent_(_, _, _, _)).Times(0); @@ -122,11 +123,12 @@ TEST_F(HttpInspectorTest, InlineReadParseError) { "a52df4a0-ed00-4a19-86a7-80e5049c6c84\r\nx-envoy-expected-rq-timeout-ms: " "15000\r\ncontent-length: 0\r\n\r\n"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); EXPECT_CALL(dispatcher_, createFileEvent_(_, _, _, _)).Times(0); EXPECT_CALL(socket_, setRequestedApplicationProtocols(_)).Times(0); auto accepted = filter_->onAccept(cb_); @@ -143,11 +145,12 @@ TEST_F(HttpInspectorTest, InspectHttp10) { "15000\r\ncontent-length: 0\r\n\r\n"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); const std::vector alpn_protos{absl::string_view("http/1.0")}; @@ -166,11 +169,12 @@ TEST_F(HttpInspectorTest, InspectHttp11) { "15000\r\ncontent-length: 0\r\n\r\n"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); const std::vector alpn_protos{absl::string_view("http/1.1")}; @@ -189,11 +193,12 @@ TEST_F(HttpInspectorTest, InspectHttp11WithNonEmptyRequestBody) { "15000\r\ncontent-length: 3\r\n\r\nfoo"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); const std::vector alpn_protos{absl::string_view("http/1.1")}; @@ -209,11 +214,12 @@ TEST_F(HttpInspectorTest, ExtraSpaceInRequestLine) { // ^^ ^^ EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); const std::vector alpn_protos{absl::string_view("http/1.1")}; @@ -228,11 +234,12 @@ TEST_F(HttpInspectorTest, InvalidHttpMethod) { const absl::string_view header = "BAD /anything HTTP/1.1"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); EXPECT_CALL(socket_, setRequestedApplicationProtocols(_)).Times(0); EXPECT_CALL(cb_, continueFilterChain(true)); @@ -245,11 +252,12 @@ TEST_F(HttpInspectorTest, InvalidHttpRequestLine) { const absl::string_view header = "BAD /anything HTTP/1.1\r\n"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); EXPECT_CALL(socket_, setRequestedApplicationProtocols(_)).Times(0); EXPECT_CALL(cb_, continueFilterChain(_)); @@ -262,11 +270,12 @@ TEST_F(HttpInspectorTest, OldHttpProtocol) { const absl::string_view header = "GET /anything HTTP/0.9\r\n"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); const std::vector alpn_protos{absl::string_view("http/1.0")}; EXPECT_CALL(socket_, setRequestedApplicationProtocols(alpn_protos)); @@ -280,11 +289,12 @@ TEST_F(HttpInspectorTest, InvalidRequestLine) { const absl::string_view header = "GET /anything HTTP/1.1 BadRequestLine\r\n"; EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&header](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= header.size()); - memcpy(buffer, header.data(), header.size()); - return Api::SysCallSizeResult{ssize_t(header.size()), 0}; - })); + .WillOnce( + Invoke([&header](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= header.size()); + memcpy(buffer, header.data(), header.size()); + return Api::SysCallSizeResult{ssize_t(header.size()), 0}; + })); EXPECT_CALL(socket_, setRequestedApplicationProtocols(_)).Times(0); EXPECT_CALL(cb_, continueFilterChain(true)); @@ -304,11 +314,12 @@ TEST_F(HttpInspectorTest, InspectHttp2) { std::vector data = Hex::decode(header); EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&data](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= data.size()); - memcpy(buffer, data.data(), data.size()); - return Api::SysCallSizeResult{ssize_t(data.size()), 0}; - })); + .WillOnce( + Invoke([&data](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= data.size()); + memcpy(buffer, data.data(), data.size()); + return Api::SysCallSizeResult{ssize_t(data.size()), 0}; + })); const std::vector alpn_protos{absl::string_view("h2c")}; @@ -325,11 +336,12 @@ TEST_F(HttpInspectorTest, InvalidConnectionPreface) { const std::vector data = Hex::decode(header); EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&data](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= data.size()); - memcpy(buffer, data.data(), data.size()); - return Api::SysCallSizeResult{ssize_t(data.size()), 0}; - })); + .WillOnce( + Invoke([&data](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + ASSERT(length >= data.size()); + memcpy(buffer, data.data(), data.size()); + return Api::SysCallSizeResult{ssize_t(data.size()), 0}; + })); EXPECT_CALL(socket_, setRequestedApplicationProtocols(_)).Times(0); EXPECT_CALL(cb_, continueFilterChain(true)).Times(0); @@ -368,8 +380,8 @@ TEST_F(HttpInspectorTest, MultipleReadsHttp2) { for (size_t i = 1; i <= 24; i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce( - Invoke([&data, i](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + .WillOnce(Invoke( + [&data, i](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= i); memcpy(buffer, data.data(), i); return Api::SysCallSizeResult{ssize_t(i), 0}; @@ -401,8 +413,8 @@ TEST_F(HttpInspectorTest, MultipleReadsHttp2BadPreface) { for (size_t i = 1; i <= data.size(); i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce( - Invoke([&data, i](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + .WillOnce(Invoke( + [&data, i](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= i); memcpy(buffer, data.data(), i); return Api::SysCallSizeResult{ssize_t(i), 0}; @@ -433,8 +445,8 @@ TEST_F(HttpInspectorTest, MultipleReadsHttp1) { for (size_t i = 1; i <= data.size(); i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce( - Invoke([&data, i](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + .WillOnce(Invoke( + [&data, i](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= i); memcpy(buffer, data.data(), i); return Api::SysCallSizeResult{ssize_t(i), 0}; @@ -467,7 +479,7 @@ TEST_F(HttpInspectorTest, MultipleReadsHttp1IncompleteHeader) { for (size_t i = 1; i <= data.size(); i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&data, &end_stream, i](int, void* buffer, size_t length, + .WillOnce(Invoke([&data, &end_stream, i](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= i); memcpy(buffer, data.data(), i); @@ -499,8 +511,8 @@ TEST_F(HttpInspectorTest, MultipleReadsHttp1IncompleteBadHeader) { for (size_t i = 1; i <= data.size(); i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce( - Invoke([&data, i](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + .WillOnce(Invoke( + [&data, i](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= i); memcpy(buffer, data.data(), i); return Api::SysCallSizeResult{ssize_t(i), 0}; @@ -533,7 +545,7 @@ TEST_F(HttpInspectorTest, MultipleReadsHttp1BadProtocol) { for (size_t i = 1; i <= truncate_header.size(); i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke([&truncate_header, i](int, void* buffer, size_t length, + .WillOnce(Invoke([&truncate_header, i](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= truncate_header.size()); memcpy(buffer, truncate_header.data(), truncate_header.size()); @@ -577,8 +589,8 @@ TEST_F(HttpInspectorTest, Http1WithLargeRequestLine) { len = size_t(Config::MAX_INSPECT_SIZE / (3 - i)); } EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce( - Invoke([&data, len](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + .WillOnce(Invoke( + [&data, len](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= len); memcpy(buffer, data.data(), len); return Api::SysCallSizeResult{ssize_t(len), 0}; @@ -613,8 +625,8 @@ TEST_F(HttpInspectorTest, Http1WithLargeHeader) { for (size_t i = 1; i <= 20; i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce( - Invoke([&data, i](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { + .WillOnce(Invoke( + [&data, i](os_fd_t, void* buffer, size_t length, int) -> Api::SysCallSizeResult { ASSERT(length >= data.size()); memcpy(buffer, data.data(), i); return Api::SysCallSizeResult{ssize_t(i), 0}; diff --git a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc index 1969cac95f8f..8d1da06977a4 100644 --- a/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc +++ b/test/extensions/filters/listener/tls_inspector/tls_inspector_test.cc @@ -163,12 +163,12 @@ TEST_P(TlsInspectorTest, MultipleReads) { })); for (size_t i = 1; i <= client_hello.size(); i++) { EXPECT_CALL(os_sys_calls_, recv(42, _, _, MSG_PEEK)) - .WillOnce(Invoke( - [&client_hello, i](int, void* buffer, size_t length, int) -> Api::SysCallSizeResult { - ASSERT(length >= client_hello.size()); - memcpy(buffer, client_hello.data(), client_hello.size()); - return Api::SysCallSizeResult{ssize_t(i), 0}; - })); + .WillOnce(Invoke([&client_hello, i](os_fd_t, void* buffer, size_t length, + int) -> Api::SysCallSizeResult { + ASSERT(length >= client_hello.size()); + memcpy(buffer, client_hello.data(), client_hello.size()); + return Api::SysCallSizeResult{ssize_t(i), 0}; + })); } } diff --git a/test/extensions/filters/network/direct_response/BUILD b/test/extensions/filters/network/direct_response/BUILD index aa56a9f94f50..a828acc3d659 100644 --- a/test/extensions/filters/network/direct_response/BUILD +++ b/test/extensions/filters/network/direct_response/BUILD @@ -17,6 +17,12 @@ envoy_extension_cc_test( "direct_response_integration_test.cc", ], extension_name = "envoy.filters.network.direct_response", + tags = [ + # TODO(wrowe,sunjayBhatia): Skipping this on Windows as MSVC does not allow invoking + # connection.close() from within the lambda that is passed to the RawConnectionDriver + # constructor + "skip_on_windows", + ], deps = [ "//source/extensions/filters/network/direct_response:config", "//test/integration:integration_lib", diff --git a/test/extensions/filters/network/mongo_proxy/codec_impl_test.cc b/test/extensions/filters/network/mongo_proxy/codec_impl_test.cc index 63ea96b3c9a7..1c960dd87150 100644 --- a/test/extensions/filters/network/mongo_proxy/codec_impl_test.cc +++ b/test/extensions/filters/network/mongo_proxy/codec_impl_test.cc @@ -332,10 +332,12 @@ TEST_F(MongoCodecImplTest, QueryToStringWithEscape) { query.numberToReturn(-1); query.query(Bson::DocumentImpl::create()->addString("string_need_esc", "{\"foo\": \"bar\n\"}")); - EXPECT_EQ(R"EOF({"opcode": "OP_QUERY", "id": 1, "response_to": 1, "flags": "0x4", )EOF" - R"EOF("collection": "test", "skip": 20, "return": -1, "query": )EOF" - R"EOF({"string_need_esc": "{\"foo\": \"bar\n\"}"}, "fields": {}})EOF", - query.toString(true)); + const std::string expectedQuery = + R"EOF({"opcode": "OP_QUERY", "id": 1, "response_to": 1, "flags": "0x4", )EOF" + R"EOF("collection": "test", "skip": 20, "return": -1, "query": )EOF" + R"EOF({"string_need_esc": "{\"foo\": \"bar\n\"}"}, "fields": {}})EOF"; + + EXPECT_EQ(query.toString(true), expectedQuery); EXPECT_NO_THROW(Json::Factory::loadFromString(query.toString(true))); EXPECT_NO_THROW(Json::Factory::loadFromString(query.toString(false))); diff --git a/test/extensions/filters/network/mysql_proxy/mysql_integration_test.cc b/test/extensions/filters/network/mysql_proxy/mysql_integration_test.cc index 1a0a2cbe061d..d970fdae5ddd 100644 --- a/test/extensions/filters/network/mysql_proxy/mysql_integration_test.cc +++ b/test/extensions/filters/network/mysql_proxy/mysql_integration_test.cc @@ -1,5 +1,3 @@ -#include - #include "extensions/filters/network/mysql_proxy/mysql_codec.h" #include "extensions/filters/network/mysql_proxy/mysql_codec_clogin.h" #include "extensions/filters/network/mysql_proxy/mysql_codec_clogin_resp.h" diff --git a/test/extensions/quic_listeners/quiche/BUILD b/test/extensions/quic_listeners/quiche/BUILD index f7b52aed56d2..7e24810fe50b 100644 --- a/test/extensions/quic_listeners/quiche/BUILD +++ b/test/extensions/quic_listeners/quiche/BUILD @@ -27,7 +27,11 @@ envoy_cc_test( name = "envoy_quic_writer_test", srcs = ["envoy_quic_writer_test.cc"], external_deps = ["quiche_quic_platform"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ "//source/common/network:io_socket_error_lib", "//source/extensions/quic_listeners/quiche:envoy_quic_packet_writer_lib", @@ -52,7 +56,11 @@ envoy_cc_test( envoy_cc_test( name = "envoy_quic_server_stream_test", srcs = ["envoy_quic_server_stream_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ ":quic_test_utils_for_envoy_lib", ":test_utils_lib", @@ -72,7 +80,11 @@ envoy_cc_test( envoy_cc_test( name = "envoy_quic_client_stream_test", srcs = ["envoy_quic_client_stream_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ ":quic_test_utils_for_envoy_lib", ":test_utils_lib", @@ -92,7 +104,11 @@ envoy_cc_test( envoy_cc_test( name = "envoy_quic_server_session_test", srcs = ["envoy_quic_server_session_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ ":quic_test_utils_for_envoy_lib", "//include/envoy/stats:stats_macros", @@ -119,7 +135,11 @@ envoy_cc_test( envoy_cc_test( name = "envoy_quic_client_session_test", srcs = ["envoy_quic_client_session_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ ":quic_test_utils_for_envoy_lib", "//include/envoy/stats:stats_macros", @@ -140,7 +160,11 @@ envoy_cc_test( envoy_cc_test( name = "active_quic_listener_test", srcs = ["active_quic_listener_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ ":quic_test_utils_for_envoy_lib", "//source/extensions/quic_listeners/quiche:active_quic_listener_lib", @@ -156,7 +180,11 @@ envoy_cc_test( envoy_cc_test( name = "envoy_quic_dispatcher_test", srcs = ["envoy_quic_dispatcher_test.cc"], - tags = ["nofips"], + # quic_sent_packet_manager.cc does not compile error: warning C4715: 'quic::QuicSentPacketManager::OnRetransmissionTimeout': not all control paths return a value + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ ":quic_test_utils_for_envoy_lib", "//include/envoy/stats:stats_macros", @@ -202,7 +230,11 @@ envoy_cc_test( envoy_cc_test( name = "envoy_quic_utils_test", srcs = ["envoy_quic_utils_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ ":quic_test_utils_for_envoy_lib", "//source/extensions/quic_listeners/quiche:envoy_quic_utils_lib", @@ -214,7 +246,11 @@ envoy_cc_test( envoy_cc_test( name = "active_quic_listener_config_test", srcs = ["active_quic_listener_config_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ "//source/common/config:utility_lib", "//source/extensions/quic_listeners/quiche:active_quic_listener_config_lib", @@ -225,7 +261,11 @@ envoy_cc_test( envoy_cc_test( name = "envoy_quic_simulated_watermark_buffer_test", srcs = ["envoy_quic_simulated_watermark_buffer_test.cc"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = ["//source/extensions/quic_listeners/quiche:envoy_quic_simulated_watermark_buffer_lib"], ) diff --git a/test/extensions/quic_listeners/quiche/integration/BUILD b/test/extensions/quic_listeners/quiche/integration/BUILD index e277da580d53..ec7a3cd5dcfa 100644 --- a/test/extensions/quic_listeners/quiche/integration/BUILD +++ b/test/extensions/quic_listeners/quiche/integration/BUILD @@ -12,7 +12,11 @@ envoy_cc_test( name = "quic_http_integration_test", srcs = ["quic_http_integration_test.cc"], data = ["//test/config/integration/certs"], - tags = ["nofips"], + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + tags = [ + "nofips", + "skip_on_windows", + ], deps = [ "//source/extensions/filters/http/dynamo:config", "//source/extensions/quic_listeners/quiche:active_quic_listener_config_lib", diff --git a/test/extensions/quic_listeners/quiche/platform/BUILD b/test/extensions/quic_listeners/quiche/platform/BUILD index ced7bf94658d..f48ced9263f2 100644 --- a/test/extensions/quic_listeners/quiche/platform/BUILD +++ b/test/extensions/quic_listeners/quiche/platform/BUILD @@ -205,7 +205,7 @@ envoy_cc_test_library( hdrs = ["quic_test_output_impl.h"], tags = ["nofips"], deps = [ - "//source/common/filesystem:filesystem_lib", + "//test/test_common:file_system_for_test_lib", "@com_googlesource_quiche//:quic_platform_base", "@com_googlesource_quiche//:quiche_common_platform", ], diff --git a/test/extensions/quic_listeners/quiche/platform/quic_test_output_impl.cc b/test/extensions/quic_listeners/quiche/platform/quic_test_output_impl.cc index 9b67b3d3131e..556f6cd3e18a 100644 --- a/test/extensions/quic_listeners/quiche/platform/quic_test_output_impl.cc +++ b/test/extensions/quic_listeners/quiche/platform/quic_test_output_impl.cc @@ -8,7 +8,7 @@ #include -#include "common/filesystem/filesystem_impl.h" +#include "test/test_common/file_system_for_test.h" #include "absl/time/clock.h" #include "absl/time/time.h" @@ -36,7 +36,7 @@ void QuicRecordTestOutputToFile(const std::string& filename, quiche::QuicheStrin output_dir += '/'; } - Envoy::Filesystem::InstanceImplPosix file_system; + Envoy::Filesystem::Instance& file_system = Envoy::Filesystem::fileSystemForTest(); if (!file_system.directoryExists(output_dir)) { QUIC_LOG(ERROR) << "Directory does not exist while writing test output: " << output_dir; return; @@ -87,7 +87,7 @@ bool QuicLoadTestOutputImpl(quiche::QuicheStringPiece filename, std::string* dat const std::string read_path = read_dir + filename.data(); - Envoy::Filesystem::InstanceImplPosix file_system; + Envoy::Filesystem::Instance& file_system = Envoy::Filesystem::fileSystemForTest(); if (!file_system.fileExists(read_path)) { QUIC_LOG(ERROR) << "Test output file does not exist: " << read_path; return false; diff --git a/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc b/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc index 5eb1d9629d36..63d2aef7b392 100644 --- a/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc +++ b/test/extensions/quic_listeners/quiche/quic_io_handle_wrapper_test.cc @@ -1,8 +1,8 @@ -#include - #include #include +#include "envoy/common/platform.h" + #include "common/network/address_impl.h" #include "extensions/quic_listeners/quiche/quic_io_handle_wrapper.h" diff --git a/test/extensions/stats_sinks/common/statsd/udp_statsd_test.cc b/test/extensions/stats_sinks/common/statsd/udp_statsd_test.cc index c35926dd4e5e..c2b3ea48542c 100644 --- a/test/extensions/stats_sinks/common/statsd/udp_statsd_test.cc +++ b/test/extensions/stats_sinks/common/statsd/udp_statsd_test.cc @@ -3,6 +3,7 @@ #include #include +#include "common/api/os_sys_calls_impl.h" #include "common/network/address_impl.h" #include "common/network/utility.h" @@ -55,7 +56,8 @@ TEST(UdpOverUdsStatsdSinkTest, InitWithPipeAddress) { // this uses low level networking calls because our abstractions in this area only work for IP // sockets. Revisit this also. auto io_handle = uds_address->socket(Network::Address::SocketType::Datagram); - RELEASE_ASSERT(fcntl(io_handle->fd(), F_SETFL, 0) != -1, ""); + RELEASE_ASSERT( + Api::OsSysCallsSingleton::get().setsocketblocking(io_handle->fd(), false).rc_ != -1, ""); uds_address->bind(io_handle->fd()); // Do the flush which should have somewhere to write now. diff --git a/test/extensions/tracers/common/ot/BUILD b/test/extensions/tracers/common/ot/BUILD index fba078c13bbc..76fd9d8b1378 100644 --- a/test/extensions/tracers/common/ot/BUILD +++ b/test/extensions/tracers/common/ot/BUILD @@ -2,17 +2,23 @@ licenses(["notice"]) # Apache 2 load( "//bazel:envoy_build_system.bzl", - "envoy_cc_test", "envoy_package", ) +load( + "//test/extensions:extensions_build_system.bzl", + "envoy_extension_cc_test", +) envoy_package() -envoy_cc_test( +envoy_extension_cc_test( name = "opentracing_driver_impl_test", srcs = [ "opentracing_driver_impl_test.cc", ], + extension_name = "envoy.tracers.dynamic_ot", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/extensions/tracers/dynamic_ot:dynamic_opentracing_driver_lib", "//test/mocks/http:http_mocks", diff --git a/test/extensions/tracers/datadog/BUILD b/test/extensions/tracers/datadog/BUILD index 6ba8482ffdb5..1e6b94c6e0f0 100644 --- a/test/extensions/tracers/datadog/BUILD +++ b/test/extensions/tracers/datadog/BUILD @@ -17,6 +17,8 @@ envoy_extension_cc_test( "datadog_tracer_impl_test.cc", ], extension_name = "envoy.tracers.datadog", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/common/common:base64_lib", "//source/common/http:header_map_lib", @@ -40,6 +42,8 @@ envoy_extension_cc_test( name = "config_test", srcs = ["config_test.cc"], extension_name = "envoy.tracers.datadog", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/extensions/tracers/datadog:config", "//test/mocks/server:server_mocks", diff --git a/test/extensions/tracers/dynamic_ot/BUILD b/test/extensions/tracers/dynamic_ot/BUILD index 4a7382e0efc0..4037befe21f9 100644 --- a/test/extensions/tracers/dynamic_ot/BUILD +++ b/test/extensions/tracers/dynamic_ot/BUILD @@ -20,6 +20,8 @@ envoy_extension_cc_test( "@io_opentracing_cpp//mocktracer:libmocktracer_plugin.so", ], extension_name = "envoy.tracers.dynamic_ot", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/common/http:header_map_lib", "//source/extensions/tracers/dynamic_ot:dynamic_opentracing_driver_lib", @@ -37,6 +39,8 @@ envoy_extension_cc_test( "@io_opentracing_cpp//mocktracer:libmocktracer_plugin.so", ], extension_name = "envoy.tracers.dynamic_ot", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/extensions/tracers/dynamic_ot:config", "//test/mocks/server:server_mocks", diff --git a/test/extensions/tracers/lightstep/BUILD b/test/extensions/tracers/lightstep/BUILD index 0d9ea91ba326..40815b572d75 100644 --- a/test/extensions/tracers/lightstep/BUILD +++ b/test/extensions/tracers/lightstep/BUILD @@ -17,6 +17,8 @@ envoy_extension_cc_test( "lightstep_tracer_impl_test.cc", ], extension_name = "envoy.tracers.lightstep", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/common/common:base64_lib", "//source/common/http:header_map_lib", @@ -42,6 +44,8 @@ envoy_extension_cc_test( name = "config_test", srcs = ["config_test.cc"], extension_name = "envoy.tracers.lightstep", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/extensions/tracers/lightstep:config", "//test/mocks/server:server_mocks", diff --git a/test/extensions/tracers/opencensus/BUILD b/test/extensions/tracers/opencensus/BUILD index 01b231bc240b..9aa809b29f8d 100644 --- a/test/extensions/tracers/opencensus/BUILD +++ b/test/extensions/tracers/opencensus/BUILD @@ -15,6 +15,8 @@ envoy_extension_cc_test( name = "tracer_test", srcs = ["tracer_test.cc"], extension_name = "envoy.tracers.opencensus", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/extensions/tracers/opencensus:opencensus_tracer_impl", "//test/mocks/http:http_mocks", @@ -28,6 +30,8 @@ envoy_extension_cc_test( name = "config_test", srcs = ["config_test.cc"], extension_name = "envoy.tracers.opencensus", + # TODO(wrowe): envoy_extension_ rules don't currently exclude windows extensions + tags = ["skip_on_windows"], deps = [ "//source/extensions/tracers/opencensus:config", "//test/mocks/server:server_mocks", diff --git a/test/extensions/tracers/xray/tracer_test.cc b/test/extensions/tracers/xray/tracer_test.cc index ae0dc558cb2d..ef7b721c565c 100644 --- a/test/extensions/tracers/xray/tracer_test.cc +++ b/test/extensions/tracers/xray/tracer_test.cc @@ -52,7 +52,7 @@ TEST_F(XRayTracerTest, SerializeSpanTest) { constexpr auto expected_x_forwarded_for = "false"; constexpr auto expected_upstream_address = "10.0.0.200"; - auto on_send = [](const std::string& json) { + auto on_send = [&](const std::string& json) { ASSERT_FALSE(json.empty()); daemon::Segment s; MessageUtil::loadFromJson(json, s, ProtobufMessage::getNullValidationVisitor()); @@ -102,7 +102,7 @@ TEST_F(XRayTracerTest, ChildSpanHasParentInfo) { const XRay::Span* xray_parent_span = static_cast(parent_span.get()); const std::string expected_parent_id = xray_parent_span->Id(); - auto on_send = [xray_parent_span, expected_parent_id](const std::string& json) { + auto on_send = [&](const std::string& json) { ASSERT_FALSE(json.empty()); daemon::Segment s; MessageUtil::loadFromJson(json, s, ProtobufMessage::getNullValidationVisitor()); diff --git a/test/extensions/tracers/zipkin/tracer_test.cc b/test/extensions/tracers/zipkin/tracer_test.cc index 320c1df4e5ed..878af93da699 100644 --- a/test/extensions/tracers/zipkin/tracer_test.cc +++ b/test/extensions/tracers/zipkin/tracer_test.cc @@ -184,7 +184,7 @@ TEST_F(ZipkinTracerTest, SpanCreation) { ON_CALL(config, operationName()).WillByDefault(Return(Tracing::OperationName::Ingress)); TestRandomGenerator generator; - const uint generated_parent_id = generator.random(); + const uint64_t generated_parent_id = generator.random(); SpanContext modified_root_span_context(root_span_context.trace_id_high(), root_span_context.trace_id(), root_span_context.id(), generated_parent_id, root_span_context.sampled()); diff --git a/test/extensions/transport_sockets/tls/BUILD b/test/extensions/transport_sockets/tls/BUILD index 6e878a85d326..bc1b9b9cbf0f 100644 --- a/test/extensions/transport_sockets/tls/BUILD +++ b/test/extensions/transport_sockets/tls/BUILD @@ -24,6 +24,8 @@ envoy_cc_test( ], external_deps = ["ssl"], shard_count = 4, + # TODO(wrowe): Diagnose timeout error on Windows (skipped for the moment) + tags = ["fails_on_windows"], deps = [ ":test_private_key_method_provider_test_lib", "//include/envoy/network:transport_socket_interface", diff --git a/test/integration/BUILD b/test/integration/BUILD index 7ec27ca352f5..5b621d493b1a 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -127,6 +127,8 @@ envoy_cc_test( envoy_cc_test( name = "eds_integration_test", srcs = ["eds_integration_test.cc"], + # Times out on Windows + tags = ["fails_on_windows"], deps = [ ":http_integration_lib", "//source/common/upstream:load_balancer_lib", @@ -228,6 +230,8 @@ envoy_sh_test( "//test/config/integration:server_config_files", "//tools:socket_passing", ], + # Hot restart does not apply on Windows, skipping + tags = ["skip_on_windows"], ) envoy_sh_test( @@ -238,6 +242,8 @@ envoy_sh_test( "//source/exe:envoy-static", "//test/config/integration:server_config_files", ], + # TODO: This script invocation does not work on Windows, see: https://github.com/bazelbuild/bazel/issues/10959 + tags = ["fails_on_windows"], ) envoy_cc_test( @@ -578,6 +584,8 @@ envoy_cc_test( "integration_test.h", ], shard_count = 2, + # Times out on Windows + tags = ["fails_on_windows"], deps = [ ":http_integration_lib", "//source/common/http:header_map_lib", @@ -616,6 +624,8 @@ envoy_cc_test( "websocket_integration_test.cc", "websocket_integration_test.h", ], + # Times out on Windows + tags = ["fails_on_windows"], deps = [ ":http_protocol_integration_lib", "//source/common/http:header_map_lib", @@ -632,9 +642,15 @@ envoy_cc_test( srcs = [ "echo_integration_test.cc", ], - # Uncomment this line to run this test repeatedly in exclusive mode if not using docker-sandbox, - # or RBE, see comments in AddRemoveListener. - # tags = ["exclusive"], + tags = [ + # Uncomment this line to run this test repeatedly in exclusive mode if not using docker-sandbox, + # or RBE, see comments in AddRemoveListener. + # "exclusive", + # TODO(wrowe,sunjayBhatia): Skipping this on Windows as MSVC does not allow invoking + # connection.close() from within the lambda that is passed to the RawConnectionDriver + # constructor + "skip_on_windows", + ], deps = [ ":integration_lib", "//source/extensions/filters/network/echo:config", diff --git a/test/integration/tcp_dump.cc b/test/integration/tcp_dump.cc index 95cd8b55c0e0..b8d7c8486156 100644 --- a/test/integration/tcp_dump.cc +++ b/test/integration/tcp_dump.cc @@ -1,12 +1,12 @@ #include "test/integration/tcp_dump.h" #include -#include -#include #include #include +#include "envoy/common/platform.h" + #include "common/common/assert.h" #include "common/common/fmt.h" @@ -14,6 +14,9 @@ namespace Envoy { TcpDump::TcpDump(const std::string& path, const std::string& iface, const std::vector& ports) { +#ifdef WIN32 + ENVOY_LOG_MISC(debug, "tcpdump not supported on windows"); +#else // Remove any extant pcap file. ::unlink(path.c_str()); // Derive the port filter expression. @@ -60,9 +63,11 @@ TcpDump::TcpDump(const std::string& path, const std::string& iface, // Give 50ms sleep. ::usleep(50000); } +#endif } TcpDump::~TcpDump() { +#ifndef WIN32 if (tcpdump_pid_ > 0) { RELEASE_ASSERT(::kill(tcpdump_pid_, SIGINT) == 0, ""); int status; @@ -71,6 +76,7 @@ TcpDump::~TcpDump() { RELEASE_ASSERT(WEXITSTATUS(status) == 0, ""); ENVOY_LOG_MISC(debug, "tcpdump terminated"); } +#endif } } // namespace Envoy diff --git a/test/main.cc b/test/main.cc index 132b9e8ae990..42bc71b05ed3 100644 --- a/test/main.cc +++ b/test/main.cc @@ -13,10 +13,28 @@ #include "tools/cpp/runfiles/runfiles.h" +#if defined(WIN32) +static void NoopInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, + const wchar_t* file, unsigned int line, + uintptr_t pReserved) { + return; +} +#endif + using bazel::tools::cpp::runfiles::Runfiles; // The main entry point (and the rest of this file) should have no logic in it, // this allows overriding by site specific versions of main.cc. int main(int argc, char** argv) { +#if defined(WIN32) + _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); + + _set_invalid_parameter_handler(NoopInvalidParameterHandler); + + WSADATA wsa_data; + const WORD version_requested = MAKEWORD(2, 2); + RELEASE_ASSERT(WSAStartup(version_requested, &wsa_data) == 0, ""); +#endif + #ifndef __APPLE__ absl::InitializeSymbolizer(argv[0]); #endif diff --git a/test/mocks/network/io_handle.h b/test/mocks/network/io_handle.h index 787ea202f464..460d90f7c428 100644 --- a/test/mocks/network/io_handle.h +++ b/test/mocks/network/io_handle.h @@ -13,7 +13,7 @@ class MockIoHandle : public IoHandle { MockIoHandle(); ~MockIoHandle() override; - MOCK_METHOD(int, fd, (), (const)); + MOCK_METHOD(os_fd_t, fd, (), (const)); MOCK_METHOD(Api::IoCallUint64Result, close, ()); MOCK_METHOD(bool, isOpen, (), (const)); MOCK_METHOD(Api::IoCallUint64Result, readv, diff --git a/test/server/BUILD b/test/server/BUILD index 6dded97d08a3..eb90f57bfaaa 100644 --- a/test/server/BUILD +++ b/test/server/BUILD @@ -252,7 +252,11 @@ envoy_cc_test( envoy_cc_test( name = "listener_manager_impl_quic_only_test", srcs = ["listener_manager_impl_quic_only_test.cc"], - tags = ["nofips"], + tags = [ + "nofips", + # Skipping as quiche quic_stream_send_buffer.cc does not currently compile on Windows + "skip_on_windows", + ], deps = [ ":listener_manager_impl_test_lib", ":utility_lib", diff --git a/test/server/listener_manager_impl_test.cc b/test/server/listener_manager_impl_test.cc index 04072b8beca0..a032037daf9b 100644 --- a/test/server/listener_manager_impl_test.cc +++ b/test/server/listener_manager_impl_test.cc @@ -461,7 +461,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, StatsScopeTest) { config: {} )EOF"; - EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, {false})); + EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, ListenSocketCreationParams(false))); manager_->addOrUpdateListener(parseListenerFromV2Yaml(yaml), "", true); manager_->listeners().front().get().listenerScope().counterFromString("foo").inc(); @@ -1338,7 +1338,7 @@ name: foo ASSERT_TRUE(SOCKET_VALID(syscall_result.rc_)); ListenerHandle* listener_foo = expectListenerCreate(true, true); - EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, {false})) + EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, ListenSocketCreationParams(false))) .WillOnce(Invoke([this, &syscall_result, &real_listener_factory]( const Network::Address::InstanceConstSharedPtr& address, Network::Address::SocketType socket_type, @@ -1896,7 +1896,7 @@ name: foo )EOF"; ListenerHandle* listener_foo = expectListenerCreate(true, true); - EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, {false})); + EXPECT_CALL(listener_factory_, createListenSocket(_, _, _, ListenSocketCreationParams(false))); EXPECT_CALL(listener_foo->target_, initialize()); EXPECT_TRUE(manager_->addOrUpdateListener(parseListenerFromV2Yaml(listener_foo_yaml), "", true)); @@ -3450,7 +3450,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstFilter) { } class OriginalDstTestFilter : public Extensions::ListenerFilters::OriginalDst::OriginalDstFilter { - Network::Address::InstanceConstSharedPtr getOriginalDst(int) override { + Network::Address::InstanceConstSharedPtr getOriginalDst(os_fd_t) override { return Network::Address::InstanceConstSharedPtr{ new Network::Address::Ipv4Instance("127.0.0.2", 2345)}; } @@ -3524,7 +3524,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstTestFilter) { class OriginalDstTestFilterIPv6 : public Extensions::ListenerFilters::OriginalDst::OriginalDstFilter { - Network::Address::InstanceConstSharedPtr getOriginalDst(int) override { + Network::Address::InstanceConstSharedPtr getOriginalDst(os_fd_t) override { return Network::Address::InstanceConstSharedPtr{ new Network::Address::Ipv6Instance("1::2", 2345)}; } diff --git a/test/server/listener_manager_impl_test.h b/test/server/listener_manager_impl_test.h index 2ab79f6f487b..49a29cc4a6dc 100644 --- a/test/server/listener_manager_impl_test.h +++ b/test/server/listener_manager_impl_test.h @@ -193,7 +193,7 @@ class ListenerManagerImplTest : public testing::Test { setsockopt_(_, expected_sockopt_level, expected_sockopt_name, _, sizeof(int))) .Times(expected_num_calls) .WillRepeatedly( - Invoke([expected_value](int, int, int, const void* optval, socklen_t) -> int { + Invoke([expected_value](os_fd_t, int, int, const void* optval, socklen_t) -> int { EXPECT_EQ(expected_value, *static_cast(optval)); return 0; })); diff --git a/test/server/server_test.cc b/test/server/server_test.cc index c583594c0582..36ea86675dc3 100644 --- a/test/server/server_test.cc +++ b/test/server/server_test.cc @@ -86,10 +86,12 @@ class RunHelperTest : public testing::Test { RunHelperTest() { InSequence s; +#ifndef WIN32 sigterm_ = new Event::MockSignalEvent(&dispatcher_); sigint_ = new Event::MockSignalEvent(&dispatcher_); sigusr1_ = new Event::MockSignalEvent(&dispatcher_); sighup_ = new Event::MockSignalEvent(&dispatcher_); +#endif EXPECT_CALL(overload_manager_, start()); EXPECT_CALL(cm_, setInitializedCb(_)).WillOnce(SaveArg<0>(&cm_init_callback_)); ON_CALL(server_, shutdown()).WillByDefault(Assign(&shutdown_, true)); @@ -109,10 +111,12 @@ class RunHelperTest : public testing::Test { ReadyWatcher start_workers_; std::unique_ptr helper_; std::function cm_init_callback_; +#ifndef WIN32 Event::MockSignalEvent* sigterm_; Event::MockSignalEvent* sigint_; Event::MockSignalEvent* sigusr1_; Event::MockSignalEvent* sighup_; +#endif bool shutdown_ = false; }; @@ -121,13 +125,18 @@ TEST_F(RunHelperTest, Normal) { cm_init_callback_(); } +// no signals on Windows +#ifndef WIN32 TEST_F(RunHelperTest, ShutdownBeforeCmInitialize) { EXPECT_CALL(start_workers_, ready()).Times(0); sigterm_->callback_(); EXPECT_CALL(server_, isShutdown()).WillOnce(Return(shutdown_)); cm_init_callback_(); } +#endif +// no signals on Windows +#ifndef WIN32 TEST_F(RunHelperTest, ShutdownBeforeInitManagerInit) { EXPECT_CALL(start_workers_, ready()).Times(0); Init::ExpectableTargetImpl target; @@ -138,6 +147,7 @@ TEST_F(RunHelperTest, ShutdownBeforeInitManagerInit) { EXPECT_CALL(server_, isShutdown()).WillOnce(Return(shutdown_)); target.ready(); } +#endif class InitializingInitManager : public Init::ManagerImpl { public: diff --git a/test/tools/router_check/test/BUILD b/test/tools/router_check/test/BUILD index 9ed7a3c3fe6e..4e8e7f8885b8 100644 --- a/test/tools/router_check/test/BUILD +++ b/test/tools/router_check/test/BUILD @@ -15,6 +15,8 @@ envoy_sh_test( ":configs", "//test/tools/router_check:router_check_tool", ], + # TODO: This script invocation does not work on Windows, see: https://github.com/bazelbuild/bazel/issues/10959 + tags = ["fails_on_windows"], ) filegroup( diff --git a/test/tools/type_whisperer/BUILD b/test/tools/type_whisperer/BUILD index 281d75874102..5d2787128058 100644 --- a/test/tools/type_whisperer/BUILD +++ b/test/tools/type_whisperer/BUILD @@ -7,5 +7,7 @@ envoy_package() envoy_cc_test( name = "api_type_db_test", srcs = ["api_type_db_test.cc"], + # MSVC does not allow strings over a certain length, see error C2026 + tags = ["skip_on_windows"], deps = ["//tools/type_whisperer:api_type_db_lib"], )