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

Side by Side Diff: sandbox/linux/services/syscall_wrappers_unittest.cc

Issue 807213002: Revert "Use the libc clone wrapper in sys_clone." (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « sandbox/linux/services/syscall_wrappers.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sandbox/linux/services/syscall_wrappers.h" 5 #include "sandbox/linux/services/syscall_wrappers.h"
6 6
7 #include <sys/syscall.h> 7 #include <sys/syscall.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/wait.h> 9 #include <sys/wait.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 21 matching lines...) Expand all
32 TEST(SyscallWrappers, CloneParentSettid) { 32 TEST(SyscallWrappers, CloneParentSettid) {
33 pid_t ptid = 0; 33 pid_t ptid = 0;
34 pid_t child = sys_clone(CLONE_PARENT_SETTID | SIGCHLD, nullptr, &ptid, 34 pid_t child = sys_clone(CLONE_PARENT_SETTID | SIGCHLD, nullptr, &ptid,
35 nullptr, nullptr); 35 nullptr, nullptr);
36 TestUtils::HandlePostForkReturn(child); 36 TestUtils::HandlePostForkReturn(child);
37 EXPECT_LT(0, child); 37 EXPECT_LT(0, child);
38 EXPECT_EQ(child, ptid); 38 EXPECT_EQ(child, ptid);
39 } 39 }
40 40
41 TEST(SyscallWrappers, CloneChildSettid) { 41 TEST(SyscallWrappers, CloneChildSettid) {
42 // Warm up the libc pid cache, if there is one.
43 ASSERT_EQ(sys_getpid(), getpid());
44
45 pid_t ctid = 0; 42 pid_t ctid = 0;
46 pid_t pid = 43 pid_t pid =
47 sys_clone(CLONE_CHILD_SETTID | SIGCHLD, nullptr, nullptr, &ctid, nullptr); 44 sys_clone(CLONE_CHILD_SETTID | SIGCHLD, nullptr, nullptr, &ctid, nullptr);
48 45
49 const int kSuccessExit = 0; 46 const int kSuccessExit = 0;
50 if (0 == pid) { 47 if (0 == pid) {
51 // In child. Check both the raw getpid syscall and the libc getpid wrapper 48 // In child.
52 // (which may rely on a pid cache). 49 if (sys_getpid() == ctid)
53 if (sys_getpid() == ctid && getpid() == ctid)
54 _exit(kSuccessExit); 50 _exit(kSuccessExit);
55 _exit(1); 51 _exit(1);
56 } 52 }
57 53
58 ASSERT_NE(-1, pid); 54 ASSERT_NE(-1, pid);
59 int status = 0; 55 int status = 0;
60 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); 56 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0)));
61 ASSERT_TRUE(WIFEXITED(status)); 57 ASSERT_TRUE(WIFEXITED(status));
62 EXPECT_EQ(kSuccessExit, WEXITSTATUS(status)); 58 EXPECT_EQ(kSuccessExit, WEXITSTATUS(status));
63 } 59 }
64 60
65 } // namespace 61 } // namespace
66 62
67 } // namespace sandbox 63 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/services/syscall_wrappers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698