1f08c3bdfSopenharmony_ci#!/bin/bash
2f08c3bdfSopenharmony_ci
3f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines  Corp., 2008
4f08c3bdfSopenharmony_ci# Author: Matt Helsley <matthltc@us.ibm.com>
5f08c3bdfSopenharmony_ci#
6f08c3bdfSopenharmony_ci# This library is free software; you can redistribute it and/or
7f08c3bdfSopenharmony_ci# modify it under the terms of the GNU Lesser General Public
8f08c3bdfSopenharmony_ci# License as published by the Free Software Foundation; either
9f08c3bdfSopenharmony_ci# version 2.1 of the License, or (at your option) any later version.
10f08c3bdfSopenharmony_ci#
11f08c3bdfSopenharmony_ci# This library is distributed in the hope that it will be useful,
12f08c3bdfSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of
13f08c3bdfSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14f08c3bdfSopenharmony_ci# Lesser General Public License for more details.
15f08c3bdfSopenharmony_ci#
16f08c3bdfSopenharmony_ci# You should have received a copy of the GNU Lesser General Public
17f08c3bdfSopenharmony_ci# License along with this library; if not, write to the Free Software
18f08c3bdfSopenharmony_ci# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19f08c3bdfSopenharmony_ci#
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_ci#
22f08c3bdfSopenharmony_ci# Freeze the cgroup and then make sure that writing "FREEZING" into
23f08c3bdfSopenharmony_ci# freezer.state reports an error (EIO) and doesn't change the freezer's state
24f08c3bdfSopenharmony_ci# (which was "FROZEN").
25f08c3bdfSopenharmony_ci#
26f08c3bdfSopenharmony_ci
27f08c3bdfSopenharmony_ci. "${CGROUPS_TESTROOT}/libcgroup_freezer"
28f08c3bdfSopenharmony_ciSETS_DEFAULTS="${TCID=freeze_write_freezing.sh} ${TST_COUNT=1} ${TST_TOTAL=1}"
29f08c3bdfSopenharmony_cideclare -r TCID
30f08c3bdfSopenharmony_cideclare -r TST_COUNT
31f08c3bdfSopenharmony_cideclare -r TST_TOTAL
32f08c3bdfSopenharmony_ciexport TCID TST_COUNT TST_TOTAL
33f08c3bdfSopenharmony_ci
34f08c3bdfSopenharmony_cirunning_cgroup_test
35f08c3bdfSopenharmony_cimount_freezer && {
36f08c3bdfSopenharmony_cimake_sample_cgroup && {
37f08c3bdfSopenharmony_ci
38f08c3bdfSopenharmony_ciwhile /bin/true ; do
39f08c3bdfSopenharmony_ci	trap 'break' ERR
40f08c3bdfSopenharmony_ci	assert_cgroup_freezer_state "THAWED" \
41f08c3bdfSopenharmony_ci			"ERROR: cgroup freezer started in non-THAWED state"
42f08c3bdfSopenharmony_ci	issue_freeze_cmd
43f08c3bdfSopenharmony_ci	wait_until_frozen
44f08c3bdfSopenharmony_ci	"${CG_FILE_WRITE}" "FREEZING" > freezer.state 2>&1 | \
45f08c3bdfSopenharmony_ci		grep -E 'Input/output error$'
46f08c3bdfSopenharmony_ci	assert_cgroup_freezer_state "FROZEN" "ERROR: writing FREEZING to freezer.state should not change freezer state from FROZEN (expected IO error)"
47f08c3bdfSopenharmony_ci	result=$FINISHED
48f08c3bdfSopenharmony_ci	break
49f08c3bdfSopenharmony_cidone
50f08c3bdfSopenharmony_citrap '' ERR
51f08c3bdfSopenharmony_cicleanup_cgroup_test
52f08c3bdfSopenharmony_citst_resm TINFO " Cleaning up $0"
53f08c3bdfSopenharmony_ci
54f08c3bdfSopenharmony_cirm_sample_cgroup ; }
55f08c3bdfSopenharmony_ciumount_freezer ; }
56f08c3bdfSopenharmony_ci
57f08c3bdfSopenharmony_ci# Failsafe cleanup
58f08c3bdfSopenharmony_cicleanup_freezer || /bin/true
59f08c3bdfSopenharmony_ci
60f08c3bdfSopenharmony_ciexit $result
61