1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 3 #please run as root 4 5 #we need 256M, below is the size in kB 6 needmem=262144 7 mnt=./huge 8 exitcode=0 9 10 ##get pagesize and freepages from /proc/meminfo 11 #while read name size unit; do 12 # if [ "$name" = "HugePages_Free:" ]; then 13 # freepgs=$size 14 # fi 15 # if [ "$name" = "Hugepagesize:" ]; then 16 # pgsize=$size 17 # fi 18 #done < /proc/meminfo 19 # 20 ##set proper nr_hugepages 21 #if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then 22 # nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` 23 # needpgs=`expr $needmem / $pgsize` 24 # tries=2 25 # while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do 26 # lackpgs=$(( $needpgs - $freepgs )) 27 # echo 3 > /proc/sys/vm/drop_caches 28 # echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages 29 # if [ $? -ne 0 ]; then 30 # echo "Please run this test as root" 31 # exit 1 32 # fi 33 # while read name size unit; do 34 # if [ "$name" = "HugePages_Free:" ]; then 35 # freepgs=$size 36 # fi 37 # done < /proc/meminfo 38 # tries=$((tries - 1)) 39 # done 40 # if [ $freepgs -lt $needpgs ]; then 41 # printf "Not enough huge pages available (%d < %d)\n" \ 42 # $freepgs $needpgs 43 # exit 1 44 # fi 45 #else 46 # echo "no hugetlbfs support in kernel?" 47 # exit 1 48 #fi 49 # 50 #mkdir $mnt 51 #mount -t hugetlbfs none $mnt 52 # 53 #echo "---------------------" 54 #echo "running hugepage-mmap" 55 #echo "---------------------" 56 #./hugepage-mmap 57 #if [ $? -ne 0 ]; then 58 # echo "[FAIL]" 59 # exitcode=1 60 #else 61 # echo "[PASS]" 62 #fi 63 64 # SYSVIPC must not be enabled on Android. 65 #shmmax=`cat /proc/sys/kernel/shmmax` 66 #shmall=`cat /proc/sys/kernel/shmall` 67 #echo 268435456 > /proc/sys/kernel/shmmax 68 #echo 4194304 > /proc/sys/kernel/shmall 69 #echo "--------------------" 70 #echo "running hugepage-shm" 71 #echo "--------------------" 72 #./hugepage-shm 73 #if [ $? -ne 0 ]; then 74 # echo "[FAIL]" 75 # exitcode=1 76 #else 77 # echo "[PASS]" 78 #fi 79 #echo $shmmax > /proc/sys/kernel/shmmax 80 #echo $shmall > /proc/sys/kernel/shmall 81 # 82 #echo "-------------------" 83 #echo "running map_hugetlb" 84 #echo "-------------------" 85 #./map_hugetlb 86 #if [ $? -ne 0 ]; then 87 # echo "[FAIL]" 88 # exitcode=1 89 #else 90 # echo "[PASS]" 91 #fi 92 # 93 #echo "NOTE: The above hugetlb tests provide minimal coverage. Use" 94 #echo " https://github.com/libhugetlbfs/libhugetlbfs.git for" 95 #echo " hugetlb regression testing." 96 # 97 # The userfaultfd syscall is not required on Android. 98 #echo "-------------------" 99 #echo "running userfaultfd" 100 #echo "-------------------" 101 #./userfaultfd anon 128 32 102 #if [ $? -ne 0 ]; then 103 # echo "[FAIL]" 104 # exitcode=1 105 #else 106 # echo "[PASS]" 107 #fi 108 # 109 #echo "---------------------------" 110 #echo "running userfaultfd_hugetlb" 111 #echo "---------------------------" 112 ## 256MB total huge pages == 128MB src and 128MB dst 113 #./userfaultfd hugetlb 128 32 $mnt/ufd_test_file 114 #if [ $? -ne 0 ]; then 115 # echo "[FAIL]" 116 # exitcode=1 117 #else 118 # echo "[PASS]" 119 #fi 120 #rm -f $mnt/ufd_test_file 121 # 122 #echo "-------------------------" 123 #echo "running userfaultfd_shmem" 124 #echo "-------------------------" 125 #./userfaultfd shmem 128 32 126 #if [ $? -ne 0 ]; then 127 # echo "[FAIL]" 128 # exitcode=1 129 #else 130 # echo "[PASS]" 131 #fi 132 # 133 ##cleanup 134 #umount $mnt 135 #rm -rf $mnt 136 #echo $nr_hugepgs > /proc/sys/vm/nr_hugepages 137 # 138 #echo "-----------------------" 139 #echo "running compaction_test" 140 #echo "-----------------------" 141 #./compaction_test 142 #if [ $? -ne 0 ]; then 143 # echo "[FAIL]" 144 # exitcode=1 145 #else 146 # echo "[PASS]" 147 #fi 148 149 echo "----------------------" 150 echo "running on-fault-limit" 151 echo "----------------------" 152 # Android does not have sudo 153 # sudo -u nobody ./on-fault-limit 154 su nobody ./on-fault-limit 155 if [ $? -ne 0 ]; then 156 echo "[FAIL]" 157 exitcode=1 158 else 159 echo "[PASS]" 160 fi 161 162 echo "--------------------" 163 echo "running mlock2-tests" 164 echo "--------------------" 165 ./mlock2-tests 166 if [ $? -ne 0 ]; then 167 echo "[FAIL]" 168 exitcode=1 169 else 170 echo "[PASS]" 171 fi 172 173 echo "-----------------------------" 174 echo "running virtual_address_range" 175 echo "-----------------------------" 176 # Android VTS will run a 32-bit suite where 177 # the virtual_address_range test will not exist. 178 if [ -x ./virtual_address_range ] 179 then 180 ./virtual_address_range 181 if [ $? -ne 0 ]; then 182 echo "[FAIL]" 183 exitcode=1 184 else 185 echo "[PASS]" 186 fi 187 fi 188 exit $exitcode 189