diff options
| author | Viresh Kumar <viresh.kumar@linaro.org> | 2017-01-13 01:36:47 -0500 |
|---|---|---|
| committer | Shuah Khan <shuahkh@osg.samsung.com> | 2017-01-19 12:32:21 -0500 |
| commit | 6751faf3d8338d525e8d9c35ae87cbfed48ce958 (patch) | |
| tree | 2f16d7690aa6794e30a97cf99756ba267d2a5658 /tools/testing | |
| parent | b03eaf8dbac5534590ec52612f789d8fb292af9c (diff) | |
selftest: cpufreq: Add support to test cpufreq modules
This patch adds support for cpufreq modules like cpufreq drivers and
cpufreq governors. The tests will insert the modules in different orders
and them perform basic cpufreq tests. The modules are then removed from
the kernel.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/cpufreq/Makefile | 2 | ||||
| -rwxr-xr-x | tools/testing/selftests/cpufreq/main.sh | 45 | ||||
| -rwxr-xr-x | tools/testing/selftests/cpufreq/module.sh | 243 |
3 files changed, 284 insertions, 6 deletions
diff --git a/tools/testing/selftests/cpufreq/Makefile b/tools/testing/selftests/cpufreq/Makefile index f5c6bb1965a1..80c8727dcec1 100644 --- a/tools/testing/selftests/cpufreq/Makefile +++ b/tools/testing/selftests/cpufreq/Makefile | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | all: | 1 | all: |
| 2 | 2 | ||
| 3 | TEST_PROGS := main.sh | 3 | TEST_PROGS := main.sh |
| 4 | TEST_FILES := cpu.sh cpufreq.sh governor.sh | 4 | TEST_FILES := cpu.sh cpufreq.sh governor.sh module.sh |
| 5 | 5 | ||
| 6 | include ../lib.mk | 6 | include ../lib.mk |
| 7 | 7 | ||
diff --git a/tools/testing/selftests/cpufreq/main.sh b/tools/testing/selftests/cpufreq/main.sh index 9ff662f67ea4..2515867ac9de 100755 --- a/tools/testing/selftests/cpufreq/main.sh +++ b/tools/testing/selftests/cpufreq/main.sh | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | source cpu.sh | 3 | source cpu.sh |
| 4 | source cpufreq.sh | 4 | source cpufreq.sh |
| 5 | source governor.sh | 5 | source governor.sh |
| 6 | source module.sh | ||
| 6 | 7 | ||
| 7 | FUNC=basic # do basic tests by default | 8 | FUNC=basic # do basic tests by default |
| 8 | OUTFILE=cpufreq_selftest | 9 | OUTFILE=cpufreq_selftest |
| @@ -12,12 +13,15 @@ CPUFREQROOT= | |||
| 12 | 13 | ||
| 13 | helpme() | 14 | helpme() |
| 14 | { | 15 | { |
| 15 | printf "Usage: $0 [-h] [-to args] | 16 | printf "Usage: $0 [-h] [-todg args] |
| 16 | [-h <help>] | 17 | [-h <help>] |
| 17 | [-o <output-file-for-dump>] | 18 | [-o <output-file-for-dump>] |
| 18 | [-t <basic: Basic cpufreq testing | 19 | [-t <basic: Basic cpufreq testing |
| 19 | suspend: suspend/resume, | 20 | suspend: suspend/resume, |
| 20 | hibernate: hibernate/resume>] | 21 | hibernate: hibernate/resume, |
| 22 | modtest: test driver or governor modules. Only to be used with -d or -g options>] | ||
| 23 | [-d <driver's module name: only with \"-t modtest>\"] | ||
| 24 | [-g <governor's module name: only with \"-t modtest>\"] | ||
| 21 | \n" | 25 | \n" |
| 22 | exit 2 | 26 | exit 2 |
| 23 | } | 27 | } |
| @@ -56,14 +60,14 @@ prerequisite() | |||
| 56 | 60 | ||
| 57 | parse_arguments() | 61 | parse_arguments() |
| 58 | { | 62 | { |
| 59 | while getopts ht:o: arg | 63 | while getopts ht:o:d:g: arg |
| 60 | do | 64 | do |
| 61 | case $arg in | 65 | case $arg in |
| 62 | h) # --help | 66 | h) # --help |
| 63 | helpme | 67 | helpme |
| 64 | ;; | 68 | ;; |
| 65 | 69 | ||
| 66 | t) # --func_type (Function to perform: basic, suspend, hibernate (default: basic)) | 70 | t) # --func_type (Function to perform: basic, suspend, hibernate, modtest (default: basic)) |
| 67 | FUNC=$OPTARG | 71 | FUNC=$OPTARG |
| 68 | ;; | 72 | ;; |
| 69 | 73 | ||
| @@ -71,6 +75,14 @@ parse_arguments() | |||
| 71 | OUTFILE=$OPTARG | 75 | OUTFILE=$OPTARG |
| 72 | ;; | 76 | ;; |
| 73 | 77 | ||
| 78 | d) # --driver-mod-name (Name of the driver module) | ||
| 79 | DRIVER_MOD=$OPTARG | ||
| 80 | ;; | ||
| 81 | |||
| 82 | g) # --governor-mod-name (Name of the governor module) | ||
| 83 | GOVERNOR_MOD=$OPTARG | ||
| 84 | ;; | ||
| 85 | |||
| 74 | \?) | 86 | \?) |
| 75 | helpme | 87 | helpme |
| 76 | ;; | 88 | ;; |
| @@ -83,7 +95,7 @@ do_test() | |||
| 83 | # Check if CPUs are managed by cpufreq or not | 95 | # Check if CPUs are managed by cpufreq or not |
| 84 | count=$(count_cpufreq_managed_cpus) | 96 | count=$(count_cpufreq_managed_cpus) |
| 85 | 97 | ||
| 86 | if [ $count = 0 ]; then | 98 | if [ $count = 0 -a $FUNC != "modtest" ]; then |
| 87 | echo "No cpu is managed by cpufreq core, exiting" | 99 | echo "No cpu is managed by cpufreq core, exiting" |
| 88 | exit 2; | 100 | exit 2; |
| 89 | fi | 101 | fi |
| @@ -101,6 +113,29 @@ do_test() | |||
| 101 | do_suspend "hibernate" 1 | 113 | do_suspend "hibernate" 1 |
| 102 | ;; | 114 | ;; |
| 103 | 115 | ||
| 116 | "modtest") | ||
| 117 | # Do we have modules in place? | ||
| 118 | if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then | ||
| 119 | echo "No driver or governor module passed with -d or -g" | ||
| 120 | exit 2; | ||
| 121 | fi | ||
| 122 | |||
| 123 | if [ $DRIVER_MOD ]; then | ||
| 124 | if [ $GOVERNOR_MOD ]; then | ||
| 125 | module_test $DRIVER_MOD $GOVERNOR_MOD | ||
| 126 | else | ||
| 127 | module_driver_test $DRIVER_MOD | ||
| 128 | fi | ||
| 129 | else | ||
| 130 | if [ $count = 0 ]; then | ||
| 131 | echo "No cpu is managed by cpufreq core, exiting" | ||
| 132 | exit 2; | ||
| 133 | fi | ||
| 134 | |||
| 135 | module_governor_test $GOVERNOR_MOD | ||
| 136 | fi | ||
| 137 | ;; | ||
| 138 | |||
| 104 | *) | 139 | *) |
| 105 | echo "Invalid [-f] function type" | 140 | echo "Invalid [-f] function type" |
| 106 | helpme | 141 | helpme |
diff --git a/tools/testing/selftests/cpufreq/module.sh b/tools/testing/selftests/cpufreq/module.sh new file mode 100755 index 000000000000..8ff2244a33a1 --- /dev/null +++ b/tools/testing/selftests/cpufreq/module.sh | |||
| @@ -0,0 +1,243 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Modules specific tests cases | ||
| 4 | |||
| 5 | # protect against multiple inclusion | ||
| 6 | if [ $FILE_MODULE ]; then | ||
| 7 | return 0 | ||
| 8 | else | ||
| 9 | FILE_MODULE=DONE | ||
| 10 | fi | ||
| 11 | |||
| 12 | source cpu.sh | ||
| 13 | source cpufreq.sh | ||
| 14 | source governor.sh | ||
| 15 | |||
| 16 | # Check basic insmod/rmmod | ||
| 17 | # $1: module | ||
| 18 | test_basic_insmod_rmmod() | ||
| 19 | { | ||
| 20 | printf "** Test: Running ${FUNCNAME[0]} **\n\n" | ||
| 21 | |||
| 22 | printf "Inserting $1 module\n" | ||
| 23 | # insert module | ||
| 24 | insmod $1 | ||
| 25 | if [ $? != 0 ]; then | ||
| 26 | printf "Insmod $1 failed\n" | ||
| 27 | exit; | ||
| 28 | fi | ||
| 29 | |||
| 30 | printf "Removing $1 module\n" | ||
| 31 | # remove module | ||
| 32 | rmmod $1 | ||
| 33 | if [ $? != 0 ]; then | ||
| 34 | printf "rmmod $1 failed\n" | ||
| 35 | exit; | ||
| 36 | fi | ||
| 37 | |||
| 38 | printf "\n" | ||
| 39 | } | ||
| 40 | |||
| 41 | # Insert cpufreq driver module and perform basic tests | ||
| 42 | # $1: cpufreq-driver module to insert | ||
| 43 | # $2: If we want to play with CPUs (1) or not (0) | ||
| 44 | module_driver_test_single() | ||
| 45 | { | ||
| 46 | printf "** Test: Running ${FUNCNAME[0]} for driver $1 and cpus_hotplug=$2 **\n\n" | ||
| 47 | |||
| 48 | if [ $2 -eq 1 ]; then | ||
| 49 | # offline all non-boot CPUs | ||
| 50 | for_each_non_boot_cpu offline_cpu | ||
| 51 | printf "\n" | ||
| 52 | fi | ||
| 53 | |||
| 54 | # insert module | ||
| 55 | printf "Inserting $1 module\n\n" | ||
| 56 | insmod $1 | ||
| 57 | if [ $? != 0 ]; then | ||
| 58 | printf "Insmod $1 failed\n" | ||
| 59 | return; | ||
| 60 | fi | ||
| 61 | |||
| 62 | if [ $2 -eq 1 ]; then | ||
| 63 | # online all non-boot CPUs | ||
| 64 | for_each_non_boot_cpu online_cpu | ||
| 65 | printf "\n" | ||
| 66 | fi | ||
