xref: /aosp_15_r20/external/ltp/testcases/kernel/power_management/runpwtests04.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker#! /bin/sh
2*49cdfc7eSAndroid Build Coastguard Worker#
3*49cdfc7eSAndroid Build Coastguard Worker# Copyright (c) International Business Machines  Corp., 2001
4*49cdfc7eSAndroid Build Coastguard Worker# Author: Nageswara R Sastry <[email protected]>
5*49cdfc7eSAndroid Build Coastguard Worker#
6*49cdfc7eSAndroid Build Coastguard Worker# This program is free software;  you can redistribute it and#or modify
7*49cdfc7eSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by
8*49cdfc7eSAndroid Build Coastguard Worker# the Free Software Foundation; either version 2 of the License, or
9*49cdfc7eSAndroid Build Coastguard Worker# (at your option) any later version.
10*49cdfc7eSAndroid Build Coastguard Worker#
11*49cdfc7eSAndroid Build Coastguard Worker# This program is distributed in the hope that it will be useful, but
12*49cdfc7eSAndroid Build Coastguard Worker# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13*49cdfc7eSAndroid Build Coastguard Worker# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14*49cdfc7eSAndroid Build Coastguard Worker# for more details.
15*49cdfc7eSAndroid Build Coastguard Worker#
16*49cdfc7eSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License
17*49cdfc7eSAndroid Build Coastguard Worker# along with this program;  if not, write to the Free Software Foundation,
18*49cdfc7eSAndroid Build Coastguard Worker# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*49cdfc7eSAndroid Build Coastguard Worker#
20*49cdfc7eSAndroid Build Coastguard Worker
21*49cdfc7eSAndroid Build Coastguard Workerexport TCID="Power_Management04"
22*49cdfc7eSAndroid Build Coastguard Workerexport TST_TOTAL=1
23*49cdfc7eSAndroid Build Coastguard Worker
24*49cdfc7eSAndroid Build Coastguard Worker. test.sh
25*49cdfc7eSAndroid Build Coastguard Worker. pm_include.sh
26*49cdfc7eSAndroid Build Coastguard Worker
27*49cdfc7eSAndroid Build Coastguard Workercheck_cpuidle_sysfs_files() {
28*49cdfc7eSAndroid Build Coastguard Worker	RC=0
29*49cdfc7eSAndroid Build Coastguard Worker	if [ -d /sys/devices/system/cpu/cpuidle ] ; then
30*49cdfc7eSAndroid Build Coastguard Worker		for files in current_governor_ro current_driver
31*49cdfc7eSAndroid Build Coastguard Worker		do
32*49cdfc7eSAndroid Build Coastguard Worker			cat /sys/devices/system/cpu/cpuidle/${files} \
33*49cdfc7eSAndroid Build Coastguard Worker				>/dev/null 2>&1
34*49cdfc7eSAndroid Build Coastguard Worker			if [ $? -ne 0 ] ; then
35*49cdfc7eSAndroid Build Coastguard Worker				echo "${0}: FAIL: cat ${files}"
36*49cdfc7eSAndroid Build Coastguard Worker				RC=1
37*49cdfc7eSAndroid Build Coastguard Worker			fi
38*49cdfc7eSAndroid Build Coastguard Worker		done
39*49cdfc7eSAndroid Build Coastguard Worker	fi
40*49cdfc7eSAndroid Build Coastguard Worker	if [ ${RC} -eq 0 ] ; then
41*49cdfc7eSAndroid Build Coastguard Worker		echo "${0}: PASS: Checking cpu idle sysfs files"
42*49cdfc7eSAndroid Build Coastguard Worker	else
43*49cdfc7eSAndroid Build Coastguard Worker		echo "${0}: FAIL: Checking cpu idle sysfs files"
44*49cdfc7eSAndroid Build Coastguard Worker	fi
45*49cdfc7eSAndroid Build Coastguard Worker	return $RC
46*49cdfc7eSAndroid Build Coastguard Worker}
47*49cdfc7eSAndroid Build Coastguard Worker
48*49cdfc7eSAndroid Build Coastguard Worker# Checking test environment
49*49cdfc7eSAndroid Build Coastguard Workercheck_arch
50*49cdfc7eSAndroid Build Coastguard Worker
51*49cdfc7eSAndroid Build Coastguard Worker# Checking cpuidle sysfs interface files
52*49cdfc7eSAndroid Build Coastguard Workerif check_cpuidle_sysfs_files ; then
53*49cdfc7eSAndroid Build Coastguard Worker	tst_resm TPASS "CPUIDLE sysfs tests passed"
54*49cdfc7eSAndroid Build Coastguard Workerelse
55*49cdfc7eSAndroid Build Coastguard Worker    tst_resm TFAIL "CPUIDLE sysfs tests failed"
56*49cdfc7eSAndroid Build Coastguard Workerfi
57*49cdfc7eSAndroid Build Coastguard Worker
58*49cdfc7eSAndroid Build Coastguard Workertst_exit
59