freeze_thaw.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. # The sleep process is frozen. We then thaw the process before it exits.
  22. # We expect the process to still be alive as we cleanup the test.
  23. #
  24. . "${CGROUPS_TESTROOT}/libcgroup_freezer"
  25. SETS_DEFAULTS="${TCID=freeze_thaw.sh} ${TST_COUNT=1} ${TST_TOTAL=1}"
  26. declare -r TCID
  27. declare -r TST_COUNT
  28. declare -r TST_TOTAL
  29. export TCID TST_COUNT TST_TOTAL
  30. running_cgroup_test
  31. mount_freezer && {
  32. make_sample_cgroup && {
  33. start_sample_proc && {
  34. while /bin/true ; do
  35. trap 'break' ERR
  36. assert_cgroup_freezer_state "THAWED" \
  37. "ERROR: cgroup freezer started in non-THAWED state"
  38. add_sample_proc_to_cgroup
  39. issue_freeze_cmd
  40. wait_until_frozen
  41. assert_sample_proc_is_frozen
  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