xref: /aosp_15_r20/external/ltp/testcases/kernel/power_management/runpwtests02.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_Management02"
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_smt() {
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	2000000000000000000000000000000000000000000000000000000000000000000000
33*49cdfc7eSAndroid Build Coastguard Worker	ox324 -0xfffffffffffffffffffff"
34*49cdfc7eSAndroid Build Coastguard Worker	test_file="/sys/devices/system/cpu/sched_smt_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	echo "${0}: ---Valid test cases---"
40*49cdfc7eSAndroid Build Coastguard Worker	check_input "${valid_input}" valid $test_file
41*49cdfc7eSAndroid Build Coastguard Worker	RC=$?
42*49cdfc7eSAndroid Build Coastguard Worker	echo "${0}: ---Invalid test cases---"
43*49cdfc7eSAndroid Build Coastguard Worker	check_input "${invalid_input}" invalid $test_file
44*49cdfc7eSAndroid Build Coastguard Worker	RC=$(( RC | $? ))
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# Check sched_smt_power_savings interface on HT machines
52*49cdfc7eSAndroid Build Coastguard Workerhyper_threaded=$(is_hyper_threaded)
53*49cdfc7eSAndroid Build Coastguard Workerif [ ! -f /sys/devices/system/cpu/sched_smt_power_savings ] ; then
54*49cdfc7eSAndroid Build Coastguard Worker	tst_brkm TCONF "Required kernel configuration for SCHED_SMT NOT set"
55*49cdfc7eSAndroid Build Coastguard Workerelse
56*49cdfc7eSAndroid Build Coastguard Worker	if [ $hyper_threaded -ne 0 ]; then
57*49cdfc7eSAndroid Build Coastguard Worker		tst_brkm TCONF "sched_smt_power_saving interface in system" \
58*49cdfc7eSAndroid Build Coastguard Worker			"not hyper-threaded"
59*49cdfc7eSAndroid Build Coastguard Worker	fi
60*49cdfc7eSAndroid Build Coastguard Workerfi
61*49cdfc7eSAndroid Build Coastguard Worker
62*49cdfc7eSAndroid Build Coastguard Workerif test_sched_smt ; then
63*49cdfc7eSAndroid Build Coastguard Worker	tst_resm TPASS "SCHED_SMT sysfs test"
64*49cdfc7eSAndroid Build Coastguard Workerelse
65*49cdfc7eSAndroid Build Coastguard Worker	tst_resm TFAIL "SCHED_SMT sysfs test"
66*49cdfc7eSAndroid Build Coastguard Workerfi
67*49cdfc7eSAndroid Build Coastguard Worker
68*49cdfc7eSAndroid Build Coastguard Workertst_exit
69