1 //===-- report_test.cpp -----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "tests/scudo_unit_test.h"
13 TEST(ScudoReportDeathTest
, Check
) {
15 EXPECT_DEATH(CHECK_GT(-1, 1),
16 "\\(-1\\) > \\(1\\) \\(\\(u64\\)op1=18446744073709551615, "
20 TEST(ScudoReportDeathTest
, Generic
) {
21 // Potentially unused if EXPECT_DEATH isn't defined.
22 UNUSED
void *P
= reinterpret_cast<void *>(0x42424242U
);
23 EXPECT_DEATH(scudo::reportError("TEST123"), "Scudo ERROR.*TEST123");
24 EXPECT_DEATH(scudo::reportInvalidFlag("ABC", "DEF"), "Scudo ERROR.*ABC.*DEF");
25 EXPECT_DEATH(scudo::reportHeaderCorruption(P
), "Scudo ERROR.*42424242");
26 EXPECT_DEATH(scudo::reportSanityCheckError("XYZ"), "Scudo ERROR.*XYZ");
27 EXPECT_DEATH(scudo::reportAlignmentTooBig(123, 456), "Scudo ERROR.*123.*456");
28 EXPECT_DEATH(scudo::reportAllocationSizeTooBig(123, 456, 789),
29 "Scudo ERROR.*123.*456.*789");
30 EXPECT_DEATH(scudo::reportOutOfMemory(4242), "Scudo ERROR.*4242");
32 scudo::reportInvalidChunkState(scudo::AllocatorAction::Recycling
, P
),
33 "Scudo ERROR.*recycling.*42424242");
35 scudo::reportInvalidChunkState(scudo::AllocatorAction::Sizing
, P
),
36 "Scudo ERROR.*sizing.*42424242");
38 scudo::reportMisalignedPointer(scudo::AllocatorAction::Deallocating
, P
),
39 "Scudo ERROR.*deallocating.*42424242");
40 EXPECT_DEATH(scudo::reportDeallocTypeMismatch(
41 scudo::AllocatorAction::Reallocating
, P
, 0, 1),
42 "Scudo ERROR.*reallocating.*42424242");
43 EXPECT_DEATH(scudo::reportDeleteSizeMismatch(P
, 123, 456),
44 "Scudo ERROR.*42424242.*123.*456");
47 TEST(ScudoReportDeathTest
, CSpecific
) {
48 EXPECT_DEATH(scudo::reportAlignmentNotPowerOfTwo(123), "Scudo ERROR.*123");
49 EXPECT_DEATH(scudo::reportCallocOverflow(123, 456), "Scudo ERROR.*123.*456");
50 EXPECT_DEATH(scudo::reportInvalidPosixMemalignAlignment(789),
52 EXPECT_DEATH(scudo::reportPvallocOverflow(123), "Scudo ERROR.*123");
53 EXPECT_DEATH(scudo::reportInvalidAlignedAllocAlignment(123, 456),
54 "Scudo ERROR.*123.*456");