Lisa Nguyen | adf9df9 | 2015-01-25 18:16:45 -0800 | [diff] [blame] | 1 | #!/bin/sh |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 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 | |
Sanjay Singh Rawat | 912729b | 2013-08-21 20:18:40 +0530 | [diff] [blame] | 26 | # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/PmQaSpecification#thermal_04 |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 27 | |
Lisa Nguyen | adf9df9 | 2015-01-25 18:16:45 -0800 | [diff] [blame] | 28 | . ../include/functions.sh |
Amit Daniel Kachhap | 1fe389c | 2012-04-04 15:14:38 +0530 | [diff] [blame] | 29 | HEAT_CPU_MODERATE=../utils/heat_cpu |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 30 | pid=0 |
| 31 | |
| 32 | heater_kill() { |
Sanjay Singh Rawat | c7af87b | 2013-12-15 13:30:37 +0530 | [diff] [blame] | 33 | if [ $pid -ne 0 ]; then |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 34 | kill -9 $pid |
| 35 | fi |
| 36 | } |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 37 | |
| 38 | verify_cooling_device_temp_change() { |
Lisa Nguyen | 4e0b59a | 2015-01-25 17:46:40 -0800 | [diff] [blame] | 39 | dirpath=$THERMAL_PATH/$1 |
| 40 | cdev_name=$1 |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 41 | shift 1 |
Lisa Nguyen | ddd07af | 2015-11-17 23:15:22 -0800 | [diff] [blame] | 42 | check_for_thermal_zones |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 43 | if [ $? -ne 0 ] ; then |
Lisa Nguyen | ddd07af | 2015-11-17 23:15:22 -0800 | [diff] [blame] | 44 | log_skip "No thermal zones found." |
| 45 | return 1 |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 46 | fi |
Lisa Nguyen | ddd07af | 2015-11-17 23:15:22 -0800 | [diff] [blame] | 47 | |
| 48 | tzonepath="$THERMAL_PATH/thermal_zone0" |
Lisa Nguyen | 4e0b59a | 2015-01-25 17:46:40 -0800 | [diff] [blame] | 49 | max_state=$(cat $dirpath/max_state) |
| 50 | prev_state_val=$(cat $dirpath/cur_state) |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 51 | |
Lisa Nguyen | 4e0b59a | 2015-01-25 17:46:40 -0800 | [diff] [blame] | 52 | count=1 |
| 53 | cur_state_val=0 |
| 54 | init_temp=0 |
| 55 | final_temp=0 |
| 56 | cool_temp=0 |
Lisa Nguyen | f62f354 | 2015-01-26 17:33:03 -0800 | [diff] [blame] | 57 | $HEAT_CPU_MODERATE moderate & |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 58 | pid=$! |
Hongbo Zhang | d85f7bd | 2013-02-06 11:09:31 +0800 | [diff] [blame] | 59 | test $pid -eq 0 && return |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 60 | |
| 61 | while (test $count -le $max_state); do |
| 62 | echo 0 > $dirpath/cur_state |
| 63 | sleep 5 |
| 64 | init_temp=$(cat $tzonepath/temp) |
| 65 | |
| 66 | echo $count > $dirpath/cur_state |
| 67 | sleep 5 |
| 68 | final_temp=$(cat $tzonepath/temp) |
| 69 | cool_temp=$(($init_temp - $final_temp)) |
| 70 | check "$cdev_name:state=$count effective cool=$cool_temp "\ |
Amit Daniel Kachhap | 1fe389c | 2012-04-04 15:14:38 +0530 | [diff] [blame] | 71 | "test $cool_temp -ge 0" |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 72 | count=$((count+1)) |
| 73 | done |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 74 | heater_kill |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 75 | echo $prev_state_val > $dirpath/cur_state |
| 76 | } |
| 77 | |
Lisa Nguyen | 5a0c2ba | 2015-01-27 13:57:25 -0800 | [diff] [blame] | 78 | trap "heater_kill; sigtrap" HUP INT TERM |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 79 | |
Javi Merino | afd1557 | 2014-09-23 15:05:45 +0530 | [diff] [blame] | 80 | set_thermal_governors user_space |
| 81 | |
Amit Daniel Kachhap | f2408a6 | 2012-03-26 15:18:33 +0530 | [diff] [blame] | 82 | for_each_cooling_device verify_cooling_device_temp_change |
Javi Merino | afd1557 | 2014-09-23 15:05:45 +0530 | [diff] [blame] | 83 | |
| 84 | restore_thermal_governors |
| 85 | |
Sanjay Singh Rawat | 3bf6194 | 2013-04-10 14:06:14 +0530 | [diff] [blame] | 86 | test_status_show |