aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-01-12 13:25:00 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2015-01-12 14:51:16 +0530
commiteb344cc3bfbe682a6499bc505dda1f841149de36 (patch)
tree184cdc4aa0feaffd83f7824bb0287beb88456a71
parentdb3190492f1c895503434e87e516940c18107d06 (diff)
module tests
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rwxr-xr-xcpufreq.sh24
-rwxr-xr-xmodule-tests.sh184
-rwxr-xr-xrunme.sh43
3 files changed, 230 insertions, 21 deletions
diff --git a/cpufreq.sh b/cpufreq.sh
index 4f4c2db..dde999a 100755
--- a/cpufreq.sh
+++ b/cpufreq.sh
@@ -192,21 +192,6 @@ shuffle_frequency_for_all_cpus()
echo ""
}
-# Calls the routine $1 passed to it and dumps all messages in:
-# - script output: $2.txt
-# - cpufreq messages: $2.cpufreq.txt
-# - complete dmesg: $2.full.txt
-call_routine()
-{
- # call routine
- $1 >> $2.txt
-
- dmesg | grep cpufreq >> $2.cpufreq.txt
-
- # We may need the full logs as well
- dmesg --read-clear >> $2.full.txt
-}
-
# clear dumps
clear_dumps()
{
@@ -215,6 +200,15 @@ clear_dumps()
echo "" > $2.full.txt
}
+# $1: output file name
+dmesg_dumps()
+{
+ dmesg | grep cpufreq >> $1.cpufreq.txt
+
+ # We may need the full logs as well
+ dmesg --read-clear >> $1.full.txt
+}
+
# Basic cpufreq tests
cpufreq_basic_tests()
{
diff --git a/module-tests.sh b/module-tests.sh
new file mode 100755
index 0000000..909b114
--- /dev/null
+++ b/module-tests.sh
@@ -0,0 +1,184 @@
+#!/bin/bash
+#
+# Modules specific tests cases
+
+# protect against multiple inclusion
+if [ $FILE_MODULE ]; then
+ return 0
+else
+ FILE_MODULE=DONE
+fi
+
+source cpu.sh
+source cpufreq.sh
+source governor.sh
+
+# 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)
+module_driver_test_prepare()
+{
+ if [ $3 = 1 ]; then
+ # offline all non-boot CPUs
+ for_each_non_boot_cpu offline_cpu
+ fi
+
+ # insert module
+ insmod $1
+ if [ $? != 0 ]; then
+ echo "Insmod $1 failed"
+ return;
+ fi
+
+ if [ $3 = 1 ]; then
+ # online all non-boot CPUs
+ for_each_non_boot_cpu online_cpu
+ fi
+
+ # run basic tests
+ cpufreq_basic_tests
+
+ # remove module
+ rmmod $1
+ if [ $? != 0 ]; then
+ echo "rmmod $1 failed"
+ return;
+ fi
+
+ # There shouldn't be any cpufreq directories now.
+ for_each_cpu cpu_should_not_have_cpufreq_directory
+}
+
+# $1: cpufreq-driver module to insert
+module_driver_test()
+{
+ # check if module is present or not
+ ls $1 > /dev/null
+ if [ $? != 0 ]; then
+ echo "$1: not present in `pwd` folder"
+ return;
+ fi
+
+ # Do simple module test
+ module_driver_test_prepare $1 0
+
+ # Remove CPUs before inserting module and then bring them back
+ module_driver_test_prepare $1 1
+}
+
+# find governor name based on governor module name
+# $1: governor module name
+find_gov_name()
+{
+ if [ $1 = "cpufreq_ondemand.ko" ]; then
+ echo "ondemand"
+ elif [ $1 = "cpufreq_conservative.ko" ]; then
+ echo "conservative"
+ elif [ $1 = "cpufreq_userspace.ko" ]; then
+ echo "userspace"
+ elif [ $1 = "cpufreq_performance.ko" ]; then
+ echo "performance"
+ elif [ $1 = "cpufreq_powersave.ko" ]; then
+ echo "powersave"
+ elif [ $1 = "cpufreq_interactive.ko" ]; then
+ echo "interactive" # not in mainline, but android
+ fi
+}
+
+# $1: governor string, $2: governor module, $3: cpu
+# example: module_governor_test_prepare_cpu "ondemand" "cpufreq_ondemand.ko" 2
+module_governor_test_prepare_cpu()
+{
+ # save old governor
+ old_gov=$(cat $CPU_PATH/$3/cpufreq/scaling_governor)
+
+ # switch to new governor
+ switch_show_governor $3 $1
+
+ # try removing module, it should fail as governor is used
+ rmmod $2
+ if [ $? = 0 ]; then
+ echo "WARN: rmmod $2 succeeded even if governor is used"
+ insmod $2
+ fi
+
+ # switch back to old governor
+ switch_show_governor $3 $old_gov
+}
+
+# Insert cpufreq governor module and perform basic tests
+# $1: cpufreq-governor module to insert
+module_governor_test()
+{
+ # check if module is present or not
+ ls $1 > /dev/null
+ if [ $? != 0 ]; then
+ echo "$1: not present in `pwd` folder"
+ return;
+ fi
+
+ # insert module
+ insmod $1
+ if [ $? != 0 ]; then
+ echo "Insmod $1 failed"
+ return;
+ fi
+
+ # switch to new governor for each cpu
+ for_each_cpu module_governor_test_prepare_cpu $(find_gov_name $1) $1
+
+ # remove module
+ rmmod $1
+ if [ $? != 0 ]; then
+ echo "rmmod $1 failed"
+ return;
+ fi
+}
+
+# test modules: driver and governor
+# $1: driver module, $2: governor module
+module_test()
+{
+ # check if modules are present or not
+ ls $1 $2 > /dev/null
+ if [ $? != 0 ]; then
+ echo "$1 or $2: is not present in `pwd` folder"
+ return;
+ fi
+
+ # TEST1: Insert gov after driver
+ # insert driver module
+ insmod $1
+ if [ $? != 0 ]; then
+ echo "Insmod $1 failed"
+ return;
+ fi
+
+ # run governor tests
+ module_governor_test $2
+
+ # remove driver module
+ rmmod $1
+ if [ $? != 0 ]; then
+ echo "rmmod $1 failed"
+ return;
+ fi
+
+ # TEST2: Insert driver after governor
+ # insert governor module
+ insmod $2
+ if [ $? != 0 ]; then
+ echo "Insmod $2 failed"
+ return;
+ fi
+
+ # run governor tests
+ module_driver_test $1
+
+ # remove driver module
+ rmmod $2
+ if [ $? != 0 ]; then
+ echo "rmmod $2 failed"
+ return;
+ fi
+}
diff --git a/runme.sh b/runme.sh
index 0897392..7031052 100755
--- a/runme.sh
+++ b/runme.sh
@@ -11,7 +11,7 @@ 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>] [-f <basic: cpufreq_basic_tests, sp1: governor_race, sp2: simple_lockdep, sp3: hotplug_with_updates>]"
+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]"
# Parse arguments
parse_arguments()
@@ -32,6 +32,14 @@ parse_arguments()
OUTFILE=$OPTARG
;;
+ d) # --driver-mod-name (Name of the driver module)
+ DRIVER_MOD=$OPTARG
+ ;;
+
+ g) # --governor-mod-name (Name of the governor module)
+ GOVERNOR_MOD=$OPTARG
+ ;;
+
\?) # getopts issues an error message
echo "$USAGE "
exit 1
@@ -41,14 +49,27 @@ parse_arguments()
}
# Run isolation test for $FUNC
-run_func()
+__run_func()
{
- # clear dumps first, we will append it later
- clear_dumps
-
case "$FUNC" in
"basic")
- call_routine cpufreq_basic_tests $OUTFILE
+ cpufreq_basic_tests
+ ;;
+
+ "modtest")
+ # Do we have modules in place?
+ if [ ! $DRIVER_MOD -a ! $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
+ module_governor_test $GOVERNOR_MOD
+ fi
;;
"sp1")
@@ -69,6 +90,16 @@ run_func()
esac
}
+# Takes dumps as well
+run_func()
+{
+ # clear dumps first, we will append it later
+ clear_dumps
+
+ __run_func >> $OUTFILE
+ dmesg_dumps $OUTFILE
+}
+
# Parse isol arguments
parse_arguments $@