mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Internal change.
PiperOrigin-RevId: 567370524
This commit is contained in:
@@ -1446,6 +1446,7 @@ cc_binary(
|
||||
srcs = ["msync.cc"],
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
gtest,
|
||||
"//test/util:file_descriptor",
|
||||
"//test/util:memory_util",
|
||||
"//test/util:posix_error",
|
||||
|
||||
@@ -132,6 +132,10 @@ TEST(AlarmTest, SaSiginfo) {
|
||||
ASSERT_THAT(pause(), SyscallFailsWithErrno(EINTR));
|
||||
}
|
||||
|
||||
#ifndef SA_INTERRUPT
|
||||
#define SA_INTERRUPT 0x20000000
|
||||
#endif // SA_INTERRUPT
|
||||
|
||||
// No random save as the test relies on alarm timing. Cooperative save tests
|
||||
// already cover the save between alarm and pause.
|
||||
TEST(AlarmTest, SaInterrupt) {
|
||||
|
||||
@@ -28,10 +28,11 @@
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/strings/str_split.h"
|
||||
#include "absl/synchronization/notification.h"
|
||||
#include "test/util/capability_util.h"
|
||||
#include "test/util/cgroup_util.h"
|
||||
#include "test/util/cleanup.h"
|
||||
#include "test/util/linux_capability_util.h"
|
||||
#include "test/util/mount_util.h"
|
||||
#include "test/util/posix_error.h"
|
||||
#include "test/util/temp_path.h"
|
||||
#include "test/util/test_util.h"
|
||||
#include "test/util/thread_util.h"
|
||||
@@ -857,7 +858,7 @@ TEST(CPUAcctCgroup, NoDoubleAccounting) {
|
||||
|
||||
// WriteAndVerifyControlValue attempts to write val to a cgroup file at path,
|
||||
// and verify the value by reading it afterwards.
|
||||
PosixError WriteAndVerifyControlValue(const Cgroup& c, std::string_view path,
|
||||
PosixError WriteAndVerifyControlValue(const Cgroup& c, absl::string_view path,
|
||||
int64_t val) {
|
||||
RETURN_IF_ERRNO(c.WriteIntegerControlFile(path, val));
|
||||
ASSIGN_OR_RETURN_ERRNO(int64_t newval, c.ReadIntegerControlFile(path));
|
||||
@@ -874,7 +875,7 @@ PosixError WriteAndVerifyControlValue(const Cgroup& c, std::string_view path,
|
||||
PosixErrorOr<std::vector<bool>> ParseBitmap(std::string s) {
|
||||
std::vector<bool> bitmap;
|
||||
bitmap.reserve(64);
|
||||
for (const std::string_view& t : absl::StrSplit(s, ',')) {
|
||||
for (const absl::string_view& t : absl::StrSplit(s, ',')) {
|
||||
std::vector<std::string> parts = absl::StrSplit(t, absl::MaxSplits('-', 2));
|
||||
if (parts.size() == 2) {
|
||||
ASSIGN_OR_RETURN_ERRNO(uint64_t start, Atoi<uint64_t>(parts[0]));
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/util/file_descriptor.h"
|
||||
#include "test/util/memory_util.h"
|
||||
#include "test/util/posix_error.h"
|
||||
|
||||
@@ -300,6 +300,11 @@ TEST(ShmTest, ShmCtlSet) {
|
||||
ASSERT_NO_ERRNO(Shmdt(addr));
|
||||
}
|
||||
|
||||
#ifndef SHM_DEST
|
||||
// Not defined in bionic
|
||||
#define SHM_DEST 0x200
|
||||
#endif
|
||||
|
||||
TEST(ShmTest, RemovedSegmentsAreMarkedDeleted) {
|
||||
ShmSegment shm = ASSERT_NO_ERRNO_AND_VALUE(
|
||||
Shmget(IPC_PRIVATE, kAllocSize, IPC_CREAT | 0777));
|
||||
|
||||
@@ -161,15 +161,15 @@ TEST_P(DualStackSocketTest, AddressOperations) {
|
||||
|
||||
if (operation == Operation::SendTo) {
|
||||
EXPECT_EQ(sock_addr_in6->sin6_family, AF_INET6);
|
||||
EXPECT_TRUE(IN6_IS_ADDR_UNSPECIFIED(sock_addr_in6->sin6_addr.s6_addr32))
|
||||
EXPECT_TRUE(IN6_IS_ADDR_UNSPECIFIED(&sock_addr_in6->sin6_addr))
|
||||
<< OperationToString(operation)
|
||||
<< " getsocknam=" << GetAddrStr(AsSockAddr(&sock_addr));
|
||||
|
||||
EXPECT_NE(sock_addr_in6->sin6_port, 0);
|
||||
} else if (IN6_IS_ADDR_V4MAPPED(
|
||||
reinterpret_cast<const sockaddr_in6*>(addr_in)
|
||||
->sin6_addr.s6_addr32)) {
|
||||
EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(sock_addr_in6->sin6_addr.s6_addr32))
|
||||
&(reinterpret_cast<const sockaddr_in6*>(addr_in)
|
||||
->sin6_addr))) {
|
||||
EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(&sock_addr_in6->sin6_addr))
|
||||
<< OperationToString(operation)
|
||||
<< " getsocknam=" << GetAddrStr(AsSockAddr(&sock_addr));
|
||||
}
|
||||
@@ -183,11 +183,10 @@ TEST_P(DualStackSocketTest, AddressOperations) {
|
||||
ASSERT_EQ(addrlen, sizeof(struct sockaddr_in6));
|
||||
|
||||
if (addr.family() == AF_INET ||
|
||||
IN6_IS_ADDR_V4MAPPED(reinterpret_cast<const sockaddr_in6*>(addr_in)
|
||||
->sin6_addr.s6_addr32)) {
|
||||
IN6_IS_ADDR_V4MAPPED(
|
||||
&(reinterpret_cast<const sockaddr_in6*>(addr_in)->sin6_addr))) {
|
||||
EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(
|
||||
reinterpret_cast<const sockaddr_in6*>(&peer_addr)
|
||||
->sin6_addr.s6_addr32))
|
||||
&(reinterpret_cast<const sockaddr_in6*>(&peer_addr)->sin6_addr)))
|
||||
<< OperationToString(operation)
|
||||
<< " getpeername=" << GetAddrStr(AsSockAddr(&peer_addr));
|
||||
}
|
||||
|
||||
@@ -143,9 +143,10 @@ TEST_P(TCPSocketPairTest, RSTCausesPollHUP) {
|
||||
|
||||
// Confirm we at least have one unread byte.
|
||||
int bytes_available = 0;
|
||||
ASSERT_THAT(
|
||||
RetryEINTR(ioctl)(sockets->second_fd(), FIONREAD, &bytes_available),
|
||||
SyscallSucceeds());
|
||||
ASSERT_THAT(RetryEINTR([&]() {
|
||||
return ioctl(sockets->second_fd(), FIONREAD, &bytes_available);
|
||||
})(),
|
||||
SyscallSucceeds());
|
||||
EXPECT_GT(bytes_available, 0);
|
||||
|
||||
// Now close the connected socket without reading the data from the second,
|
||||
|
||||
@@ -2475,7 +2475,7 @@ TEST(UdpInet6SocketTest, ConnectInet4Sockaddr) {
|
||||
ASSERT_NE(addr = inet_ntop(sockname.ss_family, &sockname, addr_buf,
|
||||
sizeof(addr_buf)),
|
||||
nullptr);
|
||||
ASSERT_TRUE(IN6_IS_ADDR_V4MAPPED(sin6->sin6_addr.s6_addr)) << addr;
|
||||
ASSERT_TRUE(IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) << addr;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -53,7 +53,7 @@ class Cgroup {
|
||||
}
|
||||
|
||||
// Creates a child cgroup under this cgroup with the given name.
|
||||
PosixErrorOr<Cgroup> CreateChild(std::string_view name) const;
|
||||
PosixErrorOr<Cgroup> CreateChild(absl::string_view name) const;
|
||||
|
||||
std::string Relpath(absl::string_view leaf) const {
|
||||
return JoinPath(cgroup_path_, leaf);
|
||||
@@ -104,7 +104,7 @@ class Cgroup {
|
||||
PosixError EnterThread(pid_t pid) const;
|
||||
|
||||
private:
|
||||
Cgroup(std::string_view path, std::string_view mountpoint);
|
||||
Cgroup(absl::string_view path, absl::string_view mountpoint);
|
||||
|
||||
PosixErrorOr<absl::flat_hash_set<pid_t>> ParsePIDList(
|
||||
absl::string_view data) const;
|
||||
|
||||
@@ -209,7 +209,8 @@ MountOptionals() {
|
||||
}
|
||||
|
||||
PosixError ParseOptionalTag(std::string_view tag, MountOptional* opt) {
|
||||
std::vector<std::string_view> key_value = absl::StrSplit(tag, ':');
|
||||
std::vector<absl::string_view> key_value =
|
||||
absl::StrSplit(absl::string_view(tag.data(), tag.size()), ':');
|
||||
if (key_value.size() != 2) return PosixError(0);
|
||||
if (key_value[0] == "shared") {
|
||||
if (!absl::SimpleAtoi(key_value[1], &opt->shared))
|
||||
|
||||
@@ -193,6 +193,13 @@
|
||||
#include "test/util/posix_error.h"
|
||||
#include "test/util/save_util.h"
|
||||
|
||||
// Android's libc, Bionic, specifies that many syscall arguments are _Nonnull,
|
||||
// causing tests that specifically test for syscall behavior on null arguments
|
||||
// to fail to build.
|
||||
#if defined(__BIONIC__) && defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wnonnull"
|
||||
#endif
|
||||
|
||||
namespace gvisor {
|
||||
namespace testing {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user