diff options
author | Senthil Kumaran <senthil.kumaran@linaro.org> | 2013-07-09 20:41:44 +0530 |
---|---|---|
committer | Senthil Kumaran <senthil.kumaran@linaro.org> | 2013-07-09 20:41:44 +0530 |
commit | e08df618109eebb8746e01ae5f402411ad8bdc0e (patch) | |
tree | 7552daaa3fed0ab7f59e4f11ae0e08ec1c72632e /common | |
parent | dd303651fd2557610f24f3ed845267742554a53a (diff) |
Add pm-qa test definition and related scripts.
Diffstat (limited to 'common')
46 files changed, 3223 insertions, 0 deletions
diff --git a/common/pm-qa.yaml b/common/pm-qa.yaml new file mode 100644 index 0000000..abcec89 --- /dev/null +++ b/common/pm-qa.yaml @@ -0,0 +1,14 @@ +metadata: + format: "Lava-Test Test Definition 1.0" + name: pm-qa + description: "pm-qa tests." + +run: + steps: + - './common/scripts/pm-qa.sh' + +parse: + pattern: "^(?P<test_case_id>[\\w/\\.]+)\\:\\s+\\S*\\s+\\S*\\s+\\S*\\.\\.\\.\\s+(?P<result>\\w+)$" + fixupdict: + Ok: pass + Err: fail diff --git a/common/scripts/pm-qa.sh b/common/scripts/pm-qa.sh new file mode 100755 index 0000000..444826b --- /dev/null +++ b/common/scripts/pm-qa.sh @@ -0,0 +1,60 @@ +#!/system/bin/sh + +scripts_dir="/data/benchmark/pm-qa" +test_func(){ + if [ ! -d "${scripts_dir}" ]; then + echo "pm-qa=fail" + exit + fi + + mkdir /data/bin/ + cd /data/bin + + busybox ln -s -f /system/bin/busybox awk + busybox ln -s -f /system/bin/busybox basename + busybox ln -s -f /system/bin/busybox chmod + busybox ln -s -f /system/bin/busybox chown + busybox ln -s -f /system/bin/busybox cp + busybox ln -s -f /system/bin/busybox diff + busybox ln -s -f /system/bin/busybox find + busybox ln -s -f /system/bin/busybox grep + busybox ln -s -f /system/bin/busybox rm + busybox ln -s -f /system/bin/busybox seq + busybox ln -s -f /system/bin/busybox taskset + busybox ln -s -f /system/bin/busybox tee + busybox ln -s -f /system/bin/busybox printf + busybox ln -s -f /system/bin/busybox wc + + busybox ln -s -f /system/bin/fake_command command + busybox ln -s -f /system/bin/fake_sudo sudo + busybox ln -s -f /system/bin/fake_udevadm udevadm + + export PATH=/data/bin:$PATH + + cd "${scripts_dir}" + + pwd_dir=$PWD + echo $pwd + tests_dirs="cpuidle cpufreq cpuhotplug sched_mc suspend thermal utils" + + for dir in $tests_dirs; do + subDir=${pwd_dir}/$dir + if [ -d $subDir ]; then + cd $subDir + else + continue + fi + + echo `pwd` + for file in `find . -name "*.sh"`; do + path=$file + echo $path + /system/bin/sh $path + done + cd .. + done + + echo "pm-qa=pass" +} + +test_func diff --git a/common/scripts/pm-qa/Switches.sh b/common/scripts/pm-qa/Switches.sh new file mode 100644 index 0000000..cc59992 --- /dev/null +++ b/common/scripts/pm-qa/Switches.sh @@ -0,0 +1,11 @@ +# These are switches to enable/disable some tests. + +# Thermal tests +export thermal_try_max=0 + +# Suspend tests +export suspend_dbus=0 +export suspend_pmsuspend=1 +export suspend_mem=1 +export suspend_ac=0 +export suspend_power=0 diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_01.sh b/common/scripts/pm-qa/cpufreq/cpufreq_01.sh new file mode 100755 index 0000000..dd93c29 --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_01.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_01 + +source ../include/functions.sh + +FILES="scaling_available_frequencies scaling_cur_freq scaling_setspeed" + +for_each_cpu check_cpufreq_files $FILES +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_02.sh b/common/scripts/pm-qa/cpufreq/cpufreq_02.sh new file mode 100755 index 0000000..1ec725f --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_02.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_02 + +source ../include/functions.sh + +FILES="scaling_available_governors scaling_governor" + +for_each_cpu check_cpufreq_files $FILES +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_03.sh b/common/scripts/pm-qa/cpufreq/cpufreq_03.sh new file mode 100755 index 0000000..ae32fee --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_03.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_03 + +source ../include/functions.sh + +check_governor() { + + local cpu=$1 + local newgov=$2 + + shift 2 + + local oldgov=$(get_governor $cpu) + + set_governor $cpu $newgov + + check "governor change to '$newgov'" "test \"$(get_governor $cpu)\" == \"$newgov\"" + + set_governor $cpu $oldgov +} + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +for_each_cpu for_each_governor check_governor || exit 1 +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_04.sh b/common/scripts/pm-qa/cpufreq/cpufreq_04.sh new file mode 100755 index 0000000..3edf83f --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_04.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_04 + +source ../include/functions.sh + +check_frequency() { + + local cpu=$1 + local newfreq=$2 + + shift 2 + + local oldgov=$(get_governor $cpu) + local oldfreq=$(get_frequency $cpu) + + set_governor $cpu userspace + set_frequency $cpu $newfreq + + check "setting frequency '$(frequnit $newfreq)'" "test \"$(get_frequency $cpu)\" == \"$newfreq\"" + + set_frequency $cpu $oldfreq + set_governor $cpu $oldgov +} + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z "$supported" ]; then + log_skip "userspace not supported" +else + for_each_cpu for_each_frequency check_frequency || exit 1 +fi +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_05.sh b/common/scripts/pm-qa/cpufreq/cpufreq_05.sh new file mode 100755 index 0000000..a0b82f4 --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_05.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_05 + +source ../include/functions.sh + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +save_governors + +trap restore_governors SIGHUP SIGINT SIGTERM + +switch_ondemand() { + local cpu=$1 + set_governor $cpu 'ondemand' +} + +switch_conservative() { + local cpu=$1 + set_governor $cpu 'conservative' +} + +switch_userspace() { + local cpu=$1 + set_governor $cpu 'userspace' +} + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "ondemand") +if [ -z "$supported" ]; then + log_skip "ondemand not supported" +else + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + switch_ondemand $cpu + done + check "'ondemand' directory exists" "test -d $CPU_PATH/cpufreq/ondemand" +fi + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "conservative") +if [ -z "$supported" ]; then + log_skip "conservative not supported" +else + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + switch_conservative $cpu + done + check "'conservative' directory exists" "test -d $CPU_PATH/cpufreq/conservative" +fi + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z "$supported" ]; then + log_skip "userspace not supported" +else + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + switch_userspace $cpu + done + + check "'ondemand' directory is not there" "test ! -d $CPU_PATH/cpufreq/ondemand" + check "'conservative' directory is not there" "test ! -d $CPU_PATH/cpufreq/conservative" +fi + +# if more than one cpu, combine governors +nrcpus=$(ls $CPU_PATH | grep "cpu[0-9].*" | wc -l) +if [ $nrcpus > 1 ]; then + affected=$(cat $CPU_PATH/cpu0/cpufreq/affected_cpus | grep 1) + if [ -z $affected ]; then + switch_ondemand cpu0 + switch_conservative cpu1 + check "'ondemand' directory exists" "test -d $CPU_PATH/cpufreq/ondemand" + check "'conservative' directory exists" "test -d $CPU_PATH/cpufreq/conservative" + else + log_skip "combine governors not supported" + fi +fi + +restore_governors +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_06.sh b/common/scripts/pm-qa/cpufreq/cpufreq_06.sh new file mode 100755 index 0000000..08f7a6d --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_06.sh @@ -0,0 +1,124 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_06 + +source ../include/functions.sh + +CPUCYCLE=../utils/cpucycle + +compute_freq_ratio() { + + local cpu=$1 + local freq=$2 + + set_frequency $cpu $freq + + result=$($CPUCYCLE $cpu) + if [ $? != 0 ]; then + return 1 + fi + + results[$index]=$(echo "scale=3;($result / $freq)" | bc -l) + index=$((index + 1)) +} + +compute_freq_ratio_sum() { + + res=${results[$index]} + sum=$(echo "($sum + $res)" | bc -l) + index=$((index + 1)) + +} + +__check_freq_deviation() { + + res=${results[$index]} + + # compute deviation + dev=$(echo "scale=3;((( $res - $avg ) / $avg) * 100 )" | bc -l) + + # change to absolute + dev=$(echo $dev | awk '{ print ($1 >= 0) ? $1 : 0 - $1}') + + index=$((index + 1)) + + res=$(echo "($dev > 5.0)" | bc -l) + if [ "$res" = "1" ]; then + return 1 + fi + + return 0 +} + +check_freq_deviation() { + + local cpu=$1 + local freq=$2 + + check "deviation for frequency $(frequnit $freq)" __check_freq_deviation + +} + +check_deviation() { + + local cpu=$1 + + set_governor $cpu userspace + + for_each_frequency $cpu compute_freq_ratio + + index=0 + sum=0 + + for_each_frequency $cpu compute_freq_ratio_sum + + avg=$(echo "scale=3;($sum / $index)" | bc -l) + + index=0 + for_each_frequency $cpu check_freq_deviation +} + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z "$supported" ]; then + log_skip "userspace not supported" + exit 0 +fi + +save_governors +save_frequencies + +trap "restore_frequencies; restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_deviation + +restore_frequencies +restore_governors +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_07.sh b/common/scripts/pm-qa/cpufreq/cpufreq_07.sh new file mode 100755 index 0000000..516e0a7 --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_07.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_07 + +source ../include/functions.sh + +CPUBURN=../utils/cpuburn + +check_ondemand() { + + local cpu=$1 + local maxfreq=$(get_max_frequency $cpu) + local minfreq=$(get_min_frequency $cpu) + local curfreq=$(get_frequency $cpu) + local pid= + + set_governor $cpu ondemand + + # wait for a quescient point + for i in $(seq 1 10); do + + if [ "$minfreq" == "$(get_frequency $cpu)" ]; then + + $CPUBURN $cpu & + pid=$! + + sleep 1 + wait_latency $cpu + curfreq=$(get_frequency $cpu) + kill $pid + + check "'ondemand' increase frequency on load" "test \"$curfreq\" == \"$maxfreq\"" + if [ "$?" != "0" ]; then + return 1 + fi + + sleep 1 + curfreq=$(get_frequency $cpu) + + check "'ondemand' decrease frequency on idle" "test \"$curfreq\" == \"$minfreq\"" + if [ "$?" != "0" ]; then + return 1 + fi + + return 0 + fi + + sleep 1 + + done + + log_skip "can not reach a quescient point for 'ondemand'" + + return 1 +} + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "ondemand") +if [ -z "$supported" ]; then + log_skip "ondemand not supported" + exit 0 +fi + +save_governors + +trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_ondemand + +restore_governors +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_08.sh b/common/scripts/pm-qa/cpufreq/cpufreq_08.sh new file mode 100755 index 0000000..d78c191 --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_08.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_08 + +source ../include/functions.sh + +CPUBURN=../utils/cpuburn + +check_frequency() { + local cpu=$1 + local freq=$2 + local curfreq= + local pid= + + $CPUBURN $cpu & + pid=$! + + set_frequency $cpu $freq + + wait_latency $cpu + curfreq=$(get_frequency $cpu) + kill $pid + + check "'userspace' $(frequnit $freq) is fixed" "test \"$curfreq\" == \"$freq\"" + if [ "$?" != "0" ]; then + return 1 + fi + + return 0 +} + +check_userspace() { + + local cpu=$1 + local maxfreq=$(get_max_frequency $cpu) + local minfreq=$(get_min_frequency $cpu) + local curfreq=$(get_frequency $cpu) + + set_governor $cpu userspace + + for_each_frequency $cpu check_frequency $minfreq +} + +save_governors + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z "$supported" ]; then + log_skip "userspace not supported" + exit 0 +fi + +trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_userspace + +restore_governors +test_status_show diff --git a/common/scripts/pm-qa/cpufreq/cpufreq_09.sh b/common/scripts/pm-qa/cpufreq/cpufreq_09.sh new file mode 100755 index 0000000..3ffccec --- /dev/null +++ b/common/scripts/pm-qa/cpufreq/cpufreq_09.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpufreq_09 + +source ../include/functions.sh + +CPUBURN=../utils/cpuburn + +check_powersave() { + + local cpu=$1 + local minfreq=$(get_min_frequency $cpu) + local curfreq=$(get_frequency $cpu) + + set_governor $cpu powersave + + wait_latency $cpu + curfreq=$(get_frequency $cpu) + + check "'powersave' sets frequency to $(frequnit $minfreq)" "test \"$curfreq\" == \"$minfreq\"" + if [ "$?" != "0" ]; then + return 1 + fi + + $CPUBURN $cpu & + pid=$! + + wait_latency $cpu + curfreq=$(get_frequency $cpu) + kill $pid + + check "'powersave' frequency $(frequnit $minfreq) is fixed" "test \"$curfreq\" == \"$minfreq\"" + if [ "$?" != "0" ]; then + return 1 + fi + + return 0 +} + +save_governors + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "powersave") +if [ -z "$supported" ]; then + log_skip "powersave not supported" + exit 0 +fi + +trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_powersave + +restore_governors +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/1_sanity_check.sh b/common/scripts/pm-qa/cpuhotplug/1_sanity_check.sh new file mode 100755 index 0000000..e091879 --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/1_sanity_check.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : + +source ../include/functions.sh + +sanity_check() { + local ret=$(cat $CPU_PATH/offline) + if [ -z "$ret" ]; then + return 0 + else + return 1 + fi +} + +check "all cpu are online" "sanity_check" +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_01.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_01.sh new file mode 100755 index 0000000..a1dfe93 --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_01.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_01 + +source ../include/functions.sh + +FILES="online offline possible present" + +for i in $FILES; do + check_file $i $CPU_PATH || return 1 +done + +for_each_cpu check_cpuhotplug_files online +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_02.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_02.sh new file mode 100755 index 0000000..2c582cf --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_02.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_02 + +source ../include/functions.sh + +check_state() { + local cpu=$1 + local dirpath=$CPU_PATH/$1 + local state= + shift 1 + + if [ "$cpu" == "cpu0" ]; then + return 0 + fi + + set_offline $cpu + state=$(get_online $cpu) + + check "cpu is offline" "test $state -eq 0" + if [ $? -ne 0 ]; then + set_online $cpu + return 1 + fi + + set_online $cpu + state=$(get_online $cpu) + + check "cpu is online" "test $state -eq 1" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 +} + +for_each_cpu check_state +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_03.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_03.sh new file mode 100755 index 0000000..d4816ca --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_03.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_03 + +source ../include/functions.sh + +check_affinity_fails() { + local cpu=$1 + local cpuid=${cpu:3} + local dirpath=$CPU_PATH/$1 + local ret= + + if [ "$cpu" == "cpu0" ]; then + return 0 + fi + + set_offline $cpu + + taskset -c $cpuid /bin/true + ret=$? + check "setting affinity on cpu fails" "test $ret -ne 0" + + set_online $cpu + + return 0 +} + +for_each_cpu check_affinity_fails +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_04.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_04.sh new file mode 100755 index 0000000..67098e1 --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_04.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_04 + +CPUBURN=../utils/cpuburn +source ../include/functions.sh + +check_task_migrate() { + local cpu=$1 + local cpuid=${cpu:3} + local cpumask=$((1 << cpuid)) + local dirpath=$CPU_PATH/$1 + local pid= + local ret= + + if [ "$cpu" == "cpu0" ]; then + return 0 + fi + + taskset -c 0x$cpumask $CPUBURN $cpu & + pid=$! + sleep 1 # let taskset to do setaffinity before checking + + ret=$(taskset -p $pid | cut -d ':' -f 2) + ret=$(echo $ret) # remove trailing whitespace + ret=$(printf "%d" 0x$ret) + check "affinity is set" "test $cpumask -eq $ret" + + sleep 1 + set_offline $cpu + ret=$? + + check "offlining a cpu with affinity succeed" "test $ret -eq 0" + + ret=$(taskset -p $pid | cut -d ':' -f 2) + ret=$(echo $ret) + ret=$(printf "%d" 0x$ret) + check "affinity changed" "test $cpumask -ne $ret" + + kill $pid + + # in any case we set the cpu online in case of the test fails + set_online $cpu + + return 0 +} + +for_each_cpu check_task_migrate +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_05.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_05.sh new file mode 100755 index 0000000..98371d4 --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_05.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_05 + +source ../include/functions.sh + +check_procinfo() { + local cpu=$1 + local cpuid=${cpu:3} + local ret= + + if [ "$cpu" == "cpu0" ]; then + return 0 + fi + + set_offline $cpu + + TAB=$(printf "\t"); grep "processor$TAB: $cpuid" /proc/cpuinfo + ret=$? + + check "offline processor not found in cpuinfo" "test $ret -ne 0" + + set_online $cpu +} + +for_each_cpu check_procinfo +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_06.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_06.sh new file mode 100755 index 0000000..1f2641d --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_06.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_06 + +source ../include/functions.sh + +check_procinfo() { + local cpu=$1 + local cpuid=${cpu:3} + local ret= + + if [ "$cpu" == "cpu0" ]; then + return 0 + fi + + set_offline $cpu + + grep "CPU$cpuid" /proc/interrupts + ret=$? + + check "offline processor not found in interrupts" "test $ret -ne 0" + + set_online $cpu +} + +for_each_cpu check_procinfo +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_07.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_07.sh new file mode 100755 index 0000000..6486dd7 --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_07.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_07 + +source ../include/functions.sh +TMPFILE=cpuhotplug_07.tmp + +check_notification() { + local cpu=$1 + local cpuid=${cpu:3} + local pid= + local ret= + + if [ "$cpu" == "cpu0" ]; then + return 0 + fi + + # damn ! udevadm is buffering the output, we have to use a temp file + # to retrieve the output + rm -f $TMPFILE + udevadm monitor --kernel --subsystem-match=cpu > $TMPFILE & + pid=$! + + set_offline $cpu + set_online $cpu + + # let the time the notification to reach userspace + # and buffered in the file + sleep 1 + kill $pid + + grep "offline" $TMPFILE | grep -q "/devices/system/cpu/$cpu" + ret=$? + check "offline event was received" "test $ret -eq 0" + + grep "online" $TMPFILE | grep -q "/devices/system/cpu/$cpu" + ret=$? + check "online event was received" "test $ret -eq 0" + + rm -f $TMPFILE +} + +for_each_cpu check_notification +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/cpuhotplug_08.sh b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_08.sh new file mode 100755 index 0000000..d413595 --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/cpuhotplug_08.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuhotplug_08 + +source ../include/functions.sh + +function randomize() { + echo $[ ( $RANDOM % $1 ) + 1 ] +} + +random_stress() { + local cpu_present=$(cat /sys/devices/system/cpu/present | cut -d '-' -f 2) + local cpurand=$(randomize $cpu_present) + local ret= + + # randomize will in range "1-$cpu_present) so cpu0 is ignored + set_offline cpu$cpurand + ret=$? + check "cpu$cpurand is offline" "test $ret -eq 0" + + set_online cpu$cpurand + ret=$? + check "cpu$cpurand is online" "test $ret -eq 0" +} + +for i in $(seq 1 50); do random_stress || break; done +test_status_show diff --git a/common/scripts/pm-qa/cpuhotplug/z_sanity_check.sh b/common/scripts/pm-qa/cpuhotplug/z_sanity_check.sh new file mode 100755 index 0000000..c39413e --- /dev/null +++ b/common/scripts/pm-qa/cpuhotplug/z_sanity_check.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : + +source ../include/functions.sh + +sanity_check() { + local ret=$(cat $CPU_PATH/offline) + if [ -z "$ret" ]; then + return 0 + else + return 1 + fi +} + +check "all cpu are back online" "sanity_check" +test_status_show diff --git a/common/scripts/pm-qa/cpuidle/cpuidle_01.sh b/common/scripts/pm-qa/cpuidle/cpuidle_01.sh new file mode 100755 index 0000000..ec7b911 --- /dev/null +++ b/common/scripts/pm-qa/cpuidle/cpuidle_01.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuidle_01 + +source ../include/functions.sh + +STATES="desc latency name power time usage" +FILES="current_driver current_governor_ro" + +check_cpuidle_state_files() { + + local dirpath=$CPU_PATH/$1/cpuidle + shift 1 + + for i in $(ls -d $dirpath/state*); do + for j in $STATES; do + check_file $j $i || return 1 + done + done + + return 0 +} + +check_cpuidle_files() { + + local dirpath=$CPU_PATH/cpuidle + + for i in $FILES; do + check_file $i $CPU_PATH/cpuidle || return 1 + done + + return 0 +} + +check_cpuidle_files + +for_each_cpu check_cpuidle_state_files +test_status_show diff --git a/common/scripts/pm-qa/cpuidle/cpuidle_02.sh b/common/scripts/pm-qa/cpuidle/cpuidle_02.sh new file mode 100755 index 0000000..491107b --- /dev/null +++ b/common/scripts/pm-qa/cpuidle/cpuidle_02.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuidle_02 + +source ../include/functions.sh + +CPUIDLE_KILLER=./cpuidle_killer + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +check "cpuidle program runs successfully (120 secs)" "./$CPUIDLE_KILLER" +test_status_show diff --git a/common/scripts/pm-qa/cpuidle/cpuidle_03.sh b/common/scripts/pm-qa/cpuidle/cpuidle_03.sh new file mode 100755 index 0000000..25cca1b --- /dev/null +++ b/common/scripts/pm-qa/cpuidle/cpuidle_03.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cpuidle_03 + +source ../include/functions.sh + +CPUIDLE_KILLER=./cpuidle_killer + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +restore_cpus() { + for_each_cpu set_online +} + +check_cpuidle_kill() { + + if [ "$1" = "cpu0" ]; then + log_skip "skipping cpu0" + return 0 + fi + + set_offline $1 + check "cpuidle program runs successfully (120 secs)" "./$CPUIDLE_KILLER" +} + +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +trap "restore_cpus; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_cpuidle_kill +restore_cpus +test_status_show diff --git a/common/scripts/pm-qa/cpuidle/cpuidle_killer b/common/scripts/pm-qa/cpuidle/cpuidle_killer Binary files differnew file mode 100755 index 0000000..209bee3 --- /dev/null +++ b/common/scripts/pm-qa/cpuidle/cpuidle_killer diff --git a/common/scripts/pm-qa/cputopology/cputopology_01.sh b/common/scripts/pm-qa/cputopology/cputopology_01.sh new file mode 100755 index 0000000..60a11e3 --- /dev/null +++ b/common/scripts/pm-qa/cputopology/cputopology_01.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cputopology_01 + +source ../include/functions.sh + +check_physical_package_id() { + + local package_id=$CPU_PATH/$1/topology/physical_package_id + local val=$(cat $package_id) + + check "topology is enabled" "test \"$val\" != \"-1\"" +} + +for_each_cpu check_physical_package_id || exit 1 +test_status_show diff --git a/common/scripts/pm-qa/cputopology/cputopology_02.sh b/common/scripts/pm-qa/cputopology/cputopology_02.sh new file mode 100755 index 0000000..7c9a46d --- /dev/null +++ b/common/scripts/pm-qa/cputopology/cputopology_02.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#cputopology_02 + +source ../include/functions.sh + +FILES="core_id core_siblings core_siblings_list physical_package_id \ +thread_siblings thread_siblings_list" + +for_each_cpu check_topology_files $FILES +test_status_show diff --git a/common/scripts/pm-qa/include/functions.sh b/common/scripts/pm-qa/include/functions.sh new file mode 100644 index 0000000..874d2d2 --- /dev/null +++ b/common/scripts/pm-qa/include/functions.sh @@ -0,0 +1,346 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation) +# - initial API and implementation +# + +source ../Switches.sh + +CPU_PATH="/sys/devices/system/cpu" +TEST_NAME=$(basename ${0%.sh}) +PREFIX=$TEST_NAME +INC=0 +CPU= +pass_count=0 +fail_count=0 + +test_status_show() { + echo "-------- total = $(($pass_count + $fail_count))" + echo "-------- pass = $pass_count" + # report failure only if it is there + if [ $fail_count -ne 0 ] ; then + echo "-------- fail = $fail_count" + fi +} + +log_begin() { + printf "%-76s" "$TEST_NAME.$INC$CPU: $@... " + INC=$(($INC+1)) +} + +log_end() { + printf "$*\n" +} + +log_skip() { + log_begin "$@" + log_end "skip" +} + +for_each_cpu() { + + local func=$1 + shift 1 + + cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") + + for cpu in $cpus; do + INC=0 + CPU=/$cpu + $func $cpu $@ + done + + return 0 +} + +for_each_governor() { + + local cpu=$1 + local func=$2 + local dirpath=$CPU_PATH/$cpu/cpufreq + local governors=$(cat $dirpath/scaling_available_governors) + shift 2 + + for governor in $governors; do + $func $cpu $governor $@ + done + + return 0 +} + +for_each_frequency() { + + local cpu=$1 + local func=$2 + local dirpath=$CPU_PATH/$cpu/cpufreq + local frequencies=$(cat $dirpath/scaling_available_frequencies) + shift 2 + + for frequency in $frequencies; do + $func $cpu $frequency $@ + done + + return 0 +} + +set_governor() { + + local cpu=$1 + local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_governor + local newgov=$2 + + echo $newgov > $dirpath +} + +get_governor() { + + local cpu=$1 + local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_governor + + cat $dirpath +} + +wait_latency() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu/cpufreq + local latency= + local nrfreq= + + latency=$(cat $dirpath/cpuinfo_transition_latency) + if [ $? != 0 ]; then + return 1 + fi + + nrfreq=$(cat $dirpath/scaling_available_frequencies | wc -w) + if [ $? != 0 ]; then + return 1 + fi + + nrfreq=$((nrfreq + 1)) + ../utils/nanosleep $(($nrfreq * $latency)) +} + +frequnit() { + local freq=$1 + local ghz=$(echo "scale=1;($freq / 1000000)" | bc -l) + local mhz=$(echo "scale=1;($freq / 1000)" | bc -l) + + res=$(echo "($ghz > 1.0)" | bc -l) + if [ "$res" = "1" ]; then + echo $ghz GHz + return 0 + fi + + res=$(echo "($mhz > 1.0)" | bc -l) + if [ "$res" = "1" ];then + echo $mhz MHz + return 0 + fi + + echo $freq KHz +} + +set_frequency() { + + local cpu=$1 + local dirpath=$CPU_PATH/$cpu/cpufreq + local newfreq=$2 + local setfreqpath=$dirpath/scaling_setspeed + + echo $newfreq > $setfreqpath + wait_latency $cpu +} + +get_frequency() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_cur_freq + cat $dirpath +} + +get_max_frequency() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_max_freq + cat $dirpath +} + +get_min_frequency() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu/cpufreq/scaling_min_freq + cat $dirpath +} + +set_online() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + if [ "$cpu" = "cpu0" ]; then + return 0 + fi + + echo 1 > $dirpath/online +} + +set_offline() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + if [ "$cpu" = "cpu0" ]; then + return 0 + fi + + echo 0 > $dirpath/online +} + +get_online() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + cat $dirpath/online +} + +check() { + + local descr=$1 + local func=$2 + shift 2; + + log_begin "checking $descr" + + $func $@ + if [ $? != 0 ]; then + log_end "Err" + fail_count=$(($fail_count + 1)) + return 1 + fi + + log_end "Ok" + pass_count=$(($pass_count + 1)) + + return 0 +} + +check_file() { + local file=$1 + local dir=$2 + + check "'$file' exists" "test -f" $dir/$file +} + +check_cpufreq_files() { + + local dirpath=$CPU_PATH/$1/cpufreq + shift 1 + + for i in $@; do + check_file $i $dirpath || return 1 + done + + return 0 +} + +check_sched_mc_files() { + + local dirpath=$CPU_PATH + + for i in $@; do + check_file $i $dirpath || return 1 + done + + return 0 +} + +check_topology_files() { + + local dirpath=$CPU_PATH/$1/topology + shift 1 + + for i in $@; do + check_file $i $dirpath || return 1 + done + + return 0 +} + +check_cpuhotplug_files() { + + local dirpath=$CPU_PATH/$1 + shift 1 + + for i in $@; do + check_file $i $dirpath || return 1 + done + + return 0 +} + +save_governors() { + + governors_backup= + local index=0 + + for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + governors_backup[$index]=$(cat $CPU_PATH/$i/cpufreq/scaling_governor) + index=$((index + 1)) + done +} + +restore_governors() { + + local index=0 + local oldgov= + + for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + oldgov=${governors_backup[$index]} + echo $oldgov > $CPU_PATH/$i/cpufreq/scaling_governor + index=$((index + 1)) + done +} + +save_frequencies() { + + frequencies_backup= + local index=0 + local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") + local cpu= + + for cpu in $cpus; do + frequencies_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_cur_freq) + index=$((index + 1)) + done +} + +restore_frequencies() { + + local index=0 + local oldfreq= + local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") + + for cpu in $cpus; do + oldfreq=${frequencies_backup[$index]} + echo $oldfreq > $CPU_PATH/$cpu/cpufreq/scaling_setspeed + index=$((index + 1)) + done +} + +sigtrap() { + exit 255 +} diff --git a/common/scripts/pm-qa/include/suspend_functions.sh b/common/scripts/pm-qa/include/suspend_functions.sh new file mode 100644 index 0000000..f06689f --- /dev/null +++ b/common/scripts/pm-qa/include/suspend_functions.sh @@ -0,0 +1,294 @@ +#!/bin/bash +# +# Script to automate suspend / resume +# +# Copyright (C) 2008-2009 Canonical Ltd. +# +# Authors: +# Michael Frey <michael.frey@canonical.com> +# Andy Whitcroft <apw@canonical.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# +# Script to automate suspend / resume +# +# We set a RTC alarm that wakes the system back up and then sleep +# for seconds before we go back to sleep. +# +# Changelog: +# +# Version for Linaro PM-QA: +# - this script is edited and integrated into Linaro PM-QA +# - hongbo.zhang@linaro.org, March, 2012 +# + + +LOGDIR='/var/lib/pm-utils' +LOGFILE="$LOGDIR/stress.log" + +# Options Config +dry=0 +auto=1 +pm_trace=1 +timer_sleep=20 + +# root is needed to fiddle with the clock and use the rtc wakeups. +if [ $(id -u) != 0 ]; then + log_skip "run as non-root" + exit 0 +fi + +# Ensure the log directory exists. +mkdir -p "$LOGDIR" + +setup_wakeup_timer () +{ + timeout="$1" + + # Request wakeup from the RTC or ACPI alarm timers. Set the timeout + # at 'now' + $timeout seconds. + ctl='/sys/class/rtc/rtc0/wakealarm' + if [ -f "$ctl" ]; then + # Cancel any outstanding timers. + echo "0" >"$ctl" + # rtcN/wakealarm can use relative time in seconds + echo "+$timeout" >"$ctl" + return 0 + fi + ctl='/proc/acpi/alarm' + if [ -f "$ctl" ]; then + echo `date '+%F %H:%M:%S' -d '+ '$timeout' seconds'` >"$ctl" + return 0 + fi + + echo "no method to awaken machine automatically" 1>&2 + exit 1 +} + +suspend_system () +{ + if [ "$dry" -eq 1 ]; then + echo "DRY-RUN: suspend machine for $timer_sleep" + sleep 1 + return + fi + + setup_wakeup_timer "$timer_sleep" + + dmesg >"$LOGFILE.dmesg.A" + + # Initiate suspend in different ways. + case "$1" in + dbus) + dbus-send --session --type=method_call \ + --dest=org.freedesktop.PowerManagement \ + /org/freedesktop/PowerManagement \ + org.freedesktop.PowerManagement.Suspend \ + >> "$LOGFILE" || { + ECHO "FAILED: dbus suspend failed" 1>&2 + return 1 + } + ;; + pmsuspend) + pm-suspend >> "$LOGFILE" + ;; + mem) + `echo "mem" > /sys/power/state` >> "$LOGFILE" + ;; + esac + + # Wait on the machine coming back up -- pulling the dmesg over. + echo "v---" >>"$LOGFILE" + retry=30 + while [ "$retry" -gt 0 ]; do + let "retry=$retry-1" + + # Accumulate the dmesg delta. + dmesg >"$LOGFILE.dmesg.B" + diff "$LOGFILE.dmesg.A" "$LOGFILE.dmesg.B" | \ + grep '^>' >"$LOGFILE.dmesg" + mv "$LOGFILE.dmesg.B" "$LOGFILE.dmesg.A" + + echo "Waiting for suspend to complete $retry to go ..." \ + >> "$LOGFILE" + cat "$LOGFILE.dmesg" >> "$LOGFILE" + + if [ "`grep -c 'Back to C!' $LOGFILE.dmesg`" -ne 0 ]; then + break; + fi + sleep 1 + done + echo "^---" >>"$LOGFILE" + rm -f "$LOGFILE.dmesg"* + if [ "$retry" -eq 0 ]; then + ECHO "SUSPEND FAILED, did not go to sleep" 1>&2 + return 1 + fi +} + +ECHO () +{ + echo "$@" | tee -a "$LOGFILE" +} + +enable_trace() +{ + if [ -w /sys/power/pm_trace ]; then + echo 1 > '/sys/power/pm_trace' + fi +} + +disable_trace() +{ + if [ -w /sys/power/pm_trace ]; then + echo 0 > '/sys/power/pm_trace' + fi +} + +trace_state=-1 + +save_trace() +{ + if [ -r /sys/power/pm_trace ]; then + trace_state=`cat /sys/power/pm_trace` + fi +} + +restore_trace() +{ + if [ "$trace_state" -ne -1 -a -w /sys/power/pm_trace ]; then + echo "$trace_state" > '/sys/power/pm_trace' + fi +} + +battery_count() +{ + cat /proc/acpi/battery/*/state 2>/dev/null | \ + awk ' + BEGIN { total = 0 } + /present:.*yes/ { total += 1 } + END { print total } + ' +} + +battery_capacity() +{ + cat /proc/acpi/battery/*/state 2>/dev/null | \ + awk ' + BEGIN { total = 0 } + /remaining capacity:/ { total += $3 } + END { print total } + ' +} + +ac_needed=-1 +ac_is=-1 +ac_becomes=-1 + +ac_required() +{ + ac_check + + ac_needed="$1" + ac_becomes="$1" +} + +ac_transitions() +{ + ac_check + + ac_needed="$1" + ac_becomes="$2" +} + +ac_online() +{ + cat /proc/acpi/ac_adapter/*/state 2>/dev/null | \ + awk ' + BEGIN { online = 0; offline = 0 } + /on-line/ { online = 1 } + /off-line/ { offline = 1 } + END { + if (online) { + print "1" + } else if (offline) { + print "0" + } else { + print "-1" + } + } + ' +} + +ac_check() +{ + typeset ac_current=`ac_online` + + if [ "$ac_becomes" -ne -1 -a "$ac_current" -ne -1 -a \ + "$ac_current" -ne "$ac_becomes" ]; then + ECHO "*** WARNING: AC power not in expected state" \ + "($ac_becomes) after test" + fi + ac_is="$ac_becomes" +} + +phase=0 +phase_first=1 +phase_interactive=1 + +phase() +{ + typeset sleep + + let phase="$phase+1" + + if [ "$ac_needed" -ne "$ac_is" ]; then + case "$ac_needed" in + 0) echo "*** please ensure your AC cord is detached" ;; + 1) echo "*** please ensure your AC cord is attached" ;; + esac + ac_is="$ac_needed" + fi + + if [ "$timer_sleep" -gt 60 ]; then + let sleep="$timer_sleep / 60" + sleep="$sleep minutes" + else + sleep="$timer_sleep seconds" + fi + echo "*** machine will suspend for $sleep" + + if [ "$auto" -eq 1 ]; then + : + + elif [ "$phase_interactive" -eq 1 ]; then + echo "*** press return when ready" + read x + + elif [ "$phase_first" -eq 1 ]; then + echo "*** NOTE: there will be no further user interaction from this point" + echo "*** press return when ready" + phase_first=0 + read x + fi +} + +save_trace + +if [ "$pm_trace" -eq 1 ]; then + enable_trace +else + disable_trace +fi + diff --git a/common/scripts/pm-qa/include/thermal_functions.sh b/common/scripts/pm-qa/include/thermal_functions.sh new file mode 100644 index 0000000..8a4d627 --- /dev/null +++ b/common/scripts/pm-qa/include/thermal_functions.sh @@ -0,0 +1,281 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# Contributors: +# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics) +# - initial API and implementation +# + +THERMAL_PATH="/sys/devices/virtual/thermal" +MAX_ZONE=0-12 +MAX_CDEV=0-50 +ALL_ZONE= +ALL_CDEV= + +check_valid_temp() { + local file=$1 + local zone_name=$2 + local dir=$THERMAL_PATH/$2 + + local temp_file=$dir/$1 + local func=cat + shift 2; + + local temp_val=$($func $temp_file) + local descr="'$zone_name'/'$file' ='$temp_val'" + log_begin "checking $descr" + + if [ $temp_val -gt 0 ]; then + log_end "pass" + return 0 + fi + + log_end "fail" + + return 1 +} + +for_each_thermal_zone() { + + local func=$1 + shift 1 + + zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + + ALL_ZONE=$zone + for zone in $zones; do + INC=0 + $func $zone $@ + done + + return 0 +} + +get_total_trip_point_of_zone() { + + local zone_path=$THERMAL_PATH/$1 + local count=0 + shift 1 + trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") + for trip in $trips; do + count=$((count + 1)) + done + return $count +} + +for_each_trip_point_of_zone() { + + local zone_path=$THERMAL_PATH/$1 + local count=0 + local func=$2 + local zone_name=$1 + shift 2 + trips=$(ls $zone_path | grep "trip_point_['$MAX_ZONE']_temp") + for trip in $trips; do + $func $zone_name $count + count=$((count + 1)) + done + return 0 +} + +for_each_binding_of_zone() { + + local zone_path=$THERMAL_PATH/$1 + local count=0 + local func=$2 + local zone_name=$1 + shift 2 + trips=$(ls $zone_path | grep "cdev['$MAX_CDEV']_trip_point") + for trip in $trips; do + $func $zone_name $count + count=$((count + 1)) + done + + return 0 + +} + +check_valid_binding() { + local trip_point=$1 + local zone_name=$2 + local dirpath=$THERMAL_PATH/$2 + local temp_file=$2/$1 + local trip_point_val=$(cat $dirpath/$trip_point) + get_total_trip_point_of_zone $zone_name + local trip_point_max=$? + local descr="'$temp_file' valid binding" + shift 2 + + log_begin "checking $descr" + if [ $trip_point_val -ge $trip_point_max ]; then + log_end "fail" + return 1 + fi + + log_end "pass" + return 0 +} + +validate_trip_bindings() { + local zone_name=$1 + local bind_no=$2 + local dirpath=$THERMAL_PATH/$1 + local trip_point=cdev$2_trip_point + shift 2 + + check_file $trip_point $dirpath || return 1 + check_valid_binding $trip_point $zone_name || return 1 +} + +validate_trip_level() { + local zone_name=$1 + local trip_no=$2 + local dirpath=$THERMAL_PATH/$1 + local trip_temp=trip_point_$2_temp + local trip_type=trip_point_$2_type + shift 2 + + check_file $trip_temp $dirpath || return 1 + check_file $trip_type $dirpath || return 1 + check_valid_temp $trip_temp $zone_name || return 1 +} + +for_each_cooling_device() { + + local func=$1 + shift 1 + + devices=$(ls $THERMAL_PATH | grep "cooling_device['$MAX_CDEV']") + + ALL_DEVICE=$devices + for device in $devices; do + INC=0 + $func $device $@ + done + + return 0 +} +check_scaling_freq() { + + local before_freq_list=$1 + local after_freq_list=$2 + shift 2 + local index=0 + + local flag=0 + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + if [ $before_freq_list[$index] != $afterf_req_list[$index] ] ; then + flag=1 + fi + index=$((index + 1)) + done + return $flag +} + +store_scaling_maxfreq() { + scale_freq= + local index=0 + + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + scale_freq[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_max_freq) + index=$((index + 1)) + done + return 0 +} + +get_trip_id() { + + local trip_name=$1 + shift 1 + + local id1=$(echo $trip_name|cut -c12) + local id2=$(echo $trip_name|cut -c13) + if [ $id2 != "_" ]; then + id1=$(($id2 + 10*$id1)) + fi + return $id1 +} + +disable_all_thermal_zones() { + + mode_list= + local index=0 + + local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + for zone in $th_zones; do + mode_list[$index]=$(cat $THERMAL_PATH/$zone/mode) + index=$((index + 1)) + echo -n "disabled" > $THERMAL_PATH/$zone/mode + done + return 0 +} + +enable_all_thermal_zones() { + + local index=0 + + local th_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + for zone in $th_zones; do + echo $mode_list[$index] > $THERMAL_PATH/$zone/mode + index=$((index + 1)) + done + return 0 +} + +GPU_HEAT_BIN=/usr/bin/glmark2 +gpu_pid=0 + +start_glmark2() { + if [ -n "$ANDROID" ]; then + am start org.linaro.glmark2/.Glmark2Activity + return + fi + + if [ -x $GPU_HEAT_BIN ]; then + $GPU_HEAT_BIN & + gpu_pid=$(pidof $GPU_HEAT_BIN) + # Starting X application from serial console needs this + if [ -z "$gpu_pid" ]; then + cp /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.bk + echo "autologin-user=root" >> /etc/lightdm/lightdm.conf + export DISPLAY=localhost:0.0 + restart lightdm + sleep 5 + mv /etc/lightdm/lightdm.conf.bk /etc/lightdm/lightdm.conf + $GPU_HEAT_BIN & + gpu_pid=$(pidof $GPU_HEAT_BIN) + fi + test -z "$gpu_pid" && cpu_pid=0 + echo "start gpu heat binary $gpu_pid" + else + echo "glmark2 not found." 1>&2 + fi +} + +kill_glmark2() { + if [ -n "$ANDROID" ]; then + am kill org.linaro.glmark2 + return + fi + + if [ "$gpu_pid" != 0 ]; then + kill -9 $gpu_pid + fi +} diff --git a/common/scripts/pm-qa/suspend/suspend_01.sh b/common/scripts/pm-qa/suspend/suspend_01.sh new file mode 100755 index 0000000..6f36302 --- /dev/null +++ b/common/scripts/pm-qa/suspend/suspend_01.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2012, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Hongbo ZHANG <hongbo.zhang@linaro.org> (ST-Ericsson Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#suspend_01 + + +source ../include/functions.sh +source ../include/suspend_functions.sh + +if [ "$suspend_dbus" -eq 0 ]; then + log_skip "dbus message suspend test not enabled" + exit 0 +fi + +if [ -x /usr/bin/dbus-send ]; then + phase + check "suspend by dbus message" suspend_system "dbus" + if [ $? -ne 0 ]; then + cat "$LOGFILE" 1>&2 + fi +else + log_skip "dbus-send command not exist" +fi + +restore_trace +test_status_show +rm -f "$LOGFILE" diff --git a/common/scripts/pm-qa/suspend/suspend_02.sh b/common/scripts/pm-qa/suspend/suspend_02.sh new file mode 100755 index 0000000..ceb6398 --- /dev/null +++ b/common/scripts/pm-qa/suspend/suspend_02.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2012, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Hongbo ZHANG <hongbo.zhang@linaro.org> (ST-Ericsson Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#suspend_02 + + +source ../include/functions.sh +source ../include/suspend_functions.sh + +if [ "$suspend_pmsuspend" -eq 0 ]; then + log_skip "pm-suspend test not enabled" + exit 0 +fi + +if [ -x /usr/sbin/pm-suspend ]; then + phase + check "suspend via pm-suspend" suspend_system "pmsuspend" + if [ $? -ne 0 ]; then + cat "$LOGFILE" 1>&2 + fi +else + log_skip "pm-suspend command not exist" +fi + +restore_trace +test_status_show +rm -f "$LOGFILE" + diff --git a/common/scripts/pm-qa/suspend/suspend_03.sh b/common/scripts/pm-qa/suspend/suspend_03.sh new file mode 100755 index 0000000..de81627 --- /dev/null +++ b/common/scripts/pm-qa/suspend/suspend_03.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2012, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Hongbo ZHANG <hongbo.zhang@linaro.org> (ST-Ericsson Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#suspend_03 + + +source ../include/functions.sh +source ../include/suspend_functions.sh + +if [ "$suspend_mem" -eq 0 ]; then + log_skip "suspend to ram via sysfs not enabled" + exit 0 +fi + +supported=$(cat /sys/power/state | grep "mem") +if [ -n "$supported" ]; then + phase + check "suspend to ram via sysfs" suspend_system "mem" + if [ $? -ne 0 ]; then + cat "$LOGFILE" 1>&2 + fi +else + log_skip "suspend to ram via sysfs not supported" +fi + +restore_trace +test_status_show +rm -f "$LOGFILE" diff --git a/common/scripts/pm-qa/suspend/suspend_04.sh b/common/scripts/pm-qa/suspend/suspend_04.sh new file mode 100755 index 0000000..0eb70dd --- /dev/null +++ b/common/scripts/pm-qa/suspend/suspend_04.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2012, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Hongbo ZHANG <hongbo.zhang@linaro.org> (ST-Ericsson Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#suspend_04 + + +source ../include/functions.sh +source ../include/suspend_functions.sh + +if [ "$suspend_ac" -eq 0 ]; then + log_skip "suspend test involving ac power remove" + exit 0 +fi + +if [ ! -d /proc/acpi/battery/ ]; then + log_skip "acpi interface is not there" + exit 0 +fi + +battery_count=`battery_count` +if [ "$battery_count" -eq 0 ]; then + log_skip "no BATTERY detected for ac tests" +else + ac_required 0 + phase + sleep 2 + check "suspend with AC disconnected" suspend_system "mem" + + ac_required 1 + phase + sleep 2 + check "suspend with AC connected" suspend_system "mem" + + ac_transitions 1 0 + echo "*** please remove the AC cord while the machine is suspended" + phase + sleep 2 + check "loss of AC while suspended" suspend_system "mem" + + ac_transitions 0 1 + echo "*** please insert the AC cord while the machine is suspended" + phase + sleep 2 + check "return of AC while suspended" suspend_system "mem" + if [ $? -ne 0 ]; then + cat "$LOGFILE" 1>&2 + fi +fi + +restore_trace +test_status_show +rm -f "$LOGFILE" diff --git a/common/scripts/pm-qa/suspend/suspend_05.sh b/common/scripts/pm-qa/suspend/suspend_05.sh new file mode 100755 index 0000000..55396e5 --- /dev/null +++ b/common/scripts/pm-qa/suspend/suspend_05.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2012, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributors: +# Hongbo ZHANG <hongbo.zhang@linaro.org> (ST-Ericsson Corporation) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#suspend_05 + + +source ../include/functions.sh +source ../include/suspend_functions.sh + +args_power_sleep=60 + +if [ "$suspend_power" -eq 0 ]; then + log_skip "battery consumption test while suspend" + exit 0 +fi + +if [ ! -d /proc/acpi/battery/ ]; then + log_skip "acpi interface is not there" + exit 0 +fi + +battery_count=`battery_count` +if [ "$battery_count" -eq 0 ]; then + log_skip "no BATTERY detected for power test" +else + save_timer_sleep="$timer_sleep" + let timer_sleep="$args_power_sleep" + + ac_required 0 + phase + + # get start values + date_before=`date +%s` + bat_before=`battery_capacity` + + # Suspend + check "battery drain during suspend" suspend_system "mem" + if [ $? -ne 0 ]; then + cat "$LOGFILE" 1>&2 + fi + + # get end values + date_after=`date +%s` + bat_after=`battery_capacity` + + # do the calculations + let consumed="$bat_before - $bat_after" + let elapsed="$date_after - $date_before" + let usage="($consumed * 60*60) / $elapsed" + + # output the results + ECHO "before: $bat_before mWh" + ECHO "after: $bat_after mWh" + ECHO "consumed: $consumed mW" + ECHO "sleep seconds: $elapsed sec" + ECHO "overall usage: $usage mW" + + report_battery="$usage mW" + + if [ $elapsed -lt 600 ] + then + ECHO "WARNING: the suspend was less than 10 minutes" + ECHO " to get reliable numbers increase the sleep time" + report_battery="$report_battery (unreliable)" + fi + + timer_sleep="$save_timer_sleep" +fi + +restore_trace +test_status_show +rm -f "$LOGFILE" diff --git a/common/scripts/pm-qa/thermal/thermal_01.sh b/common/scripts/pm-qa/thermal/thermal_01.sh new file mode 100755 index 0000000..5a74296 --- /dev/null +++ b/common/scripts/pm-qa/thermal/thermal_01.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# Contributors: +# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_01 + +source ../include/functions.sh +source ../include/thermal_functions.sh + +ATTRIBUTES="mode temp type uevent" + +check_thermal_zone_attributes() { + + local dirpath=$THERMAL_PATH/$1 + local zone_name=$1 + shift 1 + for i in $ATTRIBUTES; do + check_file $i $dirpath || return 1 + done + + check_valid_temp "temp" $zone_name || return 1 +} + +check_thermal_zone_mode() { + + local dirpath=$THERMAL_PATH/$1 + local zone_name=$1 + shift 1 + local prev_mode=$(cat $dirpath/mode) + echo -n enabled > $dirpath/mode + local cur_mode=$(cat $dirpath/mode) + check "$zone_name cur_mode=$cur_mode"\ + "test $cur_mode = enabled" || return 1 + echo -n disabled > $dirpath/mode + local cur_mode=$(cat $dirpath/mode) + check "$zone_name cur_mode=$cur_mode"\ + "test $cur_mode = disabled" || return 1 + + echo $prev_mode > $dirpath/mode +} + +check_thermal_zone_trip_level() { + + local all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + for i in $all_zones; do + for_each_trip_point_of_zone $i "validate_trip_level" || return 1 + done +} + +check_thermal_zone_bindings() { + + local all_zones=$(ls $THERMAL_PATH | grep "thermal_zone['$MAX_ZONE']") + for i in $all_zones; do + for_each_binding_of_zone $i "validate_trip_bindings" || return 1 + done +} + +for_each_thermal_zone check_thermal_zone_attributes + +for_each_thermal_zone check_thermal_zone_mode + +check_thermal_zone_trip_level + +check_thermal_zone_bindings +test_status_show diff --git a/common/scripts/pm-qa/thermal/thermal_02.sh b/common/scripts/pm-qa/thermal/thermal_02.sh new file mode 100755 index 0000000..a78618c --- /dev/null +++ b/common/scripts/pm-qa/thermal/thermal_02.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# Contributors: +# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_02 + +source ../include/functions.sh +source ../include/thermal_functions.sh + +CDEV_ATTRIBUTES="cur_state max_state type uevent" + +check_cooling_device_attributes() { + + local dirpath=$THERMAL_PATH/$1 + local cdev_name=$1 + shift 1 + + for i in $CDEV_ATTRIBUTES; do + check_file $i $dirpath || return 1 + done + +} + +check_cooling_device_states() { + local dirpath=$THERMAL_PATH/$1 + local cdev_name=$1 + shift 1 + local max_state=$(cat $dirpath/max_state) + local prev_state_val=$(cat $dirpath/cur_state) + local count=0 + local cur_state_val=0 + while (test $count -le $max_state); do + echo $count > $dirpath/cur_state + cur_state_val=$(cat $dirpath/cur_state) + check "$cdev_name cur_state=$count"\ + "test $cur_state_val -eq $count" || return 1 + count=$((count+1)) + done + echo $prev_state_val > $dirpath/cur_state +} + +for_each_cooling_device check_cooling_device_attributes + +for_each_cooling_device check_cooling_device_states +test_status_show diff --git a/common/scripts/pm-qa/thermal/thermal_03.sh b/common/scripts/pm-qa/thermal/thermal_03.sh new file mode 100755 index 0000000..92e9569 --- /dev/null +++ b/common/scripts/pm-qa/thermal/thermal_03.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# Contributors: +# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_03 + +source ../include/functions.sh +source ../include/thermal_functions.sh + +CPU_HEAT_BIN=../utils/heat_cpu +cpu_pid=0 + +heater_kill() { + if [ $cpu_pid != 0 ]; then + kill -9 $cpu_pid + fi + kill_glmark2 +} + +check_temperature_change() { + local dirpath=$THERMAL_PATH/$1 + local zone_name=$1 + shift 1 + + local init_temp=$(cat $dirpath/temp) + $CPU_HEAT_BIN & + cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') + test -z $cpu_pid && cpu_pid=0 + check "start cpu heat binary" "test $cpu_pid -ne 0" + test $cpu_pid -eq 0 && return + + start_glmark2 + + sleep 5 + local final_temp=$(cat $dirpath/temp) + heater_kill + check "temperature variation with load" "test $final_temp -gt $init_temp" +} + +trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_thermal_zone check_temperature_change +test_status_show diff --git a/common/scripts/pm-qa/thermal/thermal_04.sh b/common/scripts/pm-qa/thermal/thermal_04.sh new file mode 100755 index 0000000..58aac43 --- /dev/null +++ b/common/scripts/pm-qa/thermal/thermal_04.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# Contributors: +# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_04 + +source ../include/functions.sh +source ../include/thermal_functions.sh +HEAT_CPU_MODERATE=../utils/heat_cpu +pid=0 + +heater_kill() { + if [ $pid != 0 ]; then + kill -9 $pid + fi +} + +verify_cooling_device_temp_change() { + local dirpath=$THERMAL_PATH/$1 + local cdev_name=$1 + shift 1 + local tzonepath=$THERMAL_PATH/thermal_zone0 + test -d $tzonepath + if [ $? -ne 0 ] ; then + echo "No thermal zone present" + return 1; + fi + local max_state=$(cat $dirpath/max_state) + local prev_state_val=$(cat $dirpath/cur_state) + local prev_mode_val=$(cat $tzonepath/mode) + echo -n disabled > $tzonepath/mode + + local count=1 + local cur_state_val=0 + local init_temp=0 + local final_temp=0 + local cool_temp=0 + ./$HEAT_CPU_MODERATE moderate & + pid=$! + test $pid -eq 0 && return + + while (test $count -le $max_state); do + echo 0 > $dirpath/cur_state + sleep 5 + init_temp=$(cat $tzonepath/temp) + + echo $count > $dirpath/cur_state + sleep 5 + final_temp=$(cat $tzonepath/temp) + cool_temp=$(($init_temp - $final_temp)) + check "$cdev_name:state=$count effective cool=$cool_temp "\ + "test $cool_temp -ge 0" + count=$((count+1)) + done + heater_kill + echo $prev_mode_val > $tzonepath/mode + echo $prev_state_val > $dirpath/cur_state +} + +trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cooling_device verify_cooling_device_temp_change +test_status_show diff --git a/common/scripts/pm-qa/thermal/thermal_05.sh b/common/scripts/pm-qa/thermal/thermal_05.sh new file mode 100755 index 0000000..3dcaa8d --- /dev/null +++ b/common/scripts/pm-qa/thermal/thermal_05.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# Contributors: +# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_05 + +source ../include/functions.sh +source ../include/thermal_functions.sh + +verify_cpufreq_cooling_device_action() { + local dirpath=$THERMAL_PATH/$1 + local cdev_name=$1 + shift 1 + + local cpufreq_cdev=$(cat $dirpath/type) + cat $dirpath/type | grep cpufreq + if [ $? -ne 0 ] ; then + return 0 + fi + + local max_state=$(cat $dirpath/max_state) + local prev_state_val=$(cat $dirpath/cur_state) + disable_all_thermal_zones + + local count=1 + local before_scale_max=0 + local after_scale_max=0 + local change=0 + + while (test $count -le $max_state); do + echo 0 > $dirpath/cur_state + sleep 1 + + store_scaling_maxfreq + before_scale_max=$scale_freq + + echo $count > $dirpath/cur_state + sleep 1 + + store_scaling_maxfreq + after_scale_max=$scale_freq + + check_scaling_freq $before_scale_max $after_scale_max + change=$? + + check "cdev=$cdev_name state=$count" "test $change -ne 0" + + count=$((count+1)) + done + enable_all_thermal_zones + echo $prev_state_val > $dirpath/cur_state +} +for_each_cooling_device verify_cpufreq_cooling_device_action +test_status_show diff --git a/common/scripts/pm-qa/thermal/thermal_06.sh b/common/scripts/pm-qa/thermal/thermal_06.sh new file mode 100755 index 0000000..e170028 --- /dev/null +++ b/common/scripts/pm-qa/thermal/thermal_06.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2011, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# Contributors: +# Amit Daniel <amit.kachhap@linaro.org> (Samsung Electronics) +# - initial API and implementation +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts#thermal_06 + +source ../include/functions.sh +source ../include/thermal_functions.sh + +if [ "$thermal_try_max" -eq 0 ]; then + log_skip "test of trip points being crossed" + exit 0 +fi + +TEST_LOOP=100 +CPU_HEAT_BIN=../utils/heat_cpu +cpu_pid=0 + +heater_kill() { + if [ $cpu_pid != 0 ]; then + kill -9 $cpu_pid + fi + kill_glmark2 +} + +check_trip_point_change() { + local dirpath=$THERMAL_PATH/$1 + local zone_name=$1 + shift 1 + + local count=0 + local cur_temp=0 + local trip_temp=0 + local trip_cross= + local trip_id= + local trip_type=0 + local trip_type_path=0 + $CPU_HEAT_BIN & + cpu_pid=$(ps | grep heat_cpu| awk '{print $1}') + test -z $cpu_pid && cpu_pid=0 + check "start cpu heat binary" "test $cpu_pid -ne 0" + test $cpu_pid -eq 0 && return + + start_glmark2 + + local index=0 + for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do + trip_cross[$index]=0 + index=$((index + 1)) + done + while (test $count -lt $TEST_LOOP); do + index=0 + sleep 1 + for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do + cur_temp=$(cat $dirpath/temp) + trip_temp=$(cat $dirpath/$trip) + if [ $cur_temp -gt $trip_temp ]; then + trip_cross[$index]=$((${trip_cross[$index]} + 1)) + fi + index=$((index + 1)) + + done + count=$((count + 1)) + done + index=0 + for trip in $(ls $dirpath | grep "trip_point_['$MAX_ZONE']_temp"); do + get_trip_id $trip + trip_id=$? + trip_type=$(cat $dirpath/trip_point_$((trip_id))_type) + trip_temp=$(cat $dirpath/$trip) + + if [ $trip_type != "critical" ]; then + count=${trip_cross[$index]} + check "$trip:$trip_temp crossed" "test $count -gt 0" + fi + index=$((index + 1)) + done + + heater_kill +} + +trap "heater_kill; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_thermal_zone check_trip_point_change +test_status_show diff --git a/common/scripts/pm-qa/utils/cpuburn b/common/scripts/pm-qa/utils/cpuburn Binary files differnew file mode 100755 index 0000000..c40673f --- /dev/null +++ b/common/scripts/pm-qa/utils/cpuburn diff --git a/common/scripts/pm-qa/utils/cpucycle b/common/scripts/pm-qa/utils/cpucycle Binary files differnew file mode 100755 index 0000000..995ca14 --- /dev/null +++ b/common/scripts/pm-qa/utils/cpucycle diff --git a/common/scripts/pm-qa/utils/heat_cpu b/common/scripts/pm-qa/utils/heat_cpu Binary files differnew file mode 100755 index 0000000..00c693d --- /dev/null +++ b/common/scripts/pm-qa/utils/heat_cpu diff --git a/common/scripts/pm-qa/utils/nanosleep b/common/scripts/pm-qa/utils/nanosleep Binary files differnew file mode 100755 index 0000000..7b75a27 --- /dev/null +++ b/common/scripts/pm-qa/utils/nanosleep |