// Printing memory profiling only works in the configuration where we can
// detect leaks.
// REQUIRES: leak-detection
//
// RUN: %clangxx_asan %s -o %t
// RUN: %run %t 2>&1 | FileCheck %s
#include <sanitizer/common_interface_defs.h>

#include <stdio.h>

char *sink[1000];

int main() {
  int idx = 0;
  for (int i = 0; i < 17; i++)
    sink[idx++] = new char[131];
  for (int i = 0; i < 42; i++)
    sink[idx++] = new char[24];

  __sanitizer_print_memory_profile(100);
  __sanitizer_print_memory_profile(50);
}

// CHECK: Live Heap Allocations: {{.*}}; showing top 100%
// CHECK: 2227 byte(s) ({{.*}}%) in 17 allocation(s)
// CHECK: 1008 byte(s) ({{.*}}%) in 42 allocation(s)
// CHECK: Live Heap Allocations: {{.*}}; showing top 50%
// CHECK: 2227 byte(s) ({{.*}}%) in 17 allocation(s)
// CHECK-NOT: 1008 byte

// RUN: %clangxx_asan %s -o %t
// RUN: %t 2>&1 | FileCheck %s
#include <sanitizer/common_interface_defs.h>

#include <stdio.h>

char *sink[1000];

int main() {
  int idx = 0;
  for (int i = 0; i < 17; i++)
    sink[idx++] = new char[131];
  for (int i = 0; i < 42; i++)
    sink[idx++] = new char[24];

  __sanitizer_print_memory_profile(100);
  __sanitizer_print_memory_profile(50);
}

// CHECK: Live Heap Allocations: {{.*}}; showing top 100%
// CHECK: 2227 byte(s) ({{.*}}%) in 17 allocation(s)
// CHECK: 1008 byte(s) ({{.*}}%) in 42 allocation(s)
// CHECK: Live Heap Allocations: {{.*}}; showing top 50%
// CHECK: 2227 byte(s) ({{.*}}%) in 17 allocation(s)
// CHECK-NOT: 1008 byte

--- 
+++ 
@@ -1,5 +1,9 @@
+// Printing memory profiling only works in the configuration where we can
+// detect leaks.
+// REQUIRES: leak-detection
+//
 // RUN: %clangxx_asan %s -o %t
-// RUN: %t 2>&1 | FileCheck %s
+// RUN: %run %t 2>&1 | FileCheck %s
 #include <sanitizer/common_interface_defs.h>
 
 #include <stdio.h>
Fix the test for printing the memory profile. This fuctionality is only
available along side the leak checking, so use the REQUIRES for that.

Also, use %run as other tests do when launching the built binary.

This fixes check-asan for me on Linux and looks like it should fix the
linux sanitizer bots as well.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@271785 91177308-0d34-0410-b5e6-96231b3b80d8
