blob: 6fdc469ec4cfaae35421f16773add803ac1f5e5f [file] [log] [blame]
Lisa Nguyenadf9df92015-01-25 18:16:45 -08001#!/bin/sh
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +05302#
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 Rawat912729b2013-08-21 20:18:40 +053026# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/PmQaSpecification#thermal_06
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053027
Lisa Nguyenadf9df92015-01-25 18:16:45 -080028. ../include/functions.sh
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053029
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053030TEST_LOOP=100
Hongbo Zhang40807512013-01-09 15:01:11 +080031CPU_HEAT_BIN=../utils/heat_cpu
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080032cpu_pid=0
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080033trip_cross_array="trip_cross"
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080034
35heater_kill() {
Sanjay Singh Rawatc7af87b2013-12-15 13:30:37 +053036 if [ $cpu_pid -ne 0 ]; then
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080037 kill -9 $cpu_pid
38 fi
Hongbo Zhang40807512013-01-09 15:01:11 +080039 kill_glmark2
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080040}
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053041
42check_trip_point_change() {
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080043 zone_name=$1
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080044 dirpath=$THERMAL_PATH/$zone_name
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053045 shift 1
46
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080047 count=0
48 cur_temp=0
49 trip_temp=0
50 trip_type=0
51 trip_type_path=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053052 $CPU_HEAT_BIN &
Li Zhijian837c5642017-10-17 11:02:21 +080053 get_os
Lisa Nguyenc190ca52016-07-25 21:46:51 -070054 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
zhanghongbo4dbc9772012-05-11 15:07:56 +080060 test -z $cpu_pid && cpu_pid=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053061 check "start cpu heat binary" "test $cpu_pid -ne 0"
Hongbo Zhangd85f7bd2013-02-06 11:09:31 +080062 test $cpu_pid -eq 0 && return
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053063
Hongbo Zhang40807512013-01-09 15:01:11 +080064 start_glmark2
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053065
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080066 index=0
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080067
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 Kachhapd57a91c2012-03-26 17:06:54 +053075 done
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080076
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053077 while (test $count -lt $TEST_LOOP); do
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080078 index=0
79 sleep 1
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053080
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080081 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 Kachhapd57a91c2012-03-26 17:06:54 +053096 done
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053097
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080098 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 Kachhapd57a91c2012-03-26 17:06:54 +0530111 done
112
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800113 heater_kill
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530114}
115
Lisa Nguyen5a0c2ba2015-01-27 13:57:25 -0800116trap "heater_kill; sigtrap" HUP INT TERM
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800117
Lisa Nguyenddd07af2015-11-17 23:15:22 -0800118check_for_thermal_zones
119if [ $? -ne 0 ]; then
Lisa Nguyend75a9832015-11-17 18:40:10 -0800120 log_skip "No thermal zones found"
121else
Lisa Nguyencca3b382016-09-11 21:19:54 -0700122 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 Nguyend75a9832015-11-17 18:40:10 -0800128fi
Sanjay Singh Rawat3bf61942013-04-10 14:06:14 +0530129test_status_show