-
Notifications
You must be signed in to change notification settings - Fork 5.5k
quiche: add epoll_server for testing #6650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
1068b8e
30a1dd6
79570f3
fa174ac
f44663a
35c09c6
8105de3
4c18507
05fb83b
2a6b9f8
ea66710
93f08e6
751b7a9
3883e6d
499ccb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,10 @@ licenses(["notice"]) # Apache 2 | |
| load(":genrule_cmd.bzl", "genrule_cmd") | ||
| load( | ||
| "@envoy//bazel:envoy_build_system.bzl", | ||
| "envoy_cc_library", | ||
| "envoy_cc_test", | ||
| "envoy_cc_test_library", | ||
| "envoy_copts", | ||
| "envoy_select_quiche", | ||
| ) | ||
|
|
||
|
|
@@ -48,7 +51,9 @@ genrule( | |
| visibility = ["//visibility:private"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| quiche_copt = ["-Wno-unused-parameter"] | ||
|
|
||
| envoy_cc_library( | ||
| name = "http2_platform", | ||
| hdrs = [ | ||
| "quiche/http2/platform/api/http2_arraysize.h", | ||
|
|
@@ -73,11 +78,12 @@ cc_library( | |
| ], | ||
| "@envoy", | ||
| ), | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@envoy//source/extensions/quic_listeners/quiche/platform:http2_platform_impl_lib"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "spdy_platform", | ||
| hdrs = [ | ||
| "quiche/spdy/platform/api/spdy_arraysize.h", | ||
|
|
@@ -99,26 +105,29 @@ cc_library( | |
| ], | ||
| "@envoy", | ||
| ), | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@envoy//source/extensions/quic_listeners/quiche/platform:spdy_platform_impl_lib"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "spdy_simple_arena_lib", | ||
| srcs = ["quiche/spdy/core/spdy_simple_arena.cc"], | ||
| hdrs = ["quiche/spdy/core/spdy_simple_arena.h"], | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = [":spdy_platform"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "spdy_platform_unsafe_arena_lib", | ||
| hdrs = ["quiche/spdy/platform/api/spdy_unsafe_arena.h"], | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@envoy//source/extensions/quic_listeners/quiche/platform:spdy_platform_unsafe_arena_impl_lib"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "quic_platform", | ||
| srcs = ["quiche/quic/platform/api/quic_mutex.cc"] + envoy_select_quiche( | ||
| [ | ||
|
|
@@ -138,35 +147,36 @@ cc_library( | |
| ], | ||
| "@envoy", | ||
| ), | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| ":quic_platform_base", | ||
| "@envoy//source/extensions/quic_listeners/quiche/platform:quic_platform_impl_lib", | ||
| ], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "quic_platform_export", | ||
| hdrs = ["quiche/quic/platform/api/quic_export.h"], | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@envoy//source/extensions/quic_listeners/quiche/platform:quic_platform_export_impl_lib"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_test_library( | ||
| name = "quic_platform_port_utils", | ||
| testonly = 1, | ||
| hdrs = envoy_select_quiche( | ||
| ["quiche/quic/platform/api/quic_port_utils.h"], | ||
| "@envoy", | ||
| ), | ||
| visibility = ["//visibility:public"], | ||
| repository = "@envoy", | ||
| deps = envoy_select_quiche( | ||
| ["@envoy//source/extensions/quic_listeners/quiche/platform:quic_platform_port_utils_impl_lib"], | ||
| "@envoy", | ||
| ), | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "quic_platform_base", | ||
| hdrs = [ | ||
| "quiche/quic/platform/api/quic_aligned.h", | ||
|
|
@@ -217,29 +227,32 @@ cc_library( | |
| ], | ||
| "@envoy", | ||
| ), | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| ":quic_platform_export", | ||
| "@envoy//source/extensions/quic_listeners/quiche/platform:quic_platform_base_impl_lib", | ||
| ], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "quic_platform_sleep", | ||
| hdrs = ["quiche/quic/platform/api/quic_sleep.h"], | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@envoy//source/extensions/quic_listeners/quiche/platform:quic_platform_sleep_impl_lib"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "quic_time_lib", | ||
| srcs = ["quiche/quic/core/quic_time.cc"], | ||
| hdrs = ["quiche/quic/core/quic_time.h"], | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = [":quic_platform"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| envoy_cc_library( | ||
| name = "quic_buffer_allocator_lib", | ||
| srcs = [ | ||
| "quiche/quic/core/quic_buffer_allocator.cc", | ||
|
|
@@ -249,10 +262,51 @@ cc_library( | |
| "quiche/quic/core/quic_buffer_allocator.h", | ||
| "quiche/quic/core/quic_simple_buffer_allocator.h", | ||
| ], | ||
| repository = "@envoy", | ||
| visibility = ["//visibility:public"], | ||
| deps = [":quic_platform_export"], | ||
| ) | ||
|
|
||
| envoy_cc_test_library( | ||
| name = "epoll_server_platform", | ||
| hdrs = [ | ||
| "quiche/epoll_server/platform/api/epoll_address_test_utils.h", | ||
| "quiche/epoll_server/platform/api/epoll_bug.h", | ||
| "quiche/epoll_server/platform/api/epoll_expect_bug.h", | ||
| "quiche/epoll_server/platform/api/epoll_export.h", | ||
| "quiche/epoll_server/platform/api/epoll_logging.h", | ||
| "quiche/epoll_server/platform/api/epoll_ptr_util.h", | ||
| "quiche/epoll_server/platform/api/epoll_test.h", | ||
| "quiche/epoll_server/platform/api/epoll_thread.h", | ||
| "quiche/epoll_server/platform/api/epoll_time.h", | ||
| ], | ||
| repository = "@envoy", | ||
| deps = ["@envoy//test/extensions/quic_listeners/quiche/platform:epoll_server_platform_impl_lib"], | ||
| ) | ||
|
|
||
| envoy_cc_test_library( | ||
| name = "epoll_server_lib", | ||
| srcs = [ | ||
| "quiche/epoll_server/fake_simple_epoll_server.cc", | ||
| "quiche/epoll_server/simple_epoll_server.cc", | ||
| ], | ||
| hdrs = [ | ||
| "quiche/epoll_server/fake_simple_epoll_server.h", | ||
| "quiche/epoll_server/simple_epoll_server.h", | ||
| ], | ||
| copts = envoy_copts("@envoy") + quiche_copt, | ||
| repository = "@envoy", | ||
| deps = [":epoll_server_platform"], | ||
| ) | ||
|
|
||
| envoy_cc_test( | ||
| name = "epoll_server_test", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is also defined in test/extensions/quic_listeners/quiche/platform/BUILD, should we delete one of them?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, the one is //test/ is used for debugging. I removed that one instead. |
||
| srcs = ["quiche/epoll_server/simple_epoll_server_test.cc"], | ||
| copts = quiche_copt, | ||
| repository = "@envoy", | ||
| deps = [":epoll_server_lib"], | ||
| ) | ||
|
|
||
| envoy_cc_test( | ||
| name = "http2_platform_test", | ||
| srcs = envoy_select_quiche( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include <sys/socket.h> | ||
|
|
||
| #include <algorithm> | ||
|
|
||
| #include "envoy/network/address.h" | ||
|
|
||
| #include "test/test_common/environment.h" | ||
|
|
||
| namespace epoll_server { | ||
|
|
||
| namespace { | ||
|
|
||
| int addressFamilyUnderTestHelper() { | ||
| std::vector<Envoy::Network::Address::IpVersion> versions = | ||
| Envoy::TestEnvironment::getIpVersionsForTest(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using std::find for clarity? if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v4) { if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v6) { return -1;
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, my code in comment doesn't actually work, it should be if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v4) != versions.end()) { |
||
| if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v4) != | ||
| versions.end()) { | ||
| return AF_INET; | ||
| } | ||
| if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v6) != | ||
| versions.end()) { | ||
| return AF_INET6; | ||
| } | ||
| return -1; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| // Returns the address family to be used for test. Return v4 if the environment | ||
| // supports v4 only or both v4 and v6. Otherwise return v6 or an invalid value. | ||
| int AddressFamilyUnderTestImpl() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is confusingly named, but doing the right thing.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renaming requires upstream change. I added a comment here for the return value. |
||
| static const int version = addressFamilyUnderTestHelper(); | ||
| return version; | ||
| } | ||
|
|
||
| } // namespace epoll_server | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to explicitly add the
envoy_coptsif this is aenvoy_cc_test_library?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed actually. Removed.