aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Linux/auto_memory_profile_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/TestCases/Linux/auto_memory_profile_test.cc')
-rw-r--r--test/asan/TestCases/Linux/auto_memory_profile_test.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/asan/TestCases/Linux/auto_memory_profile_test.cc b/test/asan/TestCases/Linux/auto_memory_profile_test.cc
new file mode 100644
index 000000000000..3f8ad4673e75
--- /dev/null
+++ b/test/asan/TestCases/Linux/auto_memory_profile_test.cc
@@ -0,0 +1,32 @@
+// Tests heap_profile=1.
+// Printing memory profiling only works in the configuration where we can
+// detect leaks.
+// REQUIRES: leak-detection
+//
+// RUN: %clangxx_asan %s -o %t
+// RUN: %env_asan_opts=heap_profile=1 %run %t 2>&1 | FileCheck %s
+#include <sanitizer/common_interface_defs.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+char *sink[1000];
+
+int main() {
+
+ for (int i = 0; i < 3; i++) {
+ const size_t kSize = 13000000;
+ char *x = new char[kSize];
+ memset(x, 0, kSize);
+ sink[i] = x;
+ sleep(1);
+ }
+}
+
+// CHECK: HEAP PROFILE at RSS
+// CHECK: 13000000 byte(s)
+// CHECK: HEAP PROFILE at RSS
+// CHECK: 26000000 byte(s)
+// CHECK: HEAP PROFILE at RSS
+// CHECK: 39000000 byte(s)