diff --git a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h index 3d7df5563e9f1..4f99f2d2f42b8 100644 --- a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h @@ -1,15 +1,26 @@ #pragma once -#include "absl/base/macros.h" - // 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 + +#include "extensions/quic_listeners/quiche/platform/quic_logging_impl.h" + +#include "absl/base/macros.h" + #define HTTP2_FALLTHROUGH_IMPL ABSL_FALLTHROUGH_INTENDED -#define HTTP2_DIE_IF_NULL_IMPL(ptr) ABSL_DIE_IF_NULL(ptr) +#define HTTP2_DIE_IF_NULL_IMPL(ptr) dieIfNull(ptr) +#define HTTP2_UNREACHABLE_IMPL() DCHECK(false) + +namespace http2 { + +template inline T dieIfNull(T&& ptr) { + CHECK((ptr) != nullptr); + return std::forward(ptr); +} -// TODO: implement -#define HTTP2_UNREACHABLE_IMPL() 0 +} // namespace http2 diff --git a/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc b/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc index 10b9b38787e1e..0cd37a1512624 100644 --- a/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc +++ b/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc @@ -1,3 +1,9 @@ +// 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 #include "test/test_common/logging.h" @@ -8,6 +14,7 @@ #include "quiche/http2/platform/api/http2_containers.h" #include "quiche/http2/platform/api/http2_estimate_memory_usage.h" #include "quiche/http2/platform/api/http2_logging.h" +#include "quiche/http2/platform/api/http2_macros.h" #include "quiche/http2/platform/api/http2_optional.h" #include "quiche/http2/platform/api/http2_ptr_util.h" #include "quiche/http2/platform/api/http2_string.h" @@ -19,10 +26,7 @@ // minimal, and serve primarily to verify the APIs compile and link without // issue. -namespace Envoy { -namespace Extensions { -namespace QuicListeners { -namespace Quiche { +namespace http2 { namespace { TEST(Http2PlatformTest, Http2Arraysize) { @@ -96,8 +100,10 @@ TEST(Http2PlatformTest, Http2StringPiece) { EXPECT_EQ('b', sp[0]); } +TEST(Http2PlatformTest, Http2Macro) { + EXPECT_DEBUG_DEATH(HTTP2_UNREACHABLE(), ""); + EXPECT_DEATH(HTTP2_DIE_IF_NULL(nullptr), ""); +} + } // namespace -} // namespace Quiche -} // namespace QuicListeners -} // namespace Extensions -} // namespace Envoy +} // namespace http2