Linux 3.11-rc3
[cris-mirror.git] / tools / testing / selftests / vm / run_vmtests
blobc87b6812300d62b3875c95cf31125b1aa2d28536
1 #!/bin/bash
2 #please run as root
4 #we need 256M, below is the size in kB
5 needmem=262144
6 mnt=./huge
7 exitcode=0
9 #get pagesize and freepages from /proc/meminfo
10 while read name size unit; do
11 if [ "$name" = "HugePages_Free:" ]; then
12 freepgs=$size
14 if [ "$name" = "Hugepagesize:" ]; then
15 pgsize=$size
17 done < /proc/meminfo
19 #set proper nr_hugepages
20 if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
21 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
22 needpgs=`expr $needmem / $pgsize`
23 if [ $freepgs -lt $needpgs ]; then
24 lackpgs=$(( $needpgs - $freepgs ))
25 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
26 if [ $? -ne 0 ]; then
27 echo "Please run this test as root"
28 exit 1
31 else
32 echo "no hugetlbfs support in kernel?"
33 exit 1
36 mkdir $mnt
37 mount -t hugetlbfs none $mnt
39 echo "--------------------"
40 echo "running hugepage-mmap"
41 echo "--------------------"
42 ./hugepage-mmap
43 if [ $? -ne 0 ]; then
44 echo "[FAIL]"
45 exitcode=1
46 else
47 echo "[PASS]"
50 shmmax=`cat /proc/sys/kernel/shmmax`
51 shmall=`cat /proc/sys/kernel/shmall`
52 echo 268435456 > /proc/sys/kernel/shmmax
53 echo 4194304 > /proc/sys/kernel/shmall
54 echo "--------------------"
55 echo "running hugepage-shm"
56 echo "--------------------"
57 ./hugepage-shm
58 if [ $? -ne 0 ]; then
59 echo "[FAIL]"
60 exitcode=1
61 else
62 echo "[PASS]"
64 echo $shmmax > /proc/sys/kernel/shmmax
65 echo $shmall > /proc/sys/kernel/shmall
67 echo "--------------------"
68 echo "running map_hugetlb"
69 echo "--------------------"
70 ./map_hugetlb
71 if [ $? -ne 0 ]; then
72 echo "[FAIL]"
73 exitcode=1
74 else
75 echo "[PASS]"
78 echo "--------------------"
79 echo "running hugetlbfstest"
80 echo "--------------------"
81 ./hugetlbfstest
82 if [ $? -ne 0 ]; then
83 echo "[FAIL]"
84 exitcode=1
85 else
86 echo "[PASS]"
89 #cleanup
90 umount $mnt
91 rm -rf $mnt
92 echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
93 exit $exitcode