Home | History | Annotate | Download | only in patches
      1 From 946413011af990b7220e73af57c0bc2196275524 Mon Sep 17 00:00:00 2001
      2 From: Steve Muckle <smuckle (a] google.com>
      3 Date: Wed, 1 Nov 2017 18:36:34 -0700
      4 Subject: [PATCH] ANDROID: build vm tests
      5 
      6 The hugepage-mmap, hugepage-shm, map_hugetlb, compaction, and
      7 userfaultfd tests cannot be run due to unmet dependencies.
      8 
      9 Bug: 67017050
     10 Test: make -j vts
     11 Change-Id: Ie34a1a7ffada205f90719400987e3093115fd6bb
     12 Signed-off-by: Steve Muckle <smuckle (a] google.com>
     13 ---
     14 
     15  [smuckle (a] google.com: drop changes to Android-specific files for
     16   tracking of changes to upstream]
     17 
     18  tools/testing/selftests/vm/run_vmtests | 296 +++++++++++++++++----------------
     19 
     20 diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
     21 index 07548a1fa901..32120c271d5e 100755
     22 --- a/tools/testing/selftests/vm/run_vmtests
     23 +++ b/tools/testing/selftests/vm/run_vmtests
     24 @@ -6,147 +6,151 @@ needmem=262144
     25  mnt=./huge
     26  exitcode=0
     27  
     28 -#get pagesize and freepages from /proc/meminfo
     29 -while read name size unit; do
     30 -	if [ "$name" = "HugePages_Free:" ]; then
     31 -		freepgs=$size
     32 -	fi
     33 -	if [ "$name" = "Hugepagesize:" ]; then
     34 -		pgsize=$size
     35 -	fi
     36 -done < /proc/meminfo
     37 -
     38 -#set proper nr_hugepages
     39 -if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
     40 -	nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
     41 -	needpgs=`expr $needmem / $pgsize`
     42 -	tries=2
     43 -	while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
     44 -		lackpgs=$(( $needpgs - $freepgs ))
     45 -		echo 3 > /proc/sys/vm/drop_caches
     46 -		echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
     47 -		if [ $? -ne 0 ]; then
     48 -			echo "Please run this test as root"
     49 -			exit 1
     50 -		fi
     51 -		while read name size unit; do
     52 -			if [ "$name" = "HugePages_Free:" ]; then
     53 -				freepgs=$size
     54 -			fi
     55 -		done < /proc/meminfo
     56 -		tries=$((tries - 1))
     57 -	done
     58 -	if [ $freepgs -lt $needpgs ]; then
     59 -		printf "Not enough huge pages available (%d < %d)\n" \
     60 -		       $freepgs $needpgs
     61 -		exit 1
     62 -	fi
     63 -else
     64 -	echo "no hugetlbfs support in kernel?"
     65 -	exit 1
     66 -fi
     67 -
     68 -mkdir $mnt
     69 -mount -t hugetlbfs none $mnt
     70 -
     71 -echo "---------------------"
     72 -echo "running hugepage-mmap"
     73 -echo "---------------------"
     74 -./hugepage-mmap
     75 -if [ $? -ne 0 ]; then
     76 -	echo "[FAIL]"
     77 -	exitcode=1
     78 -else
     79 -	echo "[PASS]"
     80 -fi
     81 -
     82 -shmmax=`cat /proc/sys/kernel/shmmax`
     83 -shmall=`cat /proc/sys/kernel/shmall`
     84 -echo 268435456 > /proc/sys/kernel/shmmax
     85 -echo 4194304 > /proc/sys/kernel/shmall
     86 -echo "--------------------"
     87 -echo "running hugepage-shm"
     88 -echo "--------------------"
     89 -./hugepage-shm
     90 -if [ $? -ne 0 ]; then
     91 -	echo "[FAIL]"
     92 -	exitcode=1
     93 -else
     94 -	echo "[PASS]"
     95 -fi
     96 -echo $shmmax > /proc/sys/kernel/shmmax
     97 -echo $shmall > /proc/sys/kernel/shmall
     98 -
     99 -echo "-------------------"
    100 -echo "running map_hugetlb"
    101 -echo "-------------------"
    102 -./map_hugetlb
    103 -if [ $? -ne 0 ]; then
    104 -	echo "[FAIL]"
    105 -	exitcode=1
    106 -else
    107 -	echo "[PASS]"
    108 -fi
    109 -
    110 -echo "NOTE: The above hugetlb tests provide minimal coverage.  Use"
    111 -echo "      https://github.com/libhugetlbfs/libhugetlbfs.git for"
    112 -echo "      hugetlb regression testing."
    113 -
    114 -echo "-------------------"
    115 -echo "running userfaultfd"
    116 -echo "-------------------"
    117 -./userfaultfd anon 128 32
    118 -if [ $? -ne 0 ]; then
    119 -	echo "[FAIL]"
    120 -	exitcode=1
    121 -else
    122 -	echo "[PASS]"
    123 -fi
    124 -
    125 -echo "---------------------------"
    126 -echo "running userfaultfd_hugetlb"
    127 -echo "---------------------------"
    128 -# 256MB total huge pages == 128MB src and 128MB dst
    129 -./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
    130 -if [ $? -ne 0 ]; then
    131 -	echo "[FAIL]"
    132 -	exitcode=1
    133 -else
    134 -	echo "[PASS]"
    135 -fi
    136 -rm -f $mnt/ufd_test_file
    137 -
    138 -echo "-------------------------"
    139 -echo "running userfaultfd_shmem"
    140 -echo "-------------------------"
    141 -./userfaultfd shmem 128 32
    142 -if [ $? -ne 0 ]; then
    143 -	echo "[FAIL]"
    144 -	exitcode=1
    145 -else
    146 -	echo "[PASS]"
    147 -fi
    148 -
    149 -#cleanup
    150 -umount $mnt
    151 -rm -rf $mnt
    152 -echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
    153 -
    154 -echo "-----------------------"
    155 -echo "running compaction_test"
    156 -echo "-----------------------"
    157 -./compaction_test
    158 -if [ $? -ne 0 ]; then
    159 -	echo "[FAIL]"
    160 -	exitcode=1
    161 -else
    162 -	echo "[PASS]"
    163 -fi
    164 +##get pagesize and freepages from /proc/meminfo
    165 +#while read name size unit; do
    166 +#	if [ "$name" = "HugePages_Free:" ]; then
    167 +#		freepgs=$size
    168 +#	fi
    169 +#	if [ "$name" = "Hugepagesize:" ]; then
    170 +#		pgsize=$size
    171 +#	fi
    172 +#done < /proc/meminfo
    173 +#
    174 +##set proper nr_hugepages
    175 +#if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
    176 +#	nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
    177 +#	needpgs=`expr $needmem / $pgsize`
    178 +#	tries=2
    179 +#	while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
    180 +#		lackpgs=$(( $needpgs - $freepgs ))
    181 +#		echo 3 > /proc/sys/vm/drop_caches
    182 +#		echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
    183 +#		if [ $? -ne 0 ]; then
    184 +#			echo "Please run this test as root"
    185 +#			exit 1
    186 +#		fi
    187 +#		while read name size unit; do
    188 +#			if [ "$name" = "HugePages_Free:" ]; then
    189 +#				freepgs=$size
    190 +#			fi
    191 +#		done < /proc/meminfo
    192 +#		tries=$((tries - 1))
    193 +#	done
    194 +#	if [ $freepgs -lt $needpgs ]; then
    195 +#		printf "Not enough huge pages available (%d < %d)\n" \
    196 +#		       $freepgs $needpgs
    197 +#		exit 1
    198 +#	fi
    199 +#else
    200 +#	echo "no hugetlbfs support in kernel?"
    201 +#	exit 1
    202 +#fi
    203 +#
    204 +#mkdir $mnt
    205 +#mount -t hugetlbfs none $mnt
    206 +#
    207 +#echo "---------------------"
    208 +#echo "running hugepage-mmap"
    209 +#echo "---------------------"
    210 +#./hugepage-mmap
    211 +#if [ $? -ne 0 ]; then
    212 +#	echo "[FAIL]"
    213 +#	exitcode=1
    214 +#else
    215 +#	echo "[PASS]"
    216 +#fi
    217 +
    218 +# SYSVIPC must not be enabled on Android.
    219 +#shmmax=`cat /proc/sys/kernel/shmmax`
    220 +#shmall=`cat /proc/sys/kernel/shmall`
    221 +#echo 268435456 > /proc/sys/kernel/shmmax
    222 +#echo 4194304 > /proc/sys/kernel/shmall
    223 +#echo "--------------------"
    224 +#echo "running hugepage-shm"
    225 +#echo "--------------------"
    226 +#./hugepage-shm
    227 +#if [ $? -ne 0 ]; then
    228 +#	echo "[FAIL]"
    229 +#	exitcode=1
    230 +#else
    231 +#	echo "[PASS]"
    232 +#fi
    233 +#echo $shmmax > /proc/sys/kernel/shmmax
    234 +#echo $shmall > /proc/sys/kernel/shmall
    235 +#
    236 +#echo "-------------------"
    237 +#echo "running map_hugetlb"
    238 +#echo "-------------------"
    239 +#./map_hugetlb
    240 +#if [ $? -ne 0 ]; then
    241 +#	echo "[FAIL]"
    242 +#	exitcode=1
    243 +#else
    244 +#	echo "[PASS]"
    245 +#fi
    246 +#
    247 +#echo "NOTE: The above hugetlb tests provide minimal coverage.  Use"
    248 +#echo "      https://github.com/libhugetlbfs/libhugetlbfs.git for"
    249 +#echo "      hugetlb regression testing."
    250 +#
    251 +# The userfaultfd syscall is not required on Android.
    252 +#echo "-------------------"
    253 +#echo "running userfaultfd"
    254 +#echo "-------------------"
    255 +#./userfaultfd anon 128 32
    256 +#if [ $? -ne 0 ]; then
    257 +#	echo "[FAIL]"
    258 +#	exitcode=1
    259 +#else
    260 +#	echo "[PASS]"
    261 +#fi
    262 +#
    263 +#echo "---------------------------"
    264 +#echo "running userfaultfd_hugetlb"
    265 +#echo "---------------------------"
    266 +## 256MB total huge pages == 128MB src and 128MB dst
    267 +#./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
    268 +#if [ $? -ne 0 ]; then
    269 +#	echo "[FAIL]"
    270 +#	exitcode=1
    271 +#else
    272 +#	echo "[PASS]"
    273 +#fi
    274 +#rm -f $mnt/ufd_test_file
    275 +#
    276 +#echo "-------------------------"
    277 +#echo "running userfaultfd_shmem"
    278 +#echo "-------------------------"
    279 +#./userfaultfd shmem 128 32
    280 +#if [ $? -ne 0 ]; then
    281 +#	echo "[FAIL]"
    282 +#	exitcode=1
    283 +#else
    284 +#	echo "[PASS]"
    285 +#fi
    286 +#
    287 +##cleanup
    288 +#umount $mnt
    289 +#rm -rf $mnt
    290 +#echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
    291 +#
    292 +#echo "-----------------------"
    293 +#echo "running compaction_test"
    294 +#echo "-----------------------"
    295 +#./compaction_test
    296 +#if [ $? -ne 0 ]; then
    297 +#	echo "[FAIL]"
    298 +#	exitcode=1
    299 +#else
    300 +#	echo "[PASS]"
    301 +#fi
    302  
    303  echo "----------------------"
    304  echo "running on-fault-limit"
    305  echo "----------------------"
    306 -sudo -u nobody ./on-fault-limit
    307 +# Android does not have sudo
    308 +# sudo -u nobody ./on-fault-limit
    309 +su nobody ./on-fault-limit
    310  if [ $? -ne 0 ]; then
    311  	echo "[FAIL]"
    312  	exitcode=1
    313 @@ -168,12 +172,16 @@ fi
    314  echo "-----------------------------"
    315  echo "running virtual_address_range"
    316  echo "-----------------------------"
    317 -./virtual_address_range
    318 -if [ $? -ne 0 ]; then
    319 -	echo "[FAIL]"
    320 -	exitcode=1
    321 -else
    322 -	echo "[PASS]"
    323 +# Android VTS will run a 32-bit suite where
    324 +# the virtual_address_range test will not exist.
    325 +if [ -x ./virtual_address_range ]
    326 +then
    327 +	./virtual_address_range
    328 +	if [ $? -ne 0 ]; then
    329 +		echo "[FAIL]"
    330 +		exitcode=1
    331 +	else
    332 +		echo "[PASS]"
    333 +	fi
    334  fi
    335 -
    336  exit $exitcode
    337 -- 
    338 2.16.0.rc1.238.g530d649a79-goog
    339 
    340