Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +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_04 |
| 27 | |
| 28 | source ../include/functions.sh |
| 29 | source ../include/thermal_functions.sh |
Amit Daniel Kachhap | 1fe389c | 2012-04-04 15:14:38 +0530 | [diff] [blame] | 30 | HEAT_CPU_MODERATE=../utils/heat_cpu |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame^] | 31 | pid=0 |
| 32 | |
| 33 | heater_kill() { |
| 34 | if [ $pid != 0 ]; then |
| 35 | kill -9 $pid |
| 36 | fi |
| 37 | } |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 38 | |
| 39 | verify_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 Kachhap | 1fe389c | 2012-04-04 15:14:38 +0530 | [diff] [blame] | 59 | ./$HEAT_CPU_MODERATE moderate & |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 60 | 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 Kachhap | 1fe389c | 2012-04-04 15:14:38 +0530 | [diff] [blame] | 72 | "test $cool_temp -ge 0" |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 73 | count=$((count+1)) |
| 74 | done |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame^] | 75 | heater_kill |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 76 | echo $prev_mode_val > $tzonepath/mode |
| 77 | echo $prev_state_val > $dirpath/cur_state |
| 78 | } |
| 79 | |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame^] | 80 | trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM |
| 81 | |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 82 | for_each_cooling_device verify_cooling_device_temp_change |