62 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "platform.h"10 11#if SCUDO_FUCHSIA12#include <zxtest/zxtest.h>13using Test = ::zxtest::Test;14#define TEST_SKIP(message) ZXTEST_SKIP(message)15#define TEST_HAS_FAILURE true16#else17#include "gtest/gtest.h"18using 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#endif25 26// If EXPECT_DEATH isn't defined, make it a no-op.27#ifndef EXPECT_DEATH28// If ASSERT_DEATH is defined, make EXPECT_DEATH a wrapper to it.29#ifdef ASSERT_DEATH30#define EXPECT_DEATH(X, Y) ASSERT_DEATH(([&] { X; }), "")31#else32#define EXPECT_DEATH(X, Y) \33 do { \34 } while (0)35#endif // ASSERT_DEATH36#endif // EXPECT_DEATH37 38// If EXPECT_STREQ isn't defined, define our own simple one.39#ifndef EXPECT_STREQ40#define EXPECT_STREQ(X, Y) EXPECT_EQ(strcmp(X, Y), 0)41#endif42 43#if SCUDO_FUCHSIA44#define SKIP_ON_FUCHSIA(T) DISABLED_##T45#else46#define SKIP_ON_FUCHSIA(T) T47#endif48 49#if SCUDO_DEBUG50#define SKIP_NO_DEBUG(T) T51#else52#define SKIP_NO_DEBUG(T) DISABLED_##T53#endif54 55#if SCUDO_FUCHSIA56// The zxtest library provides a default main function that does the same thing57// for Fuchsia builds.58#define SCUDO_NO_TEST_MAIN59#endif60 61extern bool UseQuarantine;62