All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] cpufreq: tests: Cpufreq test to check if all declared freqs can be set
@ 2015-01-26 10:41 Lukasz Majewski
  2015-01-26 10:41 ` [PATCH 2/3] cpufreq: tests: Provide test to check if all supported governors are working Lukasz Majewski
  2015-01-26 10:41 ` [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README Lukasz Majewski
  0 siblings, 2 replies; 7+ messages in thread
From: Lukasz Majewski @ 2015-01-26 10:41 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Linux PM list, Lukasz Majewski,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Thomas Abraham,
	Kevin Hilman, Kevin Hilman, a.nitecki, Lukasz Majewski

This test allows checking if all declared frequencies can be set on tested
board.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 tools/testing/cpufreq/cpufreq_freq_test.sh | 149 +++++++++++++++++++++++++++++
 1 file changed, 149 insertions(+)
 create mode 100755 tools/testing/cpufreq/cpufreq_freq_test.sh

diff --git a/tools/testing/cpufreq/cpufreq_freq_test.sh b/tools/testing/cpufreq/cpufreq_freq_test.sh
new file mode 100755
index 0000000..6dfd08b
--- /dev/null
+++ b/tools/testing/cpufreq/cpufreq_freq_test.sh
@@ -0,0 +1,149 @@
+#!/bin/bash
+#
+# This file provides a simple mean to test if all declared freqs at
+# "scaling_available_frequencies" can be set and if "cpuinfo_cur_freq"
+# returns this value.
+#
+# Usage: ./cpufreq_freq_test.sh
+# Requisite: Compiled in "performance" governor
+#
+# 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, you can access it online at
+# http://www.gnu.org/licenses/gpl-2.0.html.
+#
+# Copyright (C) Samsung Electronics, 2014-2015
+#
+# Author: Lukasz Majewski <l.majewski@samsung.com>
+
+set +x
+
+COLOUR_RED="\33[31m"
+COLOUR_BLUE="\33[34m"
+COLOUR_GREEN="\33[32m"
+COLOUR_DEFAULT="\33[0m"
+
+T_PATH=/sys/devices/system/cpu/cpu0/cpufreq
+BOOST_PATH=/sys/devices/system/cpu/cpufreq
+
+if [ ! -d "$T_PATH" ]; then
+    printf "   $COLOUR_RED No path to CPUFREQ $COLOUR_DEFAULT\n"
+    exit 1
+fi
+
+ERRORS=0
+
+OLD_GOV=`cat $T_PATH/scaling_governor`
+echo "CURRENT GOVERNOR: $OLD_GOV"
+echo "SET GOVERNOR: performance"
+echo "performance" > $T_PATH/scaling_governor
+
+function test_freqs1 {
+    FREQS=`cat $1`
+    for I in $FREQS; do
+	cpufreq_set_freq $I
+	if [ "$2" ]; then
+	    printf "$COLOUR_BLUE BOOST $COLOUR_DEFAULT" $I
+	fi
+	cpufreq_test_freq $I
+    done
+}
+
+function test_freqs2 {
+    FREQ=`cat $1`
+    FREQS_ARRAY=($FREQ)
+
+    for freq in ${FREQS_ARRAY[@]}
+    do
+	echo "REFERENCE FREQ: $freq"
+	for f in ${FREQS_ARRAY[@]}
+	do
+	    cpufreq_set_freq $freq
+	    echo -n "----> "
+	    cpufreq_set_freq $f
+	    cpufreq_test_freq $f
+	done
+    done
+}
+
+function restore {
+    if [ -f $BOOST_PATH/boost ]; then
+	cpufreq_boost_state $BOOST_STATE
+    fi
+
+    echo "SET GOVERNOR: $OLD_GOV"
+    echo $OLD_GOV > $T_PATH/scaling_governor
+}
+
+function die {
+    printf "   $COLOUR_RED FAILED $COLOUR_DEFAULT\n"
+    restore_gov
+    exit 1
+}
+
+function cpufreq_test_freq {
+    gzip < /dev/urandom > /dev/null &
+    pid=$!
+    sleep 0.1
+    CURR_FREQ=`cat $T_PATH/cpuinfo_cur_freq`
+    if [ $1 -eq $CURR_FREQ ]; then
+	printf "\t$COLOUR_GREEN OK $COLOUR_DEFAULT\n"
+    else
+	printf "$COLOUR_RED CURRENT $CURR_FREQ $COLOUR_DEFAULT\n"
+	ERRORS=$(( $ERRORS + 1 ))
+	#die
+    fi
+    kill -9 $pid
+    wait $! 2>/dev/null
+}
+
+function cpufreq_set_freq {
+    echo $1 > $T_PATH/scaling_max_freq || die $?
+    printf "FREQ:$COLOUR_GREEN %s $COLOUR_DEFAULT" $1
+}
+
+function cpufreq_boost_state {
+   echo $1 > $BOOST_PATH/boost
+}
+
+function cpufreq_boost_status {
+   cat $BOOST_PATH/boost
+}
+
+if [ -f $BOOST_PATH/boost ]; then
+    echo "######################################"
+    echo "TEST BOOST OPERATION"
+    echo "######################################"
+
+    BOOST_STATE=$(cpufreq_boost_status)
+    if [ $BOOST_STATE -eq 0 ]; then
+	cpufreq_boost_state 1
+    fi
+    test_freqs1 $T_PATH/scaling_boost_frequencies 1
+fi
+
+echo "######################################"
+echo "TEST AVAILABLE FREQS"
+echo "######################################"
+test_freqs1 $T_PATH/scaling_available_frequencies
+
+echo "######################################"
+echo "TEST FREQS SWITCHING"
+echo "######################################"
+test_freqs2 $T_PATH/scaling_available_frequencies
+
+echo "######################################"
+echo "ERRORS: $ERRORS"
+echo "######################################"
+
+restore
+exit 0
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] cpufreq: tests: Provide test to check if all supported governors are working
  2015-01-26 10:41 [PATCH 1/3] cpufreq: tests: Cpufreq test to check if all declared freqs can be set Lukasz Majewski
@ 2015-01-26 10:41 ` Lukasz Majewski
  2015-01-26 10:41 ` [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README Lukasz Majewski
  1 sibling, 0 replies; 7+ messages in thread
From: Lukasz Majewski @ 2015-01-26 10:41 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Linux PM list, Lukasz Majewski,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Thomas Abraham,
	Kevin Hilman, Kevin Hilman, a.nitecki, Lukasz Majewski

This test checks if all compiled in cpufreq governors can be enabled.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 tools/testing/cpufreq/governors_switch.sh | 92 +++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
 create mode 100755 tools/testing/cpufreq/governors_switch.sh

diff --git a/tools/testing/cpufreq/governors_switch.sh b/tools/testing/cpufreq/governors_switch.sh
new file mode 100755
index 0000000..16bd88c
--- /dev/null
+++ b/tools/testing/cpufreq/governors_switch.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+#
+# This file provides a simple mean to test if all declared governors
+# at "scaling_available_governors" can be set and if "scaling_governor"
+# returns this value.
+#
+# Usage: ./governors_switch
+# Requisite: None
+#
+# 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, you can access it online at
+# http://www.gnu.org/licenses/gpl-2.0.html.
+#
+# Copyright (C) Samsung Electronics, 2015
+#
+# Author: Lukasz Majewski <l.majewski@samsung.com>
+
+set +x
+T_PATCH=/sys/devices/system/cpu/cpu0/cpufreq
+
+ERRORS=0
+
+function restore_gov {
+    echo "SET GOVERNOR: $OLD_GOV"
+    echo $OLD_GOV > $T_PATCH/scaling_governor
+}
+
+function die {
+    printf "   \33[31m FAILED \33[0m \n"
+    restore_gov
+    exit $1
+}
+
+
+echo "######################################"
+printf "\33[35mGovernors permutation test\33[0m\n"
+echo "######################################"
+OLD_GOV=`cat $T_PATCH/scaling_governor`
+echo "CURRENT GOVERNOR: $OLD_GOV"
+
+GOVS=`cat $T_PATCH/scaling_available_governors`
+echo "Available governors: $GOVS"
+
+GOVS_ARRAY=($GOVS)
+GOVS_ARRAY_ELEM=${#GOVS_ARRAY[@]}
+echo "Number of elements: $GOVS_ARRAY_ELEM"
+
+if [ $GOVS_ARRAY_ELEM -le 1 ];
+then
+    echo "Only one governor present - NO testing"
+    exit 0
+fi
+
+TMP=$GOVS_ARRAY
+
+for gov in ${GOVS_ARRAY[@]}
+do
+    printf "\33[35mGOV:\t $gov\n\33[0m"
+
+    for f in ${GOVS_ARRAY[@]}
+    do
+	echo $gov > $T_PATCH/scaling_governor || die $?
+	printf "\t $f "
+	echo $f > $T_PATCH/scaling_governor || die $?
+
+	CURRENT_GOV=`cat $T_PATCH/scaling_governor`
+	if [ $CURRENT_GOV == $f ]; then
+	    printf "\t\33[32m OK \33[0m \n"
+	else
+	    printf "\t\33[31m CURRENT GOV: $CURRENT_GOV \33[0m \n"
+	    ERRORS=$(( $ERRORS + 1 ))
+	fi
+    done
+done
+
+echo "######################################"
+echo "ERRORS: $ERRORS"
+echo "######################################"
+
+restore_gov
+
+exit 0;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README
  2015-01-26 10:41 [PATCH 1/3] cpufreq: tests: Cpufreq test to check if all declared freqs can be set Lukasz Majewski
  2015-01-26 10:41 ` [PATCH 2/3] cpufreq: tests: Provide test to check if all supported governors are working Lukasz Majewski
@ 2015-01-26 10:41 ` Lukasz Majewski
  2015-01-27  3:56   ` Viresh Kumar
  1 sibling, 1 reply; 7+ messages in thread
From: Lukasz Majewski @ 2015-01-26 10:41 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Linux PM list, Lukasz Majewski,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Thomas Abraham,
	Kevin Hilman, Kevin Hilman, a.nitecki, Lukasz Majewski

This commit adds README to ./tools/testing/cpufreq directory.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 tools/testing/cpufreq/README | 53 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 tools/testing/cpufreq/README

diff --git a/tools/testing/cpufreq/README b/tools/testing/cpufreq/README
new file mode 100644
index 0000000..c934016
--- /dev/null
+++ b/tools/testing/cpufreq/README
@@ -0,0 +1,53 @@
+This file contains list of cpufreq's available regression tests with a short
+usage description.
+
+1. cpufreq_freq_test.sh
+
+Description:
+------------
+This script is supposed to test if cpufreq attributes exported by sysfs are
+exposing correct values.
+
+To achieve this goal it saves the current governor and changes it to
+"performance". Afterwards, it reads the "scaling_available_frequencies"
+property. With the list of supported frequencies it is able to enforce each of
+them by writing to "scaling_max_freq" attribute. To make the test more reliable
+a superfluous load with gzip is created to be sure that we are running with
+highest possible frequency. This high load is regulated with the 'sleep'
+duration. After this time the "cpufreq_cur_freq" is read and compared with the
+original value. As the last step the original governor is restored.
+
+This script can work with or without BOOST enabled and helps in spotting errors
+related to cpufreq and common clock framework.
+
+Used attributes:
+----------------
+- "scaling_available_frequencies"
+- "cpuinfo_cur_freq"
+- "scaling_governor"
+- "scaling_max_freq"
+
+Target devices:
+---------------
+
+All devices which exports mentioned above sysfs attributes.
+
+2. governors_switch.sh
+
+Description:
+------------
+This script is supposed to test if all governors are available and possible to
+set.
+
+Moreover, it allows to test if cpufreq is able to withstand multiple accesses to
+the same sysfs attribute without crash.
+
+Used attributes:
+----------------
+- "scaling_available_governors"
+- "scaling_governor"
+
+Target devices:
+---------------
+
+All devices which exports mentioned above sysfs attributes.
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README
  2015-01-26 10:41 ` [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README Lukasz Majewski
@ 2015-01-27  3:56   ` Viresh Kumar
  2015-01-27  8:35     ` Lukasz Majewski
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2015-01-27  3:56 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Linux PM list, Lukasz Majewski,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Thomas Abraham,
	Kevin Hilman, Kevin Hilman, a.nitecki

On 26 January 2015 at 16:11, Lukasz Majewski <l.majewski@samsung.com> wrote:
> This commit adds README to ./tools/testing/cpufreq directory.

You might want to have a look at this..

https://git.linaro.org/people/viresh.kumar/cpufreq-tests.git


I had been working on this recently ..

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README
  2015-01-27  3:56   ` Viresh Kumar
@ 2015-01-27  8:35     ` Lukasz Majewski
  2015-01-27  8:40       ` Viresh Kumar
  0 siblings, 1 reply; 7+ messages in thread
From: Lukasz Majewski @ 2015-01-27  8:35 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Linux PM list, Lukasz Majewski,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Thomas Abraham,
	Kevin Hilman, Kevin Hilman, a.nitecki

Hi Viresh,

> On 26 January 2015 at 16:11, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> > This commit adds README to ./tools/testing/cpufreq directory.
> 
> You might want to have a look at this..
> 
> https://git.linaro.org/people/viresh.kumar/cpufreq-tests.git
> 
> 
> I had been working on this recently ..

Very nice pack of tests.

What I can say after a glimpse look on them is that your tests already
implement case for "governors switching".

However the 'cpufreq_freq_test.sh' do a bit more - it uses performance,
then forces 100% CPU usage and then switch from one single frequency to
all available (including BOOST modes). For that reason I think that it
would be valuable to add this test to your suite (of course on your
discretion).

Viresh, do you plan to add your tests to
kernel's ./tools/testing/cpufreq/ directory? It would enhance
recognition of your work and encourage others to use it before
submitting patches.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README
  2015-01-27  8:35     ` Lukasz Majewski
@ 2015-01-27  8:40       ` Viresh Kumar
  2015-01-27  8:57         ` Lukasz Majewski
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2015-01-27  8:40 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Linux PM list, Lukasz Majewski,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Thomas Abraham,
	Kevin Hilman, Kevin Hilman, a.nitecki

On 27 January 2015 at 14:05, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Very nice pack of tests.

Thanks.

> What I can say after a glimpse look on them is that your tests already
> implement case for "governors switching".

Correct and much more than that :)

> However the 'cpufreq_freq_test.sh' do a bit more - it uses performance,
> then forces 100% CPU usage and then switch from one single frequency to
> all available (including BOOST modes). For that reason I think that it
> would be valuable to add this test to your suite (of course on your
> discretion).

Will you be able to send a patch for that to me (*without* the lists)?

> Viresh, do you plan to add your tests to
> kernel's ./tools/testing/cpufreq/ directory? It would enhance
> recognition of your work and encourage others to use it before
> submitting patches.

Yeah, I do plan to. I have been doing some major reworks of cpufreq
core and so I built them. I haven't found time yet to get them in, but
they will surely be there in some time :)

--
viresh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README
  2015-01-27  8:40       ` Viresh Kumar
@ 2015-01-27  8:57         ` Lukasz Majewski
  0 siblings, 0 replies; 7+ messages in thread
From: Lukasz Majewski @ 2015-01-27  8:57 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Eduardo Valentin, Linux PM list, Lukasz Majewski,
	Abhilash Kesavan, Abhilash Kesavan, Chanwoo Choi, Thomas Abraham,
	Kevin Hilman, Kevin Hilman, a.nitecki

Hi Viresh,

> On 27 January 2015 at 14:05, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> > Very nice pack of tests.
> 
> Thanks.
> 
> > What I can say after a glimpse look on them is that your tests
> > already implement case for "governors switching".
> 
> Correct and much more than that :)
> 
> > However the 'cpufreq_freq_test.sh' do a bit more - it uses
> > performance, then forces 100% CPU usage and then switch from one
> > single frequency to all available (including BOOST modes). For that
> > reason I think that it would be valuable to add this test to your
> > suite (of course on your discretion).
> 
> Will you be able to send a patch for that to me (*without* the lists)?

I rather thought about running this test as your run yours with runme.sh

> 
> > Viresh, do you plan to add your tests to
> > kernel's ./tools/testing/cpufreq/ directory? It would enhance
> > recognition of your work and encourage others to use it before
> > submitting patches.
> 
> Yeah, I do plan to. I have been doing some major reworks of cpufreq
> core and so I built them. I haven't found time yet to get them in, but
> they will surely be there in some time :)

I had similar problem with UDC/USB development in u-boot. I had a set
of "private/not ready to publish/etc" tests against regressions.

Only when I've posted those tests to the mailing list and they were
included to development tree, people started to use them before
submitting patches. I have less maintanence work and also developers
helped me a lot with improving the tests itself.

I'm a good example - I wasn't aware about your tests, and hence didn't
use them.
I believe that those tests shall land under ./tools/testing/cpufreq/
directory ASAP.

> 
> --
> viresh



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-27  8:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-26 10:41 [PATCH 1/3] cpufreq: tests: Cpufreq test to check if all declared freqs can be set Lukasz Majewski
2015-01-26 10:41 ` [PATCH 2/3] cpufreq: tests: Provide test to check if all supported governors are working Lukasz Majewski
2015-01-26 10:41 ` [PATCH 3/3] doc: cpufreq: tests: Provide cpufreq tests README Lukasz Majewski
2015-01-27  3:56   ` Viresh Kumar
2015-01-27  8:35     ` Lukasz Majewski
2015-01-27  8:40       ` Viresh Kumar
2015-01-27  8:57         ` Lukasz Majewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.