Amit Daniel Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 1 | #!/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 | |
| 28 | source ../include/functions.sh |
| 29 | source ../include/thermal_functions.sh |
| 30 | |
| 31 | CPU_HEAT_BIN=../utils/heat_cpu |
zhanghongbo | 4dbc977 | 2012-05-11 15:07:56 +0800 | [diff] [blame] | 32 | GPU_HEAT_BIN=/usr/bin/glmark2 |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame^] | 33 | cpu_pid=0 |
| 34 | gpu_pid=0 |
| 35 | |
| 36 | heater_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 Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 44 | |
| 45 | check_temperature_change() { |
| 46 | local dirpath=$THERMAL_PATH/$1 |
| 47 | local zone_name=$1 |
| 48 | shift 1 |
| 49 | |
Amit Daniel Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 50 | local init_temp=$(cat $dirpath/temp) |
| 51 | $CPU_HEAT_BIN & |
| 52 | cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') |
zhanghongbo | 4dbc977 | 2012-05-11 15:07:56 +0800 | [diff] [blame] | 53 | test -z $cpu_pid && cpu_pid=0 |
Amit Daniel Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 54 | check "start cpu heat binary" "test $cpu_pid -ne 0" |
| 55 | |
zhanghongbo | 4dbc977 | 2012-05-11 15:07:56 +0800 | [diff] [blame] | 56 | 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 Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 63 | check "start gpu heat binary" "test $gpu_pid -ne 0" |
zhanghongbo | 4dbc977 | 2012-05-11 15:07:56 +0800 | [diff] [blame] | 64 | |
Amit Daniel Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 65 | sleep 5 |
| 66 | local final_temp=$(cat $dirpath/temp) |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame^] | 67 | heater_kill |
Amit Daniel Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 68 | check "temperature variation with load" "test $final_temp -gt $init_temp" |
| 69 | } |
| 70 | |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame^] | 71 | trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM |
| 72 | |
Amit Daniel Kachhap | e9e5010 | 2012-03-26 16:38:23 +0530 | [diff] [blame] | 73 | for_each_thermal_zone check_temperature_change |