33 lines · cpp
1// Print matched suppressions only if print_suppressions=1 AND at least one is2// matched. Default is print_suppressions=true.3// RUN: %clangxx_lsan %s -o %t4// RUN: %env_lsan_opts=use_registers=0:use_stacks=0:print_suppressions=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print5// RUN: %env_lsan_opts=use_registers=0:use_stacks=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print6// RUN: %env_lsan_opts=use_registers=0:use_stacks=0:print_suppressions=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print7// RUN: %env_lsan_opts=use_registers=0:use_stacks=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-print8 9#include <stdio.h>10#include <stdlib.h>11 12#include "sanitizer/lsan_interface.h"13 14extern "C"15const char *__lsan_default_suppressions() {16 return "leak:*LSanTestLeakingFunc*";17}18 19void LSanTestLeakingFunc() {20 void *p = malloc(666);21 fprintf(stderr, "Test alloc: %p.\n", p);22}23 24int main(int argc, char **argv) {25 printf("print for nonempty output\n");26 if (argc > 1)27 LSanTestLeakingFunc();28 return 0;29}30// CHECK-print: Suppressions used:31// CHECK-print: 1 666 *LSanTestLeakingFunc*32// CHECK-dont-print-NOT: Suppressions used:33