blob: 05a43261501765eb197a2e4335288e76b29ce17e [file] [log] [blame]
Kostya Serebryany7c5ae7c2016-08-26 00:06:03 +00001// 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
Sagar Thakur6478d142017-06-19 11:28:59 +000010// UNSUPPORTED: i386-linux,i686-linux,arm-linux,armhf-linux,aarch64-linux,mips-linux,mipsel-linux,mips64-linux,mips64el-linux
Kostya Serebryany7c5ae7c2016-08-26 00:06:03 +000011
12// Tests that the allocator shuffles the chunks before returning to the user.
13
14#include <stdlib.h>
15#include <stdio.h>
16
17int 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}