freeze_cancel.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. # Copyright (c) International Business Machines Corp., 2008
  3. # Author: Matt Helsley <matthltc@us.ibm.com>
  4. #
  5. # This library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2.1 of the License, or (at your option) any later version.
  9. #
  10. # This library is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public
  16. # License along with this library; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. #
  20. # This bash script tests freezer code by starting a long sleep process.
  21. # We initially try to freeze the cgroup but then try to cancel that.
  22. # After we cancel the sleep process should eventually reach the thawed state.
  23. # We expect the process to still be alive as we cleanup the test.
  24. #
  25. . "${CGROUPS_TESTROOT}/libcgroup_freezer"
  26. SETS_DEFAULTS="${TCID=freeze_cancel.sh} ${TST_COUNT=1} ${TST_TOTAL=1}"
  27. declare -r TCID
  28. declare -r TST_COUNT
  29. declare -r TST_TOTAL
  30. export TCID TST_COUNT TST_TOTAL
  31. running_cgroup_test
  32. mount_freezer && {
  33. make_sample_cgroup && {
  34. start_sample_proc && {
  35. while /bin/true ; do
  36. trap 'break' ERR
  37. assert_cgroup_freezer_state "THAWED" \
  38. "ERROR: cgroup freezer started in non-THAWED state"
  39. add_sample_proc_to_cgroup
  40. issue_freeze_cmd
  41. wait_until_freezing
  42. issue_thaw_cmd
  43. wait_until_thawed
  44. assert_sample_proc_not_frozen
  45. result=$FINISHED
  46. break
  47. done
  48. trap '' ERR
  49. cleanup_cgroup_test
  50. tst_resm TINFO " Cleaning up $0"
  51. # We need to kill the sample process.
  52. kill_sample_proc ; }
  53. rm_sample_cgroup ; }
  54. umount_freezer ; }
  55. # Failsafe cleanup
  56. cleanup_freezer || /bin/true
  57. exit $result