| 1 | // RUN: %clangxx_scudo %s -o %t |
| 2 | // RUN: rm -rf %t-dir/random_shuffle_tmp_dir |
| 3 | // RUN: mkdir -p %t-dir/random_shuffle_tmp_dir |
| 4 | // RUN: %run %t 100 > %t-dir/random_shuffle_tmp_dir/out1 |
| 5 | // RUN: %run %t 100 > %t-dir/random_shuffle_tmp_dir/out2 |
| 6 | // RUN: %run %t 10000 > %t-dir/random_shuffle_tmp_dir/out1 |
| 7 | // RUN: %run %t 10000 > %t-dir/random_shuffle_tmp_dir/out2 |
| 8 | // RUN: not diff %t-dir/random_shuffle_tmp_dir/out? |
| 9 | // RUN: rm -rf %t-dir/random_shuffle_tmp_dir |
| 10 | |
| 11 | // Tests that the allocator shuffles the chunks before returning to the user. |
| 12 | |
| 13 | #include <stdio.h> |
| 14 | #include <stdlib.h> |
| 15 | |
| 16 | int main(int argc, char **argv) { |
| 17 | int alloc_size = argc == 2 ? atoi(nptr: argv[1]) : 100; |
| 18 | char *base = new char[alloc_size]; |
| 19 | for (int i = 0; i < 20; i++) { |
| 20 | char *p = new char[alloc_size]; |
| 21 | printf(format: "%zd\n" , base - p); |
| 22 | } |
| 23 | } |
| 24 | |