Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / asan / TestCases / strcat-overlap.cpp
blob76fd3e1f11d14ef3573d34dbfda3e25363e6e16e
1 // RUN: %clangxx_asan -O0 -fno-builtin %s -o %t
2 // RUN: not %run %t 2>&1 | FileCheck %s
3 // RUN: echo "interceptor_via_fun:bad_function" > %t.supp
4 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
5 // RUN: echo "interceptor_name:strcat" > %t.supp
6 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
7 //
8 // RUN: %clangxx_asan -O1 -fno-builtin %s -o %t
9 // RUN: not %run %t 2>&1 | FileCheck %s
10 // RUN: echo "interceptor_via_fun:bad_function" > %t.supp
11 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
12 // RUN: echo "interceptor_name:strcat" > %t.supp
13 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
15 // RUN: %clangxx_asan -O2 -fno-builtin %s -o %t
16 // RUN: not %run %t 2>&1 | FileCheck %s
17 // RUN: echo "interceptor_via_fun:bad_function" > %t.supp
18 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
19 // RUN: echo "interceptor_name:strcat" > %t.supp
20 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
22 // RUN: %clangxx_asan -O3 -fno-builtin %s -o %t
23 // RUN: not %run %t 2>&1 | FileCheck %s
24 // RUN: echo "interceptor_via_fun:bad_function" > %t.supp
25 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
26 // RUN: echo "interceptor_name:strcat" > %t.supp
27 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
29 // This test when run with suppressions invokes undefined
30 // behavior which can cause all sorts of bad things to happen
31 // depending on how strcat() is implemented. For now only run
32 // on platforms where we know the test passes.
33 // REQUIRES: x86_64h-darwin || x86_64-darwin || i386-darwin || x86_64-linux || i386-linux
34 // UNSUPPORTED: target={{.*windows-msvc.*}}
35 // UNSUPPORTED: android
37 #include <string.h>
40 // Don't inline function otherwise stacktrace changes.
41 __attribute__((noinline)) void bad_function() {
42 char buffer[] = "hello\0XXX";
43 // CHECK: strcat-param-overlap: memory ranges
44 // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
45 // CHECK: {{#0 0x.* in .*strcat}}
46 // CHECK: {{#1 0x.* in bad_function.*strcat-overlap.cpp:}}[[@LINE+2]]
47 // CHECK: {{#2 0x.* in main .*strcat-overlap.cpp:}}[[@LINE+5]]
48 strcat(buffer, buffer + 1); // BOOM
51 int main(int argc, char **argv) {
52 bad_function();
53 return 0;