| OLD | NEW |
| 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 "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 // This class takes a simple function pointer as a constructor parameter and a | 96 // This class takes a simple function pointer as a constructor parameter and a |
| 97 // class name as a template parameter to implement the BPFTesterDelegate | 97 // class name as a template parameter to implement the BPFTesterDelegate |
| 98 // interface which can be used to build BPF unittests with | 98 // interface which can be used to build BPF unittests with |
| 99 // the SandboxBPFTestRunner class. | 99 // the SandboxBPFTestRunner class. |
| 100 template <class PolicyClass> | 100 template <class PolicyClass> |
| 101 class BPFTesterSimpleDelegate : public BPFTesterDelegate { | 101 class BPFTesterSimpleDelegate : public BPFTesterDelegate { |
| 102 public: | 102 public: |
| 103 explicit BPFTesterSimpleDelegate(void (*test_function)(void)) | 103 explicit BPFTesterSimpleDelegate(void (*test_function)(void)) |
| 104 : test_function_(test_function) {} | 104 : test_function_(test_function) {} |
| 105 virtual ~BPFTesterSimpleDelegate() {} | 105 ~BPFTesterSimpleDelegate() override {} |
| 106 | 106 |
| 107 virtual scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override { | 107 scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override { |
| 108 return scoped_ptr<bpf_dsl::Policy>(new PolicyClass()); | 108 return scoped_ptr<bpf_dsl::Policy>(new PolicyClass()); |
| 109 } | 109 } |
| 110 virtual void RunTestFunction() override { | 110 void RunTestFunction() override { |
| 111 DCHECK(test_function_); | 111 DCHECK(test_function_); |
| 112 test_function_(); | 112 test_function_(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 void (*test_function_)(void); | 116 void (*test_function_)(void); |
| 117 DISALLOW_COPY_AND_ASSIGN(BPFTesterSimpleDelegate); | 117 DISALLOW_COPY_AND_ASSIGN(BPFTesterSimpleDelegate); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace sandbox | 120 } // namespace sandbox |
| 121 | 121 |
| 122 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ | 122 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ |
| OLD | NEW |