Move MSan lit-tests under test/msan
[blocksruntime.git] / lib / asan / lit_tests / TestCases / unaligned_loads_and_stores.cc
blobd50566c44e9a9b9a6ec90228fde84b803c3c9f45
1 // RUN: %clangxx_asan -O0 %s -o %t
2 // RUN: not %t A 2>&1 | FileCheck --check-prefix=CHECK-A %s
3 // RUN: not %t B 2>&1 | FileCheck --check-prefix=CHECK-B %s
4 // RUN: not %t C 2>&1 | FileCheck --check-prefix=CHECK-C %s
5 // RUN: not %t D 2>&1 | FileCheck --check-prefix=CHECK-D %s
6 // RUN: not %t E 2>&1 | FileCheck --check-prefix=CHECK-E %s
8 // RUN: not %t K 2>&1 | FileCheck --check-prefix=CHECK-K %s
9 // RUN: not %t L 2>&1 | FileCheck --check-prefix=CHECK-L %s
10 // RUN: not %t M 2>&1 | FileCheck --check-prefix=CHECK-M %s
11 // RUN: not %t N 2>&1 | FileCheck --check-prefix=CHECK-N %s
12 // RUN: not %t O 2>&1 | FileCheck --check-prefix=CHECK-O %s
14 #include <sanitizer/asan_interface.h>
16 #include <stdlib.h>
17 #include <string.h>
18 int main(int argc, char **argv) {
19 if (argc != 2) return 1;
20 char *x = new char[16];
21 memset(x, 0xab, 16);
22 int res = 1;
23 switch (argv[1][0]) {
24 case 'A': res = __sanitizer_unaligned_load16(x + 15); break;
25 // CHECK-A ERROR: AddressSanitizer: heap-buffer-overflow on address
26 // CHECK-A: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-2]]
27 // CHECK-A: is located 0 bytes to the right of 16-byte region
28 case 'B': res = __sanitizer_unaligned_load32(x + 14); break;
29 // CHECK-B: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
30 case 'C': res = __sanitizer_unaligned_load32(x + 13); break;
31 // CHECK-C: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
32 case 'D': res = __sanitizer_unaligned_load64(x + 15); break;
33 // CHECK-D: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
34 case 'E': res = __sanitizer_unaligned_load64(x + 9); break;
35 // CHECK-E: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
37 case 'K': __sanitizer_unaligned_store16(x + 15, 0); break;
38 // CHECK-K ERROR: AddressSanitizer: heap-buffer-overflow on address
39 // CHECK-K: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-2]]
40 // CHECK-K: is located 0 bytes to the right of 16-byte region
41 case 'L': __sanitizer_unaligned_store32(x + 15, 0); break;
42 // CHECK-L: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
43 case 'M': __sanitizer_unaligned_store32(x + 13, 0); break;
44 // CHECK-M: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
45 case 'N': __sanitizer_unaligned_store64(x + 10, 0); break;
46 // CHECK-N: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
47 case 'O': __sanitizer_unaligned_store64(x + 14, 0); break;
48 // CHECK-O: main{{.*}}unaligned_loads_and_stores.cc:[[@LINE-1]]
50 delete x;
51 return res;