Skip to content

Commit ae1294b

Browse files
committedSep 21, 2023
Internal change.
PiperOrigin-RevId: 567370524
1 parent f744f44 commit ae1294b

File tree

11 files changed

+39
-18
lines changed

11 files changed

+39
-18
lines changed
 

‎test/syscalls/linux/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ cc_binary(
14461446
srcs = ["msync.cc"],
14471447
linkstatic = 1,
14481448
deps = [
1449+
gtest,
14491450
"//test/util:file_descriptor",
14501451
"//test/util:memory_util",
14511452
"//test/util:posix_error",

‎test/syscalls/linux/alarm.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ TEST(AlarmTest, SaSiginfo) {
132132
ASSERT_THAT(pause(), SyscallFailsWithErrno(EINTR));
133133
}
134134

135+
#ifndef SA_INTERRUPT
136+
#define SA_INTERRUPT 0x20000000
137+
#endif // SA_INTERRUPT
138+
135139
// No random save as the test relies on alarm timing. Cooperative save tests
136140
// already cover the save between alarm and pause.
137141
TEST(AlarmTest, SaInterrupt) {

‎test/syscalls/linux/cgroup.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
#include "absl/container/flat_hash_set.h"
2929
#include "absl/strings/str_split.h"
3030
#include "absl/synchronization/notification.h"
31-
#include "test/util/capability_util.h"
3231
#include "test/util/cgroup_util.h"
3332
#include "test/util/cleanup.h"
33+
#include "test/util/linux_capability_util.h"
3434
#include "test/util/mount_util.h"
35+
#include "test/util/posix_error.h"
3536
#include "test/util/temp_path.h"
3637
#include "test/util/test_util.h"
3738
#include "test/util/thread_util.h"
@@ -857,7 +858,7 @@ TEST(CPUAcctCgroup, NoDoubleAccounting) {
857858

858859
// WriteAndVerifyControlValue attempts to write val to a cgroup file at path,
859860
// and verify the value by reading it afterwards.
860-
PosixError WriteAndVerifyControlValue(const Cgroup& c, std::string_view path,
861+
PosixError WriteAndVerifyControlValue(const Cgroup& c, absl::string_view path,
861862
int64_t val) {
862863
RETURN_IF_ERRNO(c.WriteIntegerControlFile(path, val));
863864
ASSIGN_OR_RETURN_ERRNO(int64_t newval, c.ReadIntegerControlFile(path));
@@ -874,7 +875,7 @@ PosixError WriteAndVerifyControlValue(const Cgroup& c, std::string_view path,
874875
PosixErrorOr<std::vector<bool>> ParseBitmap(std::string s) {
875876
std::vector<bool> bitmap;
876877
bitmap.reserve(64);
877-
for (const std::string_view& t : absl::StrSplit(s, ',')) {
878+
for (const absl::string_view& t : absl::StrSplit(s, ',')) {
878879
std::vector<std::string> parts = absl::StrSplit(t, absl::MaxSplits('-', 2));
879880
if (parts.size() == 2) {
880881
ASSIGN_OR_RETURN_ERRNO(uint64_t start, Atoi<uint64_t>(parts[0]));

‎test/syscalls/linux/msync.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <utility>
2121
#include <vector>
2222

23+
#include "gmock/gmock.h"
24+
#include "gtest/gtest.h"
2325
#include "test/util/file_descriptor.h"
2426
#include "test/util/memory_util.h"
2527
#include "test/util/posix_error.h"

‎test/syscalls/linux/shm.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ TEST(ShmTest, ShmCtlSet) {
300300
ASSERT_NO_ERRNO(Shmdt(addr));
301301
}
302302

303+
#ifndef SHM_DEST
304+
// Not defined in bionic
305+
#define SHM_DEST 0x200
306+
#endif
307+
303308
TEST(ShmTest, RemovedSegmentsAreMarkedDeleted) {
304309
ShmSegment shm = ASSERT_NO_ERRNO_AND_VALUE(
305310
Shmget(IPC_PRIVATE, kAllocSize, IPC_CREAT | 0777));

‎test/syscalls/linux/socket_inet_loopback.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ TEST_P(DualStackSocketTest, AddressOperations) {
161161

162162
if (operation == Operation::SendTo) {
163163
EXPECT_EQ(sock_addr_in6->sin6_family, AF_INET6);
164-
EXPECT_TRUE(IN6_IS_ADDR_UNSPECIFIED(sock_addr_in6->sin6_addr.s6_addr32))
164+
EXPECT_TRUE(IN6_IS_ADDR_UNSPECIFIED(&sock_addr_in6->sin6_addr))
165165
<< OperationToString(operation)
166166
<< " getsocknam=" << GetAddrStr(AsSockAddr(&sock_addr));
167167

168168
EXPECT_NE(sock_addr_in6->sin6_port, 0);
169169
} else if (IN6_IS_ADDR_V4MAPPED(
170-
reinterpret_cast<const sockaddr_in6*>(addr_in)
171-
->sin6_addr.s6_addr32)) {
172-
EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(sock_addr_in6->sin6_addr.s6_addr32))
170+
&(reinterpret_cast<const sockaddr_in6*>(addr_in)
171+
->sin6_addr))) {
172+
EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(&sock_addr_in6->sin6_addr))
173173
<< OperationToString(operation)
174174
<< " getsocknam=" << GetAddrStr(AsSockAddr(&sock_addr));
175175
}
@@ -183,11 +183,10 @@ TEST_P(DualStackSocketTest, AddressOperations) {
183183
ASSERT_EQ(addrlen, sizeof(struct sockaddr_in6));
184184

185185
if (addr.family() == AF_INET ||
186-
IN6_IS_ADDR_V4MAPPED(reinterpret_cast<const sockaddr_in6*>(addr_in)
187-
->sin6_addr.s6_addr32)) {
186+
IN6_IS_ADDR_V4MAPPED(
187+
&(reinterpret_cast<const sockaddr_in6*>(addr_in)->sin6_addr))) {
188188
EXPECT_TRUE(IN6_IS_ADDR_V4MAPPED(
189-
reinterpret_cast<const sockaddr_in6*>(&peer_addr)
190-
->sin6_addr.s6_addr32))
189+
&(reinterpret_cast<const sockaddr_in6*>(&peer_addr)->sin6_addr)))
191190
<< OperationToString(operation)
192191
<< " getpeername=" << GetAddrStr(AsSockAddr(&peer_addr));
193192
}

‎test/syscalls/linux/socket_ip_tcp_generic.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ TEST_P(TCPSocketPairTest, RSTCausesPollHUP) {
143143

144144
// Confirm we at least have one unread byte.
145145
int bytes_available = 0;
146-
ASSERT_THAT(
147-
RetryEINTR(ioctl)(sockets->second_fd(), FIONREAD, &bytes_available),
148-
SyscallSucceeds());
146+
ASSERT_THAT(RetryEINTR([&]() {
147+
return ioctl(sockets->second_fd(), FIONREAD, &bytes_available);
148+
})(),
149+
SyscallSucceeds());
149150
EXPECT_GT(bytes_available, 0);
150151

151152
// Now close the connected socket without reading the data from the second,

‎test/syscalls/linux/udp_socket.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2475,7 +2475,7 @@ TEST(UdpInet6SocketTest, ConnectInet4Sockaddr) {
24752475
ASSERT_NE(addr = inet_ntop(sockname.ss_family, &sockname, addr_buf,
24762476
sizeof(addr_buf)),
24772477
nullptr);
2478-
ASSERT_TRUE(IN6_IS_ADDR_V4MAPPED(sin6->sin6_addr.s6_addr)) << addr;
2478+
ASSERT_TRUE(IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) << addr;
24792479
}
24802480

24812481
} // namespace

‎test/util/cgroup_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Cgroup {
5353
}
5454

5555
// Creates a child cgroup under this cgroup with the given name.
56-
PosixErrorOr<Cgroup> CreateChild(std::string_view name) const;
56+
PosixErrorOr<Cgroup> CreateChild(absl::string_view name) const;
5757

5858
std::string Relpath(absl::string_view leaf) const {
5959
return JoinPath(cgroup_path_, leaf);
@@ -104,7 +104,7 @@ class Cgroup {
104104
PosixError EnterThread(pid_t pid) const;
105105

106106
private:
107-
Cgroup(std::string_view path, std::string_view mountpoint);
107+
Cgroup(absl::string_view path, absl::string_view mountpoint);
108108

109109
PosixErrorOr<absl::flat_hash_set<pid_t>> ParsePIDList(
110110
absl::string_view data) const;

‎test/util/mount_util.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ MountOptionals() {
209209
}
210210

211211
PosixError ParseOptionalTag(std::string_view tag, MountOptional* opt) {
212-
std::vector<std::string_view> key_value = absl::StrSplit(tag, ':');
212+
std::vector<absl::string_view> key_value =
213+
absl::StrSplit(absl::string_view(tag.data(), tag.size()), ':');
213214
if (key_value.size() != 2) return PosixError(0);
214215
if (key_value[0] == "shared") {
215216
if (!absl::SimpleAtoi(key_value[1], &opt->shared))

‎test/util/test_util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@
193193
#include "test/util/posix_error.h"
194194
#include "test/util/save_util.h"
195195

196+
// Android's libc, Bionic, specifies that many syscall arguments are _Nonnull,
197+
// causing tests that specifically test for syscall behavior on null arguments
198+
// to fail to build.
199+
#if defined(__BIONIC__) && defined(__clang__)
200+
#pragma clang diagnostic ignored "-Wnonnull"
201+
#endif
202+
196203
namespace gvisor {
197204
namespace testing {
198205

0 commit comments

Comments
 (0)