1 | //===-- scudo_unit_test.h ---------------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "platform.h" |
10 | |
11 | #if SCUDO_FUCHSIA |
12 | #include <zxtest/zxtest.h> |
13 | using Test = ::zxtest::Test; |
14 | #define TEST_SKIP(message) ZXTEST_SKIP(message) |
15 | #define TEST_HAS_FAILURE true |
16 | #else |
17 | #include "gtest/gtest.h" |
18 | using Test = ::testing::Test; |
19 | #define TEST_SKIP(message) \ |
20 | do { \ |
21 | GTEST_SKIP() << message; \ |
22 | } while (0) |
23 | #define TEST_HAS_FAILURE Test::HasFailure() |
24 | #endif |
25 | |
26 | // If EXPECT_DEATH isn't defined, make it a no-op. |
27 | #ifndef EXPECT_DEATH |
28 | // If ASSERT_DEATH is defined, make EXPECT_DEATH a wrapper to it. |
29 | #ifdef ASSERT_DEATH |
30 | #define EXPECT_DEATH(X, Y) ASSERT_DEATH(([&] { X; }), "") |
31 | #else |
32 | #define EXPECT_DEATH(X, Y) \ |
33 | do { \ |
34 | } while (0) |
35 | #endif // ASSERT_DEATH |
36 | #endif // EXPECT_DEATH |
37 | |
38 | // If EXPECT_STREQ isn't defined, define our own simple one. |
39 | #ifndef EXPECT_STREQ |
40 | #define EXPECT_STREQ(X, Y) EXPECT_EQ(strcmp(X, Y), 0) |
41 | #endif |
42 | |
43 | #if SCUDO_FUCHSIA |
44 | #define SKIP_ON_FUCHSIA(T) DISABLED_##T |
45 | #else |
46 | #define SKIP_ON_FUCHSIA(T) T |
47 | #endif |
48 | |
49 | #if SCUDO_DEBUG |
50 | #define SKIP_NO_DEBUG(T) T |
51 | #else |
52 | #define SKIP_NO_DEBUG(T) DISABLED_##T |
53 | #endif |
54 | |
55 | #if SCUDO_FUCHSIA |
56 | // The zxtest library provides a default main function that does the same thing |
57 | // for Fuchsia builds. |
58 | #define SCUDO_NO_TEST_MAIN |
59 | #endif |
60 | |
61 | extern bool UseQuarantine; |
62 | |