OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_BPF_TESTS_H__ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ |
6 #define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ |
7 | 7 |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 26 matching lines...) Expand all Loading... | |
37 // BPF_TEST() takes a C++ data type as an optional fourth parameter. If | 37 // BPF_TEST() takes a C++ data type as an optional fourth parameter. If |
38 // present, this sets up a variable that can be accessed as "BPF_AUX". This | 38 // present, this sets up a variable that can be accessed as "BPF_AUX". This |
39 // variable will be passed as an argument to the "policy" function. Policies | 39 // variable will be passed as an argument to the "policy" function. Policies |
40 // would typically use it as an argument to SandboxBPF::Trap(), if they want to | 40 // would typically use it as an argument to SandboxBPF::Trap(), if they want to |
41 // communicate data between the BPF_TEST() and a Trap() function. | 41 // communicate data between the BPF_TEST() and a Trap() function. |
42 #define BPF_TEST(test_case_name, test_name, policy, aux...) \ | 42 #define BPF_TEST(test_case_name, test_name, policy, aux...) \ |
43 BPF_DEATH_TEST(test_case_name, test_name, DEATH_SUCCESS(), policy, aux) | 43 BPF_DEATH_TEST(test_case_name, test_name, DEATH_SUCCESS(), policy, aux) |
44 | 44 |
45 // Assertions are handled exactly the same as with a normal SANDBOX_TEST() | 45 // Assertions are handled exactly the same as with a normal SANDBOX_TEST() |
46 #define BPF_ASSERT SANDBOX_ASSERT | 46 #define BPF_ASSERT SANDBOX_ASSERT |
47 #define BPF_ASSERT_EQ(x, y) BPF_ASSERT(x == y) | |
jln (very slow on Chromium)
2014/04/11 20:19:47
Don't forget parentheses around (x) and (y)
hamaji
2014/04/15 15:09:25
Done.
| |
48 #define BPF_ASSERT_NE(x, y) BPF_ASSERT(x != y) | |
49 #define BPF_ASSERT_LT(x, y) BPF_ASSERT(x < y) | |
50 #define BPF_ASSERT_GT(x, y) BPF_ASSERT(x > y) | |
51 #define BPF_ASSERT_LE(x, y) BPF_ASSERT(x <= y) | |
52 #define BPF_ASSERT_GE(x, y) BPF_ASSERT(x >= y) | |
47 | 53 |
48 // The "Aux" type is optional. We use an "empty" type by default, so that if | 54 // The "Aux" type is optional. We use an "empty" type by default, so that if |
49 // the caller doesn't provide any type, all the BPF_AUX related data compiles | 55 // the caller doesn't provide any type, all the BPF_AUX related data compiles |
50 // to nothing. | 56 // to nothing. |
51 template <class Aux = int[0]> | 57 template <class Aux = int[0]> |
52 class BPFTests : public UnitTests { | 58 class BPFTests : public UnitTests { |
53 public: | 59 public: |
54 typedef Aux AuxType; | 60 typedef Aux AuxType; |
55 | 61 |
56 class TestArgs { | 62 class TestArgs { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 } | 113 } |
108 } | 114 } |
109 | 115 |
110 private: | 116 private: |
111 DISALLOW_IMPLICIT_CONSTRUCTORS(BPFTests); | 117 DISALLOW_IMPLICIT_CONSTRUCTORS(BPFTests); |
112 }; | 118 }; |
113 | 119 |
114 } // namespace sandbox | 120 } // namespace sandbox |
115 | 121 |
116 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ | 122 #endif // SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__ |
OLD | NEW |