blob: 58aac43a3878d5487ddd1abd05cec229f6f23e6a [file] [log] [blame]
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +05301#!/bin/bash
2#
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
26# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_04
27
28source ../include/functions.sh
29source ../include/thermal_functions.sh
Amit Daniel Kachhap1fe389c2012-04-04 15:14:38 +053030HEAT_CPU_MODERATE=../utils/heat_cpu
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080031pid=0
32
33heater_kill() {
34 if [ $pid != 0 ]; then
35 kill -9 $pid
36 fi
37}
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053038
39verify_cooling_device_temp_change() {
40 local dirpath=$THERMAL_PATH/$1
41 local cdev_name=$1
42 shift 1
43 local tzonepath=$THERMAL_PATH/thermal_zone0
44 test -d $tzonepath
45 if [ $? -ne 0 ] ; then
46 echo "No thermal zone present"
47 return 1;
48 fi
49 local max_state=$(cat $dirpath/max_state)
50 local prev_state_val=$(cat $dirpath/cur_state)
51 local prev_mode_val=$(cat $tzonepath/mode)
52 echo -n disabled > $tzonepath/mode
53
54 local count=1
55 local cur_state_val=0
56 local init_temp=0
57 local final_temp=0
58 local cool_temp=0
Amit Daniel Kachhap1fe389c2012-04-04 15:14:38 +053059 ./$HEAT_CPU_MODERATE moderate &
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053060 pid=$!
Hongbo Zhangd85f7bd2013-02-06 11:09:31 +080061 test $pid -eq 0 && return
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053062
63 while (test $count -le $max_state); do
64 echo 0 > $dirpath/cur_state
65 sleep 5
66 init_temp=$(cat $tzonepath/temp)
67
68 echo $count > $dirpath/cur_state
69 sleep 5
70 final_temp=$(cat $tzonepath/temp)
71 cool_temp=$(($init_temp - $final_temp))
72 check "$cdev_name:state=$count effective cool=$cool_temp "\
Amit Daniel Kachhap1fe389c2012-04-04 15:14:38 +053073 "test $cool_temp -ge 0"
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053074 count=$((count+1))
75 done
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080076 heater_kill
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053077 echo $prev_mode_val > $tzonepath/mode
78 echo $prev_state_val > $dirpath/cur_state
79}
80
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080081trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM
82
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053083for_each_cooling_device verify_cooling_device_temp_change
Sanjay Singh Rawat3bf61942013-04-10 14:06:14 +053084test_status_show