memcg_memsw_limit_in_bytes_test.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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_memsw_limit_in_bytes_test.sh
  23. # Description: Tests memory.memsw.limit_in_bytes.
  24. # Author: Peng Haitao <penght@cn.fujitsu.com>
  25. # History: 2012/01/3 - Created.
  26. #
  27. TCID="memcg_memsw_limit_in_bytes_test"
  28. TST_TOTAL=12
  29. . memcg_lib.sh
  30. testcase_1()
  31. {
  32. test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 1
  33. }
  34. testcase_2()
  35. {
  36. test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 1
  37. }
  38. testcase_3()
  39. {
  40. test_proc_kill 0 "--mmap-anon" $PAGESIZE 1
  41. }
  42. testcase_4()
  43. {
  44. test_proc_kill 0 "--mmap-file" $PAGESIZE 1
  45. }
  46. testcase_5()
  47. {
  48. test_proc_kill 0 "--shm -k 21" $PAGESIZE 1
  49. }
  50. testcase_6()
  51. {
  52. test_limit_in_bytes $((PAGESIZE-1)) 1
  53. }
  54. testcase_7()
  55. {
  56. test_limit_in_bytes $((PAGESIZE+1)) 1
  57. }
  58. testcase_8()
  59. {
  60. test_limit_in_bytes 1 1
  61. }
  62. testcase_9()
  63. {
  64. if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
  65. tst_resm TCONF "mem+swap is not enabled"
  66. return
  67. fi
  68. echo 10M > memory.limit_in_bytes
  69. if tst_kvcmp -lt "2.6.31"; then
  70. EXPECT_FAIL echo -1 \> memory.memsw.limit_in_bytes
  71. else
  72. EXPECT_PASS echo -1 \> memory.memsw.limit_in_bytes
  73. fi
  74. }
  75. testcase_10()
  76. {
  77. if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
  78. tst_resm TCONF "mem+swap is not enabled"
  79. return
  80. fi
  81. echo 10M > memory.limit_in_bytes
  82. EXPECT_FAIL echo 1.0 \> memory.memsw.limit_in_bytes
  83. }
  84. testcase_11()
  85. {
  86. if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
  87. tst_resm TCONF "mem+swap is not enabled"
  88. return
  89. fi
  90. echo 10M > memory.limit_in_bytes
  91. EXPECT_FAIL echo 1xx \> memory.memsw.limit_in_bytes
  92. }
  93. testcase_12()
  94. {
  95. if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
  96. tst_resm TCONF "mem+swap is not enabled"
  97. return
  98. fi
  99. echo 10M > memory.limit_in_bytes
  100. EXPECT_FAIL echo xx \> memory.memsw.limit_in_bytes
  101. }
  102. run_tests
  103. tst_exit