Torez Smith | 5c7211d | 2011-03-10 10:20:25 -0600 | [diff] [blame] | 1 | #!/bin/bash |
Daniel Lezcano | 48839cd | 2011-07-21 14:23:44 +0200 | [diff] [blame] | 2 | # |
Daniel Lezcano | 35fb172 | 2011-10-03 13:56:11 +0200 | [diff] [blame^] | 3 | # PM-QA validation test suite for the power management on Linux |
Daniel Lezcano | 48839cd | 2011-07-21 14:23:44 +0200 | [diff] [blame] | 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 | # Torez Smith <torez.smith@linaro.org> (IBM Corporation) |
| 23 | # - initial API and implementation |
| 24 | # |
Torez Smith | 5c7211d | 2011-03-10 10:20:25 -0600 | [diff] [blame] | 25 | |
| 26 | ### |
| 27 | # Track how much time it takes to cycle through a loop 1000 times at this current frequency |
| 28 | ### |
| 29 | loop_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 | ### |
| 40 | echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor |
| 41 | if [ $? != 0 ]; then |
| 42 | echo "FAIL could not change governor to userspace, remained `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`" |
| 43 | exit -1 |
| 44 | fi |
| 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 | ### |
| 52 | for LOOP_FREQ in `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies` |
| 53 | do |
| 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 |
| 65 | done |
| 66 | |
| 67 | echo PASS |
| 68 | |