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 #else 16 #include "gtest/gtest.h" 17 using Test = ::testing::Test; 18 #define TEST_SKIP(message) \ 19 do { \ 20 GTEST_SKIP() << message; \ 21 } while (0) 22 #endif 23 24 // If EXPECT_DEATH isn't defined, make it a no-op. 25 #ifndef EXPECT_DEATH 26 // If ASSERT_DEATH is defined, make EXPECT_DEATH a wrapper to it. 27 #ifdef ASSERT_DEATH 28 #define EXPECT_DEATH(X, Y) ASSERT_DEATH(([&] { X; }), "") 29 #else 30 #define EXPECT_DEATH(X, Y) \ 31 do { \ 32 } while (0) 33 #endif // ASSERT_DEATH 34 #endif // EXPECT_DEATH 35 36 // If EXPECT_STREQ isn't defined, define our own simple one. 37 #ifndef EXPECT_STREQ 38 #define EXPECT_STREQ(X, Y) EXPECT_EQ(strcmp(X, Y), 0) 39 #endif 40 41 #if SCUDO_FUCHSIA 42 #define SKIP_ON_FUCHSIA(T) DISABLED_##T 43 #else 44 #define SKIP_ON_FUCHSIA(T) T 45 #endif 46 47 #if SCUDO_DEBUG 48 #define SKIP_NO_DEBUG(T) T 49 #else 50 #define SKIP_NO_DEBUG(T) DISABLED_##T 51 #endif 52 53 #if SCUDO_FUCHSIA 54 // The zxtest library provides a default main function that does the same thing 55 // for Fuchsia builds. 56 #define SCUDO_NO_TEST_MAIN 57 #endif 58 59 extern bool UseQuarantine; 60