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

Side by Side Diff: sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc

Issue 108013002: Revert of Add build_config_functions.h to avoid #ifdef (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp-bpf/bpf_tests.h ('k') | sandbox/linux/tests/unit_tests.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <errno.h> 5 #include <errno.h>
6 #include <pthread.h> 6 #include <pthread.h>
7 #include <sched.h> 7 #include <sched.h>
8 #include <sys/prctl.h> 8 #include <sys/prctl.h>
9 #include <sys/syscall.h> 9 #include <sys/syscall.h>
10 #include <sys/time.h> 10 #include <sys/time.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 #include <sys/utsname.h> 12 #include <sys/utsname.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #if defined(ANDROID) 15 #if defined(ANDROID)
16 // Work-around for buggy headers in Android's NDK 16 // Work-around for buggy headers in Android's NDK
17 #define __user 17 #define __user
18 #endif 18 #endif
19 #include <linux/futex.h> 19 #include <linux/futex.h>
20 20
21 #include <ostream> 21 #include <ostream>
22 22
23 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "build/build_config_functions.h"
26 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" 25 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
27 #include "sandbox/linux/seccomp-bpf/syscall.h" 26 #include "sandbox/linux/seccomp-bpf/syscall.h"
28 #include "sandbox/linux/seccomp-bpf/trap.h" 27 #include "sandbox/linux/seccomp-bpf/trap.h"
29 #include "sandbox/linux/seccomp-bpf/verifier.h" 28 #include "sandbox/linux/seccomp-bpf/verifier.h"
30 #include "sandbox/linux/services/broker_process.h" 29 #include "sandbox/linux/services/broker_process.h"
31 #include "sandbox/linux/services/linux_syscalls.h" 30 #include "sandbox/linux/services/linux_syscalls.h"
32 #include "sandbox/linux/tests/unit_tests.h" 31 #include "sandbox/linux/tests/unit_tests.h"
33 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
34 33
35 // Workaround for Android's prctl.h file. 34 // Workaround for Android's prctl.h file.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 BPF_ASSERT(buf[0] == '\x55'); 252 BPF_ASSERT(buf[0] == '\x55');
254 253
255 // Verify that we can return the minimum and maximum errno values. 254 // Verify that we can return the minimum and maximum errno values.
256 errno = 0; 255 errno = 0;
257 BPF_ASSERT(setuid(0) == -1); 256 BPF_ASSERT(setuid(0) == -1);
258 BPF_ASSERT(errno == 1); 257 BPF_ASSERT(errno == 1);
259 258
260 // On Android, errno is only supported up to 255, otherwise errno 259 // On Android, errno is only supported up to 255, otherwise errno
261 // processing is skipped. 260 // processing is skipped.
262 // We work around this (crbug.com/181647). 261 // We work around this (crbug.com/181647).
263 if (build::IsAndroid() && setgid(0) != -1) { 262 if (sandbox::IsAndroid() && setgid(0) != -1) {
264 errno = 0; 263 errno = 0;
265 BPF_ASSERT(setgid(0) == -ErrorCode::ERR_MAX_ERRNO); 264 BPF_ASSERT(setgid(0) == -ErrorCode::ERR_MAX_ERRNO);
266 BPF_ASSERT(errno == 0); 265 BPF_ASSERT(errno == 0);
267 } else { 266 } else {
268 errno = 0; 267 errno = 0;
269 BPF_ASSERT(setgid(0) == -1); 268 BPF_ASSERT(setgid(0) == -1);
270 BPF_ASSERT(errno == ErrorCode::ERR_MAX_ERRNO); 269 BPF_ASSERT(errno == ErrorCode::ERR_MAX_ERRNO);
271 } 270 }
272 271
273 // Finally, test an errno in between the minimum and maximum. 272 // Finally, test an errno in between the minimum and maximum.
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 0, 1773 0,
1775 0, 1774 0,
1776 &pid) == -EPERM); 1775 &pid) == -EPERM);
1777 } 1776 }
1778 1777
1779 BPF_TEST(SandboxBpf, PthreadEquality, PthreadPolicyEquality) { PthreadTest(); } 1778 BPF_TEST(SandboxBpf, PthreadEquality, PthreadPolicyEquality) { PthreadTest(); }
1780 1779
1781 BPF_TEST(SandboxBpf, PthreadBitMask, PthreadPolicyBitMask) { PthreadTest(); } 1780 BPF_TEST(SandboxBpf, PthreadBitMask, PthreadPolicyBitMask) { PthreadTest(); }
1782 1781
1783 } // namespace 1782 } // namespace
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/bpf_tests.h ('k') | sandbox/linux/tests/unit_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698