aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-01-13 15:57:34 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2015-01-13 15:57:34 +0530
commit13e176f3b5a8b25bbe05cc9f28c4e8336fcb2440 (patch)
tree94303bdcdf9caaa3c899b9966050a4aeeb5e8d6f
parenteb344cc3bfbe682a6499bc505dda1f841149de36 (diff)
some more updates
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rwxr-xr-xcpufreq.sh18
-rwxr-xr-xgovernor.sh4
-rwxr-xr-xmodule.sh (renamed from module-tests.sh)60
-rwxr-xr-xrunme.sh52
4 files changed, 108 insertions, 26 deletions
diff --git a/cpufreq.sh b/cpufreq.sh
index dde999a..a608d6f 100755
--- a/cpufreq.sh
+++ b/cpufreq.sh
@@ -105,10 +105,15 @@ __update_cpufreq_files()
if [ -f $filepath/$file ]; then
# file is writable ?
local wfile=$(ls -l $filepath/$file | awk '$1 ~ /^.*w.*/ { print $NF; }')
+
if [ ! -z $wfile ]; then
- local val=$(cat $filepath/$file)
- echo "Writing $val to: $file"
- echo $val > $filepath/$file
+ # scaling_setspeed is a special file and so we
+ # should just skip it
+ if [ $file != "scaling_setspeed" ]; then
+ local val=$(cat $filepath/$file)
+ echo "Writing $val to: $file"
+ echo $val > $filepath/$file
+ fi
fi
else
echo ""
@@ -193,11 +198,12 @@ shuffle_frequency_for_all_cpus()
}
# clear dumps
+# $1: file name
clear_dumps()
{
- echo "" > $2.txt
- echo "" > $2.cpufreq.txt
- echo "" > $2.full.txt
+ echo "" > $1.txt
+ echo "" > $1.cpufreq.txt
+ echo "" > $1.full.txt
}
# $1: output file name
diff --git a/governor.sh b/governor.sh
index a82a6d5..2d03c80 100755
--- a/governor.sh
+++ b/governor.sh
@@ -20,6 +20,8 @@ find_gov_directory()
echo "$GLOBAL_CPUFREQ/$2"
elif [ -d $CPU_PATH/$1/cpufreq -a -d $CPU_PATH/$1/cpufreq/$2 ]; then
echo "$CPU_PATH/$1/cpufreq/$2"
+ else
+ echo "INVALID"
fi
}
@@ -57,7 +59,7 @@ switch_show_governor()
# show governor files
local govpath=$(find_gov_directory $1 $2)
- if [ ! -z $govpath ]; then
+ if [ $govpath != "INVALID" ]; then
__read_cpufreq_files $govpath
fi
}
diff --git a/module-tests.sh b/module.sh
index 909b114..c30a592 100755
--- a/module-tests.sh
+++ b/module.sh
@@ -13,12 +13,39 @@ source cpu.sh
source cpufreq.sh
source governor.sh
+# Check basic insmod/rmmod
+# $1: module
+test_basic_insmod_rmmod()
+{
+ echo "** Test: Running ${FUNCNAME[0]} **"
+ echo ""
+
+ echo "Inserting $1 module"
+ # insert module
+ insmod $1
+ if [ $? != 0 ]; then
+ echo "Insmod $1 failed"
+ exit;
+ fi
+
+ echo "Removing $1 module"
+ # remove module
+ rmmod $1
+ if [ $? != 0 ]; then
+ echo "rmmod $1 failed"
+ exit;
+ fi
+
+ echo "------------------------------------------------"
+ echo ""
+}
+
# Insert cpufreq driver module and perform basic tests
# $1: cpufreq-driver module to insert
-# $3: If we want to play with CPUs (1) or not (0)
+# $2: If we want to play with CPUs (1) or not (0)
module_driver_test_prepare()
{
- if [ $3 = 1 ]; then
+ if [ $2 -eq 1 ]; then
# offline all non-boot CPUs
for_each_non_boot_cpu offline_cpu
fi
@@ -30,7 +57,7 @@ module_driver_test_prepare()
return;
fi
- if [ $3 = 1 ]; then
+ if [ $2 -eq 1 ]; then
# online all non-boot CPUs
for_each_non_boot_cpu online_cpu
fi
@@ -52,6 +79,9 @@ module_driver_test_prepare()
# $1: cpufreq-driver module to insert
module_driver_test()
{
+ echo "** Test: Running ${FUNCNAME[0]} **"
+ echo ""
+
# check if module is present or not
ls $1 > /dev/null
if [ $? != 0 ]; then
@@ -59,6 +89,9 @@ module_driver_test()
return;
fi
+ # test basic module tests
+ test_basic_insmod_rmmod $1
+
# Do simple module test
module_driver_test_prepare $1 0
@@ -89,10 +122,14 @@ find_gov_name()
# example: module_governor_test_prepare_cpu "ondemand" "cpufreq_ondemand.ko" 2
module_governor_test_prepare_cpu()
{
+ echo "** Test: Running ${FUNCNAME[0]} for $3 **"
+ echo ""
+
# save old governor
old_gov=$(cat $CPU_PATH/$3/cpufreq/scaling_governor)
# switch to new governor
+ echo "Switch from $old_gov to $1"
switch_show_governor $3 $1
# try removing module, it should fail as governor is used
@@ -100,16 +137,23 @@ module_governor_test_prepare_cpu()
if [ $? = 0 ]; then
echo "WARN: rmmod $2 succeeded even if governor is used"
insmod $2
+ else
+ echo "Pass: unable to remove $2 while it is being used"
fi
# switch back to old governor
+ echo "Switchback to $old_gov from $1"
switch_show_governor $3 $old_gov
+ echo ""
}
# Insert cpufreq governor module and perform basic tests
# $1: cpufreq-governor module to insert
module_governor_test()
{
+ echo "** Test: Running ${FUNCNAME[0]} **"
+ echo ""
+
# check if module is present or not
ls $1 > /dev/null
if [ $? != 0 ]; then
@@ -117,6 +161,9 @@ module_governor_test()
return;
fi
+ # test basic module tests
+ test_basic_insmod_rmmod $1
+
# insert module
insmod $1
if [ $? != 0 ]; then
@@ -139,6 +186,9 @@ module_governor_test()
# $1: driver module, $2: governor module
module_test()
{
+ echo "** Test: Running ${FUNCNAME[0]} **"
+ echo ""
+
# check if modules are present or not
ls $1 $2 > /dev/null
if [ $? != 0 ]; then
@@ -146,6 +196,10 @@ module_test()
return;
fi
+ # test basic module tests
+ test_basic_insmod_rmmod $1
+ test_basic_insmod_rmmod $2
+
# TEST1: Insert gov after driver
# insert driver module
insmod $1
diff --git a/runme.sh b/runme.sh
index 7031052..66f8ad0 100755
--- a/runme.sh
+++ b/runme.sh
@@ -5,22 +5,22 @@
source cpu.sh
source governor.sh
+source module.sh
source special-tests.sh
-OUTFILE=dump
FUNC=basic # do basic tests by default
# Check validity of arguments
-USAGE="Usage: $0 [-h] [-of args] [-h <help>] [-o <output-file-for-dump>] [-d <driver's module name: only with -f=modtest>] [-g <governor's module name: only with -f=modtest>] [-f <basic: cpufreq_basic_tests, sp1: governor_race, sp2: simple_lockdep, sp3: hotplug_with_updates>, mod_test: driver as module]"
+USAGE="Usage: $0 [-h] [-odgf args]\n\t[-h <help>]\n\t[-o <output-file-for-dump>]\n\t[-d <driver's module name: only with -f=modtest>] \n\t[-g <governor's module name: only with -f=modtest>] \n\t[-f <basic: cpufreq_basic_tests, sp1: governor_race, sp2: simple_lockdep, sp3: hotplug_with_updates, modtest: driver as module>]\n"
# Parse arguments
parse_arguments()
{
- while getopts hf:o: arguments 2>/dev/null
+ while getopts hd:g:f:o: arguments 2>/dev/null
do
case $arguments in
h) # --help
- echo "$USAGE"
+ printf "$USAGE"
exit 0
;;
@@ -41,7 +41,7 @@ parse_arguments()
;;
\?) # getopts issues an error message
- echo "$USAGE "
+ printf "$USAGE "
exit 1
;;
esac
@@ -51,6 +51,14 @@ parse_arguments()
# Run isolation test for $FUNC
__run_func()
{
+ # Check if CPUs are managed by cpufreq or not
+ count=$(count_cpufreq_managed_cpus)
+
+ if [ $count = 0 -a $FUNC != "modtest" ]; then
+ echo "No cpu is managed by cpufreq core, exiting"
+ return;
+ fi
+
case "$FUNC" in
"basic")
cpufreq_basic_tests
@@ -58,16 +66,23 @@ __run_func()
"modtest")
# Do we have modules in place?
- if [ ! $DRIVER_MOD -a ! $GOVERNOR_MOD ]; then
+ if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
echo "No driver or governor module passed with -d or -g"
return;
fi
- if [ $DRIVER_MOD -a $GOVERNOR_MOD ]; then
- module_test $DRIVER_MOD $GOVERNOR_MOD
- elif [ $DRIVER_MOD ]; then
- module_driver_test $DRIVER_MOD
- elif [ $GOVERNOR_MOD ]; then
+ if [ $DRIVER_MOD ]; then
+ if [ $GOVERNOR_MOD ]; then
+ module_test $DRIVER_MOD $GOVERNOR_MOD
+ else
+ module_driver_test $DRIVER_MOD
+ fi
+ else
+ if [ $count = 0 ]; then
+ echo "No cpu is managed by cpufreq core, exiting"
+ return;
+ fi
+
module_governor_test $GOVERNOR_MOD
fi
;;
@@ -86,6 +101,7 @@ __run_func()
*)
echo "Invalid [-f] function type"
+ printf "$USAGE"
;;
esac
}
@@ -93,11 +109,15 @@ __run_func()
# Takes dumps as well
run_func()
{
- # clear dumps first, we will append it later
- clear_dumps
-
- __run_func >> $OUTFILE
- dmesg_dumps $OUTFILE
+ if [ $OUTFILE ]; then
+ # clear dumps first, we will append it later
+ clear_dumps $OUTFILE
+
+ __run_func >> $OUTFILE.txt
+ dmesg_dumps $OUTFILE
+ else
+ __run_func
+ fi
}
# Parse isol arguments