31 lines · cpp
1// RUN: %clangxx_lsan %s -o %t2// The globs below do not work in the lit shell.3 4// Regular run.5// RUN: %env_lsan_opts="use_stacks=0" not %run %t > %t.out 2>&16// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out7 8// Good log_path.9// RUN: rm -f %t.log.* %t.log10// RUN: %adb_shell 'rm -f %t.log.*'11// RUN: %env_lsan_opts="use_stacks=0:log_path='"%device_rundir/%t.log"'" not %run %t > %t.out 2>&112// adb-pull doesn't support wild cards so we need to rename the log file.13// RUN: cat %device_rundir/%t.log.* >> %t.log14// RUN: %adb_shell 'cat %device_rundir/%t.log.*' >> %t.log15// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.*16 17#include <stdio.h>18#include <stdlib.h>19#include "sanitizer_common/print_address.h"20 21int main() {22 void *stack_var = malloc(1337);23 print_address("Test alloc: ", 1, stack_var);24 // Do not return from main to prevent the pointer from going out of scope.25 exit(0);26}27 28// CHECK-ERROR: LeakSanitizer: detected memory leaks29// CHECK-ERROR: Direct leak of 1337 byte(s) in 1 object(s) allocated from30// CHECK-ERROR: SUMMARY: {{.*}}Sanitizer:31