staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / memfd / run_hugetlbfs_test.sh
blobfb633eeb029010ab28e9e5918da08d6ac59a039f
1 #!/bin/bash
2 # please run as root
4 # Kselftest framework requirement - SKIP code is 4.
5 ksft_skip=4
8 # To test memfd_create with hugetlbfs, there needs to be hpages_test
9 # huge pages free. Attempt to allocate enough pages to test.
11 hpages_test=8
14 # Get count of free huge pages from /proc/meminfo
16 while read name size unit; do
17 if [ "$name" = "HugePages_Free:" ]; then
18 freepgs=$size
20 done < /proc/meminfo
23 # If not enough free huge pages for test, attempt to increase
25 if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
26 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
27 hpages_needed=`expr $hpages_test - $freepgs`
29 if [ $UID != 0 ]; then
30 echo "Please run memfd with hugetlbfs test as root"
31 exit $ksft_skip
34 echo 3 > /proc/sys/vm/drop_caches
35 echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
36 while read name size unit; do
37 if [ "$name" = "HugePages_Free:" ]; then
38 freepgs=$size
40 done < /proc/meminfo
44 # If still not enough huge pages available, exit. But, give back any huge
45 # pages potentially allocated above.
47 if [ $freepgs -lt $hpages_test ]; then
48 # nr_hugepgs non-zero only if we attempted to increase
49 if [ -n "$nr_hugepgs" ]; then
50 echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
52 printf "Not enough huge pages available (%d < %d)\n" \
53 $freepgs $needpgs
54 exit $ksft_skip
58 # Run the hugetlbfs test
60 ./memfd_test hugetlbfs
61 ./run_fuse_test.sh hugetlbfs
64 # Give back any huge pages allocated for the test
66 if [ -n "$nr_hugepgs" ]; then
67 echo $nr_hugepgs > /proc/sys/vm/nr_hugepages