brintos

brintos / llvm-project-archived public Read only

0
0
Text · 857 B · dbad784 Raw
34 lines · cpp
1// Test for on-demand leak checking.2// RUN: %clangxx_lsan %s -o %t3// RUN: %env_lsan_opts=use_stacks=0:use_registers=0:symbolize=0 %run %t foo 2>&1 | FileCheck %s4// RUN: %env_lsan_opts=use_stacks=0:use_registers=0:symbolize=0 %run %t 2>&1 | FileCheck %s5 6// UNSUPPORTED: darwin7 8#include <assert.h>9#include <stdio.h>10#include <stdlib.h>11#include <unistd.h>12#include <sanitizer/lsan_interface.h>13 14void *p;15 16int main(int argc, char *argv[]) {17  p = malloc(23);18 19  assert(__lsan_do_recoverable_leak_check() == 0);20 21  fprintf(stderr, "Test alloc: %p.\n", malloc(1337));22// CHECK: Test alloc:23 24  assert(__lsan_do_recoverable_leak_check() == 1);25// CHECK: SUMMARY: {{.*}}Sanitizer: 1337 byte26 27  // Test that we correctly reset chunk tags.28  p = 0;29  assert(__lsan_do_recoverable_leak_check() == 1);30// CHECK: SUMMARY: {{.*}}Sanitizer: 1360 byte31 32  _exit(0);33}34