xref: /llvm-project/compiler-rt/test/fuzzer/fuzzer-leak.test (revision d6af73e9fbc84315100499a096f17ec5eeeeea23)
1REQUIRES: lsan
2// See https://github.com/llvm/llvm-project/issues/97712.
3UNSUPPORTED: target={{.*}}
4
5RUN: %cpp_compiler %S/LeakTest.cpp -o %t-LeakTest
6RUN: %cpp_compiler %S/ThreadedLeakTest.cpp -o %t-ThreadedLeakTest
7RUN: %cpp_compiler %S/LeakTimeoutTest.cpp -o %t-LeakTimeoutTest
8
9RUN: rm -rf %t-corpus && mkdir -p %t-corpus
10RUN: not %run %t-LeakTest -runs=100000 -detect_leaks=1 %t-corpus 2>&1 | FileCheck %s --check-prefix=LEAK_DURING
11LEAK_DURING: ERROR: LeakSanitizer: detected memory leaks
12LEAK_DURING: Direct leak of {{.*}} byte(s) in {{.*}} object(s) allocated from:
13LEAK_DURING: INFO: to ignore leaks on libFuzzer side use -detect_leaks=0
14LEAK_DURING: Test unit written to ./leak-
15LEAK_DURING-NOT: DONE
16LEAK_DURING-NOT: Done
17
18// Verify leaking input was not added to corpus
19RUN: %run %t-LeakTest -runs=0 %t-corpus
20
21RUN: not %run %t-LeakTest -runs=0 -detect_leaks=1 %S 2>&1 | FileCheck %s --check-prefix=LEAK_IN_CORPUS
22LEAK_IN_CORPUS: ERROR: LeakSanitizer: detected memory leaks
23LEAK_IN_CORPUS: INFO: a leak has been found in the initial corpus.
24
25RUN: not %run %t-LeakTest -runs=100000000 %S/hi.txt 2>&1 | FileCheck %s --check-prefix=MULTI_RUN_LEAK
26MULTI_RUN_LEAK-NOT: pulse
27MULTI_RUN_LEAK: LeakSanitizer: detected memory leaks
28
29RUN: not %run %t-LeakTest -runs=100000 -detect_leaks=0 2>&1 | FileCheck %s --check-prefix=LEAK_AFTER
30RUN: not %run %t-LeakTest -runs=100000                 2>&1 | FileCheck %s --check-prefix=LEAK_DURING
31RUN: not %run %t-ThreadedLeakTest -runs=100000 -detect_leaks=0 2>&1 | FileCheck %s --check-prefix=LEAK_AFTER
32RUN: not %run %t-ThreadedLeakTest -runs=100000                 2>&1 | FileCheck %s --check-prefix=LEAK_DURING
33LEAK_AFTER: Done 100000 runs in
34LEAK_AFTER: ERROR: LeakSanitizer: detected memory leaks
35
36RUN: not %run %t-LeakTest -runs=100000 -max_len=1 2>&1 | FileCheck %s --check-prefix=MAX_LEN_1
37MAX_LEN_1: Test unit written to ./leak-7cf184f4c67ad58283ecb19349720b0cae756829
38
39RUN: not %run %t-LeakTimeoutTest -timeout=1 2>&1 | FileCheck %s --check-prefix=LEAK_TIMEOUT
40LEAK_TIMEOUT: ERROR: libFuzzer: timeout after
41LEAK_TIMEOUT-NOT: LeakSanitizer
42
43
44RUN: %run %t-LeakTest -error_exitcode=0
45