• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright (c) International Business Machines  Corp., 2008
4# Author: Matt Helsley <matthltc@us.ibm.com>
5#
6# This library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Lesser General Public
8# License as published by the Free Software Foundation; either
9# version 2.1 of the License, or (at your option) any later version.
10#
11# This library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# Lesser General Public License for more details.
15#
16# You should have received a copy of the GNU Lesser General Public
17# License along with this library; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19#
20
21#
22# This bash script tests freezer code by starting a long sleep process.
23# The sleep process is stopped and then frozen. We then thaw the process
24# after it normally would have exited.
25# We expect the process to still be around as we cleanup the test.
26#
27
28. "${CGROUPS_TESTROOT}/libcgroup_freezer"
29SETS_DEFAULTS="${TCID=stop_freeze_sleep_thaw_cont.sh} ${TST_COUNT=1} ${TST_TOTAL=1}"
30declare -r TCID
31declare -r TST_COUNT
32declare -r TST_TOTAL
33export TCID TST_COUNT TST_TOTAL
34
35running_cgroup_test
36mount_freezer && {
37make_sample_cgroup && {
38start_sample_proc && {
39
40while /bin/true ; do
41	trap 'break' ERR
42	assert_cgroup_freezer_state "THAWED" \
43			"ERROR: cgroup freezer started in non-THAWED state"
44	add_sample_proc_to_cgroup
45
46	kill -SIGSTOP $sample_proc
47	# TODO: reliably fix race between signal and assertion?
48	/bin/sleep 1
49	assert_sample_proc_stopped
50
51	issue_freeze_cmd
52	wait_until_frozen
53	assert_sample_proc_is_frozen
54
55	echo -n "INFO: Waiting until sleep command should have finished ($sample_proc) ... "
56	/bin/sleep $(($sample_sleep * 2))
57	echo "done."
58
59	issue_thaw_cmd
60	wait_until_thawed
61	assert_sample_proc_exists
62	assert_sample_proc_not_frozen
63	assert_sample_proc_stopped
64
65	kill -SIGCONT $sample_proc
66	# TODO: reliably fix race between signal and assertion?
67	/bin/sleep 1
68	assert_sample_proc_does_not_exist
69
70	# We don't need to kill the sample process.
71	sample_proc=""
72	result=$FINISHED
73	break
74done
75trap '' ERR
76cleanup_cgroup_test
77tst_resm TINFO " Cleaning up $0"
78
79# We may not need to kill the sample process.
80kill_sample_proc ; }
81rm_sample_cgroup ; }
82umount_freezer ; }
83
84# Failsafe cleanup
85cleanup_freezer || /bin/true
86
87exit $result
88