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

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

Issue 1849323003: Convert //sandbox to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup nonsfi_sandbox_unittest.cc Created 4 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 (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 <memory>
9
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "build/build_config.h" 12 #include "build/build_config.h"
11 #include "sandbox/linux/seccomp-bpf/bpf_tester_compatibility_delegate.h" 13 #include "sandbox/linux/seccomp-bpf/bpf_tester_compatibility_delegate.h"
12 #include "sandbox/linux/tests/unit_tests.h" 14 #include "sandbox/linux/tests/unit_tests.h"
13 15
14 namespace sandbox { 16 namespace sandbox {
15 17
16 // BPF_TEST_C() is a special version of SANDBOX_TEST(). It runs a test function 18 // BPF_TEST_C() is a special version of SANDBOX_TEST(). It runs a test function
17 // in a sub-process, under a seccomp-bpf policy specified in 19 // in a sub-process, under a seccomp-bpf policy specified in
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // class name as a template parameter to implement the BPFTesterDelegate 99 // class name as a template parameter to implement the BPFTesterDelegate
98 // interface which can be used to build BPF unittests with 100 // interface which can be used to build BPF unittests with
99 // the SandboxBPFTestRunner class. 101 // the SandboxBPFTestRunner class.
100 template <class PolicyClass> 102 template <class PolicyClass>
101 class BPFTesterSimpleDelegate : public BPFTesterDelegate { 103 class BPFTesterSimpleDelegate : public BPFTesterDelegate {
102 public: 104 public:
103 explicit BPFTesterSimpleDelegate(void (*test_function)(void)) 105 explicit BPFTesterSimpleDelegate(void (*test_function)(void))
104 : test_function_(test_function) {} 106 : test_function_(test_function) {}
105 ~BPFTesterSimpleDelegate() override {} 107 ~BPFTesterSimpleDelegate() override {}
106 108
107 scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override { 109 std::unique_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override {
108 return scoped_ptr<bpf_dsl::Policy>(new PolicyClass()); 110 return std::unique_ptr<bpf_dsl::Policy>(new PolicyClass());
109 } 111 }
110 void RunTestFunction() override { 112 void RunTestFunction() override {
111 DCHECK(test_function_); 113 DCHECK(test_function_);
112 test_function_(); 114 test_function_();
113 } 115 }
114 116
115 private: 117 private:
116 void (*test_function_)(void); 118 void (*test_function_)(void);
117 DISALLOW_COPY_AND_ASSIGN(BPFTesterSimpleDelegate); 119 DISALLOW_COPY_AND_ASSIGN(BPFTesterSimpleDelegate);
118 }; 120 };
119 121
120 } // namespace sandbox 122 } // namespace sandbox
121 123
122 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ 124 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/bpf_tester_compatibility_delegate.h ('k') | sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698