Index: sandbox/linux/seccomp-bpf/bpf_tests.h |
diff --git a/sandbox/linux/seccomp-bpf/bpf_tests.h b/sandbox/linux/seccomp-bpf/bpf_tests.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f79b20b027625052f164f8bcf2c9d248599d6d28 |
--- /dev/null |
+++ b/sandbox/linux/seccomp-bpf/bpf_tests.h |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ |
+#define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ |
+ |
+#include <setjmp.h> |
+ |
+#include <string> |
+#include <vector> |
jln (very slow on Chromium)
2012/08/24 00:49:06
I think those includes are no longer necessary.
|
+ |
+#include "sandbox/linux/tests/unit_tests.h" |
+#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
+ |
+ |
+namespace sandbox { |
+ |
+// BPF_TEST() is a special version of SANDBOX_TEST(). It turns into a no-op, |
+// if the host does not have kernel support for running BPF filters. |
+// Also, it takes advantage of the Die class to avoid calling LOG(FATAL), from |
+// inside our tests, as we don't need or even want all the error handling that |
+// LOG(FATAL) would do. |
+#define BPF_TEST(test_case_name, test_name) \ |
+ bool BPF_TEST_##test_name(); \ |
+ bool BPF_TEST_##test_name##_wrapper() { \ |
+ Die::enableSimpleExit(); \ |
+ return BPF_TEST_##test_name(); \ |
+ } \ |
+ TEST(test_case_name, test_name) { \ |
+ if (playground2::Sandbox::supportsSeccompSandbox(-1) == \ |
+ Sandbox::STATUS_AVAILABLE) { \ |
+ sandbox::BpfTests::RunTestInProcess(BPF_TEST_##test_name##_wrapper); \ |
+ } \ |
jln (very slow on Chromium)
2012/08/24 00:24:07
Please add a else branch here:
// TODO(markus): (
|
+ } \ |
+ bool BPF_TEST_##test_name() |
+ |
+// Assertions are handled exactly the same as with a normal SANDBOX_TEST() |
+#define BPF_ASSERT SANDBOX_ASSERT |
+ |
+ |
+class BpfTests : public UnitTests { |
+ private: |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(BpfTests); |
+}; |
+ |
+} // namespace |
+ |
+#endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ |