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

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

Issue 103293003: Add build_config_functions.h to avoid #ifdef (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use build_config.h exclusively. 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"
25 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" 26 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
26 #include "sandbox/linux/seccomp-bpf/syscall.h" 27 #include "sandbox/linux/seccomp-bpf/syscall.h"
27 #include "sandbox/linux/seccomp-bpf/trap.h" 28 #include "sandbox/linux/seccomp-bpf/trap.h"
28 #include "sandbox/linux/seccomp-bpf/verifier.h" 29 #include "sandbox/linux/seccomp-bpf/verifier.h"
29 #include "sandbox/linux/services/broker_process.h" 30 #include "sandbox/linux/services/broker_process.h"
30 #include "sandbox/linux/services/linux_syscalls.h" 31 #include "sandbox/linux/services/linux_syscalls.h"
31 #include "sandbox/linux/tests/unit_tests.h" 32 #include "sandbox/linux/tests/unit_tests.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 34
34 // Workaround for Android's prctl.h file. 35 // Workaround for Android's prctl.h file.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 BPF_ASSERT(buf[0] == '\x55'); 253 BPF_ASSERT(buf[0] == '\x55');
253 254
254 // Verify that we can return the minimum and maximum errno values. 255 // Verify that we can return the minimum and maximum errno values.
255 errno = 0; 256 errno = 0;
256 BPF_ASSERT(setuid(0) == -1); 257 BPF_ASSERT(setuid(0) == -1);
257 BPF_ASSERT(errno == 1); 258 BPF_ASSERT(errno == 1);
258 259
259 // On Android, errno is only supported up to 255, otherwise errno 260 // On Android, errno is only supported up to 255, otherwise errno
260 // processing is skipped. 261 // processing is skipped.
261 // We work around this (crbug.com/181647). 262 // We work around this (crbug.com/181647).
262 if (sandbox::IsAndroid() && setgid(0) != -1) { 263 if (build::IsAndroid() && setgid(0) != -1) {
263 errno = 0; 264 errno = 0;
264 BPF_ASSERT(setgid(0) == -ErrorCode::ERR_MAX_ERRNO); 265 BPF_ASSERT(setgid(0) == -ErrorCode::ERR_MAX_ERRNO);
265 BPF_ASSERT(errno == 0); 266 BPF_ASSERT(errno == 0);
266 } else { 267 } else {
267 errno = 0; 268 errno = 0;
268 BPF_ASSERT(setgid(0) == -1); 269 BPF_ASSERT(setgid(0) == -1);
269 BPF_ASSERT(errno == ErrorCode::ERR_MAX_ERRNO); 270 BPF_ASSERT(errno == ErrorCode::ERR_MAX_ERRNO);
270 } 271 }
271 272
272 // Finally, test an errno in between the minimum and maximum. 273 // Finally, test an errno in between the minimum and maximum.
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 0, 1774 0,
1774 0, 1775 0,
1775 &pid) == -EPERM); 1776 &pid) == -EPERM);
1776 } 1777 }
1777 1778
1778 BPF_TEST(SandboxBpf, PthreadEquality, PthreadPolicyEquality) { PthreadTest(); } 1779 BPF_TEST(SandboxBpf, PthreadEquality, PthreadPolicyEquality) { PthreadTest(); }
1779 1780
1780 BPF_TEST(SandboxBpf, PthreadBitMask, PthreadPolicyBitMask) { PthreadTest(); } 1781 BPF_TEST(SandboxBpf, PthreadBitMask, PthreadPolicyBitMask) { PthreadTest(); }
1781 1782
1782 } // namespace 1783 } // 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