blob: 41e67ded67e92b01c09e2036e48977534f56ecf6 [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 Thakura37c0d92017-04-24 11:02:36 +000010// UNSUPPORTED: i386-linux,i686-linux,arm-linux,armhf-linux,aarch64-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}