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

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

Issue 107693002: Move build/build_config_functions.h to sandbox/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move build:: to sandbox:: 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/seccomp-bpf/sandbox_bpf.h"
14 #include "sandbox/linux/services/build_config_functions.h"
14 #include "sandbox/linux/tests/unit_tests.h" 15 #include "sandbox/linux/tests/unit_tests.h"
15 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
16 16
17 namespace sandbox { 17 namespace sandbox {
18 18
19 // 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
20 // 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()
21 // macros from unit_tests.h to specify the expected error condition. 21 // macros from unit_tests.h to specify the expected error condition.
22 // A BPF_DEATH_TEST is always disabled under ThreadSanitizer, see 22 // A BPF_DEATH_TEST is always disabled under ThreadSanitizer, see
23 // crbug.com/243968. 23 // crbug.com/243968.
24 #define BPF_DEATH_TEST(test_case_name, test_name, death, policy, aux...) \ 24 #define BPF_DEATH_TEST(test_case_name, test_name, death, policy, aux...) \
25 void BPF_TEST_##test_name(sandbox::BpfTests<aux>::AuxType& BPF_AUX); \ 25 void BPF_TEST_##test_name(sandbox::BpfTests<aux>::AuxType& BPF_AUX); \
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 sandbox.set_proc_fd(proc_fd); 86 sandbox.set_proc_fd(proc_fd);
87 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_); 87 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_);
88 sandbox.Sandbox::StartSandbox(); 88 sandbox.Sandbox::StartSandbox();
89 89
90 arg->test()(arg->aux_); 90 arg->test()(arg->aux_);
91 } else { 91 } else {
92 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");
93 // Android, ARM and Valgrind are the three only configurations where we 93 // Android, ARM and Valgrind are the three only configurations where we
94 // accept not having kernel BPF support. 94 // accept not having kernel BPF support.
95 // 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).
96 if (!build::IsAndroid() && !IsRunningOnValgrind() && 96 if (!sandbox::IsAndroid() && !IsRunningOnValgrind() &&
97 !build::IsArchitectureARM()) { 97 !sandbox::IsArchitectureARM()) {
98 const bool seccomp_bpf_is_supported = false; 98 const bool seccomp_bpf_is_supported = false;
99 BPF_ASSERT(seccomp_bpf_is_supported); 99 BPF_ASSERT(seccomp_bpf_is_supported);
100 } 100 }
101 // 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,
102 // if we don't have kernel support. 102 // if we don't have kernel support.
103 playground2::Sandbox sandbox; 103 playground2::Sandbox sandbox;
104 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_); 104 sandbox.SetSandboxPolicyDeprecated(arg->policy(), &arg->aux_);
105 playground2::Sandbox::Program* program = 105 playground2::Sandbox::Program* program =
106 sandbox.AssembleFilter(true /* force_verification */); 106 sandbox.AssembleFilter(true /* force_verification */);
107 delete program; 107 delete program;
108 sandbox::UnitTests::IgnoreThisTest(); 108 sandbox::UnitTests::IgnoreThisTest();
109 } 109 }
110 } 110 }
111 111
112 private: 112 private:
113 DISALLOW_IMPLICIT_CONSTRUCTORS(BpfTests); 113 DISALLOW_IMPLICIT_CONSTRUCTORS(BpfTests);
114 }; 114 };
115 115
116 } // namespace 116 } // namespace
117 117
118 #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