Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / scudo / standalone / tests / report_test.cpp
blob92f1ee813036cdc5f54d6797acefe24924cd906e
1 //===-- report_test.cpp -----------------------------------------*- 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 //===----------------------------------------------------------------------===//
9 #include "tests/scudo_unit_test.h"
11 #include "report.h"
13 TEST(ScudoReportDeathTest, Check) {
14 CHECK_LT(-1, 1);
15 EXPECT_DEATH(CHECK_GT(-1, 1),
16 "\\(-1\\) > \\(1\\) \\(\\(u64\\)op1=18446744073709551615, "
17 "\\(u64\\)op2=1");
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");
31 EXPECT_DEATH(
32 scudo::reportInvalidChunkState(scudo::AllocatorAction::Recycling, P),
33 "Scudo ERROR.*recycling.*42424242");
34 EXPECT_DEATH(
35 scudo::reportInvalidChunkState(scudo::AllocatorAction::Sizing, P),
36 "Scudo ERROR.*sizing.*42424242");
37 EXPECT_DEATH(
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),
51 "Scudo ERROR.*789");
52 EXPECT_DEATH(scudo::reportPvallocOverflow(123), "Scudo ERROR.*123");
53 EXPECT_DEATH(scudo::reportInvalidAlignedAllocAlignment(123, 456),
54 "Scudo ERROR.*123.*456");