blob: 57903202cfbda49308a39a7f491ede7dc1357873 [file] [log] [blame]
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +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_03
27
28source ../include/functions.sh
29source ../include/thermal_functions.sh
30
31CPU_HEAT_BIN=../utils/heat_cpu
zhanghongbo4dbc9772012-05-11 15:07:56 +080032GPU_HEAT_BIN=/usr/bin/glmark2
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080033cpu_pid=0
34gpu_pid=0
35
36heater_kill() {
37 if [ $cpu_pid != 0 ]; then
38 kill -9 $cpu_pid
39 fi
40 if [ $gpu_pid != 0 ]; then
41 kill -9 $gpu_pid
42 fi
43}
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +053044
45check_temperature_change() {
46 local dirpath=$THERMAL_PATH/$1
47 local zone_name=$1
48 shift 1
49
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +053050 local init_temp=$(cat $dirpath/temp)
51 $CPU_HEAT_BIN &
52 cpu_pid=$(ps | grep heat_cpu| awk '{print $1}')
zhanghongbo4dbc9772012-05-11 15:07:56 +080053 test -z $cpu_pid && cpu_pid=0
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +053054 check "start cpu heat binary" "test $cpu_pid -ne 0"
55
zhanghongbo4dbc9772012-05-11 15:07:56 +080056 if [ -x $GPU_HEAT_BIN ]; then
57 $GPU_HEAT_BIN &
58 gpu_pid=$(ps | grep $GPU_HEAT_BIN| awk '{print $1}')
59 test -z $gpu_pid && gpu_pid=0
60 else
61 echo "glmark2 not found." 1>&2
62 fi
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +053063 check "start gpu heat binary" "test $gpu_pid -ne 0"
zhanghongbo4dbc9772012-05-11 15:07:56 +080064
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +053065 sleep 5
66 local final_temp=$(cat $dirpath/temp)
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080067 heater_kill
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +053068 check "temperature variation with load" "test $final_temp -gt $init_temp"
69}
70
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080071trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM
72
Amit Daniel Kachhape9e50102012-03-26 16:38:23 +053073for_each_thermal_zone check_temperature_change