blob: 8f0dee720733c649cb01ae6c5e2a74d22ffe71a3 [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=$!
61
62 while (test $count -le $max_state); do
63 echo 0 > $dirpath/cur_state
64 sleep 5
65 init_temp=$(cat $tzonepath/temp)
66
67 echo $count > $dirpath/cur_state
68 sleep 5
69 final_temp=$(cat $tzonepath/temp)
70 cool_temp=$(($init_temp - $final_temp))
71 check "$cdev_name:state=$count effective cool=$cool_temp "\
Amit Daniel Kachhap1fe389c2012-04-04 15:14:38 +053072 "test $cool_temp -ge 0"
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053073 count=$((count+1))
74 done
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080075 heater_kill
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053076 echo $prev_mode_val > $tzonepath/mode
77 echo $prev_state_val > $dirpath/cur_state
78}
79
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080080trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM
81
Amit Daniel Kachhapf2408a62012-03-26 15:18:33 +053082for_each_cooling_device verify_cooling_device_temp_change