diff options
author | Jamie Liu <jamieliu@google.com> | 2019-04-01 10:17:28 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-01 10:18:36 -0700 |
commit | 60efd53822fe8bb6b737a1e9a722d8317807ee9a (patch) | |
tree | b1698886a3f5f7dd8bf4b9bc70122116362a0afb /test/syscalls/linux | |
parent | a046054ba35e8d8c4882f9311dc964eaa1497d58 (diff) |
Fix MemfdTest_OtherProcessCanOpenFromProcfs.
- Make the body of InForkedProcess async-signal-safe.
- Pass the correct path to open().
PiperOrigin-RevId: 241348774
Change-Id: I753dfa36e4fb05521e659c173e3b7db0c7fc159b
Diffstat (limited to 'test/syscalls/linux')
-rw-r--r-- | test/syscalls/linux/memfd.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/syscalls/linux/memfd.cc b/test/syscalls/linux/memfd.cc index ccdddd4e5..c2513682d 100644 --- a/test/syscalls/linux/memfd.cc +++ b/test/syscalls/linux/memfd.cc @@ -485,10 +485,12 @@ TEST(MemfdTest, CanOpenFromProcfs) { TEST(MemfdTest, OtherProcessCanOpenFromProcfs) { const FileDescriptor memfd = ASSERT_NO_ERRNO_AND_VALUE(MemfdCreate(kMemfdName, MFD_ALLOW_SEALING)); - pid_t pid = getpid(); + const auto memfd_path = + absl::StrFormat("/proc/%d/fd/%d", getpid(), memfd.get()); const auto rest = [&] { - ASSERT_NO_ERRNO( - Open(absl::StrFormat("/proc/self/%d/%d", pid, memfd.get()), O_RDWR)); + int fd = open(memfd_path.c_str(), O_RDWR); + TEST_PCHECK(fd >= 0); + TEST_PCHECK(close(fd) >= 0); }; EXPECT_THAT(InForkedProcess(rest), IsPosixErrorOkAndHolds(0)); } |