var scope reduction
[trinity.git] / scripts / rand-vm.sh
blob6d91ee0631a4d19309dd0ae0637327ba29019bd5
1 #!/bin/sh
3 # Do a random subset of VM related syscalls.
4 # (Always do mmap, so the child processes have some local maps)
6 OLDPATH=$(pwd)
7 TRINITY_PATH=${TRINITY_PATH:-$OLDPATH}
9 if [ -d tmp ]; then
10 TRINITY_TMP=$(mktemp -d $(pwd)/tmp/trinity.XXXXXX)
11 else
12 TRINITY_TMP=$(mktemp -d /tmp/trinity.XXXXXX)
15 TRINITY_PATH=${TRINITY_PATH:-.}
16 TRINITY_TMP=$(mktemp -d /tmp/trinity.XXXXXX)
18 check_tainted()
20 if [ "$(cat /proc/sys/kernel/tainted)" != $TAINT ]; then
21 echo ERROR: Taint flag changed $(cat /proc/sys/kernel/tainted)
22 exit
26 TAINT=$(cat /proc/sys/kernel/tainted)
28 ARRAY[0]="madvise"
29 ARRAY[1]="mbind"
30 ARRAY[2]="migrate_pages"
31 ARRAY[3]="mincore"
32 ARRAY[4]="mlockall"
33 ARRAY[5]="mlock"
34 ARRAY[6]="move_pages"
35 ARRAY[7]="mprotect"
36 ARRAY[8]="mremap"
37 ARRAY[9]="msync"
38 ARRAY[10]="munlockall"
39 ARRAY[11]="munlock"
40 ARRAY[12]="munmap"
41 ARRAY[13]="remap_file_pages"
42 ARRAY[14]="vmsplice"
44 while [ 1 ];
46 syscalls="-c mmap"
47 for i in $(seq 0 2)
49 syscalls=$(echo $syscalls -c ${ARRAY[$(($RANDOM % 15))]})
50 done
52 echo testing $syscalls
54 chmod 755 $TRINITY_TMP
55 pushd $TRINITY_TMP > /dev/null
57 if [ ! -f $TRINITY_PATH/trinity ]; then
58 echo lost!
59 pwd
60 exit
63 MALLOC_CHECK_=2 $TRINITY_PATH/trinity -q -l off $syscalls -N 99999 -C 64
64 popd > /dev/null
66 check_tainted
67 echo
68 echo
69 done