memcg_force_empty.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. ################################################################################
  3. ## ##
  4. ## Copyright (c) 2009 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 Foundation, ##
  18. ## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
  19. ## ##
  20. ## Author: Li Zefan <lizf@cn.fujitsu.com> ##
  21. ## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com> ##
  22. ## Added memcg enable/disable functinality: Rishikesh K Rajak ##
  23. ## <risrajak@linux.vnet.ibm.com ##
  24. ## ##
  25. ################################################################################
  26. TCID="memcg_force_empty"
  27. TST_TOTAL=6
  28. . memcg_lib.sh
  29. # Test memory.force_empty
  30. testcase_1()
  31. {
  32. memcg_process --mmap-anon -s $PAGESIZE &
  33. pid=$!
  34. TST_CHECKPOINT_WAIT 0
  35. echo $pid > tasks
  36. signal_memcg_process $pid $PAGESIZE
  37. echo $pid > ../tasks
  38. # This expects that there is swap configured
  39. EXPECT_PASS echo 1 \> memory.force_empty
  40. stop_memcg_process $pid
  41. }
  42. testcase_2()
  43. {
  44. EXPECT_PASS echo 0 \> memory.force_empty
  45. }
  46. testcase_3()
  47. {
  48. EXPECT_PASS echo 1.0 \> memory.force_empty
  49. }
  50. testcase_4()
  51. {
  52. EXPECT_PASS echo 1xx \> memory.force_empty
  53. }
  54. testcase_5()
  55. {
  56. EXPECT_PASS echo xx \> memory.force_empty
  57. }
  58. testcase_6()
  59. {
  60. # writing to non-empty top mem cgroup's force_empty
  61. # should return failure
  62. EXPECT_FAIL echo 1 \> /dev/memcg/memory.force_empty
  63. }
  64. run_tests
  65. tst_exit