These tests are for the power mangemenat QA. The test definitions are at:
https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts
Not all the boards have cpufreq enabled or totally implemented, so the test suite was checked against a multicore and multiprocessor x86 platform.
Daniel Lezcano (14): put in place the new framework add a simple program burning cycles add a nanosleep utility add script functions test the cpufreq framework is available for frequency test the cpufreq framework is available for governor test the governor change is effective test the change of the frequency is effective in 'userspace' mode test 'ondemand' and 'conservative' trigger correctly the configuration directory test the change of the frequencies affect the performances of a test program add a cpu burn utility test the load of the cpu affects the frequency with 'ondemand' test the load of the cpu does not affect the frequency with 'userspace' test the load of the cpu does not affect the frequency with 'powersave'
Makefile | 10 ++ cpufreq/Makefile | 38 ++++++++ cpufreq/test_01.sh | 32 +++++++ cpufreq/test_02.sh | 32 +++++++ cpufreq/test_03.sh | 51 ++++++++++ cpufreq/test_04.sh | 54 +++++++++++ cpufreq/test_05.sh | 73 +++++++++++++++ cpufreq/test_06.sh | 117 +++++++++++++++++++++++ cpufreq/test_07.sh | 91 ++++++++++++++++++ cpufreq/test_08.sh | 78 ++++++++++++++++ cpufreq/test_09.sh | 74 +++++++++++++++ include/functions.sh | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++ utils/Makefile | 35 +++++++ utils/cpuburn.c | 91 ++++++++++++++++++ utils/cpucycle.c | 108 +++++++++++++++++++++ utils/nanosleep.c | 55 +++++++++++ 16 files changed, 1190 insertions(+), 0 deletions(-) create mode 100644 cpufreq/Makefile create mode 100644 cpufreq/test_01.sh create mode 100644 cpufreq/test_02.sh create mode 100644 cpufreq/test_03.sh create mode 100644 cpufreq/test_04.sh create mode 100644 cpufreq/test_05.sh create mode 100644 cpufreq/test_06.sh create mode 100644 cpufreq/test_07.sh create mode 100644 cpufreq/test_08.sh create mode 100644 cpufreq/test_09.sh create mode 100644 include/functions.sh create mode 100644 utils/Makefile create mode 100644 utils/cpuburn.c create mode 100644 utils/cpucycle.c create mode 100644 utils/nanosleep.c
In order to run the tests, invoke:
'make check'
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- Makefile | 10 ++++++++++ cpufreq/Makefile | 38 ++++++++++++++++++++++++++++++++++++++ utils/Makefile | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 0 deletions(-) create mode 100644 cpufreq/Makefile create mode 100644 utils/Makefile
diff --git a/Makefile b/Makefile index a667f35..be9df5d 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,18 @@ #
all: + @(cd utils; $(MAKE)) @(cd testcases; $(MAKE) all)
+check: + @(cd utils; $(MAKE) check) + @(cd cpufreq; $(MAKE) check) +uncheck: + @(cd cpufreq; $(MAKE) uncheck) + +recheck: uncheck check + clean: + @(cd utils; $(MAKE) clean) @(cd testcases; $(MAKE) clean)
diff --git a/cpufreq/Makefile b/cpufreq/Makefile new file mode 100644 index 0000000..5dfc00d --- /dev/null +++ b/cpufreq/Makefile @@ -0,0 +1,38 @@ +# +# 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 +# + +TST=$(wildcard *.sh) +LOG=$(TST:.sh=.log) + +check: $(LOG) + +%.log: %.sh + @./$< + +clean: + rm -f $(LOG) + +uncheck: clean + +recheck: uncheck check diff --git a/utils/Makefile b/utils/Makefile new file mode 100644 index 0000000..6b0db07 --- /dev/null +++ b/utils/Makefile @@ -0,0 +1,35 @@ +# +# 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 +# + +CFLAGS?=-g -Wall +CC?=gcc +SRC=$(wildcard *.c) +EXEC=$(SRC:%.c=%) + +check: $(EXEC) + +all: $(EXEC) + +clean: + rm -f *.o $(EXEC)
This little program takes the cpu # as parameter, set the affinity and renice itself to the maximum priority. It increments a counter during one second, display the coutner's value and exit.
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- utils/cpucycle.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-) create mode 100644 utils/cpucycle.c
diff --git a/utils/cpucycle.c b/utils/cpucycle.c new file mode 100644 index 0000000..dc4a7d7 --- /dev/null +++ b/utils/cpucycle.c @@ -0,0 +1,108 @@ +/******************************************************************************* + * 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 + * + *******************************************************************************/ + +#define _GNU_SOURCE +#include <sched.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <signal.h> +#include <unistd.h> +#include <regex.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> + +static bool intr; + +void sigalarm(int sig) +{ + intr = true; +} + +int main(int argc, char *argv[]) +{ + regex_t reg; + const char *regex = "cpu[0-9].*"; + char **aargv = NULL; + regmatch_t m[1]; + cpu_set_t cpuset; + long counter = 0; + int i; + + if (argc == 1) { + fprintf(stderr, "%s <cpuN> [cpuM] ... \n", argv[0]); + return 1; + } + + aargv = &argv[1]; + + if (regcomp(®, regex, 0)) { + fprintf(stderr, "failed to compile the regex\n"); + return 1; + } + + CPU_ZERO(&cpuset); + + for (i = 0; i < (argc - 1); i++) { + + char *aux; + int cpu; + + if (regexec(®, aargv[i], 1, m, 0)) { + fprintf(stderr, "'%s' parameter not recognized, " \ + "should be cpu[0-9]\n", aargv[i]); + return 1; + } + + aux = aargv[i] + 3; + cpu = atoi(aux); + + CPU_SET(cpu, &cpuset); + } + + if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) { + perror("sched_setaffinity"); + return 1; + } + + if (setpriority(PRIO_PROCESS, 0, -20) < 0) { + perror("setpriority"); + return 1; + } + + signal(SIGALRM, sigalarm); + + /* warmup */ + alarm(1); + for (counter = 0, intr = false; !intr ; counter++); + + alarm(1); + for (counter = 0, intr = false; !intr ; counter++); + + printf("%ld\n", counter); + + return 0; +}
On 11 Jul 26, Daniel Lezcano wrote:
This little program takes the cpu # as parameter, set the affinity and renice itself to the maximum priority. It increments a counter during one second, display the coutner's value and exit.
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org
Have you looked at the cpuburn program?
utils/cpucycle.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-) create mode 100644 utils/cpucycle.c
diff --git a/utils/cpucycle.c b/utils/cpucycle.c new file mode 100644 index 0000000..dc4a7d7 --- /dev/null +++ b/utils/cpucycle.c @@ -0,0 +1,108 @@ +/*******************************************************************************
- 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
- *******************************************************************************/
+#define _GNU_SOURCE +#include <sched.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <signal.h> +#include <unistd.h> +#include <regex.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h>
+static bool intr;
+void sigalarm(int sig) +{
- intr = true;
+}
+int main(int argc, char *argv[]) +{
- regex_t reg;
- const char *regex = "cpu[0-9].*";
- char **aargv = NULL;
- regmatch_t m[1];
- cpu_set_t cpuset;
- long counter = 0;
- int i;
- if (argc == 1) {
fprintf(stderr, "%s <cpuN> [cpuM] ... \n", argv[0]);
return 1;
- }
- aargv = &argv[1];
- if (regcomp(®, regex, 0)) {
fprintf(stderr, "failed to compile the regex\n");
return 1;
- }
- CPU_ZERO(&cpuset);
- for (i = 0; i < (argc - 1); i++) {
char *aux;
int cpu;
if (regexec(®, aargv[i], 1, m, 0)) {
fprintf(stderr, "'%s' parameter not recognized, " \
"should be cpu[0-9]\n", aargv[i]);
return 1;
}
aux = aargv[i] + 3;
cpu = atoi(aux);
CPU_SET(cpu, &cpuset);
- }
- if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) {
perror("sched_setaffinity");
return 1;
- }
- if (setpriority(PRIO_PROCESS, 0, -20) < 0) {
perror("setpriority");
return 1;
- }
- signal(SIGALRM, sigalarm);
- /* warmup */
- alarm(1);
- for (counter = 0, intr = false; !intr ; counter++);
- alarm(1);
- for (counter = 0, intr = false; !intr ; counter++);
- printf("%ld\n", counter);
- return 0;
+}
1.7.4.1
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 07/27/2011 03:47 PM, Amit Kucheria wrote:
On 11 Jul 26, Daniel Lezcano wrote:
This little program takes the cpu # as parameter, set the affinity and renice itself to the maximum priority. It increments a counter during one second, display the coutner's value and exit.
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org
Have you looked at the cpuburn program?
Yes, but as far as I know it works for x86 only and was written in assembly.
Moreover the cpuburn program is dangerous:
"*** WARNING *** This program is designed to heavily load CPU chips. Undercooled, overclocked or otherwise weak systems may fail causing data loss (filesystem corruption) and possibly permanent damage to electronic components. Nor will it catch all flaws. *** USE AT YOUR OWN RISK ***"
I prefer to use our own program doing exactly what we need. In the future, when more pm blocks test will be written and I expect cpuburn will merge with a more global cpu utility program we will write.
This utility gives a finer grain to wait for smaller amount of time. This is useful for waiting the delay between each frequency change.
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- utils/nanosleep.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) create mode 100644 utils/nanosleep.c
diff --git a/utils/nanosleep.c b/utils/nanosleep.c new file mode 100644 index 0000000..f366e53 --- /dev/null +++ b/utils/nanosleep.c @@ -0,0 +1,55 @@ +/******************************************************************************* + * 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 <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <time.h> + +int main(int argc, char *argv[]) +{ + struct timespec req = { 0 }, rem = { 0 }; + + if (argc != 2) { + fprintf(stderr, "%s <nanoseconds>\n", argv[0]); + return 1; + } + + req.tv_nsec = atoi(argv[1]); + + for (;;) { + if (!nanosleep(&req, &rem)) + break; + + if (errno == EINTR) { + req = rem; + continue; + } + + perror("failed to nanosleep"); + return 1; + } + + return 0; +}
Add a common directory for all the functions we will use later in the test scripts.
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- include/functions.sh | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 251 insertions(+), 0 deletions(-) create mode 100644 include/functions.sh
diff --git a/include/functions.sh b/include/functions.sh new file mode 100644 index 0000000..67c356a --- /dev/null +++ b/include/functions.sh @@ -0,0 +1,251 @@ +#!/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 +# + +CPU_PATH="/sys/devices/system/cpu" +TEST_NAME=$(basename ${0%.sh}) +PREFIX=$TEST_NAME +BLOCK=$(basename $(pwd)) + +setprefix_cpu() { + PREFIX=$BLOCK:$TEST_NAME/$1 +} + +log_begin() { + printf "%-75s" "$PREFIX $@ ... " +} + +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 + setprefix_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=$(cat $dirpath/cpuinfo_transition_latency) + local nrfreq=$(cat $dirpath/scaling_available_frequencies | wc -w) + + 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 +} + +check() { + + local descr=$1 + local func=$2 + shift 2; + + log_begin "checking $descr" + + $func $@ + if [ $? != 0 ]; then + log_end "FAIL" + return 1 + fi + + log_end "PASS" + + return 0 +} + +check_cpufreq_files() { + + local dirpath=$CPU_PATH/$1/cpufreq + shift 1 + + for i in $@; do + check "$i exists" "test -f" $dirpath/$i || 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 +} \ No newline at end of file
Just a nit below.
On 11 Jul 26, Daniel Lezcano wrote:
Add a common directory for all the functions we will use later in the test scripts.
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org
include/functions.sh | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 251 insertions(+), 0 deletions(-) create mode 100644 include/functions.sh
diff --git a/include/functions.sh b/include/functions.sh new file mode 100644 index 0000000..67c356a --- /dev/null +++ b/include/functions.sh @@ -0,0 +1,251 @@ +#!/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 +#
+CPU_PATH="/sys/devices/system/cpu" +TEST_NAME=$(basename ${0%.sh}) +PREFIX=$TEST_NAME +BLOCK=$(basename $(pwd))
+setprefix_cpu() {
- PREFIX=$BLOCK:$TEST_NAME/$1
+}
+log_begin() {
- printf "%-75s" "$PREFIX $@ ... "
+}
+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
- setprefix_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=$(cat $dirpath/cpuinfo_transition_latency)
- local nrfreq=$(cat $dirpath/scaling_available_frequencies | wc -w)
- 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
+}
+check() {
- local descr=$1
- local func=$2
- shift 2;
- log_begin "checking $descr"
- $func $@
- if [ $? != 0 ]; then
- log_end "FAIL"
- return 1
- fi
- log_end "PASS"
- return 0
+}
+check_cpufreq_files() {
- local dirpath=$CPU_PATH/$1/cpufreq
- shift 1
- for i in $@; do
- check "$i exists" "test -f" $dirpath/$i || 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
+} \ No newline at end of file
^^^
-- 1.7.4.1
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_01.sh | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_01.sh
diff --git a/cpufreq/test_01.sh b/cpufreq/test_01.sh new file mode 100644 index 0000000..7ff841c --- /dev/null +++ b/cpufreq/test_01.sh @@ -0,0 +1,32 @@ +#!/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#test_01 + +source ../include/functions.sh + +FILES="scaling_available_frequencies scaling_cur_freq scaling_setspeed" + +for_each_cpu check_cpufreq_files $FILES
On 11 Jul 26, Daniel Lezcano wrote:
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org
cpufreq/test_01.sh | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_01.sh
diff --git a/cpufreq/test_01.sh b/cpufreq/test_01.sh new file mode 100644 index 0000000..7ff841c --- /dev/null +++ b/cpufreq/test_01.sh @@ -0,0 +1,32 @@ +#!/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#test_01
Would it be better for future maintainability if this was anchored by an explicity test name rather than just test_01, 02, etc.?
+source ../include/functions.sh
+FILES="scaling_available_frequencies scaling_cur_freq scaling_setspeed"
+for_each_cpu check_cpufreq_files $FILES
1.7.4.1
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_02.sh | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_02.sh
diff --git a/cpufreq/test_02.sh b/cpufreq/test_02.sh new file mode 100644 index 0000000..0b3216e --- /dev/null +++ b/cpufreq/test_02.sh @@ -0,0 +1,32 @@ +#!/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#test_02 + +source ../include/functions.sh + +FILES="scaling_available_governors scaling_governor" + +for_each_cpu check_cpufreq_files $FILES
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_03.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_03.sh
diff --git a/cpufreq/test_03.sh b/cpufreq/test_03.sh new file mode 100644 index 0000000..4dff432 --- /dev/null +++ b/cpufreq/test_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#test_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
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_04.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_04.sh
diff --git a/cpufreq/test_04.sh b/cpufreq/test_04.sh new file mode 100644 index 0000000..97ec682 --- /dev/null +++ b/cpufreq/test_04.sh @@ -0,0 +1,54 @@ +#!/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#test_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 + +for_each_cpu for_each_frequency check_frequency || exit 1
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_05.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_05.sh
diff --git a/cpufreq/test_05.sh b/cpufreq/test_05.sh new file mode 100644 index 0000000..7064c13 --- /dev/null +++ b/cpufreq/test_05.sh @@ -0,0 +1,73 @@ +#!/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#test_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' +} + +for_each_cpu switch_ondemand +check "'ondemand' directory exists" "test -d $CPU_PATH/cpufreq/ondemand" + +for_each_cpu switch_conservative +check "'conservative' directory exists" "test -d $CPU_PATH/cpufreq/conservative" + +for_each_cpu switch_userspace +check "'ondemand' directory is not there" "test ! -d $CPU_PATH/cpufreq/ondemand" +check "'conservative' directory is not there" "test ! -d $CPU_PATH/cpufreq/conservative" + +# if more than one cpu, combine governors +nrcpus=$(ls $CPU_PATH | grep "cpu[0-9].*" | wc -l) +if [ $nrcpus > 0 ]; 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" +fi + +restore_governors
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_06.sh | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 117 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_06.sh
diff --git a/cpufreq/test_06.sh b/cpufreq/test_06.sh new file mode 100644 index 0000000..5e8256d --- /dev/null +++ b/cpufreq/test_06.sh @@ -0,0 +1,117 @@ +#!/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#test_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 + +save_governors +save_frequencies + +trap "restore_frequencies; restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_deviation + +restore_frequencies +restore_governors
A very simple program, similar to cpucycle, but doing nothing more than looping indefinitively.
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- utils/cpuburn.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 91 insertions(+), 0 deletions(-) create mode 100644 utils/cpuburn.c
diff --git a/utils/cpuburn.c b/utils/cpuburn.c new file mode 100644 index 0000000..12e82c0 --- /dev/null +++ b/utils/cpuburn.c @@ -0,0 +1,91 @@ +/******************************************************************************* + * 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 + * + *******************************************************************************/ + +#define _GNU_SOURCE +#include <sched.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <signal.h> +#include <unistd.h> +#include <regex.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> + +int main(int argc, char *argv[]) +{ + regex_t reg; + const char *regex = "cpu[0-9].*"; + char **aargv = NULL; + regmatch_t m[1]; + cpu_set_t cpuset; + int i; + + if (argc == 1) { + fprintf(stderr, "%s <cpuN> [cpuM] ... \n", argv[0]); + return 1; + } + + aargv = &argv[1]; + + if (regcomp(®, regex, 0)) { + fprintf(stderr, "failed to compile the regex\n"); + return 1; + } + + CPU_ZERO(&cpuset); + + for (i = 0; i < (argc - 1); i++) { + + char *aux; + int cpu; + + if (regexec(®, aargv[i], 1, m, 0)) { + fprintf(stderr, "'%s' parameter not recognized, " \ + "should be cpu[0-9]\n", aargv[i]); + return 1; + } + + aux = aargv[i] + 3; + cpu = atoi(aux); + + CPU_SET(cpu, &cpuset); + } + + if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) { + perror("sched_setaffinity"); + return 1; + } + + if (setpriority(PRIO_PROCESS, 0, -20) < 0) { + perror("setpriority"); + return 1; + } + + for (;;); + + return 0; +}
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_07.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 91 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_07.sh
diff --git a/cpufreq/test_07.sh b/cpufreq/test_07.sh new file mode 100644 index 0000000..ce567f1 --- /dev/null +++ b/cpufreq/test_07.sh @@ -0,0 +1,91 @@ +#!/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#test_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 + +save_governors + +trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_ondemand + +restore_governors
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_08.sh | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_08.sh
diff --git a/cpufreq/test_08.sh b/cpufreq/test_08.sh new file mode 100644 index 0000000..cf86494 --- /dev/null +++ b/cpufreq/test_08.sh @@ -0,0 +1,78 @@ +#!/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#test_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 + +trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_userspace + +restore_governors
Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- cpufreq/test_09.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 0 deletions(-) create mode 100644 cpufreq/test_09.sh
diff --git a/cpufreq/test_09.sh b/cpufreq/test_09.sh new file mode 100644 index 0000000..ca05b11 --- /dev/null +++ b/cpufreq/test_09.sh @@ -0,0 +1,74 @@ +#!/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#test_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 + +trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM + +for_each_cpu check_powersave + +restore_governors
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 07/26/2011 02:46 PM, Daniel Lezcano wrote:
These tests are for the power mangemenat QA. The test definitions are at:
https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts
Not all the boards have cpufreq enabled or totally implemented, so the test suite was checked against a multicore and multiprocessor x86 platform.
Amit,
are you ok if I commit the patches ? The cpufreq is not fully available on arm yet. I think the scripts are well factored and that will be easy to tweak the tests when cpufreq will be fully operational. Moreover that will give a test set for the developer to check cpufreq is working.
What do you think ?
Thanks -- Daniel
On Thu, Jul 28, 2011 at 9:13 PM, Daniel Lezcano daniel.lezcano@linaro.org wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 07/26/2011 02:46 PM, Daniel Lezcano wrote:
These tests are for the power mangemenat QA. The test definitions are at:
https://wiki.linaro.org/WorkingGroups/PowerManagement/Doc/QA/Scripts
Not all the boards have cpufreq enabled or totally implemented, so the test suite was checked against a multicore and multiprocessor x86 platform.
Amit,
are you ok if I commit the patches ? The cpufreq is not fully available on arm yet. I think the scripts are well factored and that will be easy to tweak the tests when cpufreq will be fully operational. Moreover that will give a test set for the developer to check cpufreq is working.
What do you think ?
Thanks -- Daniel
Yes, I think you should commit the patches and fix bugs if found.
Regards, Amit