|
16 | 16 | // redefine it as necessary. |
17 | 17 | #define libc_make_test_file_path(file_name) (file_name) |
18 | 18 |
|
19 | | -#if defined(LIBC_COPT_TEST_USE_FUCHSIA) |
20 | | -#include "FuchsiaTest.h" |
21 | | -#elif defined(LIBC_COPT_TEST_USE_PIGWEED) |
22 | | -#include "PigweedTest.h" |
| 19 | +// The LIBC_COPT_TEST_USE_* macros can select either of two alternate test |
| 20 | +// frameworks: |
| 21 | +// * gtest, the well-known model for them all |
| 22 | +// * zxtest, the gtest workalike subset sometimes used in the Fuchsia build |
| 23 | +// The default is to use llvm-libc's own gtest workalike framework. |
| 24 | +// |
| 25 | +// All the frameworks provide the basic EXPECT_* and ASSERT_* macros that gtest |
| 26 | +// does. The wrapper headers below define LIBC_NAMESPACE::testing::Test as the |
| 27 | +// base class for test fixture classes. Each also provides a definition of the |
| 28 | +// macro LIBC_TEST_HAS_MATCHERS() for use in `#if` conditionals to guard use of |
| 29 | +// gmock-style matchers, which zxtest does not support. |
| 30 | + |
| 31 | +#if defined(LIBC_COPT_TEST_USE_ZXTEST) |
| 32 | +#include "ZxTest.h" |
| 33 | +// TODO: Migrate Pigweed to setting LIBC_COPT_TEST_USE_GTEST instead. |
| 34 | +#elif defined(LIBC_COPT_TEST_USE_GTEST) || defined(LIBC_COPT_TEST_USE_PIGWEED) |
| 35 | +#include "GTest.h" |
23 | 36 | #else |
24 | 37 | #include "LibcTest.h" |
25 | 38 | #endif |
26 | 39 |
|
| 40 | +// These are defined the same way for each framework, in terms of the macros |
| 41 | +// they all provide. |
| 42 | + |
| 43 | +#define ASSERT_ERRNO_EQ(VAL) \ |
| 44 | + ASSERT_EQ(VAL, static_cast<int>(LIBC_NAMESPACE::libc_errno)) |
| 45 | +#define ASSERT_ERRNO_SUCCESS() \ |
| 46 | + ASSERT_EQ(0, static_cast<int>(LIBC_NAMESPACE::libc_errno)) |
| 47 | +#define ASSERT_ERRNO_FAILURE() \ |
| 48 | + ASSERT_NE(0, static_cast<int>(LIBC_NAMESPACE::libc_errno)) |
| 49 | + |
27 | 50 | #endif // LLVM_LIBC_TEST_UNITTEST_TEST_H |
0 commit comments