Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def envoy_cc_test(
deps = [],
tags = [],
args = [],
copts = [],
shard_count = None,
coverage = True,
local = False,
Expand All @@ -457,10 +458,11 @@ def envoy_cc_test(
deps = deps,
repository = repository,
tags = test_lib_tags,
copts = copts,
)
native.cc_test(
name = name,
copts = envoy_copts(repository, test = True),
copts = envoy_copts(repository, test = True) + copts,
linkopts = envoy_test_linkopts(),
linkstatic = 1,
malloc = tcmalloc_external_dep(repository),
Expand Down Expand Up @@ -488,13 +490,14 @@ def envoy_cc_test_infrastructure_library(
deps = [],
repository = "",
tags = [],
include_prefix = None):
include_prefix = None,
copts = []):
native.cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
data = data,
copts = envoy_copts(repository, test = True),
copts = envoy_copts(repository, test = True) + copts,
testonly = 1,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps] + [
envoy_external_dep_path("googletest"),
Expand All @@ -517,7 +520,8 @@ def envoy_cc_test_library(
deps = [],
repository = "",
tags = [],
include_prefix = None):
include_prefix = None,
copts = []):
deps = deps + [
repository + "//test/test_common:printers_includes",
]
Expand All @@ -531,6 +535,7 @@ def envoy_cc_test_library(
repository,
tags,
include_prefix,
copts,
)

# Envoy test binaries should be specified with this function.
Expand Down
80 changes: 67 additions & 13 deletions bazel/external/quiche.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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(
[
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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,

Copy link
Copy Markdown
Member

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_copts if this is a envoy_cc_test_library?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed actually. Removed.

repository = "@envoy",
deps = [":epoll_server_platform"],
)

envoy_cc_test(
name = "epoll_server_test",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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(
Expand Down
3 changes: 3 additions & 0 deletions bazel/external/quiche.genrule_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ cat <<EOF >sed_commands
# Rewrite include directives for platform impl files.
/^#include/ s!net/(http2|spdy|quic)/platform/impl/!extensions/quic_listeners/quiche/platform/!

# Rewrite include directives for epoll_server platform impl files.
/^#include/ s!net/tools/epoll_server/platform/impl!test/extensions/quic_listeners/quiche/platform/!

# Strip "net/third_party" from include directives to other QUICHE files.
/^#include/ s!net/third_party/quiche/src/!quiche/!

Expand Down
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://github.com/google/subpar/archive/1.3.0.tar.gz"],
),
com_googlesource_quiche = dict(
# Static snapshot of https://quiche.googlesource.com/quiche/+archive/840edb6d672931ff936004fc35a82ecac6060844.tar.gz
sha256 = "1aba26cec596e9f3b52d93fe40e1640c854e3a4c8949e362647f67eb8e2382e3",
urls = ["https://storage.googleapis.com/quiche-envoy-integration/840edb6d672931ff936004fc35a82ecac6060844.tar.gz"],
# Static snapshot of https://quiche.googlesource.com/quiche/+archive/3e188a56edbcc471799499958bfd7c05ec45b9e2.tar.gz
sha256 = "b116cfac5d39390c00f13758b21978aab953d8a67d846182f39b333644ee64b2",
urls = ["https://storage.googleapis.com/quiche-envoy-integration/3e188a56edbcc471799499958bfd7c05ec45b9e2.tar.gz"],
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,24 @@
#define CHECK(condition) \
QUIC_LOG_IF_IMPL(FATAL, ABSL_PREDICT_FALSE(!(condition))) << "CHECK failed: " #condition "."

#define CHECK_GT(a, b) CHECK((a) > (b))
#define CHECK_GE(a, b) CHECK((a) >= (b))
#define CHECK_LT(a, b) CHECK((a) < (b))
#define CHECK_LE(a, b) CHECK((a) <= (b))
#define CHECK_NE(a, b) CHECK((a) != (b))
#define CHECK_EQ(a, b) CHECK((a) == (b))

#ifdef NDEBUG
// Release build
#define DCHECK(condition) QUIC_COMPILED_OUT_LOG()
#define QUIC_COMPILED_OUT_LOG() QUIC_LOG_IMPL_INTERNAL(false, quic::NullLogStream().stream())
#define QUIC_DVLOG_IMPL(verbosity) QUIC_COMPILED_OUT_LOG()
#define QUIC_DVLOG_IF_IMPL(verbosity, condition) QUIC_COMPILED_OUT_LOG()
#define QUIC_DLOG_IMPL(severity) QUIC_COMPILED_OUT_LOG()
#define QUIC_DLOG_IF_IMPL(severity, condition) QUIC_COMPILED_OUT_LOG()
#define DCHECK(condition) QUIC_COMPILED_OUT_LOG(condition)
#define QUIC_COMPILED_OUT_LOG(condition) \
QUIC_LOG_IMPL_INTERNAL(false && (condition), quic::NullLogStream().stream())
#define QUIC_DVLOG_IMPL(verbosity) QUIC_COMPILED_OUT_LOG(false)
#define QUIC_DVLOG_IF_IMPL(verbosity, condition) QUIC_COMPILED_OUT_LOG(condition)
#define QUIC_DLOG_IMPL(severity) QUIC_COMPILED_OUT_LOG(false)
#define QUIC_DLOG_IF_IMPL(severity, condition) QUIC_COMPILED_OUT_LOG(condition)
#define QUIC_DLOG_INFO_IS_ON_IMPL() 0
#define QUIC_DLOG_EVERY_N_IMPL(severity, n) QUIC_COMPILED_OUT_LOG()
#define QUIC_DLOG_EVERY_N_IMPL(severity, n) QUIC_COMPILED_OUT_LOG(false)
#define QUIC_NOTREACHED_IMPL()
#else
// Debug build
Expand All @@ -83,6 +91,11 @@
#endif

#define DCHECK_GE(a, b) DCHECK((a) >= (b))
#define DCHECK_GT(a, b) DCHECK((a) > (b))
#define DCHECK_LT(a, b) DCHECK((a) < (b))
#define DCHECK_LE(a, b) DCHECK((a) <= (b))
#define DCHECK_NE(a, b) DCHECK((a) != (b))
#define DCHECK_EQ(a, b) DCHECK((a) == (b))

#define QUIC_PREDICT_FALSE_IMPL(x) ABSL_PREDICT_FALSE(x)

Expand Down
21 changes: 21 additions & 0 deletions test/extensions/quic_listeners/quiche/platform/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,24 @@ envoy_cc_test_library(
"//test/test_common:environment_lib",
],
)

envoy_cc_test_library(
name = "epoll_server_platform_impl_lib",
hdrs = [
"epoll_address_test_utils_impl.h",
"epoll_bug_impl.h",
"epoll_expect_bug_impl.h",
"epoll_export_impl.h",
"epoll_logging_impl.h",
"epoll_ptr_util_impl.h",
"epoll_test_impl.h",
"epoll_thread_impl.h",
"epoll_time_impl.h",
],
external_deps = ["abseil_time"],
deps = [
"//include/envoy/network:address_interface",
"//source/extensions/quic_listeners/quiche/platform:quic_platform_base_impl_lib",
"//test/test_common:environment_lib",
],
)
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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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) {
return AF_INET;
}

if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v6) {
return AF_INET6;
}

return -1;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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()) {
return AF_INET;
}
// Same for v6

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() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is confusingly named, but doing the right thing.
Possibly worth a rename or comments that this returns the "highest" supported address version of v4/v6. Given it's test code and I suspect will be unused I'm fine landing as-is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
Loading