staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / vm / test_vmalloc.sh
blob06d2bb109f06d629889a08d03bb8692c715394b7
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Copyright (C) 2018 Uladzislau Rezki (Sony) <urezki@gmail.com>
6 # This is a test script for the kernel test driver to analyse vmalloc
7 # allocator. Therefore it is just a kernel module loader. You can specify
8 # and pass different parameters in order to:
9 # a) analyse performance of vmalloc allocations;
10 # b) stressing and stability check of vmalloc subsystem.
12 TEST_NAME="vmalloc"
13 DRIVER="test_${TEST_NAME}"
15 # 1 if fails
16 exitcode=1
18 # Kselftest framework requirement - SKIP code is 4.
19 ksft_skip=4
22 # Static templates for performance, stressing and smoke tests.
23 # Also it is possible to pass any supported parameters manualy.
25 PERF_PARAM="single_cpu_test=1 sequential_test_order=1 test_repeat_count=3"
26 SMOKE_PARAM="single_cpu_test=1 test_loop_count=10000 test_repeat_count=10"
27 STRESS_PARAM="test_repeat_count=20"
29 check_test_requirements()
31 uid=$(id -u)
32 if [ $uid -ne 0 ]; then
33 echo "$0: Must be run as root"
34 exit $ksft_skip
37 if ! which modprobe > /dev/null 2>&1; then
38 echo "$0: You need modprobe installed"
39 exit $ksft_skip
42 if ! modinfo $DRIVER > /dev/null 2>&1; then
43 echo "$0: You must have the following enabled in your kernel:"
44 echo "CONFIG_TEST_VMALLOC=m"
45 exit $ksft_skip
49 run_perfformance_check()
51 echo "Run performance tests to evaluate how fast vmalloc allocation is."
52 echo "It runs all test cases on one single CPU with sequential order."
54 modprobe $DRIVER $PERF_PARAM > /dev/null 2>&1
55 echo "Done."
56 echo "Ccheck the kernel message buffer to see the summary."
59 run_stability_check()
61 echo "Run stability tests. In order to stress vmalloc subsystem we run"
62 echo "all available test cases on all available CPUs simultaneously."
63 echo "It will take time, so be patient."
65 modprobe $DRIVER $STRESS_PARAM > /dev/null 2>&1
66 echo "Done."
67 echo "Check the kernel ring buffer to see the summary."
70 run_smoke_check()
72 echo "Run smoke test. Note, this test provides basic coverage."
73 echo "Please check $0 output how it can be used"
74 echo "for deep performance analysis as well as stress testing."
76 modprobe $DRIVER $SMOKE_PARAM > /dev/null 2>&1
77 echo "Done."
78 echo "Check the kernel ring buffer to see the summary."
81 usage()
83 echo -n "Usage: $0 [ performance ] | [ stress ] | | [ smoke ] | "
84 echo "manual parameters"
85 echo
86 echo "Valid tests and parameters:"
87 echo
88 modinfo $DRIVER
89 echo
90 echo "Example usage:"
91 echo
92 echo "# Shows help message"
93 echo "./${DRIVER}.sh"
94 echo
95 echo "# Runs 1 test(id_1), repeats it 5 times on all online CPUs"
96 echo "./${DRIVER}.sh run_test_mask=1 test_repeat_count=5"
97 echo
98 echo -n "# Runs 4 tests(id_1|id_2|id_4|id_16) on one CPU with "
99 echo "sequential order"
100 echo -n "./${DRIVER}.sh single_cpu_test=1 sequential_test_order=1 "
101 echo "run_test_mask=23"
102 echo
103 echo -n "# Runs all tests on all online CPUs, shuffled order, repeats "
104 echo "20 times"
105 echo "./${DRIVER}.sh test_repeat_count=20"
106 echo
107 echo "# Performance analysis"
108 echo "./${DRIVER}.sh performance"
109 echo
110 echo "# Stress testing"
111 echo "./${DRIVER}.sh stress"
112 echo
113 exit 0
116 function validate_passed_args()
118 VALID_ARGS=`modinfo $DRIVER | awk '/parm:/ {print $2}' | sed 's/:.*//'`
121 # Something has been passed, check it.
123 for passed_arg in $@; do
124 key=${passed_arg//=*/}
125 val="${passed_arg:$((${#key}+1))}"
126 valid=0
128 for valid_arg in $VALID_ARGS; do
129 if [[ $key = $valid_arg ]] && [[ $val -gt 0 ]]; then
130 valid=1
131 break
133 done
135 if [[ $valid -ne 1 ]]; then
136 echo "Error: key or value is not correct: ${key} $val"
137 exit $exitcode
139 done
142 function run_manual_check()
145 # Validate passed parameters. If there is wrong one,
146 # the script exists and does not execute further.
148 validate_passed_args $@
150 echo "Run the test with following parameters: $@"
151 modprobe $DRIVER $@ > /dev/null 2>&1
152 echo "Done."
153 echo "Check the kernel ring buffer to see the summary."
156 function run_test()
158 if [ $# -eq 0 ]; then
159 usage
160 else
161 if [[ "$1" = "performance" ]]; then
162 run_perfformance_check
163 elif [[ "$1" = "stress" ]]; then
164 run_stability_check
165 elif [[ "$1" = "smoke" ]]; then
166 run_smoke_check
167 else
168 run_manual_check $@
173 check_test_requirements
174 run_test $@
176 exit 0