]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/scudo/random_shuffle.cpp
New upstream version 1.20.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / scudo / random_shuffle.cpp
1 // RUN: %clang_scudo %s -o %t
2 // RUN: rm -rf %T/random_shuffle_tmp_dir
3 // RUN: mkdir %T/random_shuffle_tmp_dir
4 // RUN: %run %t 100 > %T/random_shuffle_tmp_dir/out1
5 // RUN: %run %t 100 > %T/random_shuffle_tmp_dir/out2
6 // RUN: %run %t 10000 > %T/random_shuffle_tmp_dir/out1
7 // RUN: %run %t 10000 > %T/random_shuffle_tmp_dir/out2
8 // RUN: not diff %T/random_shuffle_tmp_dir/out?
9 // RUN: rm -rf %T/random_shuffle_tmp_dir
10 // UNSUPPORTED: i386-linux,i686-linux,arm-linux,armhf-linux
11
12 // Tests that the allocator shuffles the chunks before returning to the user.
13
14 #include <stdlib.h>
15 #include <stdio.h>
16
17 int main(int argc, char **argv) {
18 int alloc_size = argc == 2 ? atoi(argv[1]) : 100;
19 char *base = new char[alloc_size];
20 for (int i = 0; i < 20; i++) {
21 char *p = new char[alloc_size];
22 printf("%zd\n", base - p);
23 }
24 }