Merge tag 'xtensa-20180225' of git://github.com/jcmvbkbc/linux-xtensa
[cris-mirror.git] / tools / testing / selftests / memfd / run_tests.sh
blobc2d41ed81b24cc1c16c6fb3dac315341e16de31b
1 #!/bin/bash
2 # please run as root
5 # Normal tests requiring no special resources
7 ./run_fuse_test.sh
8 ./memfd_test
11 # To test memfd_create with hugetlbfs, there needs to be hpages_test
12 # huge pages free. Attempt to allocate enough pages to test.
14 hpages_test=8
17 # Get count of free huge pages from /proc/meminfo
19 while read name size unit; do
20 if [ "$name" = "HugePages_Free:" ]; then
21 freepgs=$size
23 done < /proc/meminfo
26 # If not enough free huge pages for test, attempt to increase
28 if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
29 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
30 hpages_needed=`expr $hpages_test - $freepgs`
32 echo 3 > /proc/sys/vm/drop_caches
33 echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
34 if [ $? -ne 0 ]; then
35 echo "Please run this test as root"
36 exit 1
38 while read name size unit; do
39 if [ "$name" = "HugePages_Free:" ]; then
40 freepgs=$size
42 done < /proc/meminfo
46 # If still not enough huge pages available, exit. But, give back any huge
47 # pages potentially allocated above.
49 if [ $freepgs -lt $hpages_test ]; then
50 # nr_hugepgs non-zero only if we attempted to increase
51 if [ -n "$nr_hugepgs" ]; then
52 echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
54 printf "Not enough huge pages available (%d < %d)\n" \
55 $freepgs $needpgs
56 exit 1
60 # Run the hugetlbfs test
62 ./memfd_test hugetlbfs
63 ./run_fuse_test.sh hugetlbfs
66 # Give back any huge pages allocated for the test
68 if [ -n "$nr_hugepgs" ]; then
69 echo $nr_hugepgs > /proc/sys/vm/nr_hugepages