From c0a9bb7b3ab6514323b52e81a5bd52210bbed490 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Thu, 14 Sep 2023 13:21:59 -0700 Subject: [PATCH] Additionally expect the custom tos/tclass in TOS_TCLASS_EXPECT_DEFAULT case. PiperOrigin-RevId: 565458888 --- test/syscalls/linux/raw_socket.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/test/syscalls/linux/raw_socket.cc b/test/syscalls/linux/raw_socket.cc index a21c5625b..4eca8971a 100644 --- a/test/syscalls/linux/raw_socket.cc +++ b/test/syscalls/linux/raw_socket.cc @@ -23,8 +23,7 @@ #include #include -#include - +#include "gmock/gmock.h" #include "gtest/gtest.h" #include "test/syscalls/linux/ip_socket_test_util.h" #include "test/syscalls/linux/unix_domain_socket_test_util.h" @@ -41,6 +40,7 @@ namespace testing { namespace { +using ::testing::AnyOf; using ::testing::IsNull; using ::testing::NotNull; @@ -1224,12 +1224,10 @@ TEST(RawSocketTest, ReceiveTOS) { if (const char* val = getenv("TOS_TCLASS_EXPECT_DEFAULT"); val != nullptr && strcmp(val, "1") == 0) { - // TODO(https://issuetracker.google.com/issues/217448626): As of writing, it - // seems like at least one Linux environment does not allow setting a custom - // TOS. In this case, we expect the default instead of the TOS that was set - // above. - EXPECT_EQ(recv_buf.ip.tos, 0u); - EXPECT_EQ(recv_tos, 0u); + // TODO(b/217448626): At least one Linux environment does not allow setting + // a custom TOS. In this case, we additionally accept the default. + EXPECT_THAT(recv_buf.ip.tos, AnyOf(kArbitraryTOS, 0u)); + EXPECT_THAT(recv_tos, AnyOf(kArbitraryTOS, 0u)); } else { EXPECT_EQ(recv_buf.ip.tos, static_cast(kArbitraryTOS)); EXPECT_EQ(recv_tos, kArbitraryTOS); @@ -1277,11 +1275,9 @@ TEST(RawSocketTest, ReceiveTClass) { if (const char* val = getenv("TOS_TCLASS_EXPECT_DEFAULT"); val != nullptr && strcmp(val, "1") == 0) { - // TODO(https://issuetracker.google.com/issues/217448626): As of writing, it - // seems like at least one Linux environment does not allow setting a custom - // TCLASS. In this case, we expect the default instead of the TCLASS that - // was set above. - EXPECT_EQ(recv_tclass, 0); + // TODO(b/217448626): At least one Linux environment does not allow setting + // a custom TCLASS. In this case, we additionally accept the default. + EXPECT_THAT(recv_tclass, AnyOf(kArbitraryTClass, 0)); } else { EXPECT_EQ(recv_tclass, kArbitraryTClass); }