Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- include/functions.sh | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/include/functions.sh b/include/functions.sh index 6702cb2..bff8e13 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -194,13 +194,20 @@ check() { 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 "$i exists" "test -f" $dirpath/$i || return 1 + check_file $i $dirpath || return 1 done
return 0 @@ -211,7 +218,7 @@ check_sched_mc_files() { local dirpath=$CPU_PATH
for i in $@; do - check "$i exists" "test -f" $dirpath/$i || return 1 + check_file $i $dirpath || return 1 done
return 0 @@ -223,7 +230,7 @@ check_topology_files() { shift 1
for i in $@; do - check "$i exists" "test -f" $dirpath/$i || return 1 + check_file $i $dirpath || return 1 done
return 0
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/Makefile | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/Makefile
diff --git a/cpuhotplug/Makefile b/cpuhotplug/Makefile new file mode 100644 index 0000000..2225d82 --- /dev/null +++ b/cpuhotplug/Makefile @@ -0,0 +1,25 @@ +# +# PM-QA validation test suite for the power management on ARM +# +# 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 +# + +include ../Test.mk
On Mon, Oct 3, 2011 at 11:18 AM, Daniel Lezcano daniel.lezcano@linaro.org wrote:
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org
cpuhotplug/Makefile | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/Makefile
diff --git a/cpuhotplug/Makefile b/cpuhotplug/Makefile new file mode 100644 index 0000000..2225d82 --- /dev/null +++ b/cpuhotplug/Makefile @@ -0,0 +1,25 @@ +# +# PM-QA validation test suite for the power management on ARM
s/on ARM/on Linux/ ?
None of these tests are ARM-specific and it might actually be nice if others adopted them too.
Otherwise, ack for the patchset.
+# 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 +#
+include ../Test.mk
1.7.1
linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 10/03/2011 10:39 AM, Amit Kucheria wrote:
On Mon, Oct 3, 2011 at 11:18 AM, Daniel Lezcano daniel.lezcano@linaro.org wrote:
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org
cpuhotplug/Makefile | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/Makefile
diff --git a/cpuhotplug/Makefile b/cpuhotplug/Makefile new file mode 100644 index 0000000..2225d82 --- /dev/null +++ b/cpuhotplug/Makefile @@ -0,0 +1,25 @@ +# +# PM-QA validation test suite for the power management on ARM
s/on ARM/on Linux/ ?
None of these tests are ARM-specific and it might actually be nice if others adopted them too.
Ok, I will change the headers for the different files with a patch on top of this patchset because it impacts all the headers.
Otherwise, ack for the patchset.
Thanks for the review.
-- Daniel
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 10/03/2011 10:39 AM, Amit Kucheria wrote:
On Mon, Oct 3, 2011 at 11:18 AM, Daniel Lezcano daniel.lezcano@linaro.org wrote:
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org
[ ... ]
Otherwise, ack for the patchset.
All patchset applied.
Thanks -- Daniel
- -- http://www.linaro.org/ Linaro.org ? Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro Facebook | http://twitter.com/#!/linaroorg Twitter | http://www.linaro.org/linaro-blog/ Blog
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- Makefile | 2 ++ cpuhotplug/cpuhotplug_01.sh | 36 ++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_01.txt | 1 + include/functions.sh | 12 ++++++++++++ 4 files changed, 51 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_01.sh create mode 100644 cpuhotplug/cpuhotplug_01.txt
diff --git a/Makefile b/Makefile index abc866b..478fec3 100644 --- a/Makefile +++ b/Makefile @@ -29,10 +29,12 @@ all: check: @(cd utils; $(MAKE) check) @(cd cpufreq; $(MAKE) check) + @(cd cpuhotplug; $(MAKE) check) @(cd sched_mc; $(MAKE) check)
uncheck: @(cd cpufreq; $(MAKE) uncheck) + @(cd cpuhotplug; $(MAKE) uncheck) @(cd sched_mc; $(MAKE) uncheck)
recheck: uncheck check diff --git a/cpuhotplug/cpuhotplug_01.sh b/cpuhotplug/cpuhotplug_01.sh new file mode 100644 index 0000000..f6f36ff --- /dev/null +++ b/cpuhotplug/cpuhotplug_01.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 diff --git a/cpuhotplug/cpuhotplug_01.txt b/cpuhotplug/cpuhotplug_01.txt new file mode 100644 index 0000000..047f13a --- /dev/null +++ b/cpuhotplug/cpuhotplug_01.txt @@ -0,0 +1 @@ +test the sysfs files are present diff --git a/include/functions.sh b/include/functions.sh index bff8e13..b2a8b47 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -236,6 +236,18 @@ check_topology_files() { 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=
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/cpuhotplug_02.sh | 60 ++++++++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_02.txt | 1 + include/functions.sh | 21 ++++++++++++++ 3 files changed, 82 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_02.sh create mode 100644 cpuhotplug/cpuhotplug_02.txt
diff --git a/cpuhotplug/cpuhotplug_02.sh b/cpuhotplug/cpuhotplug_02.sh new file mode 100644 index 0000000..4f3f3d2 --- /dev/null +++ b/cpuhotplug/cpuhotplug_02.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 diff --git a/cpuhotplug/cpuhotplug_02.txt b/cpuhotplug/cpuhotplug_02.txt new file mode 100644 index 0000000..4047c3a --- /dev/null +++ b/cpuhotplug/cpuhotplug_02.txt @@ -0,0 +1 @@ +test the cpu state is reflected in sysfs diff --git a/include/functions.sh b/include/functions.sh index b2a8b47..b34d49b 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -175,6 +175,27 @@ get_min_frequency() { cat $dirpath }
+set_online() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + echo 1 > $dirpath/online +} + +set_offline() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + echo 0 > $dirpath/online +} + +get_online() { + local cpu=$1 + local dirpath=$CPU_PATH/$cpu + + cat $dirpath/online +} + check() {
local descr=$1
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/cpuhotplug_03.sh | 51 ++++++++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_03.txt | 1 + 2 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_03.sh create mode 100644 cpuhotplug/cpuhotplug_03.txt
diff --git a/cpuhotplug/cpuhotplug_03.sh b/cpuhotplug/cpuhotplug_03.sh new file mode 100644 index 0000000..489706b --- /dev/null +++ b/cpuhotplug/cpuhotplug_03.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 \ No newline at end of file diff --git a/cpuhotplug/cpuhotplug_03.txt b/cpuhotplug/cpuhotplug_03.txt new file mode 100644 index 0000000..09eb1d9 --- /dev/null +++ b/cpuhotplug/cpuhotplug_03.txt @@ -0,0 +1 @@ +test the affinity does not work on an offline cpu
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/cpuhotplug_04.sh | 71 ++++++++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_04.txt | 1 + 2 files changed, 72 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_04.sh create mode 100644 cpuhotplug/cpuhotplug_04.txt
diff --git a/cpuhotplug/cpuhotplug_04.sh b/cpuhotplug/cpuhotplug_04.sh new file mode 100644 index 0000000..6cf944f --- /dev/null +++ b/cpuhotplug/cpuhotplug_04.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 diff --git a/cpuhotplug/cpuhotplug_04.txt b/cpuhotplug/cpuhotplug_04.txt new file mode 100644 index 0000000..c0689a3 --- /dev/null +++ b/cpuhotplug/cpuhotplug_04.txt @@ -0,0 +1 @@ +test task is migrated with task affinity
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/cpuhotplug_05.sh | 49 ++++++++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_05.txt | 1 + 2 files changed, 50 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_05.sh create mode 100644 cpuhotplug/cpuhotplug_05.txt
diff --git a/cpuhotplug/cpuhotplug_05.sh b/cpuhotplug/cpuhotplug_05.sh new file mode 100644 index 0000000..82bf2b4 --- /dev/null +++ b/cpuhotplug/cpuhotplug_05.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 diff --git a/cpuhotplug/cpuhotplug_05.txt b/cpuhotplug/cpuhotplug_05.txt new file mode 100644 index 0000000..9c4cfbf --- /dev/null +++ b/cpuhotplug/cpuhotplug_05.txt @@ -0,0 +1 @@ +test cpus are reflected on /proc/cpuinfo correctly
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/cpuhotplug_06.sh | 49 ++++++++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_06.txt | 1 + 2 files changed, 50 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_06.sh create mode 100644 cpuhotplug/cpuhotplug_06.txt
diff --git a/cpuhotplug/cpuhotplug_06.sh b/cpuhotplug/cpuhotplug_06.sh new file mode 100644 index 0000000..1b1c7eb --- /dev/null +++ b/cpuhotplug/cpuhotplug_06.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 diff --git a/cpuhotplug/cpuhotplug_06.txt b/cpuhotplug/cpuhotplug_06.txt new file mode 100644 index 0000000..1edab7c --- /dev/null +++ b/cpuhotplug/cpuhotplug_06.txt @@ -0,0 +1 @@ +test interrupts show the right configuration in /proc/interrupts
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/cpuhotplug_07.sh | 66 ++++++++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_07.txt | 1 + 2 files changed, 67 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_07.sh create mode 100644 cpuhotplug/cpuhotplug_07.txt
diff --git a/cpuhotplug/cpuhotplug_07.sh b/cpuhotplug/cpuhotplug_07.sh new file mode 100644 index 0000000..518ad06 --- /dev/null +++ b/cpuhotplug/cpuhotplug_07.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 diff --git a/cpuhotplug/cpuhotplug_07.txt b/cpuhotplug/cpuhotplug_07.txt new file mode 100644 index 0000000..ddfca55 --- /dev/null +++ b/cpuhotplug/cpuhotplug_07.txt @@ -0,0 +1 @@ +test userspace notification
Randomly offline/online a cpu
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org --- cpuhotplug/cpuhotplug_08.sh | 49 ++++++++++++++++++++++++++++++++++++++++++ cpuhotplug/cpuhotplug_08.txt | 1 + 2 files changed, 50 insertions(+), 0 deletions(-) create mode 100644 cpuhotplug/cpuhotplug_08.sh create mode 100644 cpuhotplug/cpuhotplug_08.txt
diff --git a/cpuhotplug/cpuhotplug_08.sh b/cpuhotplug/cpuhotplug_08.sh new file mode 100644 index 0000000..889221f --- /dev/null +++ b/cpuhotplug/cpuhotplug_08.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# PM-QA validation test suite for the power management on ARM +# +# 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#cpuhotp... + +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 diff --git a/cpuhotplug/cpuhotplug_08.txt b/cpuhotplug/cpuhotplug_08.txt new file mode 100644 index 0000000..ddfca55 --- /dev/null +++ b/cpuhotplug/cpuhotplug_08.txt @@ -0,0 +1 @@ +test userspace notification