1// Test for the leak_check_at_exit flag.
2// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
3// RUN: %clangxx_lsan %s -o %t
4// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
5// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-do
6// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
7// RUN: LSAN_OPTIONS=%LSAN_BASE:"leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <sanitizer/lsan_interface.h>
12
13int main(int argc, char *argv[]) {
14  fprintf(stderr, "Test alloc: %p.\n", malloc(1337));
15  if (argc > 1)
16    __lsan_do_leak_check();
17  return 0;
18}
19
20// CHECK-do: SUMMARY: {{(Leak|Address)}}Sanitizer:
21// CHECK-dont-NOT: SUMMARY: {{(Leak|Address)}}Sanitizer:
22