xref: /aosp_15_r20/external/ltp/testcases/kernel/power_management/runpwtests01.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_Management01"
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 Workertest_sched_mc() {
28*49cdfc7eSAndroid Build Coastguard Worker	get_kernel_version
29*49cdfc7eSAndroid Build Coastguard Worker	get_valid_input $kernel_version
30*49cdfc7eSAndroid Build Coastguard Worker
31*49cdfc7eSAndroid Build Coastguard Worker	invalid_input="3 4 5 6 7 8 a abcefg x1999 xffff -1 -00000
32*49cdfc7eSAndroid Build Coastguard Worker	2000000000000000000000000000000000000000000000000000000000000000000
33*49cdfc7eSAndroid Build Coastguard Worker	ox324 -0xfffffffffffffffffffff"
34*49cdfc7eSAndroid Build Coastguard Worker	test_file="/sys/devices/system/cpu/sched_mc_power_savings"
35*49cdfc7eSAndroid Build Coastguard Worker	if [ ! -f ${test_file} ] ; then
36*49cdfc7eSAndroid Build Coastguard Worker		tst_brkm TBROK "MISSING_FILE: missing file ${test_file}"
37*49cdfc7eSAndroid Build Coastguard Worker	fi
38*49cdfc7eSAndroid Build Coastguard Worker
39*49cdfc7eSAndroid Build Coastguard Worker	RC=0
40*49cdfc7eSAndroid Build Coastguard Worker	echo "${0}: ---Valid test cases---"
41*49cdfc7eSAndroid Build Coastguard Worker	check_input "${valid_input}" valid $test_file
42*49cdfc7eSAndroid Build Coastguard Worker	RC=$?
43*49cdfc7eSAndroid Build Coastguard Worker	echo "${0}: ---Invalid test cases---"
44*49cdfc7eSAndroid Build Coastguard Worker	check_input "${invalid_input}" invalid $test_file
45*49cdfc7eSAndroid Build Coastguard Worker	RC=$(( RC | $? ))
46*49cdfc7eSAndroid Build Coastguard Worker	return $RC
47*49cdfc7eSAndroid Build Coastguard Worker}
48*49cdfc7eSAndroid Build Coastguard Worker
49*49cdfc7eSAndroid Build Coastguard Worker# Checking test environment
50*49cdfc7eSAndroid Build Coastguard Workercheck_arch
51*49cdfc7eSAndroid Build Coastguard Worker
52*49cdfc7eSAndroid Build Coastguard Worker# Checking sched_mc sysfs interface
53*49cdfc7eSAndroid Build Coastguard Workermulti_socket=$(is_multi_socket)
54*49cdfc7eSAndroid Build Coastguard Workermulti_core=$(is_multi_core)
55*49cdfc7eSAndroid Build Coastguard Workerif [ ! -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
56*49cdfc7eSAndroid Build Coastguard Worker	tst_brkm TCONF "Required kernel configuration for SCHED_MC" \
57*49cdfc7eSAndroid Build Coastguard Worker		"NOT set"
58*49cdfc7eSAndroid Build Coastguard Workerelse
59*49cdfc7eSAndroid Build Coastguard Worker	if [ $multi_socket -ne 0 -a $multi_core -ne 0 ] ; then
60*49cdfc7eSAndroid Build Coastguard Worker		tst_brkm TCONF "sched_mc_power_savings interface in system" \
61*49cdfc7eSAndroid Build Coastguard Worker			"which is not a multi socket &(/) multi core"
62*49cdfc7eSAndroid Build Coastguard Worker	fi
63*49cdfc7eSAndroid Build Coastguard Workerfi
64*49cdfc7eSAndroid Build Coastguard Worker
65*49cdfc7eSAndroid Build Coastguard Workerif test_sched_mc ; then
66*49cdfc7eSAndroid Build Coastguard Worker	tst_resm TPASS "SCHED_MC sysfs tests"
67*49cdfc7eSAndroid Build Coastguard Workerelse
68*49cdfc7eSAndroid Build Coastguard Worker	tst_resm TFAIL "SCHED_MC sysfs tests"
69*49cdfc7eSAndroid Build Coastguard Workerfi
70*49cdfc7eSAndroid Build Coastguard Worker
71*49cdfc7eSAndroid Build Coastguard Workertst_exit
72