Mercurial > hg > CbC > CbC_llvm
comparison compiler-rt/test/hwasan/TestCases/malloc_fill.cpp @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 1d019706d866 |
children |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
1 // Check that we fill malloc-ed memory correctly. | 1 // Check that we fill malloc-ed memory correctly. |
2 // RUN: %clangxx_hwasan %s -o %t | 2 // RUN: %clangxx_hwasan %s -o %t |
3 // RUN: %run %t | FileCheck %s | 3 // RUN: %run %t | FileCheck %s --check-prefix=CHECK-0 |
4 // RUN: %env_hwasan_opts=max_malloc_fill_size=20 %run %t | FileCheck %s --check-prefix=CHECK-20-be | |
5 // RUN: %env_hwasan_opts=max_malloc_fill_size=0:malloc_fill_byte=8 %run %t | FileCheck %s --check-prefix=CHECK-0 | |
4 // RUN: %env_hwasan_opts=max_malloc_fill_size=10:malloc_fill_byte=8 %run %t | FileCheck %s --check-prefix=CHECK-10-8 | 6 // RUN: %env_hwasan_opts=max_malloc_fill_size=10:malloc_fill_byte=8 %run %t | FileCheck %s --check-prefix=CHECK-10-8 |
5 // RUN: %env_hwasan_opts=max_malloc_fill_size=20:malloc_fill_byte=171 %run %t | FileCheck %s --check-prefix=CHECK-20-ab | 7 // RUN: %env_hwasan_opts=max_malloc_fill_size=20:malloc_fill_byte=171 %run %t | FileCheck %s --check-prefix=CHECK-20-ab |
6 | 8 |
7 #include <stdio.h> | 9 #include <stdio.h> |
8 | 10 |
9 #include "utils.h" | |
10 | |
11 int main(int argc, char **argv) { | 11 int main(int argc, char **argv) { |
12 // With asan allocator this makes sure we get memory from mmap. | 12 // With asan allocator this makes sure we get memory from mmap. |
13 static const int kSize = 1 << 25; | 13 static const int kSize = 1 << 25; |
14 unsigned char *x = new unsigned char[kSize]; | 14 unsigned char *x = new unsigned char[kSize]; |
15 untag_printf("-"); | 15 printf("-"); |
16 for (int i = 0; i <= 32; i++) { | 16 for (int i = 0; i <= 32; i++) { |
17 untag_printf("%02x", x[i]); | 17 printf("%02x", x[i]); |
18 } | 18 } |
19 untag_printf("-\n"); | 19 printf("-\n"); |
20 delete [] x; | 20 delete [] x; |
21 } | 21 } |
22 | 22 |
23 // CHECK: -bebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebe- | 23 // CHECK-0: -000000000000000000000000000000000000000000000000000000000000000000- |
24 // CHECK-20-be: -bebebebebebebebebebebebebebebebebebebebe00000000000000000000000000- | |
24 // CHECK-10-8: -080808080808080808080000000000000000000000000000000000000000000000- | 25 // CHECK-10-8: -080808080808080808080000000000000000000000000000000000000000000000- |
25 // CHECK-20-ab: -abababababababababababababababababababab00000000000000000000000000- | 26 // CHECK-20-ab: -abababababababababababababababababababab00000000000000000000000000- |