| 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_TESTS_UNIT_TESTS_H__ | 5 #ifndef SANDBOX_LINUX_TESTS_UNIT_TESTS_H__ |
| 6 #define SANDBOX_LINUX_TESTS_UNIT_TESTS_H__ | 6 #define SANDBOX_LINUX_TESTS_UNIT_TESTS_H__ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "sandbox/linux/tests/sandbox_test_runner_function_pointer.h" | 10 #include "sandbox/linux/tests/sandbox_test_runner_function_pointer.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 #define SANDBOX_TEST_ALLOW_NOISE(test_case_name, test_name) \ | 92 #define SANDBOX_TEST_ALLOW_NOISE(test_case_name, test_name) \ |
| 93 SANDBOX_DEATH_TEST(test_case_name, test_name, DEATH_SUCCESS_ALLOW_NOISE()) | 93 SANDBOX_DEATH_TEST(test_case_name, test_name, DEATH_SUCCESS_ALLOW_NOISE()) |
| 94 | 94 |
| 95 // Simple assertion macro that is compatible with running inside of a death | 95 // Simple assertion macro that is compatible with running inside of a death |
| 96 // test. We unfortunately cannot use any of the GTest macros. | 96 // test. We unfortunately cannot use any of the GTest macros. |
| 97 #define SANDBOX_STR(x) #x | 97 #define SANDBOX_STR(x) #x |
| 98 #define SANDBOX_ASSERT(expr) \ | 98 #define SANDBOX_ASSERT(expr) \ |
| 99 ((expr) ? static_cast<void>(0) : sandbox::UnitTests::AssertionFailure( \ | 99 ((expr) ? static_cast<void>(0) : sandbox::UnitTests::AssertionFailure( \ |
| 100 SANDBOX_STR(expr), __FILE__, __LINE__)) | 100 SANDBOX_STR(expr), __FILE__, __LINE__)) |
| 101 | 101 |
| 102 #define SANDBOX_ASSERT_EQ(x, y) SANDBOX_ASSERT((x) == (y)) |
| 103 #define SANDBOX_ASSERT_NE(x, y) SANDBOX_ASSERT((x) != (y)) |
| 104 #define SANDBOX_ASSERT_LT(x, y) SANDBOX_ASSERT((x) < (y)) |
| 105 #define SANDBOX_ASSERT_GT(x, y) SANDBOX_ASSERT((x) > (y)) |
| 106 #define SANDBOX_ASSERT_LE(x, y) SANDBOX_ASSERT((x) <= (y)) |
| 107 #define SANDBOX_ASSERT_GE(x, y) SANDBOX_ASSERT((x) >= (y)) |
| 108 |
| 102 // This class allows to run unittests in their own process. The main method is | 109 // This class allows to run unittests in their own process. The main method is |
| 103 // RunTestInProcess(). | 110 // RunTestInProcess(). |
| 104 class UnitTests { | 111 class UnitTests { |
| 105 public: | 112 public: |
| 106 typedef void (*DeathCheck)(int status, | 113 typedef void (*DeathCheck)(int status, |
| 107 const std::string& msg, | 114 const std::string& msg, |
| 108 const void* aux); | 115 const void* aux); |
| 109 | 116 |
| 110 // Runs a test inside a short-lived process. Do not call this function | 117 // Runs a test inside a short-lived process. Do not call this function |
| 111 // directly. It is automatically invoked by SANDBOX_TEST(). Most sandboxing | 118 // directly. It is automatically invoked by SANDBOX_TEST(). Most sandboxing |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 const std::string& msg, | 184 const std::string& msg, |
| 178 const void* aux); | 185 const void* aux); |
| 179 | 186 |
| 180 private: | 187 private: |
| 181 DISALLOW_IMPLICIT_CONSTRUCTORS(UnitTests); | 188 DISALLOW_IMPLICIT_CONSTRUCTORS(UnitTests); |
| 182 }; | 189 }; |
| 183 | 190 |
| 184 } // namespace | 191 } // namespace |
| 185 | 192 |
| 186 #endif // SANDBOX_LINUX_TESTS_UNIT_TESTS_H__ | 193 #endif // SANDBOX_LINUX_TESTS_UNIT_TESTS_H__ |
| OLD | NEW |