1// FIXME: This test infinite loops on darwin because it crashes
2// printing a stack trace repeatedly
3UNSUPPORTED: darwin
4
5// Verifies lib/fuzzer/scripts/unbalanced_allocs.py script
6
7RUN: %cpp_compiler %S/TraceMallocTest.cpp -o %t-TraceMallocTest
8
9# Specify python because we can't use the shebang line on Windows.
10RUN: %run %t-TraceMallocTest -seed=1 -trace_malloc=1 -runs=200 2>&1 | \
11RUN:    python %libfuzzer_src/scripts/unbalanced_allocs.py --skip=5 | FileCheck %s
12
13RUN: %run %t-TraceMallocTest -seed=1 -trace_malloc=2 -runs=200 2>&1 | \
14RUN:    python %libfuzzer_src/scripts/unbalanced_allocs.py --skip=5 | FileCheck %s --check-prefixes=CHECK,CHECK2
15
16CHECK: MallocFreeTracer: START
17# Behavior of the format string "%p" is implementation defined. Account for the
18# implementation on Windows and Linux.
19CHECK: Unbalanced MALLOC[{{[0-9]+}}] [[PTR:(:?0x)?[0-9a-fA-F]+]] 4
20CHECK2-NEXT: {{ #0 0x[0-9a-f]+ in }}
21CHECK2-NEXT: {{ #1 0x[0-9a-f]+ in }}
22CHECK2-NEXT: {{ #2 0x[0-9a-f]+ in }}
23CHECK: MallocFreeTracer: STOP
24
25CHECK: MallocFreeTracer: START
26CHECK: Unbalanced FREE[{{[0-9]+}}] [[PTR]]
27CHECK2-NEXT: {{ #0 0x[0-9a-f]+ in }}
28CHECK2-NEXT: {{ #1 0x[0-9a-f]+ in }}
29CHECK2-NEXT: {{ #2 0x[0-9a-f]+ in }}
30CHECK: MallocFreeTracer: STOP
31