blob: 5774977978764225f4f6efc56783f53320dfcaae [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 &
53 cpu_pid=$(ps | grep heat_cpu| awk '{print $1}')
zhanghongbo4dbc9772012-05-11 15:07:56 +080054 test -z $cpu_pid && cpu_pid=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053055 check "start cpu heat binary" "test $cpu_pid -ne 0"
Hongbo Zhangd85f7bd2013-02-06 11:09:31 +080056 test $cpu_pid -eq 0 && return
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053057
Hongbo Zhang40807512013-01-09 15:01:11 +080058 start_glmark2
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053059
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080060 index=0
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080061
62 trip_point_temps=$(ls $thermal_zone_path | grep "trip_point_['$MAX_ZONE']_temp")
63
64 for trip in $trip_point_temps; do
65 trip_value=0
66 eval $trip_cross_array$index=$trip_value
67 eval export $trip_cross_array$index
68 index=$((index + 1))
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053069 done
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080070
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053071 while (test $count -lt $TEST_LOOP); do
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080072 index=0
73 sleep 1
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053074
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080075 for trip in $trip_point_temps; do
76 cur_temp=$(cat $thermal_zone_path/temp)
77 trip_temp=$(cat $thermal_zone_path/$trip)
78
79 if [ $cur_temp -gt $trip_temp ]; then
80 value=$(eval echo \$$trip_cross_array$index)
81 value=$((value + 1))
82 eval $trip_cross_array$index=$value
83 eval export $trip_cross_array$index
84 fi
85
86 index=$((index + 1))
87 done
88
89 count=$((count + 1))
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053090 done
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053091
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080092 index=0
93 for trip in $trip_point_temps; do
94 get_trip_id $trip
95 trip_id=$?
96 trip_type=$(cat $thermal_zone_path/trip_point_"$trip_id"_type)
97 trip_temp=$(cat $thermal_zone_path/$trip)
98
99 if [ $trip_type != "critical" ]; then
100 count=$(eval echo \$$trip_cross_array$index)
101 check "$trip:$trip_temp crossed" "test $count -gt 0"
102 fi
103
104 index=$((index + 1))
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530105 done
106
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800107 heater_kill
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530108}
109
Lisa Nguyen5a0c2ba2015-01-27 13:57:25 -0800110trap "heater_kill; sigtrap" HUP INT TERM
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800111
Lisa Nguyend75a9832015-11-17 18:40:10 -0800112if [ -z "$thermal_zones"]; then
113 log_skip "No thermal zones found"
114else
115 for_each_thermal_zone check_trip_point_change
116fi
Sanjay Singh Rawat3bf61942013-04-10 14:06:14 +0530117test_status_show