memcg_stat_test.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #! /bin/sh
  2. ################################################################################
  3. ## ##
  4. ## Copyright (c) 2012 FUJITSU LIMITED ##
  5. ## ##
  6. ## This program is free software; you can redistribute it and#or modify ##
  7. ## it under the terms of the GNU General Public License as published by ##
  8. ## the Free Software Foundation; either version 2 of the License, or ##
  9. ## (at your option) any later version. ##
  10. ## ##
  11. ## This program is distributed in the hope that it will be useful, but ##
  12. ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
  13. ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
  14. ## for more details. ##
  15. ## ##
  16. ## You should have received a copy of the GNU General Public License ##
  17. ## along with this program; if not, write to the Free Software ##
  18. ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
  19. ## ##
  20. ################################################################################
  21. #
  22. # File : memcg_stat_test.sh
  23. # Description: Tests memory.stat.
  24. # Author: Peng Haitao <penght@cn.fujitsu.com>
  25. # History: 2012/01/16 - Created.
  26. #
  27. TCID="memcg_stat_test"
  28. TST_TOTAL=8
  29. . memcg_lib.sh
  30. # Test cache
  31. testcase_1()
  32. {
  33. test_mem_stat "--shm -k 3" $PAGESIZES $PAGESIZES "cache" $PAGESIZES false
  34. }
  35. # Test mapped_file
  36. testcase_2()
  37. {
  38. test_mem_stat "--mmap-file" $PAGESIZES $PAGESIZES \
  39. "mapped_file" $PAGESIZES false
  40. }
  41. # Test unevictable with MAP_LOCKED
  42. testcase_3()
  43. {
  44. test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE \
  45. "unevictable" $PAGESIZE false
  46. }
  47. # Test unevictable with mlock
  48. testcase_4()
  49. {
  50. test_mem_stat "--mmap-lock2" $PAGESIZE $PAGESIZE \
  51. "unevictable" $PAGESIZE false
  52. }
  53. # Test hierarchical_memory_limit with enabling hierarchical accounting
  54. testcase_5()
  55. {
  56. echo 1 > memory.use_hierarchy
  57. mkdir subgroup
  58. echo $PAGESIZE > memory.limit_in_bytes
  59. echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
  60. cd subgroup
  61. check_mem_stat "hierarchical_memory_limit" $PAGESIZE
  62. cd ..
  63. rmdir subgroup
  64. }
  65. # Test hierarchical_memory_limit with disabling hierarchical accounting
  66. testcase_6()
  67. {
  68. echo 0 > memory.use_hierarchy
  69. mkdir subgroup
  70. echo $PAGESIZE > memory.limit_in_bytes
  71. echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
  72. cd subgroup
  73. check_mem_stat "hierarchical_memory_limit" $((PAGESIZE*2))
  74. cd ..
  75. rmdir subgroup
  76. }
  77. # Test hierarchical_memsw_limit with enabling hierarchical accounting
  78. testcase_7()
  79. {
  80. if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
  81. tst_resm TCONF "mem+swap is not enabled"
  82. return
  83. fi
  84. echo 1 > memory.use_hierarchy
  85. mkdir subgroup
  86. echo $PAGESIZE > memory.limit_in_bytes
  87. echo $PAGESIZE > memory.memsw.limit_in_bytes
  88. echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
  89. echo $((PAGESIZE*2)) > subgroup/memory.memsw.limit_in_bytes
  90. cd subgroup
  91. check_mem_stat "hierarchical_memsw_limit" $PAGESIZE
  92. cd ..
  93. rmdir subgroup
  94. }
  95. # Test hierarchical_memsw_limit with disabling hierarchical accounting
  96. testcase_8()
  97. {
  98. if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
  99. tst_resm TCONF "mem+swap is not enabled"
  100. return
  101. fi
  102. echo 0 > memory.use_hierarchy
  103. mkdir subgroup
  104. echo $PAGESIZE > memory.limit_in_bytes
  105. echo $PAGESIZE > memory.memsw.limit_in_bytes
  106. echo $((PAGESIZE*2)) > subgroup/memory.limit_in_bytes
  107. echo $((PAGESIZE*2)) > subgroup/memory.memsw.limit_in_bytes
  108. cd subgroup
  109. check_mem_stat "hierarchical_memsw_limit" $((PAGESIZE*2))
  110. cd ..
  111. rmdir subgroup
  112. }
  113. run_tests
  114. tst_exit