Lisa Nguyen | adf9df9 | 2015-01-25 18:16:45 -0800 | [diff] [blame] | 1 | #!/bin/sh |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +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_06 |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 27 | |
Lisa Nguyen | adf9df9 | 2015-01-25 18:16:45 -0800 | [diff] [blame] | 28 | . ../include/functions.sh |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 29 | |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 30 | TEST_LOOP=100 |
Hongbo Zhang | 4080751 | 2013-01-09 15:01:11 +0800 | [diff] [blame] | 31 | CPU_HEAT_BIN=../utils/heat_cpu |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 32 | cpu_pid=0 |
Lisa Nguyen | 15e40ff | 2015-02-02 12:30:06 -0800 | [diff] [blame] | 33 | trip_cross_array="trip_cross" |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 34 | |
| 35 | heater_kill() { |
Sanjay Singh Rawat | c7af87b | 2013-12-15 13:30:37 +0530 | [diff] [blame] | 36 | if [ $cpu_pid -ne 0 ]; then |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 37 | kill -9 $cpu_pid |
| 38 | fi |
Hongbo Zhang | 4080751 | 2013-01-09 15:01:11 +0800 | [diff] [blame] | 39 | kill_glmark2 |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 40 | } |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 41 | |
| 42 | check_trip_point_change() { |
Lisa Nguyen | 4e0b59a | 2015-01-25 17:46:40 -0800 | [diff] [blame] | 43 | zone_name=$1 |
Lisa Nguyen | 15e40ff | 2015-02-02 12:30:06 -0800 | [diff] [blame] | 44 | dirpath=$THERMAL_PATH/$zone_name |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 45 | shift 1 |
| 46 | |
Lisa Nguyen | 4e0b59a | 2015-01-25 17:46:40 -0800 | [diff] [blame] | 47 | count=0 |
| 48 | cur_temp=0 |
| 49 | trip_temp=0 |
| 50 | trip_type=0 |
| 51 | trip_type_path=0 |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 52 | $CPU_HEAT_BIN & |
Li Zhijian | 837c564 | 2017-10-17 11:02:21 +0800 | [diff] [blame] | 53 | get_os |
Lisa Nguyen | c190ca5 | 2016-07-25 21:46:51 -0700 | [diff] [blame] | 54 | if [ $? -eq 1 ]; then |
| 55 | cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') |
| 56 | else |
| 57 | cpu_pid=$(ps | grep heat_cpu| awk '{print $2}') |
| 58 | fi |
| 59 | |
zhanghongbo | 4dbc977 | 2012-05-11 15:07:56 +0800 | [diff] [blame] | 60 | test -z $cpu_pid && cpu_pid=0 |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 61 | check "start cpu heat binary" "test $cpu_pid -ne 0" |
Hongbo Zhang | d85f7bd | 2013-02-06 11:09:31 +0800 | [diff] [blame] | 62 | test $cpu_pid -eq 0 && return |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 63 | |
Hongbo Zhang | 4080751 | 2013-01-09 15:01:11 +0800 | [diff] [blame] | 64 | start_glmark2 |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 65 | |
Lisa Nguyen | 4e0b59a | 2015-01-25 17:46:40 -0800 | [diff] [blame] | 66 | index=0 |
Lisa Nguyen | 15e40ff | 2015-02-02 12:30:06 -0800 | [diff] [blame] | 67 | |
| 68 | trip_point_temps=$(ls $thermal_zone_path | grep "trip_point_['$MAX_ZONE']_temp") |
| 69 | |
| 70 | for trip in $trip_point_temps; do |
| 71 | trip_value=0 |
| 72 | eval $trip_cross_array$index=$trip_value |
| 73 | eval export $trip_cross_array$index |
| 74 | index=$((index + 1)) |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 75 | done |
Lisa Nguyen | 15e40ff | 2015-02-02 12:30:06 -0800 | [diff] [blame] | 76 | |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 77 | while (test $count -lt $TEST_LOOP); do |
Lisa Nguyen | 15e40ff | 2015-02-02 12:30:06 -0800 | [diff] [blame] | 78 | index=0 |
| 79 | sleep 1 |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 80 | |
Lisa Nguyen | 15e40ff | 2015-02-02 12:30:06 -0800 | [diff] [blame] | 81 | for trip in $trip_point_temps; do |
| 82 | cur_temp=$(cat $thermal_zone_path/temp) |
| 83 | trip_temp=$(cat $thermal_zone_path/$trip) |
| 84 | |
| 85 | if [ $cur_temp -gt $trip_temp ]; then |
| 86 | value=$(eval echo \$$trip_cross_array$index) |
| 87 | value=$((value + 1)) |
| 88 | eval $trip_cross_array$index=$value |
| 89 | eval export $trip_cross_array$index |
| 90 | fi |
| 91 | |
| 92 | index=$((index + 1)) |
| 93 | done |
| 94 | |
| 95 | count=$((count + 1)) |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 96 | done |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 97 | |
Lisa Nguyen | 15e40ff | 2015-02-02 12:30:06 -0800 | [diff] [blame] | 98 | index=0 |
| 99 | for trip in $trip_point_temps; do |
| 100 | get_trip_id $trip |
| 101 | trip_id=$? |
| 102 | trip_type=$(cat $thermal_zone_path/trip_point_"$trip_id"_type) |
| 103 | trip_temp=$(cat $thermal_zone_path/$trip) |
| 104 | |
| 105 | if [ $trip_type != "critical" ]; then |
| 106 | count=$(eval echo \$$trip_cross_array$index) |
| 107 | check "$trip:$trip_temp crossed" "test $count -gt 0" |
| 108 | fi |
| 109 | |
| 110 | index=$((index + 1)) |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 111 | done |
| 112 | |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 113 | heater_kill |
Amit Daniel Kachhap | d57a91c | 2012-03-26 17:06:54 +0530 | [diff] [blame] | 114 | } |
| 115 | |
Lisa Nguyen | 5a0c2ba | 2015-01-27 13:57:25 -0800 | [diff] [blame] | 116 | trap "heater_kill; sigtrap" HUP INT TERM |
hongbo.zhang | 9fec6ec | 2012-11-26 15:32:59 +0800 | [diff] [blame] | 117 | |
Lisa Nguyen | ddd07af | 2015-11-17 23:15:22 -0800 | [diff] [blame] | 118 | check_for_thermal_zones |
| 119 | if [ $? -ne 0 ]; then |
Lisa Nguyen | d75a983 | 2015-11-17 18:40:10 -0800 | [diff] [blame] | 120 | log_skip "No thermal zones found" |
| 121 | else |
Lisa Nguyen | cca3b38 | 2016-09-11 21:19:54 -0700 | [diff] [blame] | 122 | check_for_glmark2 |
| 123 | if [ $? -ne 0 ]; then |
| 124 | log_skip "glmark2 not found" |
| 125 | else |
| 126 | for_each_thermal_zone check_trip_point_change |
| 127 | fi |
Lisa Nguyen | d75a983 | 2015-11-17 18:40:10 -0800 | [diff] [blame] | 128 | fi |
Sanjay Singh Rawat | 3bf6194 | 2013-04-10 14:06:14 +0530 | [diff] [blame] | 129 | test_status_show |