Lisa Nguyen | adf9df9 | 2015-01-25 18:16:45 -0800 | [diff] [blame] | 1 | #!/bin/sh |
Daniel Lezcano | 4b69978 | 2011-07-26 14:39:00 +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 | 4b69978 | 2011-07-26 14:39:00 +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 | # Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) |
| 23 | # - initial API and implementation |
| 24 | # |
| 25 | |
Sanjay Singh Rawat | 912729b | 2013-08-21 20:18:40 +0530 | [diff] [blame] | 26 | # URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/PmQaSpecification#cpufreq_09 |
Daniel Lezcano | 4b69978 | 2011-07-26 14:39:00 +0200 | [diff] [blame] | 27 | |
Lisa Nguyen | adf9df9 | 2015-01-25 18:16:45 -0800 | [diff] [blame] | 28 | . ../include/functions.sh |
Daniel Lezcano | 4b69978 | 2011-07-26 14:39:00 +0200 | [diff] [blame] | 29 | |
| 30 | CPUBURN=../utils/cpuburn |
| 31 | |
| 32 | check_powersave() { |
| 33 | |
Lisa Nguyen | 4e0b59a | 2015-01-25 17:46:40 -0800 | [diff] [blame] | 34 | cpu=$1 |
| 35 | minfreq=$(get_min_frequency $cpu) |
| 36 | curfreq=$(get_frequency $cpu) |
Daniel Lezcano | 4b69978 | 2011-07-26 14:39:00 +0200 | [diff] [blame] | 37 | |
| 38 | set_governor $cpu powersave |
| 39 | |
| 40 | wait_latency $cpu |
| 41 | curfreq=$(get_frequency $cpu) |
| 42 | |
Lisa Nguyen | d1e0be9 | 2015-01-27 13:57:02 -0800 | [diff] [blame] | 43 | check "'powersave' sets frequency to $(frequnit $minfreq)" "test \"$curfreq\" = \"$minfreq\"" |
Daniel Lezcano | 4b69978 | 2011-07-26 14:39:00 +0200 | [diff] [blame] | 44 | |
| 45 | $CPUBURN $cpu & |
| 46 | pid=$! |
| 47 | |
| 48 | wait_latency $cpu |
| 49 | curfreq=$(get_frequency $cpu) |
| 50 | kill $pid |
| 51 | |
Lisa Nguyen | d1e0be9 | 2015-01-27 13:57:02 -0800 | [diff] [blame] | 52 | check "'powersave' frequency $(frequnit $minfreq) is fixed" "test \"$curfreq\" = \"$minfreq\"" |
Daniel Lezcano | 4b69978 | 2011-07-26 14:39:00 +0200 | [diff] [blame] | 53 | |
| 54 | return 0 |
| 55 | } |
| 56 | |
| 57 | save_governors |
| 58 | |
hongbo.zhang | ba2cbcc | 2012-08-07 13:35:32 +0800 | [diff] [blame] | 59 | supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "powersave") |
zhanghongbo | 13a161c | 2012-08-17 19:06:33 +0800 | [diff] [blame] | 60 | if [ -z "$supported" ]; then |
hongbo.zhang | ba2cbcc | 2012-08-07 13:35:32 +0800 | [diff] [blame] | 61 | log_skip "powersave not supported" |
Lisa Nguyen | d713d63 | 2014-08-20 17:26:04 -0700 | [diff] [blame] | 62 | return 0 |
hongbo.zhang | ba2cbcc | 2012-08-07 13:35:32 +0800 | [diff] [blame] | 63 | fi |
| 64 | |
Lisa Nguyen | 5a0c2ba | 2015-01-27 13:57:25 -0800 | [diff] [blame] | 65 | trap "restore_governors; sigtrap" HUP INT TERM |
Daniel Lezcano | 4b69978 | 2011-07-26 14:39:00 +0200 | [diff] [blame] | 66 | |
| 67 | for_each_cpu check_powersave |
| 68 | |
| 69 | restore_governors |
Sanjay Singh Rawat | 3bf6194 | 2013-04-10 14:06:14 +0530 | [diff] [blame] | 70 | test_status_show |