diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2017-01-13 09:36:46 +0300 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2017-01-19 20:32:15 +0300 |
commit | b03eaf8dbac5534590ec52612f789d8fb292af9c (patch) | |
tree | 8f12fccdaffa56790b0f7aa9aeeee3663c75bf72 /tools/testing/selftests/cpufreq/cpufreq.sh | |
parent | e66d5b673741cf6b7da250da9f84a165b1e4342d (diff) | |
download | linux-b03eaf8dbac5534590ec52612f789d8fb292af9c.tar.xz |
selftest: cpufreq: Add suspend/resume/hibernate support
This patch adds support to test basic suspend/resume and hibernation to
the cpufreq selftests.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing/selftests/cpufreq/cpufreq.sh')
-rwxr-xr-x | tools/testing/selftests/cpufreq/cpufreq.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/testing/selftests/cpufreq/cpufreq.sh b/tools/testing/selftests/cpufreq/cpufreq.sh index 2b8b05aaa874..1ed3832030b4 100755 --- a/tools/testing/selftests/cpufreq/cpufreq.sh +++ b/tools/testing/selftests/cpufreq/cpufreq.sh @@ -199,3 +199,43 @@ cpufreq_basic_tests() # Test all governors shuffle_governors_for_all_cpus 1 } + +# Suspend/resume +# $1: "suspend" or "hibernate", $2: loop count +do_suspend() +{ + printf "** Test: Running ${FUNCNAME[0]}: Trying $1 for $2 loops **\n\n" + + # Is the directory available + if [ ! -d $SYSFS/power/ -o ! -f $SYSFS/power/state ]; then + printf "$SYSFS/power/state not available\n" + return 1 + fi + + if [ $1 = "suspend" ]; then + filename="mem" + elif [ $1 = "hibernate" ]; then + filename="disk" + else + printf "$1 is not a valid option\n" + return 1 + fi + + if [ -n $filename ]; then + present=$(cat $SYSFS/power/state | grep $filename) + + if [ -z "$present" ]; then + printf "Tried to $1 but $filename isn't present in $SYSFS/power/state\n" + return 1; + fi + + for i in `seq 1 $2`; do + printf "Starting $1\n" + echo $filename > $SYSFS/power/state + printf "Came out of $1\n" + + printf "Do basic tests after finishing $1 to verify cpufreq state\n\n" + cpufreq_basic_tests + done + fi +} |