blob: 8c42fa91f698c5cfb00229a3341e86683e6b37a0 [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
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053031TEST_LOOP=100
Hongbo Zhang40807512013-01-09 15:01:11 +080032CPU_HEAT_BIN=../utils/heat_cpu
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080033cpu_pid=0
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080034trip_cross_array="trip_cross"
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080035
36heater_kill() {
Sanjay Singh Rawatc7af87b2013-12-15 13:30:37 +053037 if [ $cpu_pid -ne 0 ]; then
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080038 kill -9 $cpu_pid
39 fi
Hongbo Zhang40807512013-01-09 15:01:11 +080040 kill_glmark2
hongbo.zhang9fec6ec2012-11-26 15:32:59 +080041}
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053042
43check_trip_point_change() {
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080044 zone_name=$1
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080045 dirpath=$THERMAL_PATH/$zone_name
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053046 shift 1
47
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080048 count=0
49 cur_temp=0
50 trip_temp=0
51 trip_type=0
52 trip_type_path=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053053 $CPU_HEAT_BIN &
54 cpu_pid=$(ps | grep heat_cpu| awk '{print $1}')
zhanghongbo4dbc9772012-05-11 15:07:56 +080055 test -z $cpu_pid && cpu_pid=0
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053056 check "start cpu heat binary" "test $cpu_pid -ne 0"
Hongbo Zhangd85f7bd2013-02-06 11:09:31 +080057 test $cpu_pid -eq 0 && return
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053058
Hongbo Zhang40807512013-01-09 15:01:11 +080059 start_glmark2
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053060
Lisa Nguyen4e0b59a2015-01-25 17:46:40 -080061 index=0
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080062
63 trip_point_temps=$(ls $thermal_zone_path | grep "trip_point_['$MAX_ZONE']_temp")
64
65 for trip in $trip_point_temps; do
66 trip_value=0
67 eval $trip_cross_array$index=$trip_value
68 eval export $trip_cross_array$index
69 index=$((index + 1))
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053070 done
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080071
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053072 while (test $count -lt $TEST_LOOP); do
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080073 index=0
74 sleep 1
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053075
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080076 for trip in $trip_point_temps; do
77 cur_temp=$(cat $thermal_zone_path/temp)
78 trip_temp=$(cat $thermal_zone_path/$trip)
79
80 if [ $cur_temp -gt $trip_temp ]; then
81 value=$(eval echo \$$trip_cross_array$index)
82 value=$((value + 1))
83 eval $trip_cross_array$index=$value
84 eval export $trip_cross_array$index
85 fi
86
87 index=$((index + 1))
88 done
89
90 count=$((count + 1))
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053091 done
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +053092
Lisa Nguyen15e40ff2015-02-02 12:30:06 -080093 index=0
94 for trip in $trip_point_temps; do
95 get_trip_id $trip
96 trip_id=$?
97 trip_type=$(cat $thermal_zone_path/trip_point_"$trip_id"_type)
98 trip_temp=$(cat $thermal_zone_path/$trip)
99
100 if [ $trip_type != "critical" ]; then
101 count=$(eval echo \$$trip_cross_array$index)
102 check "$trip:$trip_temp crossed" "test $count -gt 0"
103 fi
104
105 index=$((index + 1))
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530106 done
107
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800108 heater_kill
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530109}
110
Lisa Nguyen5a0c2ba2015-01-27 13:57:25 -0800111trap "heater_kill; sigtrap" HUP INT TERM
hongbo.zhang9fec6ec2012-11-26 15:32:59 +0800112
Amit Daniel Kachhapd57a91c2012-03-26 17:06:54 +0530113for_each_thermal_zone check_trip_point_change
Sanjay Singh Rawat3bf61942013-04-10 14:06:14 +0530114test_status_show