From patchwork Fri Jul 18 10:23:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 4582321 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 696939F37C for ; Fri, 18 Jul 2014 10:23:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78F6920120 for ; Fri, 18 Jul 2014 10:23:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B8E020166 for ; Fri, 18 Jul 2014 10:23:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761601AbaGRKXX (ORCPT ); Fri, 18 Jul 2014 06:23:23 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:37106 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761597AbaGRKXU (ORCPT ); Fri, 18 Jul 2014 06:23:20 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N8W009I5KUTFI60@mailout1.samsung.com>; Fri, 18 Jul 2014 19:23:17 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-fe-53c8f59404c6 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 80.AC.04943.495F8C35; Fri, 18 Jul 2014 19:23:17 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N8W005MAKUKBK60@mmp2.samsung.com>; Fri, 18 Jul 2014 19:23:16 +0900 (KST) From: Lukasz Majewski To: Viresh Kumar Cc: "Rafael J. Wysocki" , "linux-samsung-soc@vger.kernel.org" , "cpufreq@vger.kernel.org" , Linux PM list , Thomas Abraham , "thomas.ab@samsung.com" , Lukasz Majewski , "linux-arm-kernel@lists.infradead.org" , Tomasz Figa , Lukasz Majewski Subject: [PATCH] cpufreq: tests: Providing cpufreq regression test Date: Fri, 18 Jul 2014 12:23:05 +0200 Message-id: <1405678985-21677-1-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCLMWRmVeSWpSXmKPExsVy+t9jQd2pX08EG3ycxm7xtOkHu8WbR9wW bx5uZrTY9Pgaq8Xn3iOMFjPO72OyOHP6EqvF+hmvWSw2T9jIZtGxjNFi41cPB26PnbPusnvc ubaHzWPzknqPddPeMntsudrO4tG3ZRWjx+dNcgHsUVw2Kak5mWWpRfp2CVwZS5/NZiyYpF2x at8n9gbGTuUuRk4OCQETiRN/57ND2GISF+6tZ+ti5OIQEpjOKHGy4TVYQkigi0ni8CwREJtN QE/i892nTF2MHBwiAloSL2+mgtQzC/xllvizdSMzSI2wgJPE+ym/wXpZBFQlVmz6wA5Szyvg JnH4nCfELkWJ7mcT2CYwci9gZFjFKJpakFxQnJSea6hXnJhbXJqXrpecn7uJERxWz6R2MK5s sDjEKMDBqMTDa3HzeLAQa2JZcWXuIUYJDmYlEd7s+0Ah3pTEyqrUovz4otKc1OJDjNIcLEri vAdarQOFBNITS1KzU1MLUotgskwcnFINjEJbJt6pv86aurkv28tpcUShPJtCzGU5O+W4R4ln t90Xm3auOLotc+7vOU+O22fxf6z59DUg/f6ZaFYvHqaFLQFTFbVPb+b9963glPbhvirZvfNF LrzNjL/ly5jLme4553dt/+HJnybc0n+UpyjftbnaJbu9aNs3/01rPS+cd9jByvArr0xtvRJL cUaioRZzUXEiAO/dpSUnAgAA Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds first regression test "cpufreq_freq_test.sh" for the cpufreq subsystem. Signed-off-by: Lukasz Majewski --- drivers/cpufreq/tests/README | 23 +++++ drivers/cpufreq/tests/cpufreq_freq_test.sh | 149 +++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 drivers/cpufreq/tests/README create mode 100755 drivers/cpufreq/tests/cpufreq_freq_test.sh diff --git a/drivers/cpufreq/tests/README b/drivers/cpufreq/tests/README new file mode 100644 index 0000000..66638d2 --- /dev/null +++ b/drivers/cpufreq/tests/README @@ -0,0 +1,23 @@ +This file contains list of cpufreq's available regression tests with a short +usage description. + +1. cpufreq_freq_test.sh + +Description: +------------ +This test is supposed to test if cpufreq attributes exported by sysfs are +exposing a correct values. + +It can work with or without boost enabled and helps spotting errors related to +cpufreq and common clock framework. + +Used attributes: +---------------- +- "scaling_available_frequencies" +- "cpuinfo_cur_freq" +- "scaling_governor" + +Target devices: +--------------- + +All devices which exports mentioned above sysfs attributes. \ No newline at end of file diff --git a/drivers/cpufreq/tests/cpufreq_freq_test.sh b/drivers/cpufreq/tests/cpufreq_freq_test.sh new file mode 100755 index 0000000..53156ca --- /dev/null +++ b/drivers/cpufreq/tests/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: Compile 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 +# +# Author: Lukasz Majewski + +set +x + +COLOUR_RED="\33[31m" +COLOUR_BLUE="\33[34m" +COLOUR_GREEN="\33[32m" +COLOUR_DEFAULT="\33[0m" + +T_PATCH=/sys/devices/system/cpu/cpu0/cpufreq +BOOST_PATCH=/sys/devices/system/cpu/cpufreq + +if [ ! -d "$T_PATCH" ]; then + printf " $COLOUR_RED No patch to CPUFREQ $COLOUR_DEFAULT\n" + exit 1 +fi + +ERRORS=0 + +OLD_GOV=`cat $T_PATCH/scaling_governor` +echo "CURRENT GOVERNOR: $OLD_GOV" +echo "SET GOVERNOR: performance" +echo "performance" > $T_PATCH/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_PATCH/boost ]; then + cpufreq_boost_state $BOOST_STATE + fi + + echo "SET GOVERNOR: $OLD_GOV" + echo $OLD_GOV > $T_PATCH/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_PATCH/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=`expr $ERRORS + 1` + #die + fi + kill -9 $pid + wait $! 2>/dev/null +} + +function cpufreq_set_freq { + echo $1 > $T_PATCH/scaling_max_freq || die $? + printf "FREQ:$COLOUR_GREEN %s $COLOUR_DEFAULT" $1 +} + +function cpufreq_boost_state { + echo $1 > $BOOST_PATCH/boost +} + +function cpufreq_boost_status { + cat $BOOST_PATCH/boost +} + +if [ -f $BOOST_PATCH/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_PATCH/scaling_boost_frequencies 1 +fi + +echo "######################################" +echo "TEST AVAILABLE FREQS" +echo "######################################" +test_freqs1 $T_PATCH/scaling_available_frequencies + +echo "######################################" +echo "TEST FREQS SWITCHING" +echo "######################################" +test_freqs2 $T_PATCH/scaling_available_frequencies + +echo "######################################" +echo "ERRORS: $ERRORS" +echo "######################################" + +restore +exit 0