OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ | |
6 #define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ | |
7 | |
8 #include <setjmp.h> | |
9 | |
10 #include <string> | |
11 #include <vector> | |
jln (very slow on Chromium)
2012/08/24 00:49:06
I think those includes are no longer necessary.
| |
12 | |
13 #include "sandbox/linux/tests/unit_tests.h" | |
14 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | |
15 | |
16 | |
17 namespace sandbox { | |
18 | |
19 // BPF_TEST() is a special version of SANDBOX_TEST(). It turns into a no-op, | |
20 // if the host does not have kernel support for running BPF filters. | |
21 // Also, it takes advantage of the Die class to avoid calling LOG(FATAL), from | |
22 // inside our tests, as we don't need or even want all the error handling that | |
23 // LOG(FATAL) would do. | |
24 #define BPF_TEST(test_case_name, test_name) \ | |
25 bool BPF_TEST_##test_name(); \ | |
26 bool BPF_TEST_##test_name##_wrapper() { \ | |
27 Die::enableSimpleExit(); \ | |
28 return BPF_TEST_##test_name(); \ | |
29 } \ | |
30 TEST(test_case_name, test_name) { \ | |
31 if (playground2::Sandbox::supportsSeccompSandbox(-1) == \ | |
32 Sandbox::STATUS_AVAILABLE) { \ | |
33 sandbox::BpfTests::RunTestInProcess(BPF_TEST_##test_name##_wrapper); \ | |
34 } \ | |
jln (very slow on Chromium)
2012/08/24 00:24:07
Please add a else branch here:
// TODO(markus): (
| |
35 } \ | |
36 bool BPF_TEST_##test_name() | |
37 | |
38 // Assertions are handled exactly the same as with a normal SANDBOX_TEST() | |
39 #define BPF_ASSERT SANDBOX_ASSERT | |
40 | |
41 | |
42 class BpfTests : public UnitTests { | |
43 private: | |
44 DISALLOW_IMPLICIT_CONSTRUCTORS(BpfTests); | |
45 }; | |
46 | |
47 } // namespace | |
48 | |
49 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ | |
OLD | NEW |