blob: 2929605fb84f2c651b82d7706e8aacc12b28efcd [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
29. ../include/thermal_functions.sh
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053030
Hongbo Zhang974802b2013-02-04 19:22:58 +080031if [ "$thermal_try_max" -eq 0 ]; then
hongbo.zhang82fbd052012-11-26 16:29:47 +080032 log_skip "test of trip points being crossed"
Lisa Nguyene2877d52014-08-04 12:30:43 -070033 return 0
hongbo.zhang82fbd052012-11-26 16:29:47 +080034fi
35
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053036TEST_LOOP=100
Hongbo Zhang40807512013-01-09 15:01:11 +080037CPU_HEAT_BIN=../utils/heat_cpu
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080038cpu_pid=0
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080039
40heater_kill() {
Sanjay Singh Rawatc7af87b2013-12-15 13:30:37 +053041 if [ $cpu_pid -ne 0 ]; then
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080042 kill -9 $cpu_pid
43 fi
Hongbo Zhang40807512013-01-09 15:01:11 +080044 kill_glmark2
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080045}
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053046
47check_trip_point_change() {
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080048 dirpath=$THERMAL_PATH/$1
49 zone_name=$1
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053050 shift 1
51
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080052 count=0
53 cur_temp=0
54 trip_temp=0
55 trip_type=0
56 trip_type_path=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053057 $CPU_HEAT_BIN &
58 cpu_pid=$(ps | grep heat_cpu| awk '{print $1}')
zhanghongbo4dbc9772012-05-11 15:07:56 +080059 test -z $cpu_pid && cpu_pid=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053060 check "start cpu heat binary" "test $cpu_pid -ne 0"
Hongbo Zhangd85f7bd2013-02-06 11:09:31 +080061 test $cpu_pid -eq 0 && return
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053062
Hongbo Zhang40807512013-01-09 15:01:11 +080063 start_glmark2
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053064
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080065 index=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053066 for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do
67 trip_cross[$index]=0
68 index=$((index + 1))
69 done
70 while (test $count -lt $TEST_LOOP); do
71 index=0
72 sleep 1
73 for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do
74 cur_temp=$(cat $dirpath/temp)
75 trip_temp=$(cat $dirpath/$trip)
76 if [ $cur_temp -gt $trip_temp ]; then
77 trip_cross[$index]=$((${trip_cross[$index]} + 1))
78 fi
79 index=$((index + 1))
80
81 done
82 count=$((count + 1))
83 done
84 index=0
85 for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do
86 get_trip_id $trip
87 trip_id=$?
88 trip_type=$(cat $dirpath/trip_point_$((trip_id))_type)
89 trip_temp=$(cat $dirpath/$trip)
90
91 if [ $trip_type != "critical" ]; then
92 count=${trip_cross[$index]}
93 check "$trip:$trip_temp crossed" "test $count -gt 0"
94 fi
95 index=$((index + 1))
96 done
97
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080098 heater_kill
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053099}
100
Lisa Nguyen5a0c2ba2015-01-27 13:57:25 -0800101trap "heater_kill; sigtrap" HUP INT TERM
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800102
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530103for_each_thermal_zone check_trip_point_change
Sanjay Singh Rawat3bf61942013-04-10 14:06:14 +0530104test_status_show