diff --git a/test/syscalls/linux/eventfd.cc b/test/syscalls/linux/eventfd.cc index 904a00742a..2804325dfb 100644 --- a/test/syscalls/linux/eventfd.cc +++ b/test/syscalls/linux/eventfd.cc @@ -129,7 +129,7 @@ TEST(EventfdTest, IllegalPwrite) { TEST(EventfdTest, BigWriteFails) { // Starting Linux 6.9, big writes fail. gVisor has the newer behavior. - if (!IsRunningOnGvisor()) { + if (!IsRunningOnGvisor() && GvisorPlatform() != Platform::kStarnix) { auto version = ASSERT_NO_ERRNO_AND_VALUE(GetKernelVersion()); SKIP_IF(version.major < 6 || (version.major == 6 && version.minor < 9)); } @@ -199,7 +199,7 @@ TEST(EventfdTest, NotifyNonZero) { TEST(EventfdTest, SpliceReturnsEINVAL) { // Splicing into eventfd has been disabled in // 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops"). - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); // Create an eventfd descriptor. FileDescriptor efd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(7, 0)); diff --git a/test/syscalls/linux/exec_binary.cc b/test/syscalls/linux/exec_binary.cc index f73515824e..f3be0fc201 100644 --- a/test/syscalls/linux/exec_binary.cc +++ b/test/syscalls/linux/exec_binary.cc @@ -1079,7 +1079,7 @@ class ElfInterpreterStaticTest TEST_P(ElfInterpreterStaticTest, Test) { // TODO(gvisor.dev/issue/3721): Test has been observed to segfault on 5.X // kernels. - if (!IsRunningOnGvisor()) { + if (GvisorPlatform() == Platform::kNative) { auto version = ASSERT_NO_ERRNO_AND_VALUE(GetKernelVersion()); SKIP_IF(version.major > 4); } diff --git a/test/syscalls/linux/iptables.cc b/test/syscalls/linux/iptables.cc index 3cd2051197..173afb3d17 100644 --- a/test/syscalls/linux/iptables.cc +++ b/test/syscalls/linux/iptables.cc @@ -219,7 +219,7 @@ void IPTablesTest::TearDown() { // can test that gVisor has the same initial state that a newly-booted Linux // machine would have. TEST_F(IPTablesTest, InitialState) { - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_RAW))); // @@ -424,7 +424,7 @@ TEST_F(IPTablesTest, LargeReplacePayload) { // Tests the initial state of the raw table. The raw table has PREROUTING and // OUTPUT hooks (no INPUT, FORWARD, or POSTROUTING). TEST_F(IPTablesTest, RawTableInitialState) { - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_RAW))); struct ipt_getinfo info = {}; diff --git a/test/syscalls/linux/kill.cc b/test/syscalls/linux/kill.cc index 9e6632a0dd..fa45e628e6 100644 --- a/test/syscalls/linux/kill.cc +++ b/test/syscalls/linux/kill.cc @@ -73,7 +73,7 @@ TEST(KillTest, CanKillAllPIDs) { // as our namespace may contain may more processes that cannot tolerate // the signal below. We also cannot reliably create a new pid namespace // for ourselves and test the same functionality. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); int pipe_fds[2]; ASSERT_THAT(pipe(pipe_fds), SyscallSucceeds()); diff --git a/test/syscalls/linux/memory_accounting.cc b/test/syscalls/linux/memory_accounting.cc index eac0f3f35d..a9f04d6992 100644 --- a/test/syscalls/linux/memory_accounting.cc +++ b/test/syscalls/linux/memory_accounting.cc @@ -67,7 +67,7 @@ TEST(MemoryAccounting, AnonAccountingPreservedOnSaveRestore) { // the machine. In gvisor, this test is the only thing running on the // "machine", so values in /proc/meminfo accurately reflect the memory used by // the test. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); uint64_t anon_initial = ASSERT_NO_ERRNO_AND_VALUE(AnonUsageFromMeminfo()); diff --git a/test/syscalls/linux/pidfd_test.cc b/test/syscalls/linux/pidfd_test.cc index 215af4e0b8..08ea2f2333 100644 --- a/test/syscalls/linux/pidfd_test.cc +++ b/test/syscalls/linux/pidfd_test.cc @@ -1289,7 +1289,7 @@ TEST(PidfdTest, PidfdGetfdNonDumpableExitingRace) { // Skip when running natively because the host kernel may be vulnerable to // CVE-2026-46333, which would cause the test to fail. We only want to verify // the fix inside the gVisor sandbox. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); AutoCapability cap(CAP_SYS_PTRACE, false); for (int iter = 0; iter < 100; ++iter) { int pfd[2]; diff --git a/test/syscalls/linux/proc.cc b/test/syscalls/linux/proc.cc index beba987236..36c0ff1e6e 100644 --- a/test/syscalls/linux/proc.cc +++ b/test/syscalls/linux/proc.cc @@ -1134,7 +1134,7 @@ TEST(ProcSelfMaps, MapUnmap) { TEST(ProcSelfMaps, Mprotect) { // FIXME(jamieliu): Linux's mprotect() sometimes fails to merge VMAs in this // case. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); // Reserve 5 pages of address space. Mapping m = ASSERT_NO_ERRNO_AND_VALUE( diff --git a/test/syscalls/linux/proc_net.cc b/test/syscalls/linux/proc_net.cc index ee149991e1..a907a9694c 100644 --- a/test/syscalls/linux/proc_net.cc +++ b/test/syscalls/linux/proc_net.cc @@ -625,7 +625,7 @@ TEST(ProcSysNetIpv4IpForward, Exists) { TEST(ProcSysNetIpv4IpForward, DefaultValueEqZero) { // Test is only valid in sandbox. Not hermetic in native tests // running on a arbitrary machine. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); auto const fd = ASSERT_NO_ERRNO_AND_VALUE(Open(kIpForward, O_RDONLY)); char buf = 101; diff --git a/test/syscalls/linux/ptrace.cc b/test/syscalls/linux/ptrace.cc index 8f2259b931..0d60fbca56 100644 --- a/test/syscalls/linux/ptrace.cc +++ b/test/syscalls/linux/ptrace.cc @@ -2393,7 +2393,7 @@ TEST(PtraceTest, SeizeSetOptions) { TEST(PtraceTest, SetYAMAPtraceScope) { // Do not modify the ptrace scope on the host. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN))); const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE( diff --git a/test/syscalls/linux/raw_socket_icmp.cc b/test/syscalls/linux/raw_socket_icmp.cc index 063417f351..93e0f38b57 100644 --- a/test/syscalls/linux/raw_socket_icmp.cc +++ b/test/syscalls/linux/raw_socket_icmp.cc @@ -246,7 +246,7 @@ TEST_F(RawSocketICMPTest, RawAndPingSockets) { // So we only run the test with gVisor and not hostinet, and even then require // CAP_NET_RAW. // See https://lwn.net/Articles/443051/ - SKIP_IF(!IsRunningOnGvisor() || IsRunningWithHostinet() || + SKIP_IF(GvisorPlatform() == Platform::kNative || IsRunningWithHostinet() || ASSERT_NO_ERRNO_AND_VALUE( HaveRawIPSocketCapability(AF_INET, IPPROTO_ICMP))); @@ -302,7 +302,7 @@ TEST_F(RawSocketICMPTest, ShortEchoRawAndPingSockets) { // So we only run the test with gVisor and not hostinet, and even then require // CAP_NET_RAW. // See https://lwn.net/Articles/443051/ - SKIP_IF(!IsRunningOnGvisor() || IsRunningWithHostinet() || + SKIP_IF(GvisorPlatform() == Platform::kNative || IsRunningWithHostinet() || ASSERT_NO_ERRNO_AND_VALUE( HaveRawIPSocketCapability(AF_INET, IPPROTO_ICMP))); @@ -349,7 +349,7 @@ TEST_F(RawSocketICMPTest, ShortEchoReplyRawAndPingSockets) { // So we only run the test with gVisor and not hostinet, and even then require // CAP_NET_RAW. // See https://lwn.net/Articles/443051/ - SKIP_IF(!IsRunningOnGvisor() || IsRunningWithHostinet() || + SKIP_IF(GvisorPlatform() == Platform::kNative || IsRunningWithHostinet() || ASSERT_NO_ERRNO_AND_VALUE( HaveRawIPSocketCapability(AF_INET, IPPROTO_ICMP))); diff --git a/test/syscalls/linux/readahead.cc b/test/syscalls/linux/readahead.cc index 2d91d9fa83..e35d36aca0 100644 --- a/test/syscalls/linux/readahead.cc +++ b/test/syscalls/linux/readahead.cc @@ -41,7 +41,7 @@ TEST(ReadaheadTest, UnsupportedFile) { TEST(ReadaheadTest, InvalidOffset) { // This test is not valid for some Linux Kernels. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); const TempPath in_file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(in_file.path(), O_RDWR)); @@ -92,7 +92,7 @@ TEST(ReadaheadTest, WriteOnly) { TEST(ReadaheadTest, InvalidSize) { // This test is not valid on some Linux kernels. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); const TempPath in_file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(in_file.path(), O_RDWR)); diff --git a/test/syscalls/linux/rlimits.cc b/test/syscalls/linux/rlimits.cc index 1217e0a187..5f256aa823 100644 --- a/test/syscalls/linux/rlimits.cc +++ b/test/syscalls/linux/rlimits.cc @@ -114,7 +114,7 @@ TEST(RlimitTest, RlimitNProc) { // The native test can be run in a user namespace without a mapping for // kNobody or there can be other processes that are running from the kNobody // user. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); // Run the test in a sub-thread to avoid changing UID of the current thread. ScopedThread([&] { diff --git a/test/syscalls/linux/sendfile.cc b/test/syscalls/linux/sendfile.cc index 501e83ace6..90b1acec53 100644 --- a/test/syscalls/linux/sendfile.cc +++ b/test/syscalls/linux/sendfile.cc @@ -482,7 +482,7 @@ TEST(SendFileTest, SendToNotARegularFile) { TEST(SendFileTest, SendPipeWouldBlock) { // This test fails on Linux, likely due to a Linux bug. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); // Create temp file. constexpr char kData[] = "The fool doth think he is wise, but the wise man knows himself to be a " @@ -530,7 +530,7 @@ TEST(SendFileTest, SendPipeEOF) { TEST(SendFileTest, SendToFullPipeReturnsEAGAIN) { // This test fails on Linux, likely due to a Linux bug. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); // Create and open an empty input file. const TempPath in_file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); const FileDescriptor in_fd = diff --git a/test/syscalls/linux/shm.cc b/test/syscalls/linux/shm.cc index bfad73ee20..4933b20775 100644 --- a/test/syscalls/linux/shm.cc +++ b/test/syscalls/linux/shm.cc @@ -245,7 +245,7 @@ TEST(ShmTest, ShmStat) { // This test relies on the segment we create to be the first one on the // system, causing it to occupy slot 1. We can't reasonably expect this on a // general Linux host. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); const ShmSegment shm = ASSERT_NO_ERRNO_AND_VALUE( Shmget(IPC_PRIVATE, kAllocSize, IPC_CREAT | 0777)); diff --git a/test/syscalls/linux/socket_generic_test_cases.cc b/test/syscalls/linux/socket_generic_test_cases.cc index 9a620d8c52..be6cf6c8e6 100644 --- a/test/syscalls/linux/socket_generic_test_cases.cc +++ b/test/syscalls/linux/socket_generic_test_cases.cc @@ -354,7 +354,7 @@ TEST_P(AllSocketPairTest, RecvmmsgInvalidTimeout) { TEST_P(AllSocketPairTest, RecvmmsgTimeoutBeforeRecv) { // There is a known bug in the Linux recvmmsg(2) causing it to block forever // if the timeout expires while blocking for the first message. - SKIP_IF(!IsRunningOnGvisor() || IsRunningWithHostinet()); + SKIP_IF(GvisorPlatform() == Platform::kNative || IsRunningWithHostinet()); auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); char buf[10]; diff --git a/test/syscalls/linux/socket_ip_unbound.cc b/test/syscalls/linux/socket_ip_unbound.cc index e6da7b5a01..e7669a24cc 100644 --- a/test/syscalls/linux/socket_ip_unbound.cc +++ b/test/syscalls/linux/socket_ip_unbound.cc @@ -221,7 +221,7 @@ TEST_P(IPUnboundSocketTest, InvalidLargeTOS) { TEST_P(IPUnboundSocketTest, CheckSkipECN) { // Test is inconsistent on different kernels. - SKIP_IF(!IsRunningOnGvisor() || IsRunningWithHostinet()); + SKIP_IF(GvisorPlatform() == Platform::kNative || IsRunningWithHostinet()); auto socket = ASSERT_NO_ERRNO_AND_VALUE(NewSocket()); int set = 0xFF; socklen_t set_sz = sizeof(set); diff --git a/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc b/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc index 22dad04296..d244662513 100644 --- a/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc +++ b/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc @@ -44,7 +44,7 @@ void IPv4DatagramBasedUnboundSocketTest::SetUp() { // privs. So we only run the test with gVisor and not hostinet, and even // then require CAP_NET_RAW. // See https://lwn.net/Articles/443051/ - SKIP_IF(!IsRunningOnGvisor() || IsRunningWithHostinet() || + SKIP_IF(GvisorPlatform() == Platform::kNative || IsRunningWithHostinet() || ASSERT_NO_ERRNO_AND_VALUE(HaveRawIPSocketCapability( GetParam().domain, GetParam().protocol))); } @@ -277,7 +277,7 @@ TEST_P(IPv4DatagramBasedUnboundSocketTest, IpMulticastIfSetNic) { TEST_P(IPv4DatagramBasedUnboundSocketTest, TestJoinGroupNoIf) { // TODO(b/185517803): Fix for native test. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); auto socket1 = ASSERT_NO_ERRNO_AND_VALUE(NewSocket()); auto socket2 = ASSERT_NO_ERRNO_AND_VALUE(NewSocket()); diff --git a/test/syscalls/linux/socket_ipv4_udp_unbound.cc b/test/syscalls/linux/socket_ipv4_udp_unbound.cc index 00494be238..3d57f535a0 100644 --- a/test/syscalls/linux/socket_ipv4_udp_unbound.cc +++ b/test/syscalls/linux/socket_ipv4_udp_unbound.cc @@ -93,7 +93,7 @@ TEST_P(IPv4UDPUnboundSocketTest, IpMulticastLoopbackNoGroup) { // from being sent. Group membership interface configured by address. TEST_P(IPv4UDPUnboundSocketTest, IpMulticastLoopbackAddrNoDefaultSendIf) { // TODO(b/185517803): Fix for native test. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); auto socket1 = ASSERT_NO_ERRNO_AND_VALUE(NewSocket()); auto socket2 = ASSERT_NO_ERRNO_AND_VALUE(NewSocket()); @@ -133,7 +133,7 @@ TEST_P(IPv4UDPUnboundSocketTest, IpMulticastLoopbackAddrNoDefaultSendIf) { // from being sent. Group membership interface configured by NIC ID. TEST_P(IPv4UDPUnboundSocketTest, IpMulticastLoopbackNicNoDefaultSendIf) { // TODO(b/185517803): Fix for native test. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); auto socket1 = ASSERT_NO_ERRNO_AND_VALUE(NewSocket()); auto socket2 = ASSERT_NO_ERRNO_AND_VALUE(NewSocket()); diff --git a/test/syscalls/linux/socket_netlink_netfilter.cc b/test/syscalls/linux/socket_netlink_netfilter.cc index 38c8a536e3..aff315f10a 100644 --- a/test/syscalls/linux/socket_netlink_netfilter.cc +++ b/test/syscalls/linux/socket_netlink_netfilter.cc @@ -1549,7 +1549,7 @@ TEST(NetlinkNetfilterTest, ErrNewBaseChainWithMalformedHookDataMissingHookNum) { TEST(NetlinkNetfilterTest, ErrNewBaseChainWithInvalidChainType) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCaps())); // TODO: b/421437663 - Fix this error test for native Linux. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); std::string test_table_name = GetUniqueTestTableName(); const char test_chain_name[] = "test_chain_bad_policy"; const char test_chain_type_name[] = "test_chain_type_invalid"; diff --git a/test/syscalls/linux/socket_netlink_route.cc b/test/syscalls/linux/socket_netlink_route.cc index 2d8ba22d04..1e1099269c 100644 --- a/test/syscalls/linux/socket_netlink_route.cc +++ b/test/syscalls/linux/socket_netlink_route.cc @@ -341,7 +341,7 @@ TEST_P(NetlinkSetLinkTest, ChangeLinkName) { SKIP_IF(IsRunningWithHostinet()); // Hosts that run with old kernel allow renaming only when // the interface is down. The restriction has been removed. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); Link loopback_link = ASSERT_NO_ERRNO_AND_VALUE(LoopbackLink()); FileDescriptor fd = @@ -459,7 +459,7 @@ TEST_P(NetlinkSetLinkTest, ChangeMTU) { TEST_P(NetlinkSetLinkTest, ChangeMACAddress) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_ADMIN))); - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); SKIP_IF(IsRunningWithHostinet()); Link loopback_link = ASSERT_NO_ERRNO_AND_VALUE(LoopbackLink()); diff --git a/test/syscalls/linux/statfs.cc b/test/syscalls/linux/statfs.cc index dab209d9c8..67262628e9 100644 --- a/test/syscalls/linux/statfs.cc +++ b/test/syscalls/linux/statfs.cc @@ -122,7 +122,7 @@ TEST(FstatfsTest, InternalDevShm) { TEST(FstatfsTest, BlocksFree) { // This test relies on the test being the only user of the filesystem, which // is not feasible outside of a sandbox. - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); const std::string file_path = NewTempAbsPath(); const std::string dir = std::string(Dirname(file_path)); diff --git a/test/syscalls/linux/timerfd.cc b/test/syscalls/linux/timerfd.cc index 68590df953..11d4667d03 100644 --- a/test/syscalls/linux/timerfd.cc +++ b/test/syscalls/linux/timerfd.cc @@ -311,7 +311,7 @@ TEST(TimerfdClockRealtimeTest, ClockAbsoluteRealtime) { TEST(TimerfdClockRealtimeTest, ClockAbsoluteRealtimeCancelOnSet) { // Skip on native Linux since we can't guarantee there // will be no clock jumps causing ECANCELED - SKIP_IF(!IsRunningOnGvisor()); + SKIP_IF(GvisorPlatform() == Platform::kNative); constexpr int kDelaySecs = 1;