| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SANDBOX_BPF_TEST_RUNNER_H_ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SANDBOX_BPF_TEST_RUNNER_H_ |
| 6 #define SANDBOX_LINUX_SECCOMP_BPF_SANDBOX_BPF_TEST_RUNNER_H_ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_SANDBOX_BPF_TEST_RUNNER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | |
| 11 #include "sandbox/linux/tests/sandbox_test_runner.h" | 10 #include "sandbox/linux/tests/sandbox_test_runner.h" |
| 12 | 11 |
| 13 namespace sandbox { | 12 namespace sandbox { |
| 13 namespace bpf_dsl { |
| 14 class Policy; |
| 15 } |
| 14 | 16 |
| 15 // To create a SandboxBPFTestRunner object, one needs to implement this | 17 // To create a SandboxBPFTestRunner object, one needs to implement this |
| 16 // interface and pass an instance to the SandboxBPFTestRunner constructor. | 18 // interface and pass an instance to the SandboxBPFTestRunner constructor. |
| 17 // In the child process running the test, the BPFTesterDelegate object is | 19 // In the child process running the test, the BPFTesterDelegate object is |
| 18 // guaranteed to not be destroyed until the child process terminates. | 20 // guaranteed to not be destroyed until the child process terminates. |
| 19 class BPFTesterDelegate { | 21 class BPFTesterDelegate { |
| 20 public: | 22 public: |
| 21 BPFTesterDelegate() {} | 23 BPFTesterDelegate() {} |
| 22 virtual ~BPFTesterDelegate() {} | 24 virtual ~BPFTesterDelegate() {} |
| 23 | 25 |
| 24 // This will instanciate a policy suitable for the test we want to run. It is | 26 // This will instanciate a policy suitable for the test we want to run. It is |
| 25 // guaranteed to only be called from the child process that will run the | 27 // guaranteed to only be called from the child process that will run the |
| 26 // test. | 28 // test. |
| 27 virtual scoped_ptr<bpf_dsl::SandboxBPFDSLPolicy> GetSandboxBPFPolicy() = 0; | 29 virtual scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() = 0; |
| 28 // This will be called from a child process with the BPF sandbox turned on. | 30 // This will be called from a child process with the BPF sandbox turned on. |
| 29 virtual void RunTestFunction() = 0; | 31 virtual void RunTestFunction() = 0; |
| 30 | 32 |
| 31 private: | 33 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(BPFTesterDelegate); | 34 DISALLOW_COPY_AND_ASSIGN(BPFTesterDelegate); |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 // This class implements the SandboxTestRunner interface and Run() will | 37 // This class implements the SandboxTestRunner interface and Run() will |
| 36 // initialize a seccomp-bpf sandbox (specified by |bpf_tester_delegate|) and | 38 // initialize a seccomp-bpf sandbox (specified by |bpf_tester_delegate|) and |
| 37 // run a test function (via |bpf_tester_delegate|) if the current kernel | 39 // run a test function (via |bpf_tester_delegate|) if the current kernel |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 virtual bool ShouldCheckForLeaks() const override; | 52 virtual bool ShouldCheckForLeaks() const override; |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 scoped_ptr<BPFTesterDelegate> bpf_tester_delegate_; | 55 scoped_ptr<BPFTesterDelegate> bpf_tester_delegate_; |
| 54 DISALLOW_COPY_AND_ASSIGN(SandboxBPFTestRunner); | 56 DISALLOW_COPY_AND_ASSIGN(SandboxBPFTestRunner); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 } // namespace sandbox | 59 } // namespace sandbox |
| 58 | 60 |
| 59 #endif // SANDBOX_LINUX_SECCOMP_BPF_SANDBOX_BPF_TEST_RUNNER_H_ | 61 #endif // SANDBOX_LINUX_SECCOMP_BPF_SANDBOX_BPF_TEST_RUNNER_H_ |
| OLD | NEW |