Index: sandbox/linux/services/syscall_wrappers_unittest.cc |
diff --git a/sandbox/linux/services/syscall_wrappers_unittest.cc b/sandbox/linux/services/syscall_wrappers_unittest.cc |
index 861dd5feb1c02aa7ece96186694f6b7b675a19f1..70b2d5be8a068a01b262789897c1ba8fa46733fe 100644 |
--- a/sandbox/linux/services/syscall_wrappers_unittest.cc |
+++ b/sandbox/linux/services/syscall_wrappers_unittest.cc |
@@ -58,6 +58,30 @@ TEST(SyscallWrappers, CloneChildSettid) { |
EXPECT_EQ(kSuccessExit, WEXITSTATUS(status)); |
} |
+// Some libcs cache the result of the getpid syscall. This tests that |
+// the cache is updated after sys_clone. |
+TEST(SyscallWrappers, CloneUpdatesPidCache) { |
+ // Warm up the PID cache. |
+ ASSERT_EQ(sys_getpid(), getpid()); |
+ |
+ pid_t ctid = 0; |
+ pid_t pid = |
+ sys_clone(CLONE_CHILD_SETTID | SIGCHLD, nullptr, nullptr, &ctid, nullptr); |
+ |
+ const int kSuccessExit = 0; |
+ if (0 == pid) { |
+ // In child. The pid cache should have been updated. |
+ ASSERT_EQ(ctid, getpid()); |
jln (very slow on Chromium)
2014/12/15 23:31:35
Let's not use ASSERT in there, it's confusing. I w
rickyz (no longer on Chrome)
2014/12/16 00:35:09
I merged the tests, but actually, I'm curious as t
jln (very slow on Chromium)
2014/12/16 01:11:22
ASSERT is only guaranteed to return from the curre
|
+ _exit(kSuccessExit); |
+ } |
+ |
+ ASSERT_NE(-1, pid); |
+ int status = 0; |
+ ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); |
+ ASSERT_TRUE(WIFEXITED(status)); |
+ EXPECT_EQ(kSuccessExit, WEXITSTATUS(status)); |
+} |
+ |
} // namespace |
} // namespace sandbox |