blob: f10373dd2e2947a2a5d0e32a9cada089d76f4ef4 [file] [log] [blame]
Lisa Nguyenadf9df92015-01-25 18:16:45 -08001#!/bin/sh
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +05302#
3# PM-QA validation test suite for the power management on Linux
4#
5# Copyright (C) 2011, Linaro Limited.
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License
9# as published by the Free Software Foundation; either version 2
10# of the License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20#
21# Contributors:
22# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics)
23# - initial API and implementation
24#
25
Sanjay Singh Rawat912729b2013-08-21 20:18:40 +053026# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/PmQaSpecification#thermal_04
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053027
Lisa Nguyenadf9df92015-01-25 18:16:45 -080028. ../include/functions.sh
Amit Daniel Kachhap1fe389c2012-04-04 15:14:38 +053029HEAT_CPU_MODERATE=../utils/heat_cpu
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080030pid=0
31
32heater_kill() {
Sanjay Singh Rawatc7af87b2013-12-15 13:30:37 +053033 if [ $pid -ne 0 ]; then
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080034 kill -9 $pid
35 fi
36}
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053037
38verify_cooling_device_temp_change() {
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080039 dirpath=$THERMAL_PATH/$1
40 cdev_name=$1
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053041 shift 1
Lisa Nguyenddd07af2015-11-17 23:15:22 -080042 check_for_thermal_zones
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053043 if [ $? -ne 0 ] ; then
Lisa Nguyenddd07af2015-11-17 23:15:22 -080044 log_skip "No thermal zones found."
45 return 1
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053046 fi
Lisa Nguyenddd07af2015-11-17 23:15:22 -080047
48 tzonepath="$THERMAL_PATH/thermal_zone0"
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080049 max_state=$(cat $dirpath/max_state)
50 prev_state_val=$(cat $dirpath/cur_state)
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053051
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080052 count=1
53 cur_state_val=0
54 init_temp=0
55 final_temp=0
56 cool_temp=0
Lisa Nguyenf62f3542015-01-26 17:33:03 -080057 $HEAT_CPU_MODERATE moderate &
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053058 pid=$!
Hongbo Zhangd85f7bd2013-02-06 11:09:31 +080059 test $pid -eq 0 && return
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053060
61 while (test $count -le $max_state); do
62 echo 0 > $dirpath/cur_state
63 sleep 5
64 init_temp=$(cat $tzonepath/temp)
65
66 echo $count > $dirpath/cur_state
67 sleep 5
68 final_temp=$(cat $tzonepath/temp)
69 cool_temp=$(($init_temp - $final_temp))
70 check "$cdev_name:state=$count effective cool=$cool_temp "\
Amit Daniel Kachhap1fe389c2012-04-04 15:14:38 +053071 "test $cool_temp -ge 0"
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053072 count=$((count+1))
73 done
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080074 heater_kill
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053075 echo $prev_state_val > $dirpath/cur_state
76}
77
Lisa Nguyen5a0c2ba2015-01-27 13:57:25 -080078trap "heater_kill; sigtrap" HUP INT TERM
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080079
Javi Merinoafd15572014-09-23 15:05:45 +053080set_thermal_governors user_space
81
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053082for_each_cooling_device verify_cooling_device_temp_change
Javi Merinoafd15572014-09-23 15:05:45 +053083
84restore_thermal_governors
85
Sanjay Singh Rawat3bf61942013-04-10 14:06:14 +053086test_status_show