Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1016)

Unified Diff: sandbox/linux/services/syscall_wrappers_unittest.cc

Issue 801033002: Use the libc clone wrapper in sys_clone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« sandbox/linux/services/syscall_wrappers.cc ('K') | « sandbox/linux/services/syscall_wrappers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698