run_tests.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # please run as root
  3. #
  4. # Normal tests requiring no special resources
  5. #
  6. ./run_fuse_test.sh
  7. ./memfd_test
  8. #
  9. # To test memfd_create with hugetlbfs, there needs to be hpages_test
  10. # huge pages free. Attempt to allocate enough pages to test.
  11. #
  12. hpages_test=8
  13. #
  14. # Get count of free huge pages from /proc/meminfo
  15. #
  16. while read name size unit; do
  17. if [ "$name" = "HugePages_Free:" ]; then
  18. freepgs=$size
  19. fi
  20. done < /proc/meminfo
  21. #
  22. # If not enough free huge pages for test, attempt to increase
  23. #
  24. if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
  25. nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
  26. hpages_needed=`expr $hpages_test - $freepgs`
  27. echo 3 > /proc/sys/vm/drop_caches
  28. echo $(( $hpages_needed + $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. fi
  39. #
  40. # If still not enough huge pages available, exit. But, give back any huge
  41. # pages potentially allocated above.
  42. #
  43. if [ $freepgs -lt $hpages_test ]; then
  44. # nr_hugepgs non-zero only if we attempted to increase
  45. if [ -n "$nr_hugepgs" ]; then
  46. echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
  47. fi
  48. printf "Not enough huge pages available (%d < %d)\n" \
  49. $freepgs $needpgs
  50. exit 1
  51. fi
  52. #
  53. # Run the hugetlbfs test
  54. #
  55. ./memfd_test hugetlbfs
  56. ./run_fuse_test.sh hugetlbfs
  57. #
  58. # Give back any huge pages allocated for the test
  59. #
  60. if [ -n "$nr_hugepgs" ]; then
  61. echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
  62. fi