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