• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright (c) International Business Machines  Corp., 2009
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 frozen. We then thaw the process before it exits.
24# We expect the process to still be alive as we cleanup the test.
25#
26
27SETS_DEFAULTS="${CGROUPS_TESTROOT=..} ${TCID=fork_freeze.sh} ${TST_COUNT=1} ${TST_TOTAL=1}"
28. "${CGROUPS_TESTROOT}/libcgroup_freezer"
29. "${CGROUPS_TESTROOT}/libltp"
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 "${CGROUPS_TESTROOT}/timed_forkbomb" 4 && {
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	echo "go" >> /proc/$sample_proc/fd/0
46	sleep "0.5s"
47	issue_freeze_cmd
48	wait_until_frozen
49	assert_sample_proc_is_frozen
50
51	issue_thaw_cmd
52	wait_until_thawed
53	assert_sample_proc_not_frozen
54
55	sleep 4
56
57	result=$FINISHED
58	break
59done
60trap '' ERR
61cleanup_cgroup_test
62tst_resm TINFO " Cleaning up $0"
63
64# We need to kill the sample process.
65kill_sample_proc ; }
66rm_sample_cgroup ; }
67umount_freezer ; }
68
69# Failsafe cleanup
70cleanup_freezer || /bin/true
71
72exit $result
73