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

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

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 months 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
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>
11 #include <cstring>
11 12
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/posix/eintr_wrapper.h" 14 #include "base/posix/eintr_wrapper.h"
14 #include "base/third_party/valgrind/valgrind.h" 15 #include "base/third_party/valgrind/valgrind.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "sandbox/linux/system_headers/linux_signal.h"
16 #include "sandbox/linux/tests/test_utils.h" 18 #include "sandbox/linux/tests/test_utils.h"
17 #include "sandbox/linux/tests/unit_tests.h" 19 #include "sandbox/linux/tests/unit_tests.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 namespace sandbox { 22 namespace sandbox {
21 23
22 namespace { 24 namespace {
23 25
24 TEST(SyscallWrappers, BasicSyscalls) { 26 TEST(SyscallWrappers, BasicSyscalls) {
25 EXPECT_EQ(getpid(), sys_getpid()); 27 EXPECT_EQ(getpid(), sys_getpid());
(...skipping 27 matching lines...) Expand all
53 _exit(1); 55 _exit(1);
54 } 56 }
55 57
56 ASSERT_NE(-1, pid); 58 ASSERT_NE(-1, pid);
57 int status = 0; 59 int status = 0;
58 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0))); 60 ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0)));
59 ASSERT_TRUE(WIFEXITED(status)); 61 ASSERT_TRUE(WIFEXITED(status));
60 EXPECT_EQ(kSuccessExit, WEXITSTATUS(status)); 62 EXPECT_EQ(kSuccessExit, WEXITSTATUS(status));
61 } 63 }
62 64
65 TEST(SyscallWrappers, GetRESUid) {
66 uid_t ruid, euid, suid;
67 uid_t sys_ruid, sys_euid, sys_suid;
68 ASSERT_EQ(0, getresuid(&ruid, &euid, &suid));
69 ASSERT_EQ(0, sys_getresuid(&sys_ruid, &sys_euid, &sys_suid));
70 EXPECT_EQ(ruid, sys_ruid);
71 EXPECT_EQ(euid, sys_euid);
72 EXPECT_EQ(suid, sys_suid);
73 }
74
75 TEST(SyscallWrappers, GetRESGid) {
76 gid_t rgid, egid, sgid;
77 gid_t sys_rgid, sys_egid, sys_sgid;
78 ASSERT_EQ(0, getresgid(&rgid, &egid, &sgid));
79 ASSERT_EQ(0, sys_getresgid(&sys_rgid, &sys_egid, &sys_sgid));
80 EXPECT_EQ(rgid, sys_rgid);
81 EXPECT_EQ(egid, sys_egid);
82 EXPECT_EQ(sgid, sys_sgid);
83 }
84
85 TEST(SyscallWrappers, LinuxSigSet) {
86 sigset_t sigset;
87 ASSERT_EQ(0, sigemptyset(&sigset));
88 ASSERT_EQ(0, sigaddset(&sigset, LINUX_SIGSEGV));
89 ASSERT_EQ(0, sigaddset(&sigset, LINUX_SIGBUS));
90 uint64_t linux_sigset = 0;
91 std::memcpy(&linux_sigset, &sigset,
92 std::min(sizeof(sigset), sizeof(linux_sigset)));
93 EXPECT_EQ((1ULL << (LINUX_SIGSEGV - 1)) | (1ULL << (LINUX_SIGBUS - 1)),
94 linux_sigset);
95 }
96
63 } // namespace 97 } // namespace
64 98
65 } // namespace sandbox 99 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698