From 2319f958fc930d0a0980e094928bc233976b8992 Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Wed, 6 Sep 2023 14:55:10 -0700 Subject: [PATCH] Automated rollback of changelist 536743330 PiperOrigin-RevId: 563224104 --- test/syscalls/linux/BUILD | 2 ++ test/syscalls/linux/packet_socket_dgram.cc | 10 +++++++++- test/syscalls/linux/packet_socket_raw.cc | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/test/syscalls/linux/BUILD b/test/syscalls/linux/BUILD index 47c70db6c..1997c455b 100644 --- a/test/syscalls/linux/BUILD +++ b/test/syscalls/linux/BUILD @@ -1506,6 +1506,7 @@ cc_binary( "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:endian", gtest, + "//test/util:posix_error", "//test/util:test_main", "//test/util:test_util", ], @@ -1526,6 +1527,7 @@ cc_binary( "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:endian", gtest, + "//test/util:posix_error", "//test/util:test_main", "//test/util:test_util", ], diff --git a/test/syscalls/linux/packet_socket_dgram.cc b/test/syscalls/linux/packet_socket_dgram.cc index b4f6d5356..3cb266b28 100644 --- a/test/syscalls/linux/packet_socket_dgram.cc +++ b/test/syscalls/linux/packet_socket_dgram.cc @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include #include #include @@ -34,6 +35,7 @@ #include "test/util/capability_util.h" #include "test/util/cleanup.h" #include "test/util/file_descriptor.h" +#include "test/util/posix_error.h" #include "test/util/socket_util.h" #include "test/util/test_util.h" @@ -137,7 +139,13 @@ void CookedPacketTest::SetUp() { ASSERT_THAT(socket_ = socket(AF_PACKET, SOCK_DGRAM, htons(GetParam())), SyscallSucceeds()); - restore_config_ = ASSERT_NO_ERRNO_AND_VALUE(AllowMartianPacketsOnLoopback()); + auto restore_config = AllowMartianPacketsOnLoopback(); + if (restore_config.ok()) { + restore_config_ = restore_config.ValueOrDie(); + } else { + ASSERT_THAT(restore_config.error(), PosixErrorIs(EACCES)); + GTEST_SKIP(); + } } void CookedPacketTest::TearDown() { diff --git a/test/syscalls/linux/packet_socket_raw.cc b/test/syscalls/linux/packet_socket_raw.cc index 619074a05..e2be330b4 100644 --- a/test/syscalls/linux/packet_socket_raw.cc +++ b/test/syscalls/linux/packet_socket_raw.cc @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include #include #include @@ -34,6 +35,7 @@ #include "test/util/capability_util.h" #include "test/util/cleanup.h" #include "test/util/file_descriptor.h" +#include "test/util/posix_error.h" #include "test/util/socket_util.h" #include "test/util/test_util.h" @@ -113,7 +115,13 @@ void RawPacketTest::SetUp() { ASSERT_THAT(s_ = socket(AF_PACKET, SOCK_RAW, htons(GetParam())), SyscallSucceeds()); - restore_config_ = ASSERT_NO_ERRNO_AND_VALUE(AllowMartianPacketsOnLoopback()); + auto restore_config = AllowMartianPacketsOnLoopback(); + if (restore_config.ok()) { + restore_config_ = restore_config.ValueOrDie(); + } else { + ASSERT_THAT(restore_config.error(), PosixErrorIs(EACCES)); + GTEST_SKIP(); + } } void RawPacketTest::TearDown() {