Chromium Code Reviews| Index: sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc |
| diff --git a/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc b/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc |
| index eaa9ff3cbf336a5b3446e8d4e87979242ffbfe92..8837ff0f415009cde680276df085641bee34e92b 100644 |
| --- a/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc |
| +++ b/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc |
| @@ -33,22 +33,24 @@ class FourtyTwo { |
| DISALLOW_COPY_AND_ASSIGN(FourtyTwo); |
| }; |
| -ErrorCode EmptyPolicyTakesClass(SandboxBPF* sandbox, |
| - int sysno, |
| - FourtyTwo* fourty_two) { |
| - // |aux| should point to an instance of FourtyTwo. |
| - BPF_ASSERT(fourty_two); |
| - BPF_ASSERT(FourtyTwo::kMagicValue == fourty_two->value()); |
| - if (!SandboxBPF::IsValidSyscallNumber(sysno)) { |
| - return ErrorCode(ENOSYS); |
| - } else { |
| +class EmptyClassTakingPolicy : public SandboxBPFPolicy { |
| + public: |
| + EmptyClassTakingPolicy(FourtyTwo* fourty_two) { |
|
jln (very slow on Chromium)
2014/09/23 18:42:06
nit: explicit
mdempsky
2014/09/23 18:50:20
Done.
|
| + BPF_ASSERT(fourty_two); |
| + BPF_ASSERT(FourtyTwo::kMagicValue == fourty_two->value()); |
| + } |
| + virtual ~EmptyClassTakingPolicy() {} |
| + |
| + virtual ErrorCode EvaluateSyscall(SandboxBPF* sandbox, |
| + int sysno) const OVERRIDE { |
| + DCHECK(SandboxBPF::IsValidSyscallNumber(sysno)); |
| return ErrorCode(ErrorCode::ERR_ALLOWED); |
| } |
| -} |
| +}; |
| BPF_TEST(BPFTest, |
| BPFAUXPointsToClass, |
| - EmptyPolicyTakesClass, |
| + EmptyClassTakingPolicy, |
| FourtyTwo /* *BPF_AUX */) { |
| // BPF_AUX should point to an instance of FourtyTwo. |
| BPF_ASSERT(BPF_AUX); |
| @@ -62,14 +64,14 @@ TEST(BPFTest, BPFTesterCompatibilityDelegateLeakTest) { |
| // Don't do anything, simply gives dynamic tools an opportunity to detect |
| // leaks. |
| { |
| - BPFTesterCompatibilityDelegate<FourtyTwo> simple_delegate( |
| - DummyTestFunction, EmptyPolicyTakesClass); |
| + BPFTesterCompatibilityDelegate<EmptyClassTakingPolicy, FourtyTwo> |
| + simple_delegate(DummyTestFunction); |
| } |
| { |
| // Test polymorphism. |
| scoped_ptr<BPFTesterDelegate> simple_delegate( |
| - new BPFTesterCompatibilityDelegate<FourtyTwo>(DummyTestFunction, |
| - EmptyPolicyTakesClass)); |
| + new BPFTesterCompatibilityDelegate<EmptyClassTakingPolicy, FourtyTwo>( |
| + DummyTestFunction)); |
| } |
| } |