Remove __fuchsia__ defines
These mostly guard linux-only headers; check for linux instead. PiperOrigin-RevId: 329362762
This commit is contained in:
parent
911cecaa34
commit
9d0d82088a
|
@ -22,6 +22,7 @@ exports_files(
|
|||
"socket_ipv4_tcp_unbound_external_networking_test.cc",
|
||||
"socket_ipv4_udp_unbound_external_networking_test.cc",
|
||||
"socket_ipv4_udp_unbound_loopback.cc",
|
||||
"socket_ipv4_udp_unbound_loopback_nogotsan.cc",
|
||||
"tcp_socket.cc",
|
||||
"udp_bind.cc",
|
||||
"udp_socket.cc",
|
||||
|
@ -3666,15 +3667,12 @@ cc_binary(
|
|||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "udp_socket_test_cases",
|
||||
cc_binary(
|
||||
name = "udp_socket_test",
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
"udp_socket_errqueue_test_case.cc",
|
||||
"udp_socket_test_cases.cc",
|
||||
],
|
||||
hdrs = ["udp_socket_test_cases.h"],
|
||||
srcs = ["udp_socket.cc"],
|
||||
defines = select_system(),
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
":ip_socket_test_util",
|
||||
":socket_test_util",
|
||||
|
@ -3689,17 +3687,6 @@ cc_library(
|
|||
"//test/util:test_util",
|
||||
"//test/util:thread_util",
|
||||
],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "udp_socket_test",
|
||||
testonly = 1,
|
||||
srcs = ["udp_socket.cc"],
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
":udp_socket_test_cases",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/capability.h>
|
||||
#ifndef __fuchsia__
|
||||
#include <linux/filter.h>
|
||||
#endif // __fuchsia__
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <net/ethernet.h>
|
||||
|
@ -618,8 +616,6 @@ TEST_P(RawPacketTest, GetSocketErrorBind) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef __fuchsia__
|
||||
|
||||
TEST_P(RawPacketTest, SetSocketDetachFilterNoInstalledFilter) {
|
||||
// TODO(gvisor.dev/2746): Support SO_ATTACH_FILTER/SO_DETACH_FILTER.
|
||||
//
|
||||
|
@ -647,8 +643,6 @@ TEST_P(RawPacketTest, GetSocketDetachFilter) {
|
|||
SyscallFailsWithErrno(ENOPROTOOPT));
|
||||
}
|
||||
|
||||
#endif // __fuchsia__
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(AllInetTests, RawPacketTest,
|
||||
::testing::Values(ETH_P_IP, ETH_P_ALL));
|
||||
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <linux/capability.h>
|
||||
#ifndef __fuchsia__
|
||||
#include <linux/filter.h>
|
||||
#endif // __fuchsia__
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
|
@ -815,8 +813,6 @@ void RawSocketTest::ReceiveBufFrom(int sock, char* recv_buf,
|
|||
ASSERT_NO_FATAL_FAILURE(RecvNoCmsg(sock, recv_buf, recv_buf_len));
|
||||
}
|
||||
|
||||
#ifndef __fuchsia__
|
||||
|
||||
TEST_P(RawSocketTest, SetSocketDetachFilterNoInstalledFilter) {
|
||||
// TODO(gvisor.dev/2746): Support SO_ATTACH_FILTER/SO_DETACH_FILTER.
|
||||
if (IsRunningOnGvisor()) {
|
||||
|
@ -838,8 +834,6 @@ TEST_P(RawSocketTest, GetSocketDetachFilter) {
|
|||
SyscallFailsWithErrno(ENOPROTOOPT));
|
||||
}
|
||||
|
||||
#endif // __fuchsia__
|
||||
|
||||
// AF_INET6+SOCK_RAW+IPPROTO_RAW sockets can be created, but not written to.
|
||||
TEST(RawSocketTest, IPv6ProtoRaw) {
|
||||
SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_RAW)));
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <fcntl.h>
|
||||
#ifndef __fuchsia__
|
||||
#ifdef __linux__
|
||||
#include <linux/filter.h>
|
||||
#endif // __fuchsia__
|
||||
#endif // __linux__
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <poll.h>
|
||||
|
@ -1586,7 +1586,7 @@ TEST_P(SimpleTcpSocketTest, SetTCPWindowClampAboveHalfMinRcvBuf) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef __fuchsia__
|
||||
#ifdef __linux__
|
||||
|
||||
// TODO(gvisor.dev/2746): Support SO_ATTACH_FILTER/SO_DETACH_FILTER.
|
||||
// gVisor currently silently ignores attaching a filter.
|
||||
|
@ -1620,6 +1620,8 @@ TEST_P(SimpleTcpSocketTest, SetSocketAttachDetachFilter) {
|
|||
SyscallSucceeds());
|
||||
}
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
TEST_P(SimpleTcpSocketTest, SetSocketDetachFilterNoInstalledFilter) {
|
||||
// TODO(gvisor.dev/2746): Support SO_ATTACH_FILTER/SO_DETACH_FILTER.
|
||||
SKIP_IF(IsRunningOnGvisor());
|
||||
|
@ -1641,8 +1643,6 @@ TEST_P(SimpleTcpSocketTest, GetSocketDetachFilter) {
|
|||
SyscallFailsWithErrno(ENOPROTOOPT));
|
||||
}
|
||||
|
||||
#endif // __fuchsia__
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(AllInetTests, SimpleTcpSocketTest,
|
||||
::testing::Values(AF_INET, AF_INET6));
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,57 +0,0 @@
|
|||
// Copyright 2018 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __fuchsia__
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/errqueue.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/base/macros.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "test/syscalls/linux/socket_test_util.h"
|
||||
#include "test/syscalls/linux/udp_socket_test_cases.h"
|
||||
#include "test/syscalls/linux/unix_domain_socket_test_util.h"
|
||||
#include "test/util/test_util.h"
|
||||
#include "test/util/thread_util.h"
|
||||
|
||||
namespace gvisor {
|
||||
namespace testing {
|
||||
|
||||
TEST_P(UdpSocketTest, ErrorQueue) {
|
||||
char cmsgbuf[CMSG_SPACE(sizeof(sock_extended_err))];
|
||||
msghdr msg;
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
iovec iov;
|
||||
memset(&iov, 0, sizeof(iov));
|
||||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = cmsgbuf;
|
||||
msg.msg_controllen = sizeof(cmsgbuf);
|
||||
|
||||
// recv*(MSG_ERRQUEUE) never blocks, even without MSG_DONTWAIT.
|
||||
EXPECT_THAT(RetryEINTR(recvmsg)(bind_.get(), &msg, MSG_ERRQUEUE),
|
||||
SyscallFailsWithErrno(EAGAIN));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace gvisor
|
||||
|
||||
#endif // __fuchsia__
|
File diff suppressed because it is too large
Load Diff
|
@ -1,82 +0,0 @@
|
|||
// Copyright 2019 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_GOLANG_GVISOR_TEST_SYSCALLS_LINUX_SOCKET_IPV4_UDP_UNBOUND_H_
|
||||
#define THIRD_PARTY_GOLANG_GVISOR_TEST_SYSCALLS_LINUX_SOCKET_IPV4_UDP_UNBOUND_H_
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/syscalls/linux/socket_test_util.h"
|
||||
#include "test/util/file_descriptor.h"
|
||||
#include "test/util/posix_error.h"
|
||||
|
||||
namespace gvisor {
|
||||
namespace testing {
|
||||
|
||||
// The initial port to be be used on gvisor.
|
||||
constexpr int TestPort = 40000;
|
||||
|
||||
// Fixture for tests parameterized by the address family to use (AF_INET and
|
||||
// AF_INET6) when creating sockets.
|
||||
class UdpSocketTest
|
||||
: public ::testing::TestWithParam<gvisor::testing::AddressFamily> {
|
||||
protected:
|
||||
// Creates two sockets that will be used by test cases.
|
||||
void SetUp() override;
|
||||
|
||||
// Binds the socket bind_ to the loopback and updates bind_addr_.
|
||||
PosixError BindLoopback();
|
||||
|
||||
// Binds the socket bind_ to Any and updates bind_addr_.
|
||||
PosixError BindAny();
|
||||
|
||||
// Binds given socket to address addr and updates.
|
||||
PosixError BindSocket(int socket, struct sockaddr* addr);
|
||||
|
||||
// Return initialized Any address to port 0.
|
||||
struct sockaddr_storage InetAnyAddr();
|
||||
|
||||
// Return initialized Loopback address to port 0.
|
||||
struct sockaddr_storage InetLoopbackAddr();
|
||||
|
||||
// Disconnects socket sockfd.
|
||||
void Disconnect(int sockfd);
|
||||
|
||||
// Get family for the test.
|
||||
int GetFamily();
|
||||
|
||||
// Socket used by Bind methods
|
||||
FileDescriptor bind_;
|
||||
|
||||
// Second socket used for tests.
|
||||
FileDescriptor sock_;
|
||||
|
||||
// Address for bind_ socket.
|
||||
struct sockaddr* bind_addr_;
|
||||
|
||||
// Initialized to the length based on GetFamily().
|
||||
socklen_t addrlen_;
|
||||
|
||||
// Storage for bind_addr_.
|
||||
struct sockaddr_storage bind_addr_storage_;
|
||||
|
||||
private:
|
||||
// Helper to initialize addrlen_ for the test case.
|
||||
socklen_t GetAddrLength();
|
||||
};
|
||||
} // namespace testing
|
||||
} // namespace gvisor
|
||||
|
||||
#endif // THIRD_PARTY_GOLANG_GVISOR_TEST_SYSCALLS_LINUX_SOCKET_IPV4_UDP_UNBOUND_H_
|
|
@ -15,9 +15,9 @@
|
|||
#include "test/util/fs_util.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#ifndef __fuchsia__
|
||||
#ifdef __linux__
|
||||
#include <linux/magic.h>
|
||||
#endif // __fuchsia__
|
||||
#endif // __linux__
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -633,7 +633,7 @@ PosixErrorOr<std::string> ProcessExePath(int pid) {
|
|||
return ReadLink(absl::StrCat("/proc/", pid, "/exe"));
|
||||
}
|
||||
|
||||
#ifndef __fuchsia__
|
||||
#ifdef __linux__
|
||||
PosixErrorOr<bool> IsTmpfs(const std::string& path) {
|
||||
struct statfs stat;
|
||||
if (statfs(path.c_str(), &stat)) {
|
||||
|
@ -647,7 +647,7 @@ PosixErrorOr<bool> IsTmpfs(const std::string& path) {
|
|||
}
|
||||
return stat.f_type == TMPFS_MAGIC;
|
||||
}
|
||||
#endif // __fuchsia__
|
||||
#endif // __linux__
|
||||
|
||||
} // namespace testing
|
||||
} // namespace gvisor
|
||||
|
|
|
@ -179,10 +179,10 @@ std::string CleanPath(absl::string_view path);
|
|||
// Returns the full path to the executable of the given pid or a PosixError.
|
||||
PosixErrorOr<std::string> ProcessExePath(int pid);
|
||||
|
||||
#ifndef __fuchsia__
|
||||
#ifdef __linux__
|
||||
// IsTmpfs returns true if the file at path is backed by tmpfs.
|
||||
PosixErrorOr<bool> IsTmpfs(const std::string& path);
|
||||
#endif // __fucshia__
|
||||
#endif // __linux__
|
||||
|
||||
namespace internal {
|
||||
// Not part of the public API.
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __fuchsia__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
@ -46,5 +44,3 @@ std::string RunfilePath(std::string path) {
|
|||
|
||||
} // namespace testing
|
||||
} // namespace gvisor
|
||||
|
||||
#endif // __fuchsia__
|
||||
|
|
Loading…
Reference in New Issue