1f08c3bdfSopenharmony_ci#!/bin/bash 2f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines Corp., 2008 3f08c3bdfSopenharmony_ci# Author: Matt Helsley <matthltc@us.ibm.com> 4f08c3bdfSopenharmony_ci# 5f08c3bdfSopenharmony_ci# This library is free software; you can redistribute it and/or 6f08c3bdfSopenharmony_ci# modify it under the terms of the GNU Lesser General Public 7f08c3bdfSopenharmony_ci# License as published by the Free Software Foundation; either 8f08c3bdfSopenharmony_ci# version 2.1 of the License, or (at your option) any later version. 9f08c3bdfSopenharmony_ci# 10f08c3bdfSopenharmony_ci# This library is distributed in the hope that it will be useful, 11f08c3bdfSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 12f08c3bdfSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13f08c3bdfSopenharmony_ci# Lesser General Public License for more details. 14f08c3bdfSopenharmony_ci# 15f08c3bdfSopenharmony_ci# You should have received a copy of the GNU Lesser General Public 16f08c3bdfSopenharmony_ci# License along with this library; if not, write to the Free Software 17f08c3bdfSopenharmony_ci# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18f08c3bdfSopenharmony_ci# 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_ci#set -x 21f08c3bdfSopenharmony_ciP='ltp-cgroup-freezer' 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ciexport EXIT_GOOD=0 24f08c3bdfSopenharmony_ciexport EXIT_TERMINATE=-1 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_citrap "exit ${EXIT_TERMINATE}" ERR 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci# 30f08c3bdfSopenharmony_ci# Run tests for freezer and signal controllers 31f08c3bdfSopenharmony_ci# 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_ci # TODO add: 34f08c3bdfSopenharmony_ci #vfork_freeze.sh 35f08c3bdfSopenharmony_ci # write signal/send_invalid_sig.sh 36f08c3bdfSopenharmony_ci # write signal/read_signal.kill.sh 37f08c3bdfSopenharmony_ciFREEZER_TEST_SCRIPTS=( write_freezing.sh 38f08c3bdfSopenharmony_ci freeze_write_freezing.sh 39f08c3bdfSopenharmony_ci freeze_thaw.sh 40f08c3bdfSopenharmony_ci freeze_sleep_thaw.sh 41f08c3bdfSopenharmony_ci freeze_kill_thaw.sh 42f08c3bdfSopenharmony_ci freeze_move_thaw.sh 43f08c3bdfSopenharmony_ci freeze_cancel.sh 44f08c3bdfSopenharmony_ci freeze_self_thaw.sh 45f08c3bdfSopenharmony_ci stop_freeze_thaw_cont.sh 46f08c3bdfSopenharmony_ci stop_freeze_sleep_thaw_cont.sh 47f08c3bdfSopenharmony_ci fork_freeze.sh ) 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ciTEST_SCRIPTS=( ) 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_cifunction test_setup() 52f08c3bdfSopenharmony_ci{ 53f08c3bdfSopenharmony_ci if [ -z "${LTPROOT}" ]; then 54f08c3bdfSopenharmony_ci CGROUPS_TESTROOT="$(pwd)" 55f08c3bdfSopenharmony_ci . libltp 56f08c3bdfSopenharmony_ci else 57f08c3bdfSopenharmony_ci CGROUPS_TESTROOT="${LTPROOT}/testcases/bin" 58f08c3bdfSopenharmony_ci fi 59f08c3bdfSopenharmony_ci 60f08c3bdfSopenharmony_ci ####################################################################### 61f08c3bdfSopenharmony_ci ## Initialize some LTP variables -- Set _COUNT and _TOTAL to fake values 62f08c3bdfSopenharmony_ci ## else LTP complains. 63f08c3bdfSopenharmony_ci ####################################################################### 64f08c3bdfSopenharmony_ci TCID="$0" 65f08c3bdfSopenharmony_ci TST_COUNT=1 66f08c3bdfSopenharmony_ci TST_TOTAL=$(( ${#TEST_SCRIPTS[@]} + 0 )) 67f08c3bdfSopenharmony_ci TMPDIR="${TMPDIR:-/tmp}" 68f08c3bdfSopenharmony_ci 69f08c3bdfSopenharmony_ci export LTPBIN PATH TCID TST_COUNT TST_TOTAL CGROUPS_TESTROOT 70f08c3bdfSopenharmony_ci tst_resm TINFO "Preparing to run: ${P} $@" 71f08c3bdfSopenharmony_ci 72f08c3bdfSopenharmony_ci # this is not require here 73f08c3bdfSopenharmony_ci #make all 74f08c3bdfSopenharmony_ci} 75f08c3bdfSopenharmony_ci 76f08c3bdfSopenharmony_cifunction test_prereqs() 77f08c3bdfSopenharmony_ci{ 78f08c3bdfSopenharmony_ci cat /proc/filesystems | grep -E '\bcgroup\b' > /dev/null 2>&1 || { 79f08c3bdfSopenharmony_ci tst_resm TINFO "Kernel does not support cgroups. Skipping." 80f08c3bdfSopenharmony_ci exit ${EXIT_GOOD} # 0 81f08c3bdfSopenharmony_ci } 82f08c3bdfSopenharmony_ci 83f08c3bdfSopenharmony_ci tst_resm TINFO " Testing prereqs for cgroup freezer tests." 84f08c3bdfSopenharmony_ci if [ ! -f /proc/cgroups ]; then 85f08c3bdfSopenharmony_ci tst_resm TINFO "Tests require cgroup freezer support in the kernel." 86f08c3bdfSopenharmony_ci exit 1 87f08c3bdfSopenharmony_ci fi 88f08c3bdfSopenharmony_ci 89f08c3bdfSopenharmony_ci if [ "$(grep -w freezer /proc/cgroups | cut -f1)" != "freezer" ]; then 90f08c3bdfSopenharmony_ci tst_resm TINFO "Tests require cgroup freezer support in the kernel." 91f08c3bdfSopenharmony_ci exit 1 92f08c3bdfSopenharmony_ci fi 93f08c3bdfSopenharmony_ci 94f08c3bdfSopenharmony_ci . "${CGROUPS_TESTROOT}/libcgroup_freezer" 95f08c3bdfSopenharmony_ci 96f08c3bdfSopenharmony_ci tst_resm TINFO " It's ok if there's an ERROR before the next INFO." 97f08c3bdfSopenharmony_ci mount_freezer && umount_freezer && { 98f08c3bdfSopenharmony_ci TEST_SCRIPTS=( "${TEST_SCRIPTS[@]}" "${FREEZER_TEST_SCRIPTS[@]}" ) 99f08c3bdfSopenharmony_ci } 100f08c3bdfSopenharmony_ci tst_resm TINFO " OK, resume worrying about ERRORS." 101f08c3bdfSopenharmony_ci export TST_TOTAL=$(( ${#TEST_SCRIPTS[@]} + 0 )) 102f08c3bdfSopenharmony_ci} 103f08c3bdfSopenharmony_ci 104f08c3bdfSopenharmony_cifunction main() 105f08c3bdfSopenharmony_ci{ 106f08c3bdfSopenharmony_ci local rc=0 107f08c3bdfSopenharmony_ci 108f08c3bdfSopenharmony_ci for TEST in "${TEST_SCRIPTS[@]}" ; do 109f08c3bdfSopenharmony_ci export TCID="${TEST}" 110f08c3bdfSopenharmony_ci tst_resm TINFO " running ${TEST}" 111f08c3bdfSopenharmony_ci ((TST_COUNT++)) 112f08c3bdfSopenharmony_ci export TST_COUNT 113f08c3bdfSopenharmony_ci "${CGROUPS_TESTROOT}/${TEST}" 114f08c3bdfSopenharmony_ci rc=$? 115f08c3bdfSopenharmony_ci 116f08c3bdfSopenharmony_ci if [ $rc != 0 ]; then 117f08c3bdfSopenharmony_ci tst_resm TFAIL "${TEST} $rc" 118f08c3bdfSopenharmony_ci break 119f08c3bdfSopenharmony_ci else 120f08c3bdfSopenharmony_ci tst_resm TPASS "${TEST}" 121f08c3bdfSopenharmony_ci fi 122f08c3bdfSopenharmony_ci done 123f08c3bdfSopenharmony_ci trap '' ERR 124f08c3bdfSopenharmony_ci return $rc 125f08c3bdfSopenharmony_ci} 126f08c3bdfSopenharmony_ci 127f08c3bdfSopenharmony_citest_setup && \ 128f08c3bdfSopenharmony_citest_prereqs && \ 129f08c3bdfSopenharmony_cideclare -r TST_TOTAL && \ 130f08c3bdfSopenharmony_cimain 131f08c3bdfSopenharmony_circ=$? 132f08c3bdfSopenharmony_citrap '' ERR 133f08c3bdfSopenharmony_ciexit $rc 134