blob: 0084281e552013b656fc72614feb91c4268292a9 [file] [log] [blame]
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +05301#!/bin/bash
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
26# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_06
27
28source ../include/functions.sh
29source ../include/thermal_functions.sh
30
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"
33 exit 0
34fi
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() {
41 if [ $cpu_pid != 0 ]; then
42 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() {
48 local dirpath=$THERMAL_PATH/$1
49 local zone_name=$1
50 shift 1
51
52 local count=0
53 local cur_temp=0
54 local trip_temp=0
55 local trip_cross=
56 local trip_id=
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053057 local trip_type=0
58 local trip_type_path=0
59 $CPU_HEAT_BIN &
60 cpu_pid=$(ps | grep heat_cpu| awk '{print $1}')
zhanghongbo4dbc9772012-05-11 15:07:56 +080061 test -z $cpu_pid && cpu_pid=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053062 check "start cpu heat binary" "test $cpu_pid -ne 0"
63
Hongbo Zhang40807512013-01-09 15:01:11 +080064 start_glmark2
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053065
66 local index=0
67 for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do
68 trip_cross[$index]=0
69 index=$((index + 1))
70 done
71 while (test $count -lt $TEST_LOOP); do
72 index=0
73 sleep 1
74 for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do
75 cur_temp=$(cat $dirpath/temp)
76 trip_temp=$(cat $dirpath/$trip)
77 if [ $cur_temp -gt $trip_temp ]; then
78 trip_cross[$index]=$((${trip_cross[$index]} + 1))
79 fi
80 index=$((index + 1))
81
82 done
83 count=$((count + 1))
84 done
85 index=0
86 for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do
87 get_trip_id $trip
88 trip_id=$?
89 trip_type=$(cat $dirpath/trip_point_$((trip_id))_type)
90 trip_temp=$(cat $dirpath/$trip)
91
92 if [ $trip_type != "critical" ]; then
93 count=${trip_cross[$index]}
94 check "$trip:$trip_temp crossed" "test $count -gt 0"
95 fi
96 index=$((index + 1))
97 done
98
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080099 heater_kill
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530100}
101
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800102trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM
103
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530104for_each_thermal_zone check_trip_point_change