stop_freeze_thaw_cont.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 stopped and then frozen. We then thaw the process
  22. # before it normally would have exited.
  23. # We expect the process to still be around as we cleanup the test.
  24. #
  25. . "${CGROUPS_TESTROOT}/libcgroup_freezer"
  26. SETS_DEFAULTS="${TCID=stop_freeze_thaw_cont.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. # STOP
  41. kill -SIGSTOP $sample_proc
  42. # TODO: reliably fix race between signal and assertion?
  43. assert_sample_proc_stopped
  44. # FREEZE
  45. issue_freeze_cmd
  46. wait_until_frozen
  47. assert_sample_proc_is_frozen
  48. # THAW
  49. issue_thaw_cmd
  50. wait_until_thawed
  51. assert_sample_proc_exists
  52. assert_sample_proc_not_frozen
  53. assert_sample_proc_stopped
  54. # CONTINUE
  55. kill -SIGCONT $sample_proc
  56. # TODO: reliably fix race between signal and assertion?
  57. assert_sample_proc_exists
  58. result=$FINISHED
  59. break
  60. done
  61. trap '' ERR
  62. cleanup_cgroup_test
  63. tst_resm TINFO " Cleaning up $0"
  64. # We need to stop the sample process.
  65. kill_sample_proc ; }
  66. rm_sample_cgroup ; }
  67. umount_freezer ; }
  68. # Failsafe cleanup
  69. cleanup_freezer || /bin/true
  70. exit $result