33 lines · cpp
1//===-- Unittests for assert ----------------------------------------------===//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#undef NDEBUG10#include "src/assert/assert.h"11#include "test/UnitTest/Test.h"12 13extern "C" int close(int);14 15TEST(LlvmLibcAssert, Enabled) {16 // -1 matches against any signal, which is necessary for now until17 // LIBC_NAMESPACE::abort() unblocks SIGABRT. Close standard error for the18 // child process so we don't print the assertion failure message.19 EXPECT_DEATH(20 [] {21 close(2);22 assert(0);23 },24 WITH_SIGNAL(-1));25}26 27#define NDEBUG28#include "src/assert/assert.h"29 30TEST(LlvmLibcAssert, Disabled) {31 EXPECT_EXITS([] { assert(0); }, 0);32}33