1 // The for loop in the backticks below requires bash.
4 // RUN: %clangxx_memprof %s -o %t
7 // RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always
10 // RUN: rm -f %t.log.*
11 // RUN: %env_memprof_opts=print_text=true:log_path=%t.log %run %t
12 // RUN: FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always < %t.log.*
15 // RUN: %env_memprof_opts=print_text=true:log_path=/INVALID not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID --dump-input=always
17 // Directory of log_path can't be created.
18 // RUN: %env_memprof_opts=print_text=true:log_path=/dev/null/INVALID not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BAD-DIR --dump-input=always
21 // RUN: %env_memprof_opts=print_text=true:log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \
22 // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LONG --dump-input=always
24 // Specifying the log name via the __memprof_profile_filename variable.
25 // Note we use an invalid path since that is sufficient for checking that the
26 // specified __memprof_profile_filename value is passed through to the runtime.
27 // Using an automatically generated name via %t can cause weird issues with
28 // unexpected macro expansion if the path includes tokens that match a build
29 // system macro (e.g. "linux").
30 // RUN: %clangxx_memprof %s -o %t -DPROFILE_NAME_VAR="/INVALID"
31 // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID --dump-input=always
33 #include <sanitizer/memprof_interface.h>
35 #ifdef PROFILE_NAME_VAR
36 #define xstr(s) str(s)
38 char __memprof_profile_filename
[] = xstr(PROFILE_NAME_VAR
);
43 int main(int argc
, char **argv
) {
44 char *x
= (char *)malloc(10);
47 __memprof_profile_dump();
50 // CHECK-GOOD: Memory allocation stack id
51 // CHECK-INVALID: ERROR: Can't open file: /INVALID
52 // CHECK-BAD-DIR: ERROR: Can't create directory: /dev/null
53 // CHECK-LONG: ERROR: Path is too long: 01234