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

Unified Diff: sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc

Issue 588143007: sandbox: Convert remaining legacy tests to use policy classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to jln@ feedback Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/seccomp-bpf/bpf_tests.h ('k') | sandbox/linux/seccomp-bpf/sandbox_bpf_compatibility_policy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6a4cea39fbf698d5270edff12f93b92bd2216197 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:
+ explicit EmptyClassTakingPolicy(FourtyTwo* fourty_two) {
+ 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));
}
}
« no previous file with comments | « sandbox/linux/seccomp-bpf/bpf_tests.h ('k') | sandbox/linux/seccomp-bpf/sandbox_bpf_compatibility_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698