public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Eduardo Valentin <edubezval@gmail.com>,
	Linux PM list <linux-pm@vger.kernel.org>,
	Lukasz Majewski <l.majewski@majess.pl>,
	Abhilash Kesavan <kesavan.abhilash@gmail.com>,
	Abhilash Kesavan <a.kesavan@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Thomas Abraham <thomas.ab@samsung.com>,
	Kevin Hilman <khilman@linaro.org>,
	Kevin Hilman <khilman@kernel.org>,
	a.nitecki@samsung.com, Lukasz Majewski <l.majewski@samsung.com>
Subject: [PATCH 1/3] cpufreq: tests: Cpufreq test to check if all declared freqs can be set
Date: Mon, 26 Jan 2015 11:41:22 +0100	[thread overview]
Message-ID: <1422268884-26173-1-git-send-email-l.majewski@samsung.com> (raw)

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


             reply	other threads:[~2015-01-26 10:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 10:41 Lukasz Majewski [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422268884-26173-1-git-send-email-l.majewski@samsung.com \
    --to=l.majewski@samsung.com \
    --cc=a.kesavan@samsung.com \
    --cc=a.nitecki@samsung.com \
    --cc=cw00.choi@samsung.com \
    --cc=edubezval@gmail.com \
    --cc=kesavan.abhilash@gmail.com \
    --cc=khilman@kernel.org \
    --cc=khilman@linaro.org \
    --cc=l.majewski@majess.pl \
    --cc=linux-pm@vger.kernel.org \
    --cc=thomas.ab@samsung.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox