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

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

Issue 1099263003: Reland: Introduce sys_sigprocmask and sys_sigaction. (patchset #4 id:80001 of https://codereview.ch… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 TEST(SyscallWrappers, GetRESGid) { 75 TEST(SyscallWrappers, GetRESGid) {
74 gid_t rgid, egid, sgid; 76 gid_t rgid, egid, sgid;
75 gid_t sys_rgid, sys_egid, sys_sgid; 77 gid_t sys_rgid, sys_egid, sys_sgid;
76 ASSERT_EQ(0, getresgid(&rgid, &egid, &sgid)); 78 ASSERT_EQ(0, getresgid(&rgid, &egid, &sgid));
77 ASSERT_EQ(0, sys_getresgid(&sys_rgid, &sys_egid, &sys_sgid)); 79 ASSERT_EQ(0, sys_getresgid(&sys_rgid, &sys_egid, &sys_sgid));
78 EXPECT_EQ(rgid, sys_rgid); 80 EXPECT_EQ(rgid, sys_rgid);
79 EXPECT_EQ(egid, sys_egid); 81 EXPECT_EQ(egid, sys_egid);
80 EXPECT_EQ(sgid, sys_sgid); 82 EXPECT_EQ(sgid, sys_sgid);
81 } 83 }
82 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
83 } // namespace 97 } // namespace
84 98
85 } // namespace sandbox 99 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698