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

Side by Side Diff: sandbox/linux/seccomp-bpf/bpf_tests.h

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 | « build/build_config_functions.h ('k') | sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc » ('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 #ifndef SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__
6 #define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ 6 #define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__
7 7
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 11
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "build/build_config_functions.h"
13 #include "sandbox/linux/tests/unit_tests.h" 14 #include "sandbox/linux/tests/unit_tests.h"
14 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 15 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
15 16
16 namespace sandbox { 17 namespace sandbox {
17 18
18 // A BPF_DEATH_TEST is just the same as a BPF_TEST, but it assumes that the 19 // A BPF_DEATH_TEST is just the same as a BPF_TEST, but it assumes that the
19 // test will fail with a particular known error condition. Use the DEATH_XXX() 20 // test will fail with a particular known error condition. Use the DEATH_XXX()
20 // macros from unit_tests.h to specify the expected error condition. 21 // macros from unit_tests.h to specify the expected error condition.
21 // A BPF_DEATH_TEST is always disabled under ThreadSanitizer, see 22 // A BPF_DEATH_TEST is always disabled under ThreadSanitizer, see
22 // crbug.com/243968. 23 // crbug.com/243968.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 sandbox.set_proc_fd(proc_fd); 86 sandbox.set_proc_fd(proc_fd);
86 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_); 87 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_);
87 sandbox.Sandbox::StartSandbox(); 88 sandbox.Sandbox::StartSandbox();
88 89
89 arg->test()(arg->aux_); 90 arg->test()(arg->aux_);
90 } else { 91 } else {
91 printf("This BPF test is not fully running in this configuration!\n"); 92 printf("This BPF test is not fully running in this configuration!\n");
92 // Android, ARM and Valgrind are the three only configurations where we 93 // Android, ARM and Valgrind are the three only configurations where we
93 // accept not having kernel BPF support. 94 // accept not having kernel BPF support.
94 // TODO(jln): remote ARM from this list when possible (crbug.com/243478). 95 // TODO(jln): remote ARM from this list when possible (crbug.com/243478).
95 if (!IsAndroid() && !IsRunningOnValgrind() && !IsArchitectureArm()) { 96 if (!build::IsAndroid() && !IsRunningOnValgrind() &&
97 !build::IsArchitectureARM()) {
96 const bool seccomp_bpf_is_supported = false; 98 const bool seccomp_bpf_is_supported = false;
97 BPF_ASSERT(seccomp_bpf_is_supported); 99 BPF_ASSERT(seccomp_bpf_is_supported);
98 } 100 }
99 // Call the compiler and verify the policy. That's the least we can do, 101 // Call the compiler and verify the policy. That's the least we can do,
100 // if we don't have kernel support. 102 // if we don't have kernel support.
101 playground2::Sandbox sandbox; 103 playground2::Sandbox sandbox;
102 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_); 104 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_);
103 playground2::Sandbox::Program* program = 105 playground2::Sandbox::Program* program =
104 sandbox.AssembleFilter(true /* force_verification */); 106 sandbox.AssembleFilter(true /* force_verification */);
105 delete program; 107 delete program;
106 sandbox::UnitTests::IgnoreThisTest(); 108 sandbox::UnitTests::IgnoreThisTest();
107 } 109 }
108 } 110 }
109 111
110 private: 112 private:
111 DISALLOW_IMPLICIT_CONSTRUCTORS(BpfTests); 113 DISALLOW_IMPLICIT_CONSTRUCTORS(BpfTests);
112 }; 114 };
113 115
114 } // namespace 116 } // namespace
115 117
116 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ 118 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__
OLDNEW
« no previous file with comments | « build/build_config_functions.h ('k') | sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698