blob: b012317e84df6a03c618a9f55ba23d4ccbaf7835 [file] [log] [blame]
Torez Smith5c7211d2011-03-10 10:20:25 -06001#!/bin/bash
Daniel Lezcano48839cd2011-07-21 14:23:44 +02002#
Daniel Lezcano35fb1722011-10-03 13:56:11 +02003# PM-QA validation test suite for the power management on Linux
Daniel Lezcano48839cd2011-07-21 14:23:44 +02004#
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# Torez Smith <torez.smith@linaro.org> (IBM Corporation)
23# - initial API and implementation
24#
Torez Smith5c7211d2011-03-10 10:20:25 -060025
26###
27 # Track how much time it takes to cycle through a loop 1000 times at this current frequency
28###
29loop_it() {
30 LOOP_LIMIT=1000
31 time while ( test $LOOP_LIMIT -ge 1 ); do
32 LOOP_LIMIT=$(( $LOOP_LIMIT - 1 ))
33 done
34}
35
36
37###
38 # set governor to be user space governor which allows you to manually alter the frequency
39###
40echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
41if [ $? != 0 ]; then
42 echo "FAIL could not change governor to userspace, remained `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`"
43 exit -1
44fi
45
46
47###
48 # Now loop through, changing the cpu frequency to available frequencies. Sleep for a
49 # period of about 5 seconds each time it's set to a new frequency to allow the system
50 # to settle down.
51###
52for LOOP_FREQ in `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`
53do
54 echo $LOOP_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
55 if [ $? != 0 ]; then
56 echo "FAIL could not write freq for $LOOP_FREQ"
57 exit -1
58 fi
59 sleep 5
60 if [ `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` != $LOOP_FREQ ]; then
61 echo "FAIL could not change freq to $LOOP_FREQ remained `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`"
62 exit -1
63 fi
64 loop_it
65done
66
67echo PASS
68