diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /tools/testing | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'tools/testing')
34 files changed, 322 insertions, 5956 deletions
diff --git a/tools/testing/fault-injection/failcmd.sh b/tools/testing/fault-injection/failcmd.sh deleted file mode 100644 index 78a9ed7fecd..00000000000 --- a/tools/testing/fault-injection/failcmd.sh +++ /dev/null | |||
@@ -1,219 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # NAME | ||
4 | # failcmd.sh - run a command with injecting slab/page allocation failures | ||
5 | # | ||
6 | # SYNOPSIS | ||
7 | # failcmd.sh --help | ||
8 | # failcmd.sh [<options>] command [arguments] | ||
9 | # | ||
10 | # DESCRIPTION | ||
11 | # Run command with injecting slab/page allocation failures by fault | ||
12 | # injection. | ||
13 | # | ||
14 | # NOTE: you need to run this script as root. | ||
15 | # | ||
16 | |||
17 | usage() | ||
18 | { | ||
19 | cat >&2 <<EOF | ||
20 | Usage: $0 [options] command [arguments] | ||
21 | |||
22 | OPTIONS | ||
23 | -p percent | ||
24 | --probability=percent | ||
25 | likelihood of failure injection, in percent. | ||
26 | Default value is 1 | ||
27 | |||
28 | -t value | ||
29 | --times=value | ||
30 | specifies how many times failures may happen at most. | ||
31 | Default value is 1 | ||
32 | |||
33 | --oom-kill-allocating-task=value | ||
34 | set /proc/sys/vm/oom_kill_allocating_task to specified value | ||
35 | before running the command. | ||
36 | Default value is 1 | ||
37 | |||
38 | -h, --help | ||
39 | Display a usage message and exit | ||
40 | |||
41 | --interval=value, --space=value, --verbose=value, --task-filter=value, | ||
42 | --stacktrace-depth=value, --require-start=value, --require-end=value, | ||
43 | --reject-start=value, --reject-end=value, --ignore-gfp-wait=value | ||
44 | See Documentation/fault-injection/fault-injection.txt for more | ||
45 | information | ||
46 | |||
47 | failslab options: | ||
48 | --cache-filter=value | ||
49 | |||
50 | fail_page_alloc options: | ||
51 | --ignore-gfp-highmem=value, --min-order=value | ||
52 | |||
53 | ENVIRONMENT | ||
54 | FAILCMD_TYPE | ||
55 | The following values for FAILCMD_TYPE are recognized: | ||
56 | |||
57 | failslab | ||
58 | inject slab allocation failures | ||
59 | fail_page_alloc | ||
60 | inject page allocation failures | ||
61 | |||
62 | If FAILCMD_TYPE is not defined, then failslab is used. | ||
63 | EOF | ||
64 | } | ||
65 | |||
66 | if [ $UID != 0 ]; then | ||
67 | echo must be run as root >&2 | ||
68 | exit 1 | ||
69 | fi | ||
70 | |||
71 | DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3}'` | ||
72 | |||
73 | if [ ! -d "$DEBUGFS" ]; then | ||
74 | echo debugfs is not mounted >&2 | ||
75 | exit 1 | ||
76 | fi | ||
77 | |||
78 | FAILCMD_TYPE=${FAILCMD_TYPE:-failslab} | ||
79 | FAULTATTR=$DEBUGFS/$FAILCMD_TYPE | ||
80 | |||
81 | if [ ! -d $FAULTATTR ]; then | ||
82 | echo $FAILCMD_TYPE is not available >&2 | ||
83 | exit 1 | ||
84 | fi | ||
85 | |||
86 | LONGOPTS=probability:,interval:,times:,space:,verbose:,task-filter: | ||
87 | LONGOPTS=$LONGOPTS,stacktrace-depth:,require-start:,require-end: | ||
88 | LONGOPTS=$LONGOPTS,reject-start:,reject-end:,oom-kill-allocating-task:,help | ||
89 | |||
90 | if [ $FAILCMD_TYPE = failslab ]; then | ||
91 | LONGOPTS=$LONGOPTS,ignore-gfp-wait:,cache-filter: | ||
92 | elif [ $FAILCMD_TYPE = fail_page_alloc ]; then | ||
93 | LONGOPTS=$LONGOPTS,ignore-gfp-wait:,ignore-gfp-highmem:,min-order: | ||
94 | fi | ||
95 | |||
96 | TEMP=`getopt -o p:i:t:s:v:h --long $LONGOPTS -n 'failcmd.sh' -- "$@"` | ||
97 | |||
98 | if [ $? != 0 ]; then | ||
99 | usage | ||
100 | exit 1 | ||
101 | fi | ||
102 | |||
103 | eval set -- "$TEMP" | ||
104 | |||
105 | fault_attr_default() | ||
106 | { | ||
107 | echo N > $FAULTATTR/task-filter | ||
108 | echo 0 > $FAULTATTR/probability | ||
109 | echo 1 > $FAULTATTR/times | ||
110 | } | ||
111 | |||
112 | fault_attr_default | ||
113 | |||
114 | oom_kill_allocating_task_saved=`cat /proc/sys/vm/oom_kill_allocating_task` | ||
115 | |||
116 | restore_values() | ||
117 | { | ||
118 | fault_attr_default | ||
119 | echo $oom_kill_allocating_task_saved \ | ||
120 | > /proc/sys/vm/oom_kill_allocating_task | ||
121 | } | ||
122 | |||
123 | # | ||
124 | # Default options | ||
125 | # | ||
126 | declare -i oom_kill_allocating_task=1 | ||
127 | declare task_filter=Y | ||
128 | declare -i probability=1 | ||
129 | declare -i times=1 | ||
130 | |||
131 | while true; do | ||
132 | case "$1" in | ||
133 | -p|--probability) | ||
134 | probability=$2 | ||
135 | shift 2 | ||
136 | ;; | ||
137 | -i|--interval) | ||
138 | echo $2 > $FAULTATTR/interval | ||
139 | shift 2 | ||
140 | ;; | ||
141 | -t|--times) | ||
142 | times=$2 | ||
143 | shift 2 | ||
144 | ;; | ||
145 | -s|--space) | ||
146 | echo $2 > $FAULTATTR/space | ||
147 | shift 2 | ||
148 | ;; | ||
149 | -v|--verbose) | ||
150 | echo $2 > $FAULTATTR/verbose | ||
151 | shift 2 | ||
152 | ;; | ||
153 | --task-filter) | ||
154 | task_filter=$2 | ||
155 | shift 2 | ||
156 | ;; | ||
157 | --stacktrace-depth) | ||
158 | echo $2 > $FAULTATTR/stacktrace-depth | ||
159 | shift 2 | ||
160 | ;; | ||
161 | --require-start) | ||
162 | echo $2 > $FAULTATTR/require-start | ||
163 | shift 2 | ||
164 | ;; | ||
165 | --require-end) | ||
166 | echo $2 > $FAULTATTR/require-end | ||
167 | shift 2 | ||
168 | ;; | ||
169 | --reject-start) | ||
170 | echo $2 > $FAULTATTR/reject-start | ||
171 | shift 2 | ||
172 | ;; | ||
173 | --reject-end) | ||
174 | echo $2 > $FAULTATTR/reject-end | ||
175 | shift 2 | ||
176 | ;; | ||
177 | --oom-kill-allocating-task) | ||
178 | oom_kill_allocating_task=$2 | ||
179 | shift 2 | ||
180 | ;; | ||
181 | --ignore-gfp-wait) | ||
182 | echo $2 > $FAULTATTR/ignore-gfp-wait | ||
183 | shift 2 | ||
184 | ;; | ||
185 | --cache-filter) | ||
186 | echo $2 > $FAULTATTR/cache_filter | ||
187 | shift 2 | ||
188 | ;; | ||
189 | --ignore-gfp-highmem) | ||
190 | echo $2 > $FAULTATTR/ignore-gfp-highmem | ||
191 | shift 2 | ||
192 | ;; | ||
193 | --min-order) | ||
194 | echo $2 > $FAULTATTR/min-order | ||
195 | shift 2 | ||
196 | ;; | ||
197 | -h|--help) | ||
198 | usage | ||
199 | exit 0 | ||
200 | shift | ||
201 | ;; | ||
202 | --) | ||
203 | shift | ||
204 | break | ||
205 | ;; | ||
206 | esac | ||
207 | done | ||
208 | |||
209 | [ -z "$1" ] && exit 0 | ||
210 | |||
211 | echo $oom_kill_allocating_task > /proc/sys/vm/oom_kill_allocating_task | ||
212 | echo $task_filter > $FAULTATTR/task-filter | ||
213 | echo $probability > $FAULTATTR/probability | ||
214 | echo $times > $FAULTATTR/times | ||
215 | |||
216 | trap "restore_values" SIGINT SIGTERM EXIT | ||
217 | |||
218 | cmd="echo 1 > /proc/self/make-it-fail && exec $@" | ||
219 | bash -c "$cmd" | ||
diff --git a/tools/testing/ktest/compare-ktest-sample.pl b/tools/testing/ktest/compare-ktest-sample.pl index a373a5bfff6..9a571e71683 100755 --- a/tools/testing/ktest/compare-ktest-sample.pl +++ b/tools/testing/ktest/compare-ktest-sample.pl | |||
@@ -2,9 +2,7 @@ | |||
2 | 2 | ||
3 | open (IN,"ktest.pl"); | 3 | open (IN,"ktest.pl"); |
4 | while (<IN>) { | 4 | while (<IN>) { |
5 | # hashes are now used | ||
6 | if (/\$opt\{"?([A-Z].*?)(\[.*\])?"?\}/ || | 5 | if (/\$opt\{"?([A-Z].*?)(\[.*\])?"?\}/ || |
7 | /^\s*"?([A-Z].*?)"?\s*=>\s*/ || | ||
8 | /set_test_option\("(.*?)"/) { | 6 | /set_test_option\("(.*?)"/) { |
9 | $opt{$1} = 1; | 7 | $opt{$1} = 1; |
10 | } | 8 | } |
@@ -13,7 +11,7 @@ close IN; | |||
13 | 11 | ||
14 | open (IN, "sample.conf"); | 12 | open (IN, "sample.conf"); |
15 | while (<IN>) { | 13 | while (<IN>) { |
16 | if (/^\s*#?\s*([A-Z]\S*)\s*=/) { | 14 | if (/^\s*#?\s*(\S+)\s*=/) { |
17 | $samp{$1} = 1; | 15 | $samp{$1} = 1; |
18 | } | 16 | } |
19 | } | 17 | } |
diff --git a/tools/testing/ktest/examples/README b/tools/testing/ktest/examples/README deleted file mode 100644 index a12d295a09d..00000000000 --- a/tools/testing/ktest/examples/README +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | This directory contains example configs to use ktest for various tasks. | ||
2 | The configs still need to be customized for your environment, but it | ||
3 | is broken up by task which makes it easier to understand how to set up | ||
4 | ktest. | ||
5 | |||
6 | The configs are based off of real working configs but have been modified | ||
7 | and commented to show more generic use cases that are more helpful for | ||
8 | developers. | ||
9 | |||
10 | crosstests.conf - this config shows an example of testing a git repo against | ||
11 | lots of different architectures. It only does build tests, but makes | ||
12 | it easy to compile test different archs. You can download the arch | ||
13 | cross compilers from: | ||
14 | http://kernel.org/pub/tools/crosstool/files/bin/x86_64/ | ||
15 | |||
16 | test.conf - A generic example of a config. This is based on an actual config | ||
17 | used to perform real testing. | ||
18 | |||
19 | kvm.conf - A example of a config that is used to test a virtual guest running | ||
20 | on a host. | ||
21 | |||
22 | snowball.conf - An example config that was used to demo ktest.pl against | ||
23 | a snowball ARM board. | ||
24 | |||
25 | include/ - The include directory holds default configs that can be | ||
26 | included into other configs. This is a real use example that shows how | ||
27 | to reuse configs for various machines or set ups. The files here | ||
28 | are included by other config files, where the other config files define | ||
29 | options and variables that will make the included config work for the | ||
30 | given environment. | ||
31 | |||
32 | |||
diff --git a/tools/testing/ktest/examples/crosstests.conf b/tools/testing/ktest/examples/crosstests.conf deleted file mode 100644 index 46736604c26..00000000000 --- a/tools/testing/ktest/examples/crosstests.conf +++ /dev/null | |||
@@ -1,260 +0,0 @@ | |||
1 | # | ||
2 | # Example config for cross compiling | ||
3 | # | ||
4 | # In this config, it is expected that the tool chains from: | ||
5 | # | ||
6 | # http://kernel.org/pub/tools/crosstool/files/bin/x86_64/ | ||
7 | # | ||
8 | # running on a x86_64 system have been downloaded and installed into: | ||
9 | # | ||
10 | # /usr/local/ | ||
11 | # | ||
12 | # such that the compiler binaries are something like: | ||
13 | # | ||
14 | # /usr/local/gcc-4.5.2-nolibc/mips-linux/bin/mips-linux-gcc | ||
15 | # | ||
16 | # Some of the archs will use gcc-4.5.1 instead of gcc-4.5.2 | ||
17 | # this config uses variables to differentiate them. | ||
18 | # | ||
19 | # Comments describe some of the options, but full descriptions of | ||
20 | # options are described in the samples.conf file. | ||
21 | |||
22 | # ${PWD} is defined by ktest.pl to be the directory that the user | ||
23 | # was in when they executed ktest.pl. It may be better to hardcode the | ||
24 | # path name here. THIS_DIR is the variable used through out the config file | ||
25 | # in case you want to change it. | ||
26 | |||
27 | THIS_DIR := ${PWD} | ||
28 | |||
29 | # Update the BUILD_DIR option to the location of your git repo you want to test. | ||
30 | BUILD_DIR = ${THIS_DIR}/linux.git | ||
31 | |||
32 | # The build will go into this directory. It will be created when you run the test. | ||
33 | OUTPUT_DIR = ${THIS_DIR}/cross-compile | ||
34 | |||
35 | # The build will be compiled with -j8 | ||
36 | BUILD_OPTIONS = -j8 | ||
37 | |||
38 | # The test will not stop when it hits a failure. | ||
39 | DIE_ON_FAILURE = 0 | ||
40 | |||
41 | # If you want to have ktest.pl store the failure somewhere, uncomment this option | ||
42 | # and change the directory where ktest should store the failures. | ||
43 | #STORE_FAILURES = ${THIS_DIR}/failures | ||
44 | |||
45 | # The log file is stored in the OUTPUT_DIR called cross.log | ||
46 | # If you enable this, you need to create the OUTPUT_DIR. It wont be created for you. | ||
47 | LOG_FILE = ${OUTPUT_DIR}/cross.log | ||
48 | |||
49 | # The log file will be cleared each time you run ktest. | ||
50 | CLEAR_LOG = 1 | ||
51 | |||
52 | # As some archs do not build with the defconfig, they have been marked | ||
53 | # to be ignored. If you want to test them anyway, change DO_FAILED to 1. | ||
54 | # If a test that has been marked as DO_FAILED passes, then you should change | ||
55 | # that test to be DO_DEFAULT | ||
56 | |||
57 | DO_FAILED := 0 | ||
58 | DO_DEFAULT := 1 | ||
59 | |||
60 | # By setting both DO_FAILED and DO_DEFAULT to zero, you can pick a single | ||
61 | # arch that you want to test. (uncomment RUN and chose your arch) | ||
62 | #RUN := m32r | ||
63 | |||
64 | # At the bottom of the config file exists a bisect test. You can update that | ||
65 | # test and set DO_FAILED and DO_DEFAULT to zero, and uncomment this variable | ||
66 | # to run the bisect on the arch. | ||
67 | #RUN := bisect | ||
68 | |||
69 | # By default all tests will be running gcc 4.5.2. Some tests are using 4.5.1 | ||
70 | # and they select that in the test. | ||
71 | # Note: GCC_VER is declared as on option and not a variable ('=' instead of ':=') | ||
72 | # This is important. A variable is used only in the config file and if it is set | ||
73 | # it stays that way for the rest of the config file until it is change again. | ||
74 | # Here we want GCC_VER to remain persistent and change for each test, as it is used in | ||
75 | # the MAKE_CMD. By using '=' instead of ':=' we achieve our goal. | ||
76 | |||
77 | GCC_VER = 4.5.2 | ||
78 | MAKE_CMD = PATH=/usr/local/gcc-${GCC_VER}-nolibc/${CROSS}/bin:$PATH CROSS_COMPILE=${CROSS}- make ARCH=${ARCH} | ||
79 | |||
80 | # all tests are only doing builds. | ||
81 | TEST_TYPE = build | ||
82 | |||
83 | # If you want to add configs on top of the defconfig, you can add those configs into | ||
84 | # the add-config file and uncomment this option. This is useful if you want to test | ||
85 | # all cross compiles with PREEMPT set, or TRACING on, etc. | ||
86 | #ADD_CONFIG = ${THIS_DIR}/add-config | ||
87 | |||
88 | # All tests are using defconfig | ||
89 | BUILD_TYPE = defconfig | ||
90 | |||
91 | # The test names will have the arch and cross compiler used. This will be shown in | ||
92 | # the results. | ||
93 | TEST_NAME = ${ARCH} ${CROSS} | ||
94 | |||
95 | # alpha | ||
96 | TEST_START IF ${RUN} == alpha || ${DO_DEFAULT} | ||
97 | # Notice that CROSS and ARCH are also options and not variables (again '=' instead | ||
98 | # of ':='). This is because TEST_NAME and MAKE_CMD wil use them for each test. | ||
99 | # Only options are available during runs. Variables are only present in parsing the | ||
100 | # config file. | ||
101 | CROSS = alpha-linux | ||
102 | ARCH = alpha | ||
103 | |||
104 | # arm | ||
105 | TEST_START IF ${RUN} == arm || ${DO_DEFAULT} | ||
106 | CROSS = arm-unknown-linux-gnueabi | ||
107 | ARCH = arm | ||
108 | |||
109 | # black fin | ||
110 | TEST_START IF ${RUN} == bfin || ${DO_DEFAULT} | ||
111 | CROSS = bfin-uclinux | ||
112 | ARCH = blackfin | ||
113 | BUILD_OPTIONS = -j8 vmlinux | ||
114 | |||
115 | # cris - FAILS? | ||
116 | TEST_START IF ${RUN} == cris || ${RUN} == cris64 || ${DO_FAILED} | ||
117 | CROSS = cris-linux | ||
118 | ARCH = cris | ||
119 | |||
120 | # cris32 - not right arch? | ||
121 | TEST_START IF ${RUN} == cris || ${RUN} == cris32 || ${DO_FAILED} | ||
122 | CROSS = crisv32-linux | ||
123 | ARCH = cris | ||
124 | |||
125 | # ia64 | ||
126 | TEST_START IF ${RUN} == ia64 || ${DO_DEFAULT} | ||
127 | CROSS = ia64-linux | ||
128 | ARCH = ia64 | ||
129 | |||
130 | # frv | ||
131 | TEST_START IF ${RUN} == frv || ${DO_FAILED} | ||
132 | CROSS = frv-linux | ||
133 | ARCH = frv | ||
134 | GCC_VER = 4.5.1 | ||
135 | |||
136 | # h8300 - failed make defconfig?? | ||
137 | TEST_START IF ${RUN} == h8300 || ${DO_FAILED} | ||
138 | CROSS = h8300-elf | ||
139 | ARCH = h8300 | ||
140 | GCC_VER = 4.5.1 | ||
141 | |||
142 | # m68k fails with error? | ||
143 | TEST_START IF ${RUN} == m68k || ${DO_DEFAULT} | ||
144 | CROSS = m68k-linux | ||
145 | ARCH = m68k | ||
146 | |||
147 | # mips64 | ||
148 | TEST_START IF ${RUN} == mips || ${RUN} == mips64 || ${DO_DEFAULT} | ||
149 | CROSS = mips64-linux | ||
150 | ARCH = mips | ||
151 | |||
152 | # mips32 | ||
153 | TEST_START IF ${RUN} == mips || ${RUN} == mips32 || ${DO_DEFAULT} | ||
154 | CROSS = mips-linux | ||
155 | ARCH = mips | ||
156 | |||
157 | # m32r | ||
158 | TEST_START IF ${RUN} == m32r || ${DO_FAILED} | ||
159 | CROSS = m32r-linux | ||
160 | ARCH = m32r | ||
161 | GCC_VER = 4.5.1 | ||
162 | BUILD_OPTIONS = -j8 vmlinux | ||
163 | |||
164 | # parisc64 failed? | ||
165 | TEST_START IF ${RUN} == hppa || ${RUN} == hppa64 || ${DO_FAILED} | ||
166 | CROSS = hppa64-linux | ||
167 | ARCH = parisc | ||
168 | |||
169 | # parisc | ||
170 | TEST_START IF ${RUN} == hppa || ${RUN} == hppa32 || ${DO_FAILED} | ||
171 | CROSS = hppa-linux | ||
172 | ARCH = parisc | ||
173 | |||
174 | # ppc | ||
175 | TEST_START IF ${RUN} == ppc || ${RUN} == ppc32 || ${DO_DEFAULT} | ||
176 | CROSS = powerpc-linux | ||
177 | ARCH = powerpc | ||
178 | |||
179 | # ppc64 | ||
180 | TEST_START IF ${RUN} == ppc || ${RUN} == ppc64 || ${DO_DEFAULT} | ||
181 | CROSS = powerpc64-linux | ||
182 | ARCH = powerpc | ||
183 | |||
184 | # s390 | ||
185 | TEST_START IF ${RUN} == s390 || ${DO_DEFAULT} | ||
186 | CROSS = s390x-linux | ||
187 | ARCH = s390 | ||
188 | |||
189 | # sh | ||
190 | TEST_START IF ${RUN} == sh || ${DO_DEFAULT} | ||
191 | CROSS = sh4-linux | ||
192 | ARCH = sh | ||
193 | |||
194 | # sparc64 | ||
195 | TEST_START IF ${RUN} == sparc || ${RUN} == sparc64 || ${DO_DEFAULT} | ||
196 | CROSS = sparc64-linux | ||
197 | ARCH = sparc64 | ||
198 | |||
199 | # sparc | ||
200 | TEST_START IF ${RUN} == sparc || ${RUN} == sparc32 || ${DO_DEFAULT} | ||
201 | CROSS = sparc-linux | ||
202 | ARCH = sparc | ||
203 | |||
204 | # xtensa failed | ||
205 | TEST_START IF ${RUN} == xtensa || ${DO_FAILED} | ||
206 | CROSS = xtensa-linux | ||
207 | ARCH = xtensa | ||
208 | |||
209 | # UML | ||
210 | TEST_START IF ${RUN} == uml || ${DO_DEFAULT} | ||
211 | MAKE_CMD = make ARCH=um SUBARCH=x86_64 | ||
212 | ARCH = uml | ||
213 | CROSS = | ||
214 | |||
215 | TEST_START IF ${RUN} == x86 || ${RUN} == i386 || ${DO_DEFAULT} | ||
216 | MAKE_CMD = make ARCH=i386 | ||
217 | ARCH = i386 | ||
218 | CROSS = | ||
219 | |||
220 | TEST_START IF ${RUN} == x86 || ${RUN} == x86_64 || ${DO_DEFAULT} | ||
221 | MAKE_CMD = make ARCH=x86_64 | ||
222 | ARCH = x86_64 | ||
223 | CROSS = | ||
224 | |||
225 | ################################# | ||
226 | |||
227 | # This is a bisect if needed. You need to give it a MIN_CONFIG that | ||
228 | # will be the config file it uses. Basically, just copy the created defconfig | ||
229 | # for the arch someplace and point MIN_CONFIG to it. | ||
230 | TEST_START IF ${RUN} == bisect | ||
231 | MIN_CONFIG = ${THIS_DIR}/min-config | ||
232 | CROSS = s390x-linux | ||
233 | ARCH = s390 | ||
234 | TEST_TYPE = bisect | ||
235 | BISECT_TYPE = build | ||
236 | BISECT_GOOD = v3.1 | ||
237 | BISECT_BAD = v3.2 | ||
238 | CHECKOUT = v3.2 | ||
239 | |||
240 | ################################# | ||
241 | |||
242 | # These defaults are needed to keep ktest.pl from complaining. They are | ||
243 | # ignored because the test does not go pass the build. No install or | ||
244 | # booting of the target images. | ||
245 | |||
246 | DEFAULTS | ||
247 | MACHINE = crosstest | ||
248 | SSH_USER = root | ||
249 | BUILD_TARGET = cross | ||
250 | TARGET_IMAGE = image | ||
251 | POWER_CYCLE = cycle | ||
252 | CONSOLE = console | ||
253 | LOCALVERSION = version | ||
254 | GRUB_MENU = grub | ||
255 | |||
256 | REBOOT_ON_ERROR = 0 | ||
257 | POWEROFF_ON_ERROR = 0 | ||
258 | POWEROFF_ON_SUCCESS = 0 | ||
259 | REBOOT_ON_SUCCESS = 0 | ||
260 | |||
diff --git a/tools/testing/ktest/examples/include/bisect.conf b/tools/testing/ktest/examples/include/bisect.conf deleted file mode 100644 index 009bea65bfb..00000000000 --- a/tools/testing/ktest/examples/include/bisect.conf +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | # | ||
2 | # This example shows the bisect tests (git bisect and config bisect) | ||
3 | # | ||
4 | |||
5 | |||
6 | # The config that includes this file may define a RUN_TEST | ||
7 | # variable that will tell this config what test to run. | ||
8 | # (what to set the TEST option to). | ||
9 | # | ||
10 | DEFAULTS IF NOT DEFINED RUN_TEST | ||
11 | # Requires that hackbench is in the PATH | ||
12 | RUN_TEST := ${SSH} hackbench 50 | ||
13 | |||
14 | |||
15 | # Set TEST to 'bisect' to do a normal git bisect. You need | ||
16 | # to modify the options below to make it bisect the exact | ||
17 | # commits you are interested in. | ||
18 | # | ||
19 | TEST_START IF ${TEST} == bisect | ||
20 | TEST_TYPE = bisect | ||
21 | # You must set the commit that was considered good (git bisect good) | ||
22 | BISECT_GOOD = v3.3 | ||
23 | # You must set the commit that was considered bad (git bisect bad) | ||
24 | BISECT_BAD = HEAD | ||
25 | # It's best to specify the branch to checkout before starting the bisect. | ||
26 | CHECKOUT = origin/master | ||
27 | # This can be build, boot, or test. Here we are doing a bisect | ||
28 | # that requires to run a test to know if the bisect was good or bad. | ||
29 | # The test should exit with 0 on good, non-zero for bad. But see | ||
30 | # the BISECT_RET_* options in samples.conf to override this. | ||
31 | BISECT_TYPE = test | ||
32 | TEST = ${RUN_TEST} | ||
33 | # It is usually a good idea to confirm that the GOOD and the BAD | ||
34 | # commits are truly good and bad respectively. Having BISECT_CHECK | ||
35 | # set to 1 will check both that the good commit works and the bad | ||
36 | # commit fails. If you only want to check one or the other, | ||
37 | # set BISECT_CHECK to 'good' or to 'bad'. | ||
38 | BISECT_CHECK = 1 | ||
39 | #BISECT_CHECK = good | ||
40 | #BISECT_CHECK = bad | ||
41 | |||
42 | # Usually it's a good idea to specify the exact config you | ||
43 | # want to use throughout the entire bisect. Here we placed | ||
44 | # it in the directory we called ktest.pl from and named it | ||
45 | # 'config-bisect'. | ||
46 | MIN_CONFIG = ${THIS_DIR}/config-bisect | ||
47 | # By default, if we are doing a BISECT_TYPE = test run but the | ||
48 | # build or boot fails, ktest.pl will do a 'git bisect skip'. | ||
49 | # Uncomment the below option to make ktest stop testing on such | ||
50 | # an error. | ||
51 | #BISECT_SKIP = 0 | ||
52 | # Now if you had BISECT_SKIP = 0 and the test fails, you can | ||
53 | # examine what happened and then do 'git bisect log > /tmp/replay' | ||
54 | # Set BISECT_REPLAY to /tmp/replay and ktest.pl will run the | ||
55 | # 'git bisect replay /tmp/replay' before continuing the bisect test. | ||
56 | #BISECT_REPLAY = /tmp/replay | ||
57 | # If you used BISECT_REPLAY after the bisect test failed, you may | ||
58 | # not want to continue the bisect on that commit that failed. | ||
59 | # By setting BISECT_START to a new commit. ktest.pl will checkout | ||
60 | # that commit after it has performed the 'git bisect replay' but | ||
61 | # before it continues running the bisect test. | ||
62 | #BISECT_START = 2545eb6198e7e1ec50daa0cfc64a4cdfecf24ec9 | ||
63 | |||
64 | # Now if you don't trust ktest.pl to make the decisions for you, then | ||
65 | # set BISECT_MANUAL to 1. This will cause ktest.pl not to decide | ||
66 | # if the commit was good or bad. Instead, it will ask you to tell | ||
67 | # it if the current commit was good. In the mean time, you could | ||
68 | # take the result, load it on any machine you want. Run several tests, | ||
69 | # or whatever you feel like. Then, when you are happy, you can tell | ||
70 | # ktest if you think it was good or not and ktest.pl will continue | ||
71 | # the git bisect. You can even change what commit it is currently at. | ||
72 | #BISECT_MANUAL = 1 | ||
73 | |||
74 | |||
75 | # One of the unique tests that ktest does is the config bisect. | ||
76 | # Currently (which hopefully will be fixed soon), the bad config | ||
77 | # must be a superset of the good config. This is because it only | ||
78 | # searches for a config that causes the target to fail. If the | ||
79 | # good config is not a subset of the bad config, or if the target | ||
80 | # fails because of a lack of a config, then it will not find | ||
81 | # the config for you. | ||
82 | TEST_START IF ${TEST} == config-bisect | ||
83 | TEST_TYPE = config_bisect | ||
84 | # set to build, boot, test | ||
85 | CONFIG_BISECT_TYPE = boot | ||
86 | # Set the config that is considered bad. | ||
87 | CONFIG_BISECT = ${THIS_DIR}/config-bad | ||
88 | # This config is optional. By default it uses the | ||
89 | # MIN_CONFIG as the good config. | ||
90 | CONFIG_BISECT_GOOD = ${THIS_DIR}/config-good | ||
diff --git a/tools/testing/ktest/examples/include/defaults.conf b/tools/testing/ktest/examples/include/defaults.conf deleted file mode 100644 index 63a1a83f4f0..00000000000 --- a/tools/testing/ktest/examples/include/defaults.conf +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | # This file holds defaults for most the tests. It defines the options that | ||
2 | # are most common to tests that are likely to be shared. | ||
3 | # | ||
4 | # Note, after including this file, a config file may override any option | ||
5 | # with a DEFAULTS OVERRIDE section. | ||
6 | # | ||
7 | |||
8 | # For those cases that use the same machine to boot a 64 bit | ||
9 | # and a 32 bit version. The MACHINE is the DNS name to get to the | ||
10 | # box (usually different if it was 64 bit or 32 bit) but the | ||
11 | # BOX here is defined as a variable that will be the name of the box | ||
12 | # itself. It is useful for calling scripts that will power cycle | ||
13 | # the box, as only one script needs to be created to power cycle | ||
14 | # even though the box itself has multiple operating systems on it. | ||
15 | # By default, BOX and MACHINE are the same. | ||
16 | |||
17 | DEFAULTS IF NOT DEFINED BOX | ||
18 | BOX := ${MACHINE} | ||
19 | |||
20 | |||
21 | # Consider each box as 64 bit box, unless the config including this file | ||
22 | # has defined BITS = 32 | ||
23 | |||
24 | DEFAULTS IF NOT DEFINED BITS | ||
25 | BITS := 64 | ||
26 | |||
27 | |||
28 | DEFAULTS | ||
29 | |||
30 | # THIS_DIR is used through out the configs and defaults to ${PWD} which | ||
31 | # is the directory that ktest.pl was called from. | ||
32 | |||
33 | THIS_DIR := ${PWD} | ||
34 | |||
35 | |||
36 | # to organize your configs, having each machine save their configs | ||
37 | # into a separate directly is useful. | ||
38 | CONFIG_DIR := ${THIS_DIR}/configs/${MACHINE} | ||
39 | |||
40 | # Reset the log before running each test. | ||
41 | CLEAR_LOG = 1 | ||
42 | |||
43 | # As installing kernels usually requires root privilege, default the | ||
44 | # user on the target as root. It is also required that the target | ||
45 | # allows ssh to root from the host without asking for a password. | ||
46 | |||
47 | SSH_USER = root | ||
48 | |||
49 | # For accesing the machine, we will ssh to root@machine. | ||
50 | SSH := ssh ${SSH_USER}@${MACHINE} | ||
51 | |||
52 | # Update this. The default here is ktest will ssh to the target box | ||
53 | # and run a script called 'run-test' located on that box. | ||
54 | TEST = ${SSH} run-test | ||
55 | |||
56 | # Point build dir to the git repo you use | ||
57 | BUILD_DIR = ${THIS_DIR}/linux.git | ||
58 | |||
59 | # Each machine will have its own output build directory. | ||
60 | OUTPUT_DIR = ${THIS_DIR}/build/${MACHINE} | ||
61 | |||
62 | # Yes this config is focused on x86 (but ktest works for other archs too) | ||
63 | BUILD_TARGET = arch/x86/boot/bzImage | ||
64 | TARGET_IMAGE = /boot/vmlinuz-test | ||
65 | |||
66 | # have directory for the scripts to reboot and power cycle the boxes | ||
67 | SCRIPTS_DIR := ${THIS_DIR}/scripts | ||
68 | |||
69 | # You can have each box/machine have a script to power cycle it. | ||
70 | # Name your script <box>-cycle. | ||
71 | POWER_CYCLE = ${SCRIPTS_DIR}/${BOX}-cycle | ||
72 | |||
73 | # This script is used to power off the box. | ||
74 | POWER_OFF = ${SCRIPTS_DIR}/${BOX}-poweroff | ||
75 | |||
76 | # Keep your test kernels separate from your other kernels. | ||
77 | LOCALVERSION = -test | ||
78 | |||
79 | # The /boot/grub/menu.lst is searched for the line: | ||
80 | # title Test Kernel | ||
81 | # and ktest will use that kernel to reboot into. | ||
82 | # For grub2 or other boot loaders, you need to set BOOT_TYPE | ||
83 | # to 'script' and define other ways to load the kernel. | ||
84 | # See snowball.conf example. | ||
85 | # | ||
86 | GRUB_MENU = Test Kernel | ||
87 | |||
88 | # The kernel build will use this option. | ||
89 | BUILD_OPTIONS = -j8 | ||
90 | |||
91 | # Keeping the log file with the output dir is convenient. | ||
92 | LOG_FILE = ${OUTPUT_DIR}/${MACHINE}.log | ||
93 | |||
94 | # Each box should have their own minum configuration | ||
95 | # See min-config.conf | ||
96 | MIN_CONFIG = ${CONFIG_DIR}/config-min | ||
97 | |||
98 | # For things like randconfigs, there may be configs you find that | ||
99 | # are already broken, or there may be some configs that you always | ||
100 | # want set. Uncomment ADD_CONFIG and point it to the make config files | ||
101 | # that set the configs you want to keep on (or off) in your build. | ||
102 | # ADD_CONFIG is usually something to add configs to all machines, | ||
103 | # where as, MIN_CONFIG is specific per machine. | ||
104 | #ADD_CONFIG = ${THIS_DIR}/config-broken ${THIS_DIR}/config-general | ||
105 | |||
106 | # To speed up reboots for bisects and patchcheck, instead of | ||
107 | # waiting 60 seconds for the console to be idle, if this line is | ||
108 | # seen in the console output, ktest will know the good kernel has | ||
109 | # finished rebooting and it will be able to continue the tests. | ||
110 | REBOOT_SUCCESS_LINE = ${MACHINE} login: | ||
111 | |||
112 | # The following is different ways to end the test. | ||
113 | # by setting the variable REBOOT to: none, error, fail or | ||
114 | # something else, ktest will power cycle or reboot the target box | ||
115 | # at the end of the tests. | ||
116 | # | ||
117 | # REBOOT := none | ||
118 | # Don't do anything at the end of the test. | ||
119 | # | ||
120 | # REBOOT := error | ||
121 | # Reboot the box if ktest detects an error | ||
122 | # | ||
123 | # REBOOT := fail | ||
124 | # Do not stop on failure, and after all tests are complete | ||
125 | # power off the box (for both success and error) | ||
126 | # This is good to run over a weekend and you don't want to waste | ||
127 | # electricity. | ||
128 | # | ||
129 | |||
130 | DEFAULTS IF ${REBOOT} == none | ||
131 | REBOOT_ON_SUCCESS = 0 | ||
132 | REBOOT_ON_ERROR = 0 | ||
133 | POWEROFF_ON_ERROR = 0 | ||
134 | POWEROFF_ON_SUCCESS = 0 | ||
135 | |||
136 | DEFAULTS ELSE IF ${REBOOT} == error | ||
137 | REBOOT_ON_SUCCESS = 0 | ||
138 | REBOOT_ON_ERROR = 1 | ||
139 | POWEROFF_ON_ERROR = 0 | ||
140 | POWEROFF_ON_SUCCESS = 0 | ||
141 | |||
142 | DEFAULTS ELSE IF ${REBOOT} == fail | ||
143 | REBOOT_ON_SUCCESS = 0 | ||
144 | POWEROFF_ON_ERROR = 1 | ||
145 | POWEROFF_ON_SUCCESS = 1 | ||
146 | POWEROFF_AFTER_HALT = 120 | ||
147 | DIE_ON_FAILURE = 0 | ||
148 | |||
149 | # Store the failure information into this directory | ||
150 | # such as the .config, dmesg, and build log. | ||
151 | STORE_FAILURES = ${THIS_DIR}/failures | ||
152 | |||
153 | DEFAULTS ELSE | ||
154 | REBOOT_ON_SUCCESS = 1 | ||
155 | REBOOT_ON_ERROR = 1 | ||
156 | POWEROFF_ON_ERROR = 0 | ||
157 | POWEROFF_ON_SUCCESS = 0 | ||
diff --git a/tools/testing/ktest/examples/include/min-config.conf b/tools/testing/ktest/examples/include/min-config.conf deleted file mode 100644 index c703cc46d15..00000000000 --- a/tools/testing/ktest/examples/include/min-config.conf +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | # | ||
2 | # This file has some examples for creating a MIN_CONFIG. | ||
3 | # (A .config file that is the minimum for a machine to boot, or | ||
4 | # to boot and make a network connection.) | ||
5 | # | ||
6 | # A MIN_CONFIG is very useful as it is the minimum configuration | ||
7 | # needed to boot a given machine. You can debug someone else's | ||
8 | # .config by only setting the configs in your MIN_CONFIG. The closer | ||
9 | # your MIN_CONFIG is to the true minimum set of configs needed to | ||
10 | # boot your machine, the closer the config you test with will be | ||
11 | # to the users config that had the failure. | ||
12 | # | ||
13 | # The make_min_config test allows you to create a MIN_CONFIG that | ||
14 | # is truly the minimum set of configs needed to boot a box. | ||
15 | # | ||
16 | # In this example, the final config will reside in | ||
17 | # ${CONFIG_DIR}/config-new-min and ${CONFIG_DIR}/config-new-min-net. | ||
18 | # Just move one to the location you have set for MIN_CONFIG. | ||
19 | # | ||
20 | # The first test creates a MIN_CONFIG that will be the minimum | ||
21 | # configuration to boot ${MACHINE} and be able to ssh to it. | ||
22 | # | ||
23 | # The second test creates a MIN_CONFIG that will only boot | ||
24 | # the target and most likely will not let you ssh to it. (Notice | ||
25 | # how the second test uses the first test's result to continue with. | ||
26 | # This is because the second test config is a subset of the first). | ||
27 | # | ||
28 | # The ${CONFIG_DIR}/config-skip (and -net) will hold the configs | ||
29 | # that ktest.pl found would not boot the target without them set. | ||
30 | # The config-new-min holds configs that ktest.pl could not test | ||
31 | # directly because another config that was needed to boot the box | ||
32 | # selected them. Sometimes it is possible that this file will hold | ||
33 | # the true minimum configuration. You can test to see if this is | ||
34 | # the case by running the boot test with BOOT_TYPE = allnoconfig and | ||
35 | # setting setting the MIN_CONFIG to ${CONFIG_DIR}/config-skip. If the | ||
36 | # machine still boots, then you can use the config-skip as your MIN_CONFIG. | ||
37 | # | ||
38 | # These tests can run for several hours (and perhaps days). | ||
39 | # It's OK to kill the test with a Ctrl^C. By restarting without | ||
40 | # modifying this config, ktest.pl will notice that the config-new-min(-net) | ||
41 | # exists, and will use that instead as the starting point. | ||
42 | # The USE_OUTPUT_MIN_CONFIG is set to 1 to keep ktest.pl from asking | ||
43 | # you if you want to use the OUTPUT_MIN_CONFIG as the starting point. | ||
44 | # By using the OUTPUT_MIN_CONFIG as the starting point will allow ktest.pl to | ||
45 | # start almost where it left off. | ||
46 | # | ||
47 | TEST_START IF ${TEST} == min-config | ||
48 | TEST_TYPE = make_min_config | ||
49 | OUTPUT_MIN_CONFIG = ${CONFIG_DIR}/config-new-min-net | ||
50 | IGNORE_CONFIG = ${CONFIG_DIR}/config-skip-net | ||
51 | MIN_CONFIG_TYPE = test | ||
52 | TEST = ${SSH} echo hi | ||
53 | USE_OUTPUT_MIN_CONFIG = 1 | ||
54 | |||
55 | TEST_START IF ${TEST} == min-config && ${MULTI} | ||
56 | TEST_TYPE = make_min_config | ||
57 | OUTPUT_MIN_CONFIG = ${CONFIG_DIR}/config-new-min | ||
58 | IGNORE_CONFIG = ${CONFIG_DIR}/config-skip | ||
59 | MIN_CONFIG = ${CONFIG_DIR}/config-new-min-net | ||
60 | USE_OUTPUT_MIN_CONFIG = 1 | ||
diff --git a/tools/testing/ktest/examples/include/patchcheck.conf b/tools/testing/ktest/examples/include/patchcheck.conf deleted file mode 100644 index 339d3e1700f..00000000000 --- a/tools/testing/ktest/examples/include/patchcheck.conf +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | # patchcheck.conf | ||
2 | # | ||
3 | # This contains a test that takes two git commits and will test each | ||
4 | # commit between the two. The build test will look at what files the | ||
5 | # commit has touched, and if any of those files produce a warning, then | ||
6 | # the build will fail. | ||
7 | |||
8 | |||
9 | # PATCH_START is the commit to begin with and PATCH_END is the commit | ||
10 | # to end with (inclusive). This is similar to doing a git rebase -i PATCH_START~1 | ||
11 | # and then testing each commit and doing a git rebase --continue. | ||
12 | # You can use a SHA1, a git tag, or anything that git will accept for a checkout | ||
13 | |||
14 | PATCH_START := HEAD~3 | ||
15 | PATCH_END := HEAD | ||
16 | |||
17 | # Change PATCH_CHECKOUT to be the branch you want to test. The test will | ||
18 | # do a git checkout of this branch before starting. Obviously both | ||
19 | # PATCH_START and PATCH_END must be in this branch (and PATCH_START must | ||
20 | # be contained by PATCH_END). | ||
21 | |||
22 | PATCH_CHECKOUT := test/branch | ||
23 | |||
24 | # Usually it's a good idea to have a set config to use for testing individual | ||
25 | # patches. | ||
26 | PATCH_CONFIG := ${CONFIG_DIR}/config-patchcheck | ||
27 | |||
28 | # Change PATCH_TEST to run some test for each patch. Each commit that is | ||
29 | # tested, after it is built and installed on the test machine, this command | ||
30 | # will be executed. Usually what is done is to ssh to the target box and | ||
31 | # run some test scripts. If you just want to boot test your patches | ||
32 | # comment PATCH_TEST out. | ||
33 | PATCH_TEST := ${SSH} "/usr/local/bin/ktest-test-script" | ||
34 | |||
35 | DEFAULTS IF DEFINED PATCH_TEST | ||
36 | PATCH_TEST_TYPE := test | ||
37 | |||
38 | DEFAULTS ELSE | ||
39 | PATCH_TEST_TYPE := boot | ||
40 | |||
41 | # If for some reason a file has a warning that one of your patches touch | ||
42 | # but you do not care about it, set IGNORE_WARNINGS to that commit(s) | ||
43 | # (space delimited) | ||
44 | #IGNORE_WARNINGS = 39eaf7ef884dcc44f7ff1bac803ca2a1dcf43544 6edb2a8a385f0cdef51dae37ff23e74d76d8a6ce | ||
45 | |||
46 | # If you are running a multi test, and the test failed on the first | ||
47 | # test but on, say the 5th patch. If you want to restart on the | ||
48 | # fifth patch, set PATCH_START1. This will make the first test start | ||
49 | # from this commit instead of the PATCH_START commit. | ||
50 | # Note, do not change this option. Just define PATCH_START1 in the | ||
51 | # top config (the one you pass to ktest.pl), and this will use it, | ||
52 | # otherwise it will just use PATCH_START if PATCH_START1 is not defined. | ||
53 | DEFAULTS IF NOT DEFINED PATCH_START1 | ||
54 | PATCH_START1 := ${PATCH_START} | ||
55 | |||
56 | TEST_START IF ${TEST} == patchcheck | ||
57 | TEST_TYPE = patchcheck | ||
58 | MIN_CONFIG = ${PATCH_CONFIG} | ||
59 | TEST = ${PATCH_TEST} | ||
60 | PATCHCHECK_TYPE = ${PATCH_TEST_TYPE} | ||
61 | PATCHCHECK_START = ${PATCH_START1} | ||
62 | PATCHCHECK_END = ${PATCH_END} | ||
63 | CHECKOUT = ${PATCH_CHECKOUT} | ||
64 | |||
65 | TEST_START IF ${TEST} == patchcheck && ${MULTI} | ||
66 | TEST_TYPE = patchcheck | ||
67 | MIN_CONFIG = ${PATCH_CONFIG} | ||
68 | TEST = ${PATCH_TEST} | ||
69 | PATCHCHECK_TYPE = ${PATCH_TEST_TYPE} | ||
70 | PATCHCHECK_START = ${PATCH_START} | ||
71 | PATCHCHECK_END = ${PATCH_END} | ||
72 | CHECKOUT = ${PATCH_CHECKOUT} | ||
73 | # Use multi to test different compilers? | ||
74 | MAKE_CMD = CC=gcc-4.5.1 make | ||
diff --git a/tools/testing/ktest/examples/include/tests.conf b/tools/testing/ktest/examples/include/tests.conf deleted file mode 100644 index 60cedb1a115..00000000000 --- a/tools/testing/ktest/examples/include/tests.conf +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | # | ||
2 | # This is an example of various tests that you can run | ||
3 | # | ||
4 | # The variable TEST can be of boot, build, randconfig, or test. | ||
5 | # | ||
6 | # Note that TEST is a variable created with ':=' and only exists | ||
7 | # throughout the config processing (not during the tests itself). | ||
8 | # | ||
9 | # The TEST option (defined with '=') is used to tell ktest.pl | ||
10 | # what test to run after a successful boot. The TEST option is | ||
11 | # persistent into the test runs. | ||
12 | # | ||
13 | |||
14 | # The config that includes this file may define a BOOT_TYPE | ||
15 | # variable that tells this config what type of boot test to run. | ||
16 | # If it's not defined, the below DEFAULTS will set the default | ||
17 | # to 'oldconfig'. | ||
18 | # | ||
19 | DEFAULTS IF NOT DEFINED BOOT_TYPE | ||
20 | BOOT_TYPE := oldconfig | ||
21 | |||
22 | # The config that includes this file may define a RUN_TEST | ||
23 | # variable that will tell this config what test to run. | ||
24 | # (what to set the TEST option to). | ||
25 | # | ||
26 | DEFAULTS IF NOT DEFINED RUN_TEST | ||
27 | # Requires that hackbench is in the PATH | ||
28 | RUN_TEST := ${SSH} hackbench 50 | ||
29 | |||
30 | |||
31 | # If TEST is set to 'boot' then just build a kernel and boot | ||
32 | # the target. | ||
33 | TEST_START IF ${TEST} == boot | ||
34 | TEST_TYPE = boot | ||
35 | # Notice how we set the BUILD_TYPE option to the BOOT_TYPE variable. | ||
36 | BUILD_TYPE = ${BOOT_TYPE} | ||
37 | # Do not do a make mrproper. | ||
38 | BUILD_NOCLEAN = 1 | ||
39 | |||
40 | # If you only want to build the kernel, and perhaps install | ||
41 | # and test it yourself, then just set TEST to build. | ||
42 | TEST_START IF ${TEST} == build | ||
43 | TEST_TYPE = build | ||
44 | BUILD_TYPE = ${BOOT_TYPE} | ||
45 | BUILD_NOCLEAN = 1 | ||
46 | |||
47 | # Build, install, boot and test with a randconfg 10 times. | ||
48 | # It is important that you have set MIN_CONFIG in the config | ||
49 | # that includes this file otherwise it is likely that the | ||
50 | # randconfig will not have the necessary configs needed to | ||
51 | # boot your box. This version of the test requires a min | ||
52 | # config that has enough to make sure the target has network | ||
53 | # working. | ||
54 | TEST_START ITERATE 10 IF ${TEST} == randconfig | ||
55 | MIN_CONFIG = ${CONFIG_DIR}/config-min-net | ||
56 | TEST_TYPE = test | ||
57 | BUILD_TYPE = randconfig | ||
58 | TEST = ${RUN_TEST} | ||
59 | |||
60 | # This is the same as above, but only tests to a boot prompt. | ||
61 | # The MIN_CONFIG used here does not need to have networking | ||
62 | # working. | ||
63 | TEST_START ITERATE 10 IF ${TEST} == randconfig && ${MULTI} | ||
64 | TEST_TYPE = boot | ||
65 | BUILD_TYPE = randconfig | ||
66 | MIN_CONFIG = ${CONFIG_DIR}/config-min | ||
67 | MAKE_CMD = make | ||
68 | |||
69 | # This builds, installs, boots and tests the target. | ||
70 | TEST_START IF ${TEST} == test | ||
71 | TEST_TYPE = test | ||
72 | BUILD_TYPE = ${BOOT_TYPE} | ||
73 | TEST = ${RUN_TEST} | ||
74 | BUILD_NOCLEAN = 1 | ||
diff --git a/tools/testing/ktest/examples/kvm.conf b/tools/testing/ktest/examples/kvm.conf deleted file mode 100644 index 831c7c5395f..00000000000 --- a/tools/testing/ktest/examples/kvm.conf +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | # | ||
2 | # This config is an example usage of ktest.pl with a kvm guest | ||
3 | # | ||
4 | # The guest is called 'Guest' and this would be something that | ||
5 | # could be run on the host to test a virtual machine target. | ||
6 | |||
7 | MACHINE = Guest | ||
8 | |||
9 | |||
10 | # Use virsh to read the serial console of the guest | ||
11 | CONSOLE = virsh console ${MACHINE} | ||
12 | |||
13 | #*************************************# | ||
14 | # This part is the same as test.conf # | ||
15 | #*************************************# | ||
16 | |||
17 | # The include files will set up the type of test to run. Just set TEST to | ||
18 | # which test you want to run. | ||
19 | # | ||
20 | # TESTS = patchcheck, randconfig, boot, test, config-bisect, bisect, min-config | ||
21 | # | ||
22 | # See the include/*.conf files that define these tests | ||
23 | # | ||
24 | TEST := patchcheck | ||
25 | |||
26 | # Some tests may have more than one test to run. Define MULTI := 1 to run | ||
27 | # the extra tests. | ||
28 | MULTI := 0 | ||
29 | |||
30 | # In case you want to differentiate which type of system you are testing | ||
31 | BITS := 64 | ||
32 | |||
33 | # REBOOT = none, error, fail, empty | ||
34 | # See include/defaults.conf | ||
35 | REBOOT := empty | ||
36 | |||
37 | |||
38 | # The defaults file will set up various settings that can be used by all | ||
39 | # machine configs. | ||
40 | INCLUDE include/defaults.conf | ||
41 | |||
42 | |||
43 | #*************************************# | ||
44 | # Now we are different from test.conf # | ||
45 | #*************************************# | ||
46 | |||
47 | |||
48 | # The example here assumes that Guest is running a Fedora release | ||
49 | # that uses dracut for its initfs. The POST_INSTALL will be executed | ||
50 | # after the install of the kernel and modules are complete. | ||
51 | # | ||
52 | POST_INSTALL = ${SSH} /sbin/dracut -f /boot/initramfs-test.img $KERNEL_VERSION | ||
53 | |||
54 | # Guests sometimes get stuck on reboot. We wait 3 seconds after running | ||
55 | # the reboot command and then do a full power-cycle of the guest. | ||
56 | # This forces the guest to restart. | ||
57 | # | ||
58 | POWERCYCLE_AFTER_REBOOT = 3 | ||
59 | |||
60 | # We do the same after the halt command, but this time we wait 20 seconds. | ||
61 | POWEROFF_AFTER_HALT = 20 | ||
62 | |||
63 | |||
64 | # As the defaults.conf file has a POWER_CYCLE option already defined, | ||
65 | # and options can not be defined in the same section more than once | ||
66 | # (all DEFAULTS sections are considered the same). We use the | ||
67 | # DEFAULTS OVERRIDE to tell ktest.pl to ignore the previous defined | ||
68 | # options, for the options set in the OVERRIDE section. | ||
69 | # | ||
70 | DEFAULTS OVERRIDE | ||
71 | |||
72 | # Instead of using the default POWER_CYCLE option defined in | ||
73 | # defaults.conf, we use virsh to cycle it. To do so, we destroy | ||
74 | # the guest, wait 5 seconds, and then start it up again. | ||
75 | # Crude, but effective. | ||
76 | # | ||
77 | POWER_CYCLE = virsh destroy ${MACHINE}; sleep 5; virsh start ${MACHINE} | ||
78 | |||
79 | |||
80 | DEFAULTS | ||
81 | |||
82 | # The following files each handle a different test case. | ||
83 | # Having them included allows you to set up more than one machine and share | ||
84 | # the same tests. | ||
85 | INCLUDE include/patchcheck.conf | ||
86 | INCLUDE include/tests.conf | ||
87 | INCLUDE include/bisect.conf | ||
88 | INCLUDE include/min-config.conf | ||
diff --git a/tools/testing/ktest/examples/snowball.conf b/tools/testing/ktest/examples/snowball.conf deleted file mode 100644 index a82a3c5bc2b..00000000000 --- a/tools/testing/ktest/examples/snowball.conf +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | # This example was used to boot the snowball ARM board. | ||
2 | # See http://people.redhat.com/srostedt/ktest-embedded-2012/ | ||
3 | |||
4 | # PWD is a ktest.pl variable that will result in the process working | ||
5 | # directory that ktest.pl is executed in. | ||
6 | |||
7 | # THIS_DIR is automatically assigned the PWD of the path that generated | ||
8 | # the config file. It is best to use this variable when assigning other | ||
9 | # directory paths within this directory. This allows you to easily | ||
10 | # move the test cases to other locations or to other machines. | ||
11 | # | ||
12 | THIS_DIR := /home/rostedt/work/demo/ktest-embed | ||
13 | LOG_FILE = ${OUTPUT_DIR}/snowball.log | ||
14 | CLEAR_LOG = 1 | ||
15 | MAKE_CMD = PATH=/usr/local/gcc-4.5.2-nolibc/arm-unknown-linux-gnueabi/bin:$PATH CROSS_COMPILE=arm-unknown-linux-gnueabi- make ARCH=arm | ||
16 | ADD_CONFIG = ${THIS_DIR}/addconfig | ||
17 | |||
18 | SCP_TO_TARGET = echo "don't do scp" | ||
19 | |||
20 | TFTPBOOT := /var/lib/tftpboot | ||
21 | TFTPDEF := ${TFTPBOOT}/snowball-default | ||
22 | TFTPTEST := ${OUTPUT_DIR}/${BUILD_TARGET} | ||
23 | |||
24 | SWITCH_TO_GOOD = cp ${TFTPDEF} ${TARGET_IMAGE} | ||
25 | SWITCH_TO_TEST = cp ${TFTPTEST} ${TARGET_IMAGE} | ||
26 | |||
27 | # Define each test with TEST_START | ||
28 | # The config options below it will override the defaults | ||
29 | TEST_START SKIP | ||
30 | TEST_TYPE = boot | ||
31 | BUILD_TYPE = u8500_defconfig | ||
32 | BUILD_NOCLEAN = 1 | ||
33 | |||
34 | TEST_START | ||
35 | TEST_TYPE = make_min_config | ||
36 | OUTPUT_MIN_CONFIG = ${THIS_DIR}/config.newmin | ||
37 | START_MIN_CONFIG = ${THIS_DIR}/config.orig | ||
38 | IGNORE_CONFIG = ${THIS_DIR}/config.ignore | ||
39 | BUILD_NOCLEAN = 1 | ||
40 | |||
41 | |||
42 | DEFAULTS | ||
43 | LOCALVERSION = -test | ||
44 | POWER_CYCLE = echo use the thumb luke; read a | ||
45 | CONSOLE = cat ${THIS_DIR}/snowball-cat | ||
46 | REBOOT_TYPE = script | ||
47 | SSH_USER = root | ||
48 | BUILD_OPTIONS = -j8 uImage | ||
49 | BUILD_DIR = ${THIS_DIR}/linux.git | ||
50 | OUTPUT_DIR = ${THIS_DIR}/snowball-build | ||
51 | MACHINE = snowball | ||
52 | TARGET_IMAGE = /var/lib/tftpboot/snowball-image | ||
53 | BUILD_TARGET = arch/arm/boot/uImage | ||
diff --git a/tools/testing/ktest/examples/test.conf b/tools/testing/ktest/examples/test.conf deleted file mode 100644 index b725210efb7..00000000000 --- a/tools/testing/ktest/examples/test.conf +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | # | ||
2 | # Generic config for a machine | ||
3 | # | ||
4 | |||
5 | # Name your machine (the DNS name, what you ssh to) | ||
6 | MACHINE = foo | ||
7 | |||
8 | # BOX can be different than foo, if the machine BOX has | ||
9 | # multiple partitions with different systems installed. For example, | ||
10 | # you may have a i386 and x86_64 installation on a test box. | ||
11 | # If this is the case, MACHINE defines the way to connect to the | ||
12 | # machine, which may be different between which system the machine | ||
13 | # is booting into. BOX is used for the scripts to reboot and power cycle | ||
14 | # the machine, where it does not matter which system the machine boots into. | ||
15 | # | ||
16 | #BOX := bar | ||
17 | |||
18 | # Define a way to read the console | ||
19 | CONSOLE = stty -F /dev/ttyS0 115200 parodd; cat /dev/ttyS0 | ||
20 | |||
21 | # The include files will set up the type of test to run. Just set TEST to | ||
22 | # which test you want to run. | ||
23 | # | ||
24 | # TESTS = patchcheck, randconfig, boot, test, config-bisect, bisect, min-config | ||
25 | # | ||
26 | # See the include/*.conf files that define these tests | ||
27 | # | ||
28 | TEST := patchcheck | ||
29 | |||
30 | # Some tests may have more than one test to run. Define MULTI := 1 to run | ||
31 | # the extra tests. | ||
32 | MULTI := 0 | ||
33 | |||
34 | # In case you want to differentiate which type of system you are testing | ||
35 | BITS := 64 | ||
36 | |||
37 | # REBOOT = none, error, fail, empty | ||
38 | # See include/defaults.conf | ||
39 | REBOOT := empty | ||
40 | |||
41 | # The defaults file will set up various settings that can be used by all | ||
42 | # machine configs. | ||
43 | INCLUDE include/defaults.conf | ||
44 | |||
45 | # In case you need to add a patch for a bisect or something | ||
46 | #PRE_BUILD = patch -p1 < ${THIS_DIR}/fix.patch | ||
47 | |||
48 | # Reset the repo after the build and remove all 'test' modules from the target | ||
49 | # Notice that DO_POST_BUILD is a variable (defined by ':=') and POST_BUILD | ||
50 | # is the option (defined by '=') | ||
51 | |||
52 | DO_POST_BUILD := git reset --hard | ||
53 | POST_BUILD = ${SSH} 'rm -rf /lib/modules/*-test*'; ${DO_POST_BUILD} | ||
54 | |||
55 | # The following files each handle a different test case. | ||
56 | # Having them included allows you to set up more than one machine and share | ||
57 | # the same tests. | ||
58 | INCLUDE include/patchcheck.conf | ||
59 | INCLUDE include/tests.conf | ||
60 | INCLUDE include/bisect.conf | ||
61 | INCLUDE include/min-config.conf | ||
62 | |||
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 35fc584a4ff..8d02ccb10c5 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -18,60 +18,42 @@ $| = 1; | |||
18 | my %opt; | 18 | my %opt; |
19 | my %repeat_tests; | 19 | my %repeat_tests; |
20 | my %repeats; | 20 | my %repeats; |
21 | my %default; | ||
21 | 22 | ||
22 | #default opts | 23 | #default opts |
23 | my %default = ( | 24 | $default{"NUM_TESTS"} = 1; |
24 | "NUM_TESTS" => 1, | 25 | $default{"REBOOT_TYPE"} = "grub"; |
25 | "TEST_TYPE" => "build", | 26 | $default{"TEST_TYPE"} = "test"; |
26 | "BUILD_TYPE" => "randconfig", | 27 | $default{"BUILD_TYPE"} = "randconfig"; |
27 | "MAKE_CMD" => "make", | 28 | $default{"MAKE_CMD"} = "make"; |
28 | "TIMEOUT" => 120, | 29 | $default{"TIMEOUT"} = 120; |
29 | "TMP_DIR" => "/tmp/ktest/\${MACHINE}", | 30 | $default{"TMP_DIR"} = "/tmp/ktest/\${MACHINE}"; |
30 | "SLEEP_TIME" => 60, # sleep time between tests | 31 | $default{"SLEEP_TIME"} = 60; # sleep time between tests |
31 | "BUILD_NOCLEAN" => 0, | 32 | $default{"BUILD_NOCLEAN"} = 0; |
32 | "REBOOT_ON_ERROR" => 0, | 33 | $default{"REBOOT_ON_ERROR"} = 0; |
33 | "POWEROFF_ON_ERROR" => 0, | 34 | $default{"POWEROFF_ON_ERROR"} = 0; |
34 | "REBOOT_ON_SUCCESS" => 1, | 35 | $default{"REBOOT_ON_SUCCESS"} = 1; |
35 | "POWEROFF_ON_SUCCESS" => 0, | 36 | $default{"POWEROFF_ON_SUCCESS"} = 0; |
36 | "BUILD_OPTIONS" => "", | 37 | $default{"BUILD_OPTIONS"} = ""; |
37 | "BISECT_SLEEP_TIME" => 60, # sleep time between bisects | 38 | $default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects |
38 | "PATCHCHECK_SLEEP_TIME" => 60, # sleep time between patch checks | 39 | $default{"PATCHCHECK_SLEEP_TIME"} = 60; # sleep time between patch checks |
39 | "CLEAR_LOG" => 0, | 40 | $default{"CLEAR_LOG"} = 0; |
40 | "BISECT_MANUAL" => 0, | 41 | $default{"BISECT_MANUAL"} = 0; |
41 | "BISECT_SKIP" => 1, | 42 | $default{"BISECT_SKIP"} = 1; |
42 | "MIN_CONFIG_TYPE" => "boot", | 43 | $default{"SUCCESS_LINE"} = "login:"; |
43 | "SUCCESS_LINE" => "login:", | 44 | $default{"DETECT_TRIPLE_FAULT"} = 1; |
44 | "DETECT_TRIPLE_FAULT" => 1, | 45 | $default{"BOOTED_TIMEOUT"} = 1; |
45 | "NO_INSTALL" => 0, | 46 | $default{"DIE_ON_FAILURE"} = 1; |
46 | "BOOTED_TIMEOUT" => 1, | 47 | $default{"SSH_EXEC"} = "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND"; |
47 | "DIE_ON_FAILURE" => 1, | 48 | $default{"SCP_TO_TARGET"} = "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE"; |
48 | "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND", | 49 | $default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot"; |
49 | "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE", | 50 | $default{"STOP_AFTER_SUCCESS"} = 10; |
50 | "SCP_TO_TARGET_INSTALL" => "\${SCP_TO_TARGET}", | 51 | $default{"STOP_AFTER_FAILURE"} = 60; |
51 | "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot", | 52 | $default{"STOP_TEST_AFTER"} = 600; |
52 | "STOP_AFTER_SUCCESS" => 10, | 53 | $default{"LOCALVERSION"} = "-test"; |
53 | "STOP_AFTER_FAILURE" => 60, | ||
54 | "STOP_TEST_AFTER" => 600, | ||
55 | "MAX_MONITOR_WAIT" => 1800, | ||
56 | "GRUB_REBOOT" => "grub2-reboot", | ||
57 | "SYSLINUX" => "extlinux", | ||
58 | "SYSLINUX_PATH" => "/boot/extlinux", | ||
59 | |||
60 | # required, and we will ask users if they don't have them but we keep the default | ||
61 | # value something that is common. | ||
62 | "REBOOT_TYPE" => "grub", | ||
63 | "LOCALVERSION" => "-test", | ||
64 | "SSH_USER" => "root", | ||
65 | "BUILD_TARGET" => "arch/x86/boot/bzImage", | ||
66 | "TARGET_IMAGE" => "/boot/vmlinuz-test", | ||
67 | |||
68 | "LOG_FILE" => undef, | ||
69 | "IGNORE_UNUSED" => 0, | ||
70 | ); | ||
71 | 54 | ||
72 | my $ktest_config; | 55 | my $ktest_config; |
73 | my $version; | 56 | my $version; |
74 | my $have_version = 0; | ||
75 | my $machine; | 57 | my $machine; |
76 | my $ssh_user; | 58 | my $ssh_user; |
77 | my $tmpdir; | 59 | my $tmpdir; |
@@ -81,11 +63,6 @@ my $output_config; | |||
81 | my $test_type; | 63 | my $test_type; |
82 | my $build_type; | 64 | my $build_type; |
83 | my $build_options; | 65 | my $build_options; |
84 | my $final_post_ktest; | ||
85 | my $pre_ktest; | ||
86 | my $post_ktest; | ||
87 | my $pre_test; | ||
88 | my $post_test; | ||
89 | my $pre_build; | 66 | my $pre_build; |
90 | my $post_build; | 67 | my $post_build; |
91 | my $pre_build_die; | 68 | my $pre_build_die; |
@@ -95,56 +72,35 @@ my $reboot_script; | |||
95 | my $power_cycle; | 72 | my $power_cycle; |
96 | my $reboot; | 73 | my $reboot; |
97 | my $reboot_on_error; | 74 | my $reboot_on_error; |
98 | my $switch_to_good; | ||
99 | my $switch_to_test; | ||
100 | my $poweroff_on_error; | 75 | my $poweroff_on_error; |
101 | my $reboot_on_success; | ||
102 | my $die_on_failure; | 76 | my $die_on_failure; |
103 | my $powercycle_after_reboot; | 77 | my $powercycle_after_reboot; |
104 | my $poweroff_after_halt; | 78 | my $poweroff_after_halt; |
105 | my $max_monitor_wait; | ||
106 | my $ssh_exec; | 79 | my $ssh_exec; |
107 | my $scp_to_target; | 80 | my $scp_to_target; |
108 | my $scp_to_target_install; | ||
109 | my $power_off; | 81 | my $power_off; |
110 | my $grub_menu; | 82 | my $grub_menu; |
111 | my $grub_file; | ||
112 | my $grub_number; | 83 | my $grub_number; |
113 | my $grub_reboot; | ||
114 | my $syslinux; | ||
115 | my $syslinux_path; | ||
116 | my $syslinux_label; | ||
117 | my $target; | 84 | my $target; |
118 | my $make; | 85 | my $make; |
119 | my $pre_install; | ||
120 | my $post_install; | 86 | my $post_install; |
121 | my $no_install; | ||
122 | my $noclean; | 87 | my $noclean; |
123 | my $minconfig; | 88 | my $minconfig; |
124 | my $start_minconfig; | 89 | my $start_minconfig; |
125 | my $start_minconfig_defined; | 90 | my $start_minconfig_defined; |
126 | my $output_minconfig; | 91 | my $output_minconfig; |
127 | my $minconfig_type; | ||
128 | my $use_output_minconfig; | ||
129 | my $ignore_config; | 92 | my $ignore_config; |
130 | my $ignore_errors; | ||
131 | my $addconfig; | 93 | my $addconfig; |
132 | my $in_bisect = 0; | 94 | my $in_bisect = 0; |
133 | my $bisect_bad_commit = ""; | 95 | my $bisect_bad = ""; |
134 | my $reverse_bisect; | 96 | my $reverse_bisect; |
135 | my $bisect_manual; | 97 | my $bisect_manual; |
136 | my $bisect_skip; | 98 | my $bisect_skip; |
137 | my $config_bisect_good; | 99 | my $config_bisect_good; |
138 | my $bisect_ret_good; | ||
139 | my $bisect_ret_bad; | ||
140 | my $bisect_ret_skip; | ||
141 | my $bisect_ret_abort; | ||
142 | my $bisect_ret_default; | ||
143 | my $in_patchcheck = 0; | 100 | my $in_patchcheck = 0; |
144 | my $run_test; | 101 | my $run_test; |
145 | my $redirect; | 102 | my $redirect; |
146 | my $buildlog; | 103 | my $buildlog; |
147 | my $testlog; | ||
148 | my $dmesg; | 104 | my $dmesg; |
149 | my $monitor_fp; | 105 | my $monitor_fp; |
150 | my $monitor_pid; | 106 | my $monitor_pid; |
@@ -154,171 +110,28 @@ my $bisect_sleep_time; | |||
154 | my $patchcheck_sleep_time; | 110 | my $patchcheck_sleep_time; |
155 | my $ignore_warnings; | 111 | my $ignore_warnings; |
156 | my $store_failures; | 112 | my $store_failures; |
157 | my $store_successes; | ||
158 | my $test_name; | 113 | my $test_name; |
159 | my $timeout; | 114 | my $timeout; |
160 | my $booted_timeout; | 115 | my $booted_timeout; |
161 | my $detect_triplefault; | 116 | my $detect_triplefault; |
162 | my $console; | 117 | my $console; |
163 | my $reboot_success_line; | ||
164 | my $success_line; | 118 | my $success_line; |
165 | my $stop_after_success; | 119 | my $stop_after_success; |
166 | my $stop_after_failure; | 120 | my $stop_after_failure; |
167 | my $stop_test_after; | 121 | my $stop_test_after; |
168 | my $build_target; | 122 | my $build_target; |
169 | my $target_image; | 123 | my $target_image; |
170 | my $checkout; | ||
171 | my $localversion; | 124 | my $localversion; |
172 | my $iteration = 0; | 125 | my $iteration = 0; |
173 | my $successes = 0; | 126 | my $successes = 0; |
174 | 127 | ||
175 | my $bisect_good; | ||
176 | my $bisect_bad; | ||
177 | my $bisect_type; | ||
178 | my $bisect_start; | ||
179 | my $bisect_replay; | ||
180 | my $bisect_files; | ||
181 | my $bisect_reverse; | ||
182 | my $bisect_check; | ||
183 | |||
184 | my $config_bisect; | ||
185 | my $config_bisect_type; | ||
186 | my $config_bisect_check; | ||
187 | |||
188 | my $patchcheck_type; | ||
189 | my $patchcheck_start; | ||
190 | my $patchcheck_end; | ||
191 | |||
192 | # set when a test is something other that just building or install | ||
193 | # which would require more options. | ||
194 | my $buildonly = 1; | ||
195 | |||
196 | # set when creating a new config | ||
197 | my $newconfig = 0; | ||
198 | |||
199 | my %entered_configs; | 128 | my %entered_configs; |
200 | my %config_help; | 129 | my %config_help; |
201 | my %variable; | 130 | my %variable; |
202 | |||
203 | # force_config is the list of configs that we force enabled (or disabled) | ||
204 | # in a .config file. The MIN_CONFIG and ADD_CONFIG configs. | ||
205 | my %force_config; | 131 | my %force_config; |
206 | 132 | ||
207 | # do not force reboots on config problems | ||
208 | my $no_reboot = 1; | ||
209 | |||
210 | # reboot on success | ||
211 | my $reboot_success = 0; | ||
212 | |||
213 | my %option_map = ( | ||
214 | "MACHINE" => \$machine, | ||
215 | "SSH_USER" => \$ssh_user, | ||
216 | "TMP_DIR" => \$tmpdir, | ||
217 | "OUTPUT_DIR" => \$outputdir, | ||
218 | "BUILD_DIR" => \$builddir, | ||
219 | "TEST_TYPE" => \$test_type, | ||
220 | "PRE_KTEST" => \$pre_ktest, | ||
221 | "POST_KTEST" => \$post_ktest, | ||
222 | "PRE_TEST" => \$pre_test, | ||
223 | "POST_TEST" => \$post_test, | ||
224 | "BUILD_TYPE" => \$build_type, | ||
225 | "BUILD_OPTIONS" => \$build_options, | ||
226 | "PRE_BUILD" => \$pre_build, | ||
227 | "POST_BUILD" => \$post_build, | ||
228 | "PRE_BUILD_DIE" => \$pre_build_die, | ||
229 | "POST_BUILD_DIE" => \$post_build_die, | ||
230 | "POWER_CYCLE" => \$power_cycle, | ||
231 | "REBOOT" => \$reboot, | ||
232 | "BUILD_NOCLEAN" => \$noclean, | ||
233 | "MIN_CONFIG" => \$minconfig, | ||
234 | "OUTPUT_MIN_CONFIG" => \$output_minconfig, | ||
235 | "START_MIN_CONFIG" => \$start_minconfig, | ||
236 | "MIN_CONFIG_TYPE" => \$minconfig_type, | ||
237 | "USE_OUTPUT_MIN_CONFIG" => \$use_output_minconfig, | ||
238 | "IGNORE_CONFIG" => \$ignore_config, | ||
239 | "TEST" => \$run_test, | ||
240 | "ADD_CONFIG" => \$addconfig, | ||
241 | "REBOOT_TYPE" => \$reboot_type, | ||
242 | "GRUB_MENU" => \$grub_menu, | ||
243 | "GRUB_FILE" => \$grub_file, | ||
244 | "GRUB_REBOOT" => \$grub_reboot, | ||
245 | "SYSLINUX" => \$syslinux, | ||
246 | "SYSLINUX_PATH" => \$syslinux_path, | ||
247 | "SYSLINUX_LABEL" => \$syslinux_label, | ||
248 | "PRE_INSTALL" => \$pre_install, | ||
249 | "POST_INSTALL" => \$post_install, | ||
250 | "NO_INSTALL" => \$no_install, | ||
251 | "REBOOT_SCRIPT" => \$reboot_script, | ||
252 | "REBOOT_ON_ERROR" => \$reboot_on_error, | ||
253 | "SWITCH_TO_GOOD" => \$switch_to_good, | ||
254 | "SWITCH_TO_TEST" => \$switch_to_test, | ||
255 | "POWEROFF_ON_ERROR" => \$poweroff_on_error, | ||
256 | "REBOOT_ON_SUCCESS" => \$reboot_on_success, | ||
257 | "DIE_ON_FAILURE" => \$die_on_failure, | ||
258 | "POWER_OFF" => \$power_off, | ||
259 | "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot, | ||
260 | "POWEROFF_AFTER_HALT" => \$poweroff_after_halt, | ||
261 | "MAX_MONITOR_WAIT" => \$max_monitor_wait, | ||
262 | "SLEEP_TIME" => \$sleep_time, | ||
263 | "BISECT_SLEEP_TIME" => \$bisect_sleep_time, | ||
264 | "PATCHCHECK_SLEEP_TIME" => \$patchcheck_sleep_time, | ||
265 | "IGNORE_WARNINGS" => \$ignore_warnings, | ||
266 | "IGNORE_ERRORS" => \$ignore_errors, | ||
267 | "BISECT_MANUAL" => \$bisect_manual, | ||
268 | "BISECT_SKIP" => \$bisect_skip, | ||
269 | "CONFIG_BISECT_GOOD" => \$config_bisect_good, | ||
270 | "BISECT_RET_GOOD" => \$bisect_ret_good, | ||
271 | "BISECT_RET_BAD" => \$bisect_ret_bad, | ||
272 | "BISECT_RET_SKIP" => \$bisect_ret_skip, | ||
273 | "BISECT_RET_ABORT" => \$bisect_ret_abort, | ||
274 | "BISECT_RET_DEFAULT" => \$bisect_ret_default, | ||
275 | "STORE_FAILURES" => \$store_failures, | ||
276 | "STORE_SUCCESSES" => \$store_successes, | ||
277 | "TEST_NAME" => \$test_name, | ||
278 | "TIMEOUT" => \$timeout, | ||
279 | "BOOTED_TIMEOUT" => \$booted_timeout, | ||
280 | "CONSOLE" => \$console, | ||
281 | "DETECT_TRIPLE_FAULT" => \$detect_triplefault, | ||
282 | "SUCCESS_LINE" => \$success_line, | ||
283 | "REBOOT_SUCCESS_LINE" => \$reboot_success_line, | ||
284 | "STOP_AFTER_SUCCESS" => \$stop_after_success, | ||
285 | "STOP_AFTER_FAILURE" => \$stop_after_failure, | ||
286 | "STOP_TEST_AFTER" => \$stop_test_after, | ||
287 | "BUILD_TARGET" => \$build_target, | ||
288 | "SSH_EXEC" => \$ssh_exec, | ||
289 | "SCP_TO_TARGET" => \$scp_to_target, | ||
290 | "SCP_TO_TARGET_INSTALL" => \$scp_to_target_install, | ||
291 | "CHECKOUT" => \$checkout, | ||
292 | "TARGET_IMAGE" => \$target_image, | ||
293 | "LOCALVERSION" => \$localversion, | ||
294 | |||
295 | "BISECT_GOOD" => \$bisect_good, | ||
296 | "BISECT_BAD" => \$bisect_bad, | ||
297 | "BISECT_TYPE" => \$bisect_type, | ||
298 | "BISECT_START" => \$bisect_start, | ||
299 | "BISECT_REPLAY" => \$bisect_replay, | ||
300 | "BISECT_FILES" => \$bisect_files, | ||
301 | "BISECT_REVERSE" => \$bisect_reverse, | ||
302 | "BISECT_CHECK" => \$bisect_check, | ||
303 | |||
304 | "CONFIG_BISECT" => \$config_bisect, | ||
305 | "CONFIG_BISECT_TYPE" => \$config_bisect_type, | ||
306 | "CONFIG_BISECT_CHECK" => \$config_bisect_check, | ||
307 | |||
308 | "PATCHCHECK_TYPE" => \$patchcheck_type, | ||
309 | "PATCHCHECK_START" => \$patchcheck_start, | ||
310 | "PATCHCHECK_END" => \$patchcheck_end, | ||
311 | ); | ||
312 | |||
313 | # Options may be used by other options, record them. | ||
314 | my %used_options; | ||
315 | |||
316 | # default variables that can be used | ||
317 | chomp ($variable{"PWD"} = `pwd`); | ||
318 | |||
319 | $config_help{"MACHINE"} = << "EOF" | 133 | $config_help{"MACHINE"} = << "EOF" |
320 | The machine hostname that you will test. | 134 | The machine hostname that you will test. |
321 | For build only tests, it is still needed to differentiate log files. | ||
322 | EOF | 135 | EOF |
323 | ; | 136 | ; |
324 | $config_help{"SSH_USER"} = << "EOF" | 137 | $config_help{"SSH_USER"} = << "EOF" |
@@ -328,15 +141,11 @@ EOF | |||
328 | ; | 141 | ; |
329 | $config_help{"BUILD_DIR"} = << "EOF" | 142 | $config_help{"BUILD_DIR"} = << "EOF" |
330 | The directory that contains the Linux source code (full path). | 143 | The directory that contains the Linux source code (full path). |
331 | You can use \${PWD} that will be the path where ktest.pl is run, or use | ||
332 | \${THIS_DIR} which is assigned \${PWD} but may be changed later. | ||
333 | EOF | 144 | EOF |
334 | ; | 145 | ; |
335 | $config_help{"OUTPUT_DIR"} = << "EOF" | 146 | $config_help{"OUTPUT_DIR"} = << "EOF" |
336 | The directory that the objects will be built (full path). | 147 | The directory that the objects will be built (full path). |
337 | (can not be same as BUILD_DIR) | 148 | (can not be same as BUILD_DIR) |
338 | You can use \${PWD} that will be the path where ktest.pl is run, or use | ||
339 | \${THIS_DIR} which is assigned \${PWD} but may be changed later. | ||
340 | EOF | 149 | EOF |
341 | ; | 150 | ; |
342 | $config_help{"BUILD_TARGET"} = << "EOF" | 151 | $config_help{"BUILD_TARGET"} = << "EOF" |
@@ -344,11 +153,6 @@ $config_help{"BUILD_TARGET"} = << "EOF" | |||
344 | (relative to OUTPUT_DIR) | 153 | (relative to OUTPUT_DIR) |
345 | EOF | 154 | EOF |
346 | ; | 155 | ; |
347 | $config_help{"BUILD_OPTIONS"} = << "EOF" | ||
348 | Options to add to \"make\" when building. | ||
349 | i.e. -j20 | ||
350 | EOF | ||
351 | ; | ||
352 | $config_help{"TARGET_IMAGE"} = << "EOF" | 156 | $config_help{"TARGET_IMAGE"} = << "EOF" |
353 | The place to put your image on the test machine. | 157 | The place to put your image on the test machine. |
354 | EOF | 158 | EOF |
@@ -381,7 +185,7 @@ EOF | |||
381 | ; | 185 | ; |
382 | $config_help{"REBOOT_TYPE"} = << "EOF" | 186 | $config_help{"REBOOT_TYPE"} = << "EOF" |
383 | Way to reboot the box to the test kernel. | 187 | Way to reboot the box to the test kernel. |
384 | Only valid options so far are "grub", "grub2", "syslinux", and "script". | 188 | Only valid options so far are "grub" and "script". |
385 | 189 | ||
386 | If you specify grub, it will assume grub version 1 | 190 | If you specify grub, it will assume grub version 1 |
387 | and will search in /boot/grub/menu.lst for the title \$GRUB_MENU | 191 | and will search in /boot/grub/menu.lst for the title \$GRUB_MENU |
@@ -391,19 +195,11 @@ $config_help{"REBOOT_TYPE"} = << "EOF" | |||
391 | 195 | ||
392 | The entry in /boot/grub/menu.lst must be entered in manually. | 196 | The entry in /boot/grub/menu.lst must be entered in manually. |
393 | The test will not modify that file. | 197 | The test will not modify that file. |
394 | |||
395 | If you specify grub2, then you also need to specify both \$GRUB_MENU | ||
396 | and \$GRUB_FILE. | ||
397 | |||
398 | If you specify syslinux, then you may use SYSLINUX to define the syslinux | ||
399 | command (defaults to extlinux), and SYSLINUX_PATH to specify the path to | ||
400 | the syslinux install (defaults to /boot/extlinux). But you have to specify | ||
401 | SYSLINUX_LABEL to define the label to boot to for the test kernel. | ||
402 | EOF | 198 | EOF |
403 | ; | 199 | ; |
404 | $config_help{"GRUB_MENU"} = << "EOF" | 200 | $config_help{"GRUB_MENU"} = << "EOF" |
405 | The grub title name for the test kernel to boot | 201 | The grub title name for the test kernel to boot |
406 | (Only mandatory if REBOOT_TYPE = grub or grub2) | 202 | (Only mandatory if REBOOT_TYPE = grub) |
407 | 203 | ||
408 | Note, ktest.pl will not update the grub menu.lst, you need to | 204 | Note, ktest.pl will not update the grub menu.lst, you need to |
409 | manually add an option for the test. ktest.pl will search | 205 | manually add an option for the test. ktest.pl will search |
@@ -414,22 +210,6 @@ $config_help{"GRUB_MENU"} = << "EOF" | |||
414 | title Test Kernel | 210 | title Test Kernel |
415 | kernel vmlinuz-test | 211 | kernel vmlinuz-test |
416 | GRUB_MENU = Test Kernel | 212 | GRUB_MENU = Test Kernel |
417 | |||
418 | For grub2, a search of \$GRUB_FILE is performed for the lines | ||
419 | that begin with "menuentry". It will not detect submenus. The | ||
420 | menu must be a non-nested menu. Add the quotes used in the menu | ||
421 | to guarantee your selection, as the first menuentry with the content | ||
422 | of \$GRUB_MENU that is found will be used. | ||
423 | EOF | ||
424 | ; | ||
425 | $config_help{"GRUB_FILE"} = << "EOF" | ||
426 | If grub2 is used, the full path for the grub.cfg file is placed | ||
427 | here. Use something like /boot/grub2/grub.cfg to search. | ||
428 | EOF | ||
429 | ; | ||
430 | $config_help{"SYSLINUX_LABEL"} = << "EOF" | ||
431 | If syslinux is used, the label that boots the target kernel must | ||
432 | be specified with SYSLINUX_LABEL. | ||
433 | EOF | 213 | EOF |
434 | ; | 214 | ; |
435 | $config_help{"REBOOT_SCRIPT"} = << "EOF" | 215 | $config_help{"REBOOT_SCRIPT"} = << "EOF" |
@@ -438,36 +218,20 @@ $config_help{"REBOOT_SCRIPT"} = << "EOF" | |||
438 | EOF | 218 | EOF |
439 | ; | 219 | ; |
440 | 220 | ||
441 | sub read_prompt { | 221 | sub read_yn { |
442 | my ($cancel, $prompt) = @_; | 222 | my ($prompt) = @_; |
443 | 223 | ||
444 | my $ans; | 224 | my $ans; |
445 | 225 | ||
446 | for (;;) { | 226 | for (;;) { |
447 | if ($cancel) { | 227 | print "$prompt [Y/n] "; |
448 | print "$prompt [y/n/C] "; | ||
449 | } else { | ||
450 | print "$prompt [Y/n] "; | ||
451 | } | ||
452 | $ans = <STDIN>; | 228 | $ans = <STDIN>; |
453 | chomp $ans; | 229 | chomp $ans; |
454 | if ($ans =~ /^\s*$/) { | 230 | if ($ans =~ /^\s*$/) { |
455 | if ($cancel) { | 231 | $ans = "y"; |
456 | $ans = "c"; | ||
457 | } else { | ||
458 | $ans = "y"; | ||
459 | } | ||
460 | } | 232 | } |
461 | last if ($ans =~ /^y$/i || $ans =~ /^n$/i); | 233 | last if ($ans =~ /^y$/i || $ans =~ /^n$/i); |
462 | if ($cancel) { | 234 | print "Please answer either 'y' or 'n'.\n"; |
463 | last if ($ans =~ /^c$/i); | ||
464 | print "Please answer either 'y', 'n' or 'c'.\n"; | ||
465 | } else { | ||
466 | print "Please answer either 'y' or 'n'.\n"; | ||
467 | } | ||
468 | } | ||
469 | if ($ans =~ /^c/i) { | ||
470 | exit; | ||
471 | } | 235 | } |
472 | if ($ans !~ /^y$/i) { | 236 | if ($ans !~ /^y$/i) { |
473 | return 0; | 237 | return 0; |
@@ -475,21 +239,8 @@ sub read_prompt { | |||
475 | return 1; | 239 | return 1; |
476 | } | 240 | } |
477 | 241 | ||
478 | sub read_yn { | ||
479 | my ($prompt) = @_; | ||
480 | |||
481 | return read_prompt 0, $prompt; | ||
482 | } | ||
483 | |||
484 | sub read_ync { | ||
485 | my ($prompt) = @_; | ||
486 | |||
487 | return read_prompt 1, $prompt; | ||
488 | } | ||
489 | |||
490 | sub get_ktest_config { | 242 | sub get_ktest_config { |
491 | my ($config) = @_; | 243 | my ($config) = @_; |
492 | my $ans; | ||
493 | 244 | ||
494 | return if (defined($opt{$config})); | 245 | return if (defined($opt{$config})); |
495 | 246 | ||
@@ -500,50 +251,34 @@ sub get_ktest_config { | |||
500 | 251 | ||
501 | for (;;) { | 252 | for (;;) { |
502 | print "$config = "; | 253 | print "$config = "; |
503 | if (defined($default{$config}) && length($default{$config})) { | 254 | if (defined($default{$config})) { |
504 | print "\[$default{$config}\] "; | 255 | print "\[$default{$config}\] "; |
505 | } | 256 | } |
506 | $ans = <STDIN>; | 257 | $entered_configs{$config} = <STDIN>; |
507 | $ans =~ s/^\s*(.*\S)\s*$/$1/; | 258 | $entered_configs{$config} =~ s/^\s*(.*\S)\s*$/$1/; |
508 | if ($ans =~ /^\s*$/) { | 259 | if ($entered_configs{$config} =~ /^\s*$/) { |
509 | if ($default{$config}) { | 260 | if ($default{$config}) { |
510 | $ans = $default{$config}; | 261 | $entered_configs{$config} = $default{$config}; |
511 | } else { | 262 | } else { |
512 | print "Your answer can not be blank\n"; | 263 | print "Your answer can not be blank\n"; |
513 | next; | 264 | next; |
514 | } | 265 | } |
515 | } | 266 | } |
516 | $entered_configs{$config} = ${ans}; | ||
517 | last; | 267 | last; |
518 | } | 268 | } |
519 | } | 269 | } |
520 | 270 | ||
521 | sub get_ktest_configs { | 271 | sub get_ktest_configs { |
522 | get_ktest_config("MACHINE"); | 272 | get_ktest_config("MACHINE"); |
273 | get_ktest_config("SSH_USER"); | ||
523 | get_ktest_config("BUILD_DIR"); | 274 | get_ktest_config("BUILD_DIR"); |
524 | get_ktest_config("OUTPUT_DIR"); | 275 | get_ktest_config("OUTPUT_DIR"); |
525 | 276 | get_ktest_config("BUILD_TARGET"); | |
526 | if ($newconfig) { | 277 | get_ktest_config("TARGET_IMAGE"); |
527 | get_ktest_config("BUILD_OPTIONS"); | 278 | get_ktest_config("POWER_CYCLE"); |
528 | } | 279 | get_ktest_config("CONSOLE"); |
529 | |||
530 | # options required for other than just building a kernel | ||
531 | if (!$buildonly) { | ||
532 | get_ktest_config("POWER_CYCLE"); | ||
533 | get_ktest_config("CONSOLE"); | ||
534 | } | ||
535 | |||
536 | # options required for install and more | ||
537 | if ($buildonly != 1) { | ||
538 | get_ktest_config("SSH_USER"); | ||
539 | get_ktest_config("BUILD_TARGET"); | ||
540 | get_ktest_config("TARGET_IMAGE"); | ||
541 | } | ||
542 | |||
543 | get_ktest_config("LOCALVERSION"); | 280 | get_ktest_config("LOCALVERSION"); |
544 | 281 | ||
545 | return if ($buildonly); | ||
546 | |||
547 | my $rtype = $opt{"REBOOT_TYPE"}; | 282 | my $rtype = $opt{"REBOOT_TYPE"}; |
548 | 283 | ||
549 | if (!defined($rtype)) { | 284 | if (!defined($rtype)) { |
@@ -557,20 +292,13 @@ sub get_ktest_configs { | |||
557 | 292 | ||
558 | if ($rtype eq "grub") { | 293 | if ($rtype eq "grub") { |
559 | get_ktest_config("GRUB_MENU"); | 294 | get_ktest_config("GRUB_MENU"); |
560 | } | 295 | } else { |
561 | 296 | get_ktest_config("REBOOT_SCRIPT"); | |
562 | if ($rtype eq "grub2") { | ||
563 | get_ktest_config("GRUB_MENU"); | ||
564 | get_ktest_config("GRUB_FILE"); | ||
565 | } | ||
566 | |||
567 | if ($rtype eq "syslinux") { | ||
568 | get_ktest_config("SYSLINUX_LABEL"); | ||
569 | } | 297 | } |
570 | } | 298 | } |
571 | 299 | ||
572 | sub process_variables { | 300 | sub process_variables { |
573 | my ($value, $remove_undef) = @_; | 301 | my ($value) = @_; |
574 | my $retval = ""; | 302 | my $retval = ""; |
575 | 303 | ||
576 | # We want to check for '\', and it is just easier | 304 | # We want to check for '\', and it is just easier |
@@ -588,17 +316,9 @@ sub process_variables { | |||
588 | $retval = "$retval$begin"; | 316 | $retval = "$retval$begin"; |
589 | if (defined($variable{$var})) { | 317 | if (defined($variable{$var})) { |
590 | $retval = "$retval$variable{$var}"; | 318 | $retval = "$retval$variable{$var}"; |
591 | } elsif (defined($remove_undef) && $remove_undef) { | ||
592 | # for if statements, any variable that is not defined, | ||
593 | # we simple convert to 0 | ||
594 | $retval = "${retval}0"; | ||
595 | } else { | 319 | } else { |
596 | # put back the origin piece. | 320 | # put back the origin piece. |
597 | $retval = "$retval\$\{$var\}"; | 321 | $retval = "$retval\$\{$var\}"; |
598 | # This could be an option that is used later, save | ||
599 | # it so we don't warn if this option is not one of | ||
600 | # ktests options. | ||
601 | $used_options{$var} = 1; | ||
602 | } | 322 | } |
603 | $value = $end; | 323 | $value = $end; |
604 | } | 324 | } |
@@ -611,35 +331,16 @@ sub process_variables { | |||
611 | } | 331 | } |
612 | 332 | ||
613 | sub set_value { | 333 | sub set_value { |
614 | my ($lvalue, $rvalue, $override, $overrides, $name) = @_; | 334 | my ($lvalue, $rvalue) = @_; |
615 | |||
616 | my $prvalue = process_variables($rvalue); | ||
617 | |||
618 | if ($buildonly && $lvalue =~ /^TEST_TYPE(\[.*\])?$/ && $prvalue ne "build") { | ||
619 | # Note if a test is something other than build, then we | ||
620 | # will need other manditory options. | ||
621 | if ($prvalue ne "install") { | ||
622 | $buildonly = 0; | ||
623 | } else { | ||
624 | # install still limits some manditory options. | ||
625 | $buildonly = 2; | ||
626 | } | ||
627 | } | ||
628 | 335 | ||
629 | if (defined($opt{$lvalue})) { | 336 | if (defined($opt{$lvalue})) { |
630 | if (!$override || defined(${$overrides}{$lvalue})) { | 337 | die "Error: Option $lvalue defined more than once!\n"; |
631 | my $extra = ""; | ||
632 | if ($override) { | ||
633 | $extra = "In the same override section!\n"; | ||
634 | } | ||
635 | die "$name: $.: Option $lvalue defined more than once!\n$extra"; | ||
636 | } | ||
637 | ${$overrides}{$lvalue} = $prvalue; | ||
638 | } | 338 | } |
639 | if ($rvalue =~ /^\s*$/) { | 339 | if ($rvalue =~ /^\s*$/) { |
640 | delete $opt{$lvalue}; | 340 | delete $opt{$lvalue}; |
641 | } else { | 341 | } else { |
642 | $opt{$lvalue} = $prvalue; | 342 | $rvalue = process_variables($rvalue); |
343 | $opt{$lvalue} = $rvalue; | ||
643 | } | 344 | } |
644 | } | 345 | } |
645 | 346 | ||
@@ -654,280 +355,86 @@ sub set_variable { | |||
654 | } | 355 | } |
655 | } | 356 | } |
656 | 357 | ||
657 | sub process_compare { | 358 | sub read_config { |
658 | my ($lval, $cmp, $rval) = @_; | 359 | my ($config) = @_; |
659 | |||
660 | # remove whitespace | ||
661 | |||
662 | $lval =~ s/^\s*//; | ||
663 | $lval =~ s/\s*$//; | ||
664 | |||
665 | $rval =~ s/^\s*//; | ||
666 | $rval =~ s/\s*$//; | ||
667 | |||
668 | if ($cmp eq "==") { | ||
669 | return $lval eq $rval; | ||
670 | } elsif ($cmp eq "!=") { | ||
671 | return $lval ne $rval; | ||
672 | } elsif ($cmp eq "=~") { | ||
673 | return $lval =~ m/$rval/; | ||
674 | } elsif ($cmp eq "!~") { | ||
675 | return $lval !~ m/$rval/; | ||
676 | } | ||
677 | |||
678 | my $statement = "$lval $cmp $rval"; | ||
679 | my $ret = eval $statement; | ||
680 | |||
681 | # $@ stores error of eval | ||
682 | if ($@) { | ||
683 | return -1; | ||
684 | } | ||
685 | |||
686 | return $ret; | ||
687 | } | ||
688 | |||
689 | sub value_defined { | ||
690 | my ($val) = @_; | ||
691 | |||
692 | return defined($variable{$2}) || | ||
693 | defined($opt{$2}); | ||
694 | } | ||
695 | |||
696 | my $d = 0; | ||
697 | sub process_expression { | ||
698 | my ($name, $val) = @_; | ||
699 | |||
700 | my $c = $d++; | ||
701 | |||
702 | while ($val =~ s/\(([^\(]*?)\)/\&\&\&\&VAL\&\&\&\&/) { | ||
703 | my $express = $1; | ||
704 | |||
705 | if (process_expression($name, $express)) { | ||
706 | $val =~ s/\&\&\&\&VAL\&\&\&\&/ 1 /; | ||
707 | } else { | ||
708 | $val =~ s/\&\&\&\&VAL\&\&\&\&/ 0 /; | ||
709 | } | ||
710 | } | ||
711 | |||
712 | $d--; | ||
713 | my $OR = "\\|\\|"; | ||
714 | my $AND = "\\&\\&"; | ||
715 | |||
716 | while ($val =~ s/^(.*?)($OR|$AND)//) { | ||
717 | my $express = $1; | ||
718 | my $op = $2; | ||
719 | |||
720 | if (process_expression($name, $express)) { | ||
721 | if ($op eq "||") { | ||
722 | return 1; | ||
723 | } | ||
724 | } else { | ||
725 | if ($op eq "&&") { | ||
726 | return 0; | ||
727 | } | ||
728 | } | ||
729 | } | ||
730 | |||
731 | if ($val =~ /(.*)(==|\!=|>=|<=|>|<|=~|\!~)(.*)/) { | ||
732 | my $ret = process_compare($1, $2, $3); | ||
733 | if ($ret < 0) { | ||
734 | die "$name: $.: Unable to process comparison\n"; | ||
735 | } | ||
736 | return $ret; | ||
737 | } | ||
738 | |||
739 | if ($val =~ /^\s*(NOT\s*)?DEFINED\s+(\S+)\s*$/) { | ||
740 | if (defined $1) { | ||
741 | return !value_defined($2); | ||
742 | } else { | ||
743 | return value_defined($2); | ||
744 | } | ||
745 | } | ||
746 | |||
747 | if ($val =~ /^\s*0\s*$/) { | ||
748 | return 0; | ||
749 | } elsif ($val =~ /^\s*\d+\s*$/) { | ||
750 | return 1; | ||
751 | } | ||
752 | |||
753 | die ("$name: $.: Undefined content $val in if statement\n"); | ||
754 | } | ||
755 | |||
756 | sub process_if { | ||
757 | my ($name, $value) = @_; | ||
758 | |||
759 | # Convert variables and replace undefined ones with 0 | ||
760 | my $val = process_variables($value, 1); | ||
761 | my $ret = process_expression $name, $val; | ||
762 | |||
763 | return $ret; | ||
764 | } | ||
765 | |||
766 | sub __read_config { | ||
767 | my ($config, $current_test_num) = @_; | ||
768 | 360 | ||
769 | my $in; | 361 | open(IN, $config) || die "can't read file $config"; |
770 | open($in, $config) || die "can't read file $config"; | ||
771 | 362 | ||
772 | my $name = $config; | 363 | my $name = $config; |
773 | $name =~ s,.*/(.*),$1,; | 364 | $name =~ s,.*/(.*),$1,; |
774 | 365 | ||
775 | my $test_num = $$current_test_num; | 366 | my $test_num = 0; |
776 | my $default = 1; | 367 | my $default = 1; |
777 | my $repeat = 1; | 368 | my $repeat = 1; |
778 | my $num_tests_set = 0; | 369 | my $num_tests_set = 0; |
779 | my $skip = 0; | 370 | my $skip = 0; |
780 | my $rest; | 371 | my $rest; |
781 | my $line; | ||
782 | my $test_case = 0; | 372 | my $test_case = 0; |
783 | my $if = 0; | ||
784 | my $if_set = 0; | ||
785 | my $override = 0; | ||
786 | |||
787 | my %overrides; | ||
788 | 373 | ||
789 | while (<$in>) { | 374 | while (<IN>) { |
790 | 375 | ||
791 | # ignore blank lines and comments | 376 | # ignore blank lines and comments |
792 | next if (/^\s*$/ || /\s*\#/); | 377 | next if (/^\s*$/ || /\s*\#/); |
793 | 378 | ||
794 | if (/^\s*(TEST_START|DEFAULTS)\b(.*)/) { | 379 | if (/^\s*TEST_START(.*)/) { |
795 | |||
796 | my $type = $1; | ||
797 | $rest = $2; | ||
798 | $line = $2; | ||
799 | 380 | ||
800 | my $old_test_num; | 381 | $rest = $1; |
801 | my $old_repeat; | ||
802 | $override = 0; | ||
803 | |||
804 | if ($type eq "TEST_START") { | ||
805 | 382 | ||
806 | if ($num_tests_set) { | 383 | if ($num_tests_set) { |
807 | die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n"; | 384 | die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n"; |
808 | } | 385 | } |
809 | 386 | ||
810 | $old_test_num = $test_num; | 387 | my $old_test_num = $test_num; |
811 | $old_repeat = $repeat; | 388 | my $old_repeat = $repeat; |
812 | 389 | ||
813 | $test_num += $repeat; | 390 | $test_num += $repeat; |
814 | $default = 0; | 391 | $default = 0; |
815 | $repeat = 1; | 392 | $repeat = 1; |
816 | } else { | ||
817 | $default = 1; | ||
818 | } | ||
819 | 393 | ||
820 | # If SKIP is anywhere in the line, the command will be skipped | 394 | if ($rest =~ /\s+SKIP(.*)/) { |
821 | if ($rest =~ s/\s+SKIP\b//) { | 395 | $rest = $1; |
822 | $skip = 1; | 396 | $skip = 1; |
823 | } else { | 397 | } else { |
824 | $test_case = 1; | 398 | $test_case = 1; |
825 | $skip = 0; | 399 | $skip = 0; |
826 | } | 400 | } |
827 | 401 | ||
828 | if ($rest =~ s/\sELSE\b//) { | 402 | if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) { |
829 | if (!$if) { | 403 | $repeat = $1; |
830 | die "$name: $.: ELSE found with out matching IF section\n$_"; | 404 | $rest = $2; |
831 | } | 405 | $repeat_tests{"$test_num"} = $repeat; |
832 | $if = 0; | ||
833 | |||
834 | if ($if_set) { | ||
835 | $skip = 1; | ||
836 | } else { | ||
837 | $skip = 0; | ||
838 | } | ||
839 | } | ||
840 | |||
841 | if ($rest =~ s/\sIF\s+(.*)//) { | ||
842 | if (process_if($name, $1)) { | ||
843 | $if_set = 1; | ||
844 | } else { | ||
845 | $skip = 1; | ||
846 | } | ||
847 | $if = 1; | ||
848 | } else { | ||
849 | $if = 0; | ||
850 | $if_set = 0; | ||
851 | } | 406 | } |
852 | 407 | ||
853 | if (!$skip) { | 408 | if ($rest =~ /\s+SKIP(.*)/) { |
854 | if ($type eq "TEST_START") { | 409 | $rest = $1; |
855 | if ($rest =~ s/\s+ITERATE\s+(\d+)//) { | 410 | $skip = 1; |
856 | $repeat = $1; | ||
857 | $repeat_tests{"$test_num"} = $repeat; | ||
858 | } | ||
859 | } elsif ($rest =~ s/\sOVERRIDE\b//) { | ||
860 | # DEFAULT only | ||
861 | $override = 1; | ||
862 | # Clear previous overrides | ||
863 | %overrides = (); | ||
864 | } | ||
865 | } | 411 | } |
866 | 412 | ||
867 | if (!$skip && $rest !~ /^\s*$/) { | 413 | if ($rest !~ /^\s*$/) { |
868 | die "$name: $.: Gargbage found after $type\n$_"; | 414 | die "$name: $.: Gargbage found after TEST_START\n$_"; |
869 | } | 415 | } |
870 | 416 | ||
871 | if ($skip && $type eq "TEST_START") { | 417 | if ($skip) { |
872 | $test_num = $old_test_num; | 418 | $test_num = $old_test_num; |
873 | $repeat = $old_repeat; | 419 | $repeat = $old_repeat; |
874 | } | 420 | } |
875 | 421 | ||
876 | } elsif (/^\s*ELSE\b(.*)$/) { | 422 | } elsif (/^\s*DEFAULTS(.*)$/) { |
877 | if (!$if) { | 423 | $default = 1; |
878 | die "$name: $.: ELSE found with out matching IF section\n$_"; | 424 | |
879 | } | ||
880 | $rest = $1; | 425 | $rest = $1; |
881 | if ($if_set) { | 426 | |
427 | if ($rest =~ /\s+SKIP(.*)/) { | ||
428 | $rest = $1; | ||
882 | $skip = 1; | 429 | $skip = 1; |
883 | $rest = ""; | ||
884 | } else { | 430 | } else { |
885 | $skip = 0; | 431 | $skip = 0; |
886 | |||
887 | if ($rest =~ /\sIF\s+(.*)/) { | ||
888 | # May be a ELSE IF section. | ||
889 | if (process_if($name, $1)) { | ||
890 | $if_set = 1; | ||
891 | } else { | ||
892 | $skip = 1; | ||
893 | } | ||
894 | $rest = ""; | ||
895 | } else { | ||
896 | $if = 0; | ||
897 | } | ||
898 | } | 432 | } |
899 | 433 | ||
900 | if ($rest !~ /^\s*$/) { | 434 | if ($rest !~ /^\s*$/) { |
901 | die "$name: $.: Gargbage found after DEFAULTS\n$_"; | 435 | die "$name: $.: Gargbage found after DEFAULTS\n$_"; |
902 | } | 436 | } |
903 | 437 | ||
904 | } elsif (/^\s*INCLUDE\s+(\S+)/) { | ||
905 | |||
906 | next if ($skip); | ||
907 | |||
908 | if (!$default) { | ||
909 | die "$name: $.: INCLUDE can only be done in default sections\n$_"; | ||
910 | } | ||
911 | |||
912 | my $file = process_variables($1); | ||
913 | |||
914 | if ($file !~ m,^/,) { | ||
915 | # check the path of the config file first | ||
916 | if ($config =~ m,(.*)/,) { | ||
917 | if (-f "$1/$file") { | ||
918 | $file = "$1/$file"; | ||
919 | } | ||
920 | } | ||
921 | } | ||
922 | |||
923 | if ( ! -r $file ) { | ||
924 | die "$name: $.: Can't read file $file\n$_"; | ||
925 | } | ||
926 | |||
927 | if (__read_config($file, \$test_num)) { | ||
928 | $test_case = 1; | ||
929 | } | ||
930 | |||
931 | } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) { | 438 | } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) { |
932 | 439 | ||
933 | next if ($skip); | 440 | next if ($skip); |
@@ -953,10 +460,10 @@ sub __read_config { | |||
953 | } | 460 | } |
954 | 461 | ||
955 | if ($default || $lvalue =~ /\[\d+\]$/) { | 462 | if ($default || $lvalue =~ /\[\d+\]$/) { |
956 | set_value($lvalue, $rvalue, $override, \%overrides, $name); | 463 | set_value($lvalue, $rvalue); |
957 | } else { | 464 | } else { |
958 | my $val = "$lvalue\[$test_num\]"; | 465 | my $val = "$lvalue\[$test_num\]"; |
959 | set_value($val, $rvalue, $override, \%overrides, $name); | 466 | set_value($val, $rvalue); |
960 | 467 | ||
961 | if ($repeat > 1) { | 468 | if ($repeat > 1) { |
962 | $repeats{$val} = $repeat; | 469 | $repeats{$val} = $repeat; |
@@ -983,42 +490,23 @@ sub __read_config { | |||
983 | } | 490 | } |
984 | } | 491 | } |
985 | 492 | ||
493 | close(IN); | ||
494 | |||
986 | if ($test_num) { | 495 | if ($test_num) { |
987 | $test_num += $repeat - 1; | 496 | $test_num += $repeat - 1; |
988 | $opt{"NUM_TESTS"} = $test_num; | 497 | $opt{"NUM_TESTS"} = $test_num; |
989 | } | 498 | } |
990 | 499 | ||
991 | close($in); | ||
992 | |||
993 | $$current_test_num = $test_num; | ||
994 | |||
995 | return $test_case; | ||
996 | } | ||
997 | |||
998 | sub get_test_case { | ||
999 | print "What test case would you like to run?\n"; | ||
1000 | print " (build, install or boot)\n"; | ||
1001 | print " Other tests are available but require editing the config file\n"; | ||
1002 | my $ans = <STDIN>; | ||
1003 | chomp $ans; | ||
1004 | $default{"TEST_TYPE"} = $ans; | ||
1005 | } | ||
1006 | |||
1007 | sub read_config { | ||
1008 | my ($config) = @_; | ||
1009 | |||
1010 | my $test_case; | ||
1011 | my $test_num = 0; | ||
1012 | |||
1013 | $test_case = __read_config $config, \$test_num; | ||
1014 | |||
1015 | # make sure we have all mandatory configs | 500 | # make sure we have all mandatory configs |
1016 | get_ktest_configs; | 501 | get_ktest_configs; |
1017 | 502 | ||
1018 | # was a test specified? | 503 | # was a test specified? |
1019 | if (!$test_case) { | 504 | if (!$test_case) { |
1020 | print "No test case specified.\n"; | 505 | print "No test case specified.\n"; |
1021 | get_test_case; | 506 | print "What test case would you like to run?\n"; |
507 | my $ans = <STDIN>; | ||
508 | chomp $ans; | ||
509 | $default{"TEST_TYPE"} = $ans; | ||
1022 | } | 510 | } |
1023 | 511 | ||
1024 | # set any defaults | 512 | # set any defaults |
@@ -1028,37 +516,6 @@ sub read_config { | |||
1028 | $opt{$default} = $default{$default}; | 516 | $opt{$default} = $default{$default}; |
1029 | } | 517 | } |
1030 | } | 518 | } |
1031 | |||
1032 | if ($opt{"IGNORE_UNUSED"} == 1) { | ||
1033 | return; | ||
1034 | } | ||
1035 | |||
1036 | my %not_used; | ||
1037 | |||
1038 | # check if there are any stragglers (typos?) | ||
1039 | foreach my $option (keys %opt) { | ||
1040 | my $op = $option; | ||
1041 | # remove per test labels. | ||
1042 | $op =~ s/\[.*\]//; | ||
1043 | if (!exists($option_map{$op}) && | ||
1044 | !exists($default{$op}) && | ||
1045 | !exists($used_options{$op})) { | ||
1046 | $not_used{$op} = 1; | ||
1047 | } | ||
1048 | } | ||
1049 | |||
1050 | if (%not_used) { | ||
1051 | my $s = "s are"; | ||
1052 | $s = " is" if (keys %not_used == 1); | ||
1053 | print "The following option$s not used; could be a typo:\n"; | ||
1054 | foreach my $option (keys %not_used) { | ||
1055 | print "$option\n"; | ||
1056 | } | ||
1057 | print "Set IGRNORE_UNUSED = 1 to have ktest ignore unused variables\n"; | ||
1058 | if (!read_yn "Do you want to continue?") { | ||
1059 | exit -1; | ||
1060 | } | ||
1061 | } | ||
1062 | } | 519 | } |
1063 | 520 | ||
1064 | sub __eval_option { | 521 | sub __eval_option { |
@@ -1067,18 +524,6 @@ sub __eval_option { | |||
1067 | # Add space to evaluate the character before $ | 524 | # Add space to evaluate the character before $ |
1068 | $option = " $option"; | 525 | $option = " $option"; |
1069 | my $retval = ""; | 526 | my $retval = ""; |
1070 | my $repeated = 0; | ||
1071 | my $parent = 0; | ||
1072 | |||
1073 | foreach my $test (keys %repeat_tests) { | ||
1074 | if ($i >= $test && | ||
1075 | $i < $test + $repeat_tests{$test}) { | ||
1076 | |||
1077 | $repeated = 1; | ||
1078 | $parent = $test; | ||
1079 | last; | ||
1080 | } | ||
1081 | } | ||
1082 | 527 | ||
1083 | while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) { | 528 | while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) { |
1084 | my $start = $1; | 529 | my $start = $1; |
@@ -1092,14 +537,10 @@ sub __eval_option { | |||
1092 | # otherwise see if the default OPT (without [$i]) exists. | 537 | # otherwise see if the default OPT (without [$i]) exists. |
1093 | 538 | ||
1094 | my $o = "$var\[$i\]"; | 539 | my $o = "$var\[$i\]"; |
1095 | my $parento = "$var\[$parent\]"; | ||
1096 | 540 | ||
1097 | if (defined($opt{$o})) { | 541 | if (defined($opt{$o})) { |
1098 | $o = $opt{$o}; | 542 | $o = $opt{$o}; |
1099 | $retval = "$retval$o"; | 543 | $retval = "$retval$o"; |
1100 | } elsif ($repeated && defined($opt{$parento})) { | ||
1101 | $o = $opt{$parento}; | ||
1102 | $retval = "$retval$o"; | ||
1103 | } elsif (defined($opt{$var})) { | 544 | } elsif (defined($opt{$var})) { |
1104 | $o = $opt{$var}; | 545 | $o = $opt{$var}; |
1105 | $retval = "$retval$o"; | 546 | $retval = "$retval$o"; |
@@ -1162,23 +603,8 @@ sub doprint { | |||
1162 | } | 603 | } |
1163 | 604 | ||
1164 | sub run_command; | 605 | sub run_command; |
1165 | sub start_monitor; | ||
1166 | sub end_monitor; | ||
1167 | sub wait_for_monitor; | ||
1168 | 606 | ||
1169 | sub reboot { | 607 | sub reboot { |
1170 | my ($time) = @_; | ||
1171 | |||
1172 | # Make sure everything has been written to disk | ||
1173 | run_ssh("sync"); | ||
1174 | |||
1175 | if (defined($time)) { | ||
1176 | start_monitor; | ||
1177 | # flush out current monitor | ||
1178 | # May contain the reboot success line | ||
1179 | wait_for_monitor 1; | ||
1180 | } | ||
1181 | |||
1182 | # try to reboot normally | 608 | # try to reboot normally |
1183 | if (run_command $reboot) { | 609 | if (run_command $reboot) { |
1184 | if (defined($powercycle_after_reboot)) { | 610 | if (defined($powercycle_after_reboot)) { |
@@ -1189,31 +615,12 @@ sub reboot { | |||
1189 | # nope? power cycle it. | 615 | # nope? power cycle it. |
1190 | run_command "$power_cycle"; | 616 | run_command "$power_cycle"; |
1191 | } | 617 | } |
1192 | |||
1193 | if (defined($time)) { | ||
1194 | if (wait_for_monitor($time, $reboot_success_line)) { | ||
1195 | # reboot got stuck? | ||
1196 | doprint "Reboot did not finish. Forcing power cycle\n"; | ||
1197 | run_command "$power_cycle"; | ||
1198 | } | ||
1199 | end_monitor; | ||
1200 | } | ||
1201 | } | ||
1202 | |||
1203 | sub reboot_to_good { | ||
1204 | my ($time) = @_; | ||
1205 | |||
1206 | if (defined($switch_to_good)) { | ||
1207 | run_command $switch_to_good; | ||
1208 | } | ||
1209 | |||
1210 | reboot $time; | ||
1211 | } | 618 | } |
1212 | 619 | ||
1213 | sub do_not_reboot { | 620 | sub do_not_reboot { |
1214 | my $i = $iteration; | 621 | my $i = $iteration; |
1215 | 622 | ||
1216 | return $test_type eq "build" || $no_reboot || | 623 | return $test_type eq "build" || |
1217 | ($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") || | 624 | ($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") || |
1218 | ($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build"); | 625 | ($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build"); |
1219 | } | 626 | } |
@@ -1226,7 +633,7 @@ sub dodie { | |||
1226 | if ($reboot_on_error && !do_not_reboot) { | 633 | if ($reboot_on_error && !do_not_reboot) { |
1227 | 634 | ||
1228 | doprint "REBOOTING\n"; | 635 | doprint "REBOOTING\n"; |
1229 | reboot_to_good; | 636 | reboot; |
1230 | 637 | ||
1231 | } elsif ($poweroff_on_error && defined($power_off)) { | 638 | } elsif ($poweroff_on_error && defined($power_off)) { |
1232 | doprint "POWERING OFF\n"; | 639 | doprint "POWERING OFF\n"; |
@@ -1286,108 +693,21 @@ sub end_monitor { | |||
1286 | } | 693 | } |
1287 | 694 | ||
1288 | sub wait_for_monitor { | 695 | sub wait_for_monitor { |
1289 | my ($time, $stop) = @_; | 696 | my ($time) = @_; |
1290 | my $full_line = ""; | ||
1291 | my $line; | 697 | my $line; |
1292 | my $booted = 0; | ||
1293 | my $start_time = time; | ||
1294 | my $skip_call_trace = 0; | ||
1295 | my $bug = 0; | ||
1296 | my $bug_ignored = 0; | ||
1297 | my $now; | ||
1298 | 698 | ||
1299 | doprint "** Wait for monitor to settle down **\n"; | 699 | doprint "** Wait for monitor to settle down **\n"; |
1300 | 700 | ||
1301 | # read the monitor and wait for the system to calm down | 701 | # read the monitor and wait for the system to calm down |
1302 | while (!$booted) { | 702 | do { |
1303 | $line = wait_for_input($monitor_fp, $time); | 703 | $line = wait_for_input($monitor_fp, $time); |
1304 | last if (!defined($line)); | 704 | print "$line" if (defined($line)); |
1305 | print "$line"; | 705 | } while (defined($line)); |
1306 | $full_line .= $line; | ||
1307 | |||
1308 | if (defined($stop) && $full_line =~ /$stop/) { | ||
1309 | doprint "wait for monitor detected $stop\n"; | ||
1310 | $booted = 1; | ||
1311 | } | ||
1312 | |||
1313 | if ($full_line =~ /\[ backtrace testing \]/) { | ||
1314 | $skip_call_trace = 1; | ||
1315 | } | ||
1316 | |||
1317 | if ($full_line =~ /call trace:/i) { | ||
1318 | if (!$bug && !$skip_call_trace) { | ||
1319 | if ($ignore_errors) { | ||
1320 | $bug_ignored = 1; | ||
1321 | } else { | ||
1322 | $bug = 1; | ||
1323 | } | ||
1324 | } | ||
1325 | } | ||
1326 | |||
1327 | if ($full_line =~ /\[ end of backtrace testing \]/) { | ||
1328 | $skip_call_trace = 0; | ||
1329 | } | ||
1330 | |||
1331 | if ($full_line =~ /Kernel panic -/) { | ||
1332 | $bug = 1; | ||
1333 | } | ||
1334 | |||
1335 | if ($line =~ /\n/) { | ||
1336 | $full_line = ""; | ||
1337 | } | ||
1338 | $now = time; | ||
1339 | if ($now - $start_time >= $max_monitor_wait) { | ||
1340 | doprint "Exiting monitor flush due to hitting MAX_MONITOR_WAIT\n"; | ||
1341 | return 1; | ||
1342 | } | ||
1343 | } | ||
1344 | print "** Monitor flushed **\n"; | 706 | print "** Monitor flushed **\n"; |
1345 | return $bug; | ||
1346 | } | ||
1347 | |||
1348 | sub save_logs { | ||
1349 | my ($result, $basedir) = @_; | ||
1350 | my @t = localtime; | ||
1351 | my $date = sprintf "%04d%02d%02d%02d%02d%02d", | ||
1352 | 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0]; | ||
1353 | |||
1354 | my $type = $build_type; | ||
1355 | if ($type =~ /useconfig/) { | ||
1356 | $type = "useconfig"; | ||
1357 | } | ||
1358 | |||
1359 | my $dir = "$machine-$test_type-$type-$result-$date"; | ||
1360 | |||
1361 | $dir = "$basedir/$dir"; | ||
1362 | |||
1363 | if (!-d $dir) { | ||
1364 | mkpath($dir) or | ||
1365 | die "can't create $dir"; | ||
1366 | } | ||
1367 | |||
1368 | my %files = ( | ||
1369 | "config" => $output_config, | ||
1370 | "buildlog" => $buildlog, | ||
1371 | "dmesg" => $dmesg, | ||
1372 | "testlog" => $testlog, | ||
1373 | ); | ||
1374 | |||
1375 | while (my ($name, $source) = each(%files)) { | ||
1376 | if (-f "$source") { | ||
1377 | cp "$source", "$dir/$name" or | ||
1378 | die "failed to copy $source"; | ||
1379 | } | ||
1380 | } | ||
1381 | |||
1382 | doprint "*** Saved info to $dir ***\n"; | ||
1383 | } | 707 | } |
1384 | 708 | ||
1385 | sub fail { | 709 | sub fail { |
1386 | 710 | ||
1387 | if (defined($post_test)) { | ||
1388 | run_command $post_test; | ||
1389 | } | ||
1390 | |||
1391 | if ($die_on_failure) { | 711 | if ($die_on_failure) { |
1392 | dodie @_; | 712 | dodie @_; |
1393 | } | 713 | } |
@@ -1399,7 +719,10 @@ sub fail { | |||
1399 | # no need to reboot for just building. | 719 | # no need to reboot for just building. |
1400 | if (!do_not_reboot) { | 720 | if (!do_not_reboot) { |
1401 | doprint "REBOOTING\n"; | 721 | doprint "REBOOTING\n"; |
1402 | reboot_to_good $sleep_time; | 722 | reboot; |
723 | start_monitor; | ||
724 | wait_for_monitor $sleep_time; | ||
725 | end_monitor; | ||
1403 | } | 726 | } |
1404 | 727 | ||
1405 | my $name = ""; | 728 | my $name = ""; |
@@ -1414,9 +737,38 @@ sub fail { | |||
1414 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; | 737 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; |
1415 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; | 738 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; |
1416 | 739 | ||
1417 | if (defined($store_failures)) { | 740 | return 1 if (!defined($store_failures)); |
1418 | save_logs "fail", $store_failures; | 741 | |
1419 | } | 742 | my @t = localtime; |
743 | my $date = sprintf "%04d%02d%02d%02d%02d%02d", | ||
744 | 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0]; | ||
745 | |||
746 | my $type = $build_type; | ||
747 | if ($type =~ /useconfig/) { | ||
748 | $type = "useconfig"; | ||
749 | } | ||
750 | |||
751 | my $dir = "$machine-$test_type-$type-fail-$date"; | ||
752 | my $faildir = "$store_failures/$dir"; | ||
753 | |||
754 | if (!-d $faildir) { | ||
755 | mkpath($faildir) or | ||
756 | die "can't create $faildir"; | ||
757 | } | ||
758 | if (-f "$output_config") { | ||
759 | cp "$output_config", "$faildir/config" or | ||
760 | die "failed to copy .config"; | ||
761 | } | ||
762 | if (-f $buildlog) { | ||
763 | cp $buildlog, "$faildir/buildlog" or | ||
764 | die "failed to move $buildlog"; | ||
765 | } | ||
766 | if (-f $dmesg) { | ||
767 | cp $dmesg, "$faildir/dmesg" or | ||
768 | die "failed to move $dmesg"; | ||
769 | } | ||
770 | |||
771 | doprint "*** Saved info to $faildir ***\n"; | ||
1420 | 772 | ||
1421 | return 1; | 773 | return 1; |
1422 | } | 774 | } |
@@ -1477,7 +829,8 @@ sub run_ssh { | |||
1477 | } | 829 | } |
1478 | 830 | ||
1479 | sub run_scp { | 831 | sub run_scp { |
1480 | my ($src, $dst, $cp_scp) = @_; | 832 | my ($src, $dst) = @_; |
833 | my $cp_scp = $scp_to_target; | ||
1481 | 834 | ||
1482 | $cp_scp =~ s/\$SRC_FILE/$src/g; | 835 | $cp_scp =~ s/\$SRC_FILE/$src/g; |
1483 | $cp_scp =~ s/\$DST_FILE/$dst/g; | 836 | $cp_scp =~ s/\$DST_FILE/$dst/g; |
@@ -1485,60 +838,8 @@ sub run_scp { | |||
1485 | return run_command "$cp_scp"; | 838 | return run_command "$cp_scp"; |
1486 | } | 839 | } |
1487 | 840 | ||
1488 | sub run_scp_install { | ||
1489 | my ($src, $dst) = @_; | ||
1490 | |||
1491 | my $cp_scp = $scp_to_target_install; | ||
1492 | |||
1493 | return run_scp($src, $dst, $cp_scp); | ||
1494 | } | ||
1495 | |||
1496 | sub run_scp_mod { | ||
1497 | my ($src, $dst) = @_; | ||
1498 | |||
1499 | my $cp_scp = $scp_to_target; | ||
1500 | |||
1501 | return run_scp($src, $dst, $cp_scp); | ||
1502 | } | ||
1503 | |||
1504 | sub get_grub2_index { | ||
1505 | |||
1506 | return if (defined($grub_number)); | ||
1507 | |||
1508 | doprint "Find grub2 menu ... "; | ||
1509 | $grub_number = -1; | ||
1510 | |||
1511 | my $ssh_grub = $ssh_exec; | ||
1512 | $ssh_grub =~ s,\$SSH_COMMAND,cat $grub_file,g; | ||
1513 | |||
1514 | open(IN, "$ssh_grub |") | ||
1515 | or die "unable to get $grub_file"; | ||
1516 | |||
1517 | my $found = 0; | ||
1518 | |||
1519 | while (<IN>) { | ||
1520 | if (/^menuentry.*$grub_menu/) { | ||
1521 | $grub_number++; | ||
1522 | $found = 1; | ||
1523 | last; | ||
1524 | } elsif (/^menuentry\s/) { | ||
1525 | $grub_number++; | ||
1526 | } | ||
1527 | } | ||
1528 | close(IN); | ||
1529 | |||
1530 | die "Could not find '$grub_menu' in $grub_file on $machine" | ||
1531 | if (!$found); | ||
1532 | doprint "$grub_number\n"; | ||
1533 | } | ||
1534 | |||
1535 | sub get_grub_index { | 841 | sub get_grub_index { |
1536 | 842 | ||
1537 | if ($reboot_type eq "grub2") { | ||
1538 | get_grub2_index; | ||
1539 | return; | ||
1540 | } | ||
1541 | |||
1542 | if ($reboot_type ne "grub") { | 843 | if ($reboot_type ne "grub") { |
1543 | return; | 844 | return; |
1544 | } | 845 | } |
@@ -1553,12 +854,9 @@ sub get_grub_index { | |||
1553 | open(IN, "$ssh_grub |") | 854 | open(IN, "$ssh_grub |") |
1554 | or die "unable to get menu.lst"; | 855 | or die "unable to get menu.lst"; |
1555 | 856 | ||
1556 | my $found = 0; | ||
1557 | |||
1558 | while (<IN>) { | 857 | while (<IN>) { |
1559 | if (/^\s*title\s+$grub_menu\s*$/) { | 858 | if (/^\s*title\s+$grub_menu\s*$/) { |
1560 | $grub_number++; | 859 | $grub_number++; |
1561 | $found = 1; | ||
1562 | last; | 860 | last; |
1563 | } elsif (/^\s*title\s/) { | 861 | } elsif (/^\s*title\s/) { |
1564 | $grub_number++; | 862 | $grub_number++; |
@@ -1567,7 +865,7 @@ sub get_grub_index { | |||
1567 | close(IN); | 865 | close(IN); |
1568 | 866 | ||
1569 | die "Could not find '$grub_menu' in /boot/grub/menu on $machine" | 867 | die "Could not find '$grub_menu' in /boot/grub/menu on $machine" |
1570 | if (!$found); | 868 | if ($grub_number < 0); |
1571 | doprint "$grub_number\n"; | 869 | doprint "$grub_number\n"; |
1572 | } | 870 | } |
1573 | 871 | ||
@@ -1603,20 +901,12 @@ sub wait_for_input | |||
1603 | } | 901 | } |
1604 | 902 | ||
1605 | sub reboot_to { | 903 | sub reboot_to { |
1606 | if (defined($switch_to_test)) { | ||
1607 | run_command $switch_to_test; | ||
1608 | } | ||
1609 | |||
1610 | if ($reboot_type eq "grub") { | 904 | if ($reboot_type eq "grub") { |
1611 | run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; | 905 | run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch && reboot)'"; |
1612 | } elsif ($reboot_type eq "grub2") { | 906 | return; |
1613 | run_ssh "$grub_reboot $grub_number"; | ||
1614 | } elsif ($reboot_type eq "syslinux") { | ||
1615 | run_ssh "$syslinux --once \\\"$syslinux_label\\\" $syslinux_path"; | ||
1616 | } elsif (defined $reboot_script) { | ||
1617 | run_command "$reboot_script"; | ||
1618 | } | 907 | } |
1619 | reboot; | 908 | |
909 | run_command "$reboot_script"; | ||
1620 | } | 910 | } |
1621 | 911 | ||
1622 | sub get_sha1 { | 912 | sub get_sha1 { |
@@ -1643,7 +933,6 @@ sub get_sha1 { | |||
1643 | sub monitor { | 933 | sub monitor { |
1644 | my $booted = 0; | 934 | my $booted = 0; |
1645 | my $bug = 0; | 935 | my $bug = 0; |
1646 | my $bug_ignored = 0; | ||
1647 | my $skip_call_trace = 0; | 936 | my $skip_call_trace = 0; |
1648 | my $loops; | 937 | my $loops; |
1649 | 938 | ||
@@ -1716,12 +1005,8 @@ sub monitor { | |||
1716 | 1005 | ||
1717 | if ($full_line =~ /call trace:/i) { | 1006 | if ($full_line =~ /call trace:/i) { |
1718 | if (!$bug && !$skip_call_trace) { | 1007 | if (!$bug && !$skip_call_trace) { |
1719 | if ($ignore_errors) { | 1008 | $bug = 1; |
1720 | $bug_ignored = 1; | 1009 | $failure_start = time; |
1721 | } else { | ||
1722 | $bug = 1; | ||
1723 | $failure_start = time; | ||
1724 | } | ||
1725 | } | 1010 | } |
1726 | } | 1011 | } |
1727 | 1012 | ||
@@ -1783,53 +1068,22 @@ sub monitor { | |||
1783 | fail "failed - never got a boot prompt." and return 0; | 1068 | fail "failed - never got a boot prompt." and return 0; |
1784 | } | 1069 | } |
1785 | 1070 | ||
1786 | if ($bug_ignored) { | ||
1787 | doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n"; | ||
1788 | } | ||
1789 | |||
1790 | return 1; | 1071 | return 1; |
1791 | } | 1072 | } |
1792 | 1073 | ||
1793 | sub eval_kernel_version { | ||
1794 | my ($option) = @_; | ||
1795 | |||
1796 | $option =~ s/\$KERNEL_VERSION/$version/g; | ||
1797 | |||
1798 | return $option; | ||
1799 | } | ||
1800 | |||
1801 | sub do_post_install { | 1074 | sub do_post_install { |
1802 | 1075 | ||
1803 | return if (!defined($post_install)); | 1076 | return if (!defined($post_install)); |
1804 | 1077 | ||
1805 | my $cp_post_install = eval_kernel_version $post_install; | 1078 | my $cp_post_install = $post_install; |
1079 | $cp_post_install =~ s/\$KERNEL_VERSION/$version/g; | ||
1806 | run_command "$cp_post_install" or | 1080 | run_command "$cp_post_install" or |
1807 | dodie "Failed to run post install"; | 1081 | dodie "Failed to run post install"; |
1808 | } | 1082 | } |
1809 | 1083 | ||
1810 | # Sometimes the reboot fails, and will hang. We try to ssh to the box | ||
1811 | # and if we fail, we force another reboot, that should powercycle it. | ||
1812 | sub test_booted { | ||
1813 | if (!run_ssh "echo testing connection") { | ||
1814 | reboot $sleep_time; | ||
1815 | } | ||
1816 | } | ||
1817 | |||
1818 | sub install { | 1084 | sub install { |
1819 | 1085 | ||
1820 | return if ($no_install); | 1086 | run_scp "$outputdir/$build_target", "$target_image" or |
1821 | |||
1822 | if (defined($pre_install)) { | ||
1823 | my $cp_pre_install = eval_kernel_version $pre_install; | ||
1824 | run_command "$cp_pre_install" or | ||
1825 | dodie "Failed to run pre install"; | ||
1826 | } | ||
1827 | |||
1828 | my $cp_target = eval_kernel_version $target_image; | ||
1829 | |||
1830 | test_booted; | ||
1831 | |||
1832 | run_scp_install "$outputdir/$build_target", "$cp_target" or | ||
1833 | dodie "failed to copy image"; | 1087 | dodie "failed to copy image"; |
1834 | 1088 | ||
1835 | my $install_mods = 0; | 1089 | my $install_mods = 0; |
@@ -1839,10 +1093,8 @@ sub install { | |||
1839 | open(IN, "$output_config") or dodie("Can't read config file"); | 1093 | open(IN, "$output_config") or dodie("Can't read config file"); |
1840 | while (<IN>) { | 1094 | while (<IN>) { |
1841 | if (/CONFIG_MODULES(=y)?/) { | 1095 | if (/CONFIG_MODULES(=y)?/) { |
1842 | if (defined($1)) { | 1096 | $install_mods = 1 if (defined($1)); |
1843 | $install_mods = 1; | 1097 | last; |
1844 | last; | ||
1845 | } | ||
1846 | } | 1098 | } |
1847 | } | 1099 | } |
1848 | close(IN); | 1100 | close(IN); |
@@ -1853,7 +1105,7 @@ sub install { | |||
1853 | return; | 1105 | return; |
1854 | } | 1106 | } |
1855 | 1107 | ||
1856 | run_command "$make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$tmpdir modules_install" or | 1108 | run_command "$make INSTALL_MOD_PATH=$tmpdir modules_install" or |
1857 | dodie "Failed to install modules"; | 1109 | dodie "Failed to install modules"; |
1858 | 1110 | ||
1859 | my $modlib = "/lib/modules/$version"; | 1111 | my $modlib = "/lib/modules/$version"; |
@@ -1866,7 +1118,7 @@ sub install { | |||
1866 | run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or | 1118 | run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or |
1867 | dodie "making tarball"; | 1119 | dodie "making tarball"; |
1868 | 1120 | ||
1869 | run_scp_mod "$tmpdir/$modtar", "/tmp" or | 1121 | run_scp "$tmpdir/$modtar", "/tmp" or |
1870 | dodie "failed to copy modules"; | 1122 | dodie "failed to copy modules"; |
1871 | 1123 | ||
1872 | unlink "$tmpdir/$modtar"; | 1124 | unlink "$tmpdir/$modtar"; |
@@ -1881,20 +1133,13 @@ sub install { | |||
1881 | 1133 | ||
1882 | sub get_version { | 1134 | sub get_version { |
1883 | # get the release name | 1135 | # get the release name |
1884 | return if ($have_version); | ||
1885 | doprint "$make kernelrelease ... "; | 1136 | doprint "$make kernelrelease ... "; |
1886 | $version = `$make kernelrelease | tail -1`; | 1137 | $version = `$make kernelrelease | tail -1`; |
1887 | chomp($version); | 1138 | chomp($version); |
1888 | doprint "$version\n"; | 1139 | doprint "$version\n"; |
1889 | $have_version = 1; | ||
1890 | } | 1140 | } |
1891 | 1141 | ||
1892 | sub start_monitor_and_boot { | 1142 | sub start_monitor_and_boot { |
1893 | # Make sure the stable kernel has finished booting | ||
1894 | start_monitor; | ||
1895 | wait_for_monitor 5; | ||
1896 | end_monitor; | ||
1897 | |||
1898 | get_grub_index; | 1143 | get_grub_index; |
1899 | get_version; | 1144 | get_version; |
1900 | install; | 1145 | install; |
@@ -1974,16 +1219,12 @@ sub make_oldconfig { | |||
1974 | apply_min_config; | 1219 | apply_min_config; |
1975 | } | 1220 | } |
1976 | 1221 | ||
1977 | if (!run_command "$make olddefconfig") { | 1222 | if (!run_command "$make oldnoconfig") { |
1978 | # Perhaps olddefconfig doesn't exist in this version of the kernel | 1223 | # Perhaps oldnoconfig doesn't exist in this version of the kernel |
1979 | # try oldnoconfig | 1224 | # try a yes '' | oldconfig |
1980 | doprint "olddefconfig failed, trying make oldnoconfig\n"; | 1225 | doprint "oldnoconfig failed, trying yes '' | make oldconfig\n"; |
1981 | if (!run_command "$make oldnoconfig") { | 1226 | run_command "yes '' | $make oldconfig" or |
1982 | doprint "oldnoconfig failed, trying yes '' | make oldconfig\n"; | 1227 | dodie "failed make config oldconfig"; |
1983 | # try a yes '' | oldconfig | ||
1984 | run_command "yes '' | $make oldconfig" or | ||
1985 | dodie "failed make config oldconfig"; | ||
1986 | } | ||
1987 | } | 1228 | } |
1988 | } | 1229 | } |
1989 | 1230 | ||
@@ -1991,7 +1232,6 @@ sub make_oldconfig { | |||
1991 | sub load_force_config { | 1232 | sub load_force_config { |
1992 | my ($config) = @_; | 1233 | my ($config) = @_; |
1993 | 1234 | ||
1994 | doprint "Loading force configs from $config\n"; | ||
1995 | open(IN, $config) or | 1235 | open(IN, $config) or |
1996 | dodie "failed to read $config"; | 1236 | dodie "failed to read $config"; |
1997 | while (<IN>) { | 1237 | while (<IN>) { |
@@ -2010,13 +1250,6 @@ sub build { | |||
2010 | 1250 | ||
2011 | unlink $buildlog; | 1251 | unlink $buildlog; |
2012 | 1252 | ||
2013 | # Failed builds should not reboot the target | ||
2014 | my $save_no_reboot = $no_reboot; | ||
2015 | $no_reboot = 1; | ||
2016 | |||
2017 | # Calculate a new version from here. | ||
2018 | $have_version = 0; | ||
2019 | |||
2020 | if (defined($pre_build)) { | 1253 | if (defined($pre_build)) { |
2021 | my $ret = run_command $pre_build; | 1254 | my $ret = run_command $pre_build; |
2022 | if (!$ret && defined($pre_build_die) && | 1255 | if (!$ret && defined($pre_build_die) && |
@@ -2034,21 +1267,21 @@ sub build { | |||
2034 | 1267 | ||
2035 | # old config can ask questions | 1268 | # old config can ask questions |
2036 | if ($type eq "oldconfig") { | 1269 | if ($type eq "oldconfig") { |
2037 | $type = "olddefconfig"; | 1270 | $type = "oldnoconfig"; |
2038 | 1271 | ||
2039 | # allow for empty configs | 1272 | # allow for empty configs |
2040 | run_command "touch $output_config"; | 1273 | run_command "touch $output_config"; |
2041 | 1274 | ||
2042 | if (!$noclean) { | 1275 | run_command "mv $output_config $outputdir/config_temp" or |
2043 | run_command "mv $output_config $outputdir/config_temp" or | 1276 | dodie "moving .config"; |
2044 | dodie "moving .config"; | ||
2045 | |||
2046 | run_command "$make mrproper" or dodie "make mrproper"; | ||
2047 | 1277 | ||
2048 | run_command "mv $outputdir/config_temp $output_config" or | 1278 | if (!$noclean && !run_command "$make mrproper") { |
2049 | dodie "moving config_temp"; | 1279 | dodie "make mrproper"; |
2050 | } | 1280 | } |
2051 | 1281 | ||
1282 | run_command "mv $outputdir/config_temp $output_config" or | ||
1283 | dodie "moving config_temp"; | ||
1284 | |||
2052 | } elsif (!$noclean) { | 1285 | } elsif (!$noclean) { |
2053 | unlink "$output_config"; | 1286 | unlink "$output_config"; |
2054 | run_command "$make mrproper" or | 1287 | run_command "$make mrproper" or |
@@ -2064,7 +1297,7 @@ sub build { | |||
2064 | load_force_config($minconfig); | 1297 | load_force_config($minconfig); |
2065 | } | 1298 | } |
2066 | 1299 | ||
2067 | if ($type ne "olddefconfig") { | 1300 | if ($type ne "oldnoconfig") { |
2068 | run_command "$make $type" or | 1301 | run_command "$make $type" or |
2069 | dodie "failed make config"; | 1302 | dodie "failed make config"; |
2070 | } | 1303 | } |
@@ -2076,9 +1309,6 @@ sub build { | |||
2076 | undef $redirect; | 1309 | undef $redirect; |
2077 | 1310 | ||
2078 | if (defined($post_build)) { | 1311 | if (defined($post_build)) { |
2079 | # Because a post build may change the kernel version | ||
2080 | # do it now. | ||
2081 | get_version; | ||
2082 | my $ret = run_command $post_build; | 1312 | my $ret = run_command $post_build; |
2083 | if (!$ret && defined($post_build_die) && | 1313 | if (!$ret && defined($post_build_die) && |
2084 | $post_build_die) { | 1314 | $post_build_die) { |
@@ -2088,15 +1318,10 @@ sub build { | |||
2088 | 1318 | ||
2089 | if (!$build_ret) { | 1319 | if (!$build_ret) { |
2090 | # bisect may need this to pass | 1320 | # bisect may need this to pass |
2091 | if ($in_bisect) { | 1321 | return 0 if ($in_bisect); |
2092 | $no_reboot = $save_no_reboot; | ||
2093 | return 0; | ||
2094 | } | ||
2095 | fail "failed build" and return 0; | 1322 | fail "failed build" and return 0; |
2096 | } | 1323 | } |
2097 | 1324 | ||
2098 | $no_reboot = $save_no_reboot; | ||
2099 | |||
2100 | return 1; | 1325 | return 1; |
2101 | } | 1326 | } |
2102 | 1327 | ||
@@ -2115,10 +1340,6 @@ sub halt { | |||
2115 | sub success { | 1340 | sub success { |
2116 | my ($i) = @_; | 1341 | my ($i) = @_; |
2117 | 1342 | ||
2118 | if (defined($post_test)) { | ||
2119 | run_command $post_test; | ||
2120 | } | ||
2121 | |||
2122 | $successes++; | 1343 | $successes++; |
2123 | 1344 | ||
2124 | my $name = ""; | 1345 | my $name = ""; |
@@ -2133,13 +1354,12 @@ sub success { | |||
2133 | doprint "*******************************************\n"; | 1354 | doprint "*******************************************\n"; |
2134 | doprint "*******************************************\n"; | 1355 | doprint "*******************************************\n"; |
2135 | 1356 | ||
2136 | if (defined($store_successes)) { | ||
2137 | save_logs "success", $store_successes; | ||
2138 | } | ||
2139 | |||
2140 | if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) { | 1357 | if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) { |
2141 | doprint "Reboot and wait $sleep_time seconds\n"; | 1358 | doprint "Reboot and wait $sleep_time seconds\n"; |
2142 | reboot_to_good $sleep_time; | 1359 | reboot; |
1360 | start_monitor; | ||
1361 | wait_for_monitor $sleep_time; | ||
1362 | end_monitor; | ||
2143 | } | 1363 | } |
2144 | } | 1364 | } |
2145 | 1365 | ||
@@ -2166,10 +1386,7 @@ sub child_run_test { | |||
2166 | $poweroff_on_error = 0; | 1386 | $poweroff_on_error = 0; |
2167 | $die_on_failure = 1; | 1387 | $die_on_failure = 1; |
2168 | 1388 | ||
2169 | $redirect = "$testlog"; | ||
2170 | run_command $run_test or $failed = 1; | 1389 | run_command $run_test or $failed = 1; |
2171 | undef $redirect; | ||
2172 | |||
2173 | exit $failed; | 1390 | exit $failed; |
2174 | } | 1391 | } |
2175 | 1392 | ||
@@ -2185,7 +1402,6 @@ sub do_run_test { | |||
2185 | my $line; | 1402 | my $line; |
2186 | my $full_line; | 1403 | my $full_line; |
2187 | my $bug = 0; | 1404 | my $bug = 0; |
2188 | my $bug_ignored = 0; | ||
2189 | 1405 | ||
2190 | wait_for_monitor 1; | 1406 | wait_for_monitor 1; |
2191 | 1407 | ||
@@ -2210,11 +1426,7 @@ sub do_run_test { | |||
2210 | doprint $line; | 1426 | doprint $line; |
2211 | 1427 | ||
2212 | if ($full_line =~ /call trace:/i) { | 1428 | if ($full_line =~ /call trace:/i) { |
2213 | if ($ignore_errors) { | 1429 | $bug = 1; |
2214 | $bug_ignored = 1; | ||
2215 | } else { | ||
2216 | $bug = 1; | ||
2217 | } | ||
2218 | } | 1430 | } |
2219 | 1431 | ||
2220 | if ($full_line =~ /Kernel panic -/) { | 1432 | if ($full_line =~ /Kernel panic -/) { |
@@ -2227,10 +1439,6 @@ sub do_run_test { | |||
2227 | } | 1439 | } |
2228 | } while (!$child_done && !$bug); | 1440 | } while (!$child_done && !$bug); |
2229 | 1441 | ||
2230 | if (!$bug && $bug_ignored) { | ||
2231 | doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n"; | ||
2232 | } | ||
2233 | |||
2234 | if ($bug) { | 1442 | if ($bug) { |
2235 | my $failure_start = time; | 1443 | my $failure_start = time; |
2236 | my $now; | 1444 | my $now; |
@@ -2253,43 +1461,6 @@ sub do_run_test { | |||
2253 | waitpid $child_pid, 0; | 1461 | waitpid $child_pid, 0; |
2254 | $child_exit = $?; | 1462 | $child_exit = $?; |
2255 | 1463 | ||
2256 | if (!$bug && $in_bisect) { | ||
2257 | if (defined($bisect_ret_good)) { | ||
2258 | if ($child_exit == $bisect_ret_good) { | ||
2259 | return 1; | ||
2260 | } | ||
2261 | } | ||
2262 | if (defined($bisect_ret_skip)) { | ||
2263 | if ($child_exit == $bisect_ret_skip) { | ||
2264 | return -1; | ||
2265 | } | ||
2266 | } | ||
2267 | if (defined($bisect_ret_abort)) { | ||
2268 | if ($child_exit == $bisect_ret_abort) { | ||
2269 | fail "test abort" and return -2; | ||
2270 | } | ||
2271 | } | ||
2272 | if (defined($bisect_ret_bad)) { | ||
2273 | if ($child_exit == $bisect_ret_skip) { | ||
2274 | return 0; | ||
2275 | } | ||
2276 | } | ||
2277 | if (defined($bisect_ret_default)) { | ||
2278 | if ($bisect_ret_default eq "good") { | ||
2279 | return 1; | ||
2280 | } elsif ($bisect_ret_default eq "bad") { | ||
2281 | return 0; | ||
2282 | } elsif ($bisect_ret_default eq "skip") { | ||
2283 | return -1; | ||
2284 | } elsif ($bisect_ret_default eq "abort") { | ||
2285 | return -2; | ||
2286 | } else { | ||
2287 | fail "unknown default action: $bisect_ret_default" | ||
2288 | and return -2; | ||
2289 | } | ||
2290 | } | ||
2291 | } | ||
2292 | |||
2293 | if ($bug || $child_exit) { | 1464 | if ($bug || $child_exit) { |
2294 | return 0 if $in_bisect; | 1465 | return 0 if $in_bisect; |
2295 | fail "test failed" and return 0; | 1466 | fail "test failed" and return 0; |
@@ -2316,7 +1487,7 @@ sub run_git_bisect { | |||
2316 | if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) { | 1487 | if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) { |
2317 | doprint "$1 [$2]\n"; | 1488 | doprint "$1 [$2]\n"; |
2318 | } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) { | 1489 | } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) { |
2319 | $bisect_bad_commit = $1; | 1490 | $bisect_bad = $1; |
2320 | doprint "Found bad commit... $1\n"; | 1491 | doprint "Found bad commit... $1\n"; |
2321 | return 0; | 1492 | return 0; |
2322 | } else { | 1493 | } else { |
@@ -2329,7 +1500,10 @@ sub run_git_bisect { | |||
2329 | 1500 | ||
2330 | sub bisect_reboot { | 1501 | sub bisect_reboot { |
2331 | doprint "Reboot and sleep $bisect_sleep_time seconds\n"; | 1502 | doprint "Reboot and sleep $bisect_sleep_time seconds\n"; |
2332 | reboot_to_good $bisect_sleep_time; | 1503 | reboot; |
1504 | start_monitor; | ||
1505 | wait_for_monitor $bisect_sleep_time; | ||
1506 | end_monitor; | ||
2333 | } | 1507 | } |
2334 | 1508 | ||
2335 | # returns 1 on success, 0 on failure, -1 on skip | 1509 | # returns 1 on success, 0 on failure, -1 on skip |
@@ -2400,7 +1574,7 @@ sub run_bisect { | |||
2400 | } | 1574 | } |
2401 | 1575 | ||
2402 | # Are we looking for where it worked, not failed? | 1576 | # Are we looking for where it worked, not failed? |
2403 | if ($reverse_bisect && $ret >= 0) { | 1577 | if ($reverse_bisect) { |
2404 | $ret = !$ret; | 1578 | $ret = !$ret; |
2405 | } | 1579 | } |
2406 | 1580 | ||
@@ -2414,28 +1588,21 @@ sub run_bisect { | |||
2414 | } | 1588 | } |
2415 | } | 1589 | } |
2416 | 1590 | ||
2417 | sub update_bisect_replay { | ||
2418 | my $tmp_log = "$tmpdir/ktest_bisect_log"; | ||
2419 | run_command "git bisect log > $tmp_log" or | ||
2420 | die "can't create bisect log"; | ||
2421 | return $tmp_log; | ||
2422 | } | ||
2423 | |||
2424 | sub bisect { | 1591 | sub bisect { |
2425 | my ($i) = @_; | 1592 | my ($i) = @_; |
2426 | 1593 | ||
2427 | my $result; | 1594 | my $result; |
2428 | 1595 | ||
2429 | die "BISECT_GOOD[$i] not defined\n" if (!defined($bisect_good)); | 1596 | die "BISECT_GOOD[$i] not defined\n" if (!defined($opt{"BISECT_GOOD[$i]"})); |
2430 | die "BISECT_BAD[$i] not defined\n" if (!defined($bisect_bad)); | 1597 | die "BISECT_BAD[$i] not defined\n" if (!defined($opt{"BISECT_BAD[$i]"})); |
2431 | die "BISECT_TYPE[$i] not defined\n" if (!defined($bisect_type)); | 1598 | die "BISECT_TYPE[$i] not defined\n" if (!defined($opt{"BISECT_TYPE[$i]"})); |
2432 | 1599 | ||
2433 | my $good = $bisect_good; | 1600 | my $good = $opt{"BISECT_GOOD[$i]"}; |
2434 | my $bad = $bisect_bad; | 1601 | my $bad = $opt{"BISECT_BAD[$i]"}; |
2435 | my $type = $bisect_type; | 1602 | my $type = $opt{"BISECT_TYPE[$i]"}; |
2436 | my $start = $bisect_start; | 1603 | my $start = $opt{"BISECT_START[$i]"}; |
2437 | my $replay = $bisect_replay; | 1604 | my $replay = $opt{"BISECT_REPLAY[$i]"}; |
2438 | my $start_files = $bisect_files; | 1605 | my $start_files = $opt{"BISECT_FILES[$i]"}; |
2439 | 1606 | ||
2440 | if (defined($start_files)) { | 1607 | if (defined($start_files)) { |
2441 | $start_files = " -- " . $start_files; | 1608 | $start_files = " -- " . $start_files; |
@@ -2447,7 +1614,8 @@ sub bisect { | |||
2447 | $good = get_sha1($good); | 1614 | $good = get_sha1($good); |
2448 | $bad = get_sha1($bad); | 1615 | $bad = get_sha1($bad); |
2449 | 1616 | ||
2450 | if (defined($bisect_reverse) && $bisect_reverse == 1) { | 1617 | if (defined($opt{"BISECT_REVERSE[$i]"}) && |
1618 | $opt{"BISECT_REVERSE[$i]"} == 1) { | ||
2451 | doprint "Performing a reverse bisect (bad is good, good is bad!)\n"; | 1619 | doprint "Performing a reverse bisect (bad is good, good is bad!)\n"; |
2452 | $reverse_bisect = 1; | 1620 | $reverse_bisect = 1; |
2453 | } else { | 1621 | } else { |
@@ -2459,31 +1627,8 @@ sub bisect { | |||
2459 | $type = "boot"; | 1627 | $type = "boot"; |
2460 | } | 1628 | } |
2461 | 1629 | ||
2462 | # Check if a bisect was running | 1630 | my $check = $opt{"BISECT_CHECK[$i]"}; |
2463 | my $bisect_start_file = "$builddir/.git/BISECT_START"; | 1631 | if (defined($check) && $check ne "0") { |
2464 | |||
2465 | my $check = $bisect_check; | ||
2466 | my $do_check = defined($check) && $check ne "0"; | ||
2467 | |||
2468 | if ( -f $bisect_start_file ) { | ||
2469 | print "Bisect in progress found\n"; | ||
2470 | if ($do_check) { | ||
2471 | print " If you say yes, then no checks of good or bad will be done\n"; | ||
2472 | } | ||
2473 | if (defined($replay)) { | ||
2474 | print "** BISECT_REPLAY is defined in config file **"; | ||
2475 | print " Ignore config option and perform new git bisect log?\n"; | ||
2476 | if (read_ync " (yes, no, or cancel) ") { | ||
2477 | $replay = update_bisect_replay; | ||
2478 | $do_check = 0; | ||
2479 | } | ||
2480 | } elsif (read_yn "read git log and continue?") { | ||
2481 | $replay = update_bisect_replay; | ||
2482 | $do_check = 0; | ||
2483 | } | ||
2484 | } | ||
2485 | |||
2486 | if ($do_check) { | ||
2487 | 1632 | ||
2488 | # get current HEAD | 1633 | # get current HEAD |
2489 | my $head = get_sha1("HEAD"); | 1634 | my $head = get_sha1("HEAD"); |
@@ -2548,28 +1693,14 @@ sub bisect { | |||
2548 | run_command "git bisect reset" or | 1693 | run_command "git bisect reset" or |
2549 | dodie "could not reset git bisect"; | 1694 | dodie "could not reset git bisect"; |
2550 | 1695 | ||
2551 | doprint "Bad commit was [$bisect_bad_commit]\n"; | 1696 | doprint "Bad commit was [$bisect_bad]\n"; |
2552 | 1697 | ||
2553 | success $i; | 1698 | success $i; |
2554 | } | 1699 | } |
2555 | 1700 | ||
2556 | # config_ignore holds the configs that were set (or unset) for | ||
2557 | # a good config and we will ignore these configs for the rest | ||
2558 | # of a config bisect. These configs stay as they were. | ||
2559 | my %config_ignore; | 1701 | my %config_ignore; |
2560 | |||
2561 | # config_set holds what all configs were set as. | ||
2562 | my %config_set; | 1702 | my %config_set; |
2563 | 1703 | ||
2564 | # config_off holds the set of configs that the bad config had disabled. | ||
2565 | # We need to record them and set them in the .config when running | ||
2566 | # olddefconfig, because olddefconfig keeps the defaults. | ||
2567 | my %config_off; | ||
2568 | |||
2569 | # config_off_tmp holds a set of configs to turn off for now | ||
2570 | my @config_off_tmp; | ||
2571 | |||
2572 | # config_list is the set of configs that are being tested | ||
2573 | my %config_list; | 1704 | my %config_list; |
2574 | my %null_config; | 1705 | my %null_config; |
2575 | 1706 | ||
@@ -2648,21 +1779,12 @@ sub create_config { | |||
2648 | } | 1779 | } |
2649 | } | 1780 | } |
2650 | 1781 | ||
2651 | # turn off configs to keep off | ||
2652 | foreach my $config (keys %config_off) { | ||
2653 | print OUT "# $config is not set\n"; | ||
2654 | } | ||
2655 | |||
2656 | # turn off configs that should be off for now | ||
2657 | foreach my $config (@config_off_tmp) { | ||
2658 | print OUT "# $config is not set\n"; | ||
2659 | } | ||
2660 | |||
2661 | foreach my $config (keys %config_ignore) { | 1782 | foreach my $config (keys %config_ignore) { |
2662 | print OUT "$config_ignore{$config}\n"; | 1783 | print OUT "$config_ignore{$config}\n"; |
2663 | } | 1784 | } |
2664 | close(OUT); | 1785 | close(OUT); |
2665 | 1786 | ||
1787 | # exit; | ||
2666 | make_oldconfig; | 1788 | make_oldconfig; |
2667 | } | 1789 | } |
2668 | 1790 | ||
@@ -2727,7 +1849,7 @@ sub run_config_bisect { | |||
2727 | } | 1849 | } |
2728 | 1850 | ||
2729 | doprint "***** RUN TEST ***\n"; | 1851 | doprint "***** RUN TEST ***\n"; |
2730 | my $type = $config_bisect_type; | 1852 | my $type = $opt{"CONFIG_BISECT_TYPE[$iteration]"}; |
2731 | my $ret; | 1853 | my $ret; |
2732 | my %current_config; | 1854 | my %current_config; |
2733 | 1855 | ||
@@ -2739,13 +1861,6 @@ sub run_config_bisect { | |||
2739 | do { | 1861 | do { |
2740 | my @tophalf = @start_list[0 .. $half]; | 1862 | my @tophalf = @start_list[0 .. $half]; |
2741 | 1863 | ||
2742 | # keep the bottom half off | ||
2743 | if ($half < $#start_list) { | ||
2744 | @config_off_tmp = @start_list[$half + 1 .. $#start_list]; | ||
2745 | } else { | ||
2746 | @config_off_tmp = (); | ||
2747 | } | ||
2748 | |||
2749 | create_config @tophalf; | 1864 | create_config @tophalf; |
2750 | read_current_config \%current_config; | 1865 | read_current_config \%current_config; |
2751 | 1866 | ||
@@ -2762,11 +1877,7 @@ sub run_config_bisect { | |||
2762 | if (!$found) { | 1877 | if (!$found) { |
2763 | # try the other half | 1878 | # try the other half |
2764 | doprint "Top half produced no set configs, trying bottom half\n"; | 1879 | doprint "Top half produced no set configs, trying bottom half\n"; |
2765 | |||
2766 | # keep the top half off | ||
2767 | @config_off_tmp = @tophalf; | ||
2768 | @tophalf = @start_list[$half + 1 .. $#start_list]; | 1880 | @tophalf = @start_list[$half + 1 .. $#start_list]; |
2769 | |||
2770 | create_config @tophalf; | 1881 | create_config @tophalf; |
2771 | read_current_config \%current_config; | 1882 | read_current_config \%current_config; |
2772 | foreach my $config (@tophalf) { | 1883 | foreach my $config (@tophalf) { |
@@ -2842,7 +1953,7 @@ sub run_config_bisect { | |||
2842 | sub config_bisect { | 1953 | sub config_bisect { |
2843 | my ($i) = @_; | 1954 | my ($i) = @_; |
2844 | 1955 | ||
2845 | my $start_config = $config_bisect; | 1956 | my $start_config = $opt{"CONFIG_BISECT[$i]"}; |
2846 | 1957 | ||
2847 | my $tmpconfig = "$tmpdir/use_config"; | 1958 | my $tmpconfig = "$tmpdir/use_config"; |
2848 | 1959 | ||
@@ -2871,7 +1982,7 @@ sub config_bisect { | |||
2871 | # read directly what we want to check | 1982 | # read directly what we want to check |
2872 | my %config_check; | 1983 | my %config_check; |
2873 | open (IN, $output_config) | 1984 | open (IN, $output_config) |
2874 | or dodie "failed to open $output_config"; | 1985 | or dodie "faied to open $output_config"; |
2875 | 1986 | ||
2876 | while (<IN>) { | 1987 | while (<IN>) { |
2877 | if (/^((CONFIG\S*)=.*)/) { | 1988 | if (/^((CONFIG\S*)=.*)/) { |
@@ -2904,10 +2015,6 @@ sub config_bisect { | |||
2904 | $added_configs{$2} = $1; | 2015 | $added_configs{$2} = $1; |
2905 | $config_list{$2} = $1; | 2016 | $config_list{$2} = $1; |
2906 | } | 2017 | } |
2907 | } elsif (/^# ((CONFIG\S*).*)/) { | ||
2908 | # Keep these configs disabled | ||
2909 | $config_set{$2} = $1; | ||
2910 | $config_off{$2} = $1; | ||
2911 | } | 2018 | } |
2912 | } | 2019 | } |
2913 | close(IN); | 2020 | close(IN); |
@@ -2930,8 +2037,6 @@ sub config_bisect { | |||
2930 | my %config_test; | 2037 | my %config_test; |
2931 | my $once = 0; | 2038 | my $once = 0; |
2932 | 2039 | ||
2933 | @config_off_tmp = (); | ||
2934 | |||
2935 | # Sometimes kconfig does weird things. We must make sure | 2040 | # Sometimes kconfig does weird things. We must make sure |
2936 | # that the config we autocreate has everything we need | 2041 | # that the config we autocreate has everything we need |
2937 | # to test, otherwise we may miss testing configs, or | 2042 | # to test, otherwise we may miss testing configs, or |
@@ -2950,18 +2055,6 @@ sub config_bisect { | |||
2950 | } | 2055 | } |
2951 | } | 2056 | } |
2952 | my $ret; | 2057 | my $ret; |
2953 | |||
2954 | if (defined($config_bisect_check) && $config_bisect_check) { | ||
2955 | doprint " Checking to make sure bad config with min config fails\n"; | ||
2956 | create_config keys %config_list; | ||
2957 | $ret = run_config_bisect_test $config_bisect_type; | ||
2958 | if ($ret) { | ||
2959 | doprint " FAILED! Bad config with min config boots fine\n"; | ||
2960 | return -1; | ||
2961 | } | ||
2962 | doprint " Bad config with min config fails as expected\n"; | ||
2963 | } | ||
2964 | |||
2965 | do { | 2058 | do { |
2966 | $ret = run_config_bisect; | 2059 | $ret = run_config_bisect; |
2967 | } while (!$ret); | 2060 | } while (!$ret); |
@@ -2973,29 +2066,32 @@ sub config_bisect { | |||
2973 | 2066 | ||
2974 | sub patchcheck_reboot { | 2067 | sub patchcheck_reboot { |
2975 | doprint "Reboot and sleep $patchcheck_sleep_time seconds\n"; | 2068 | doprint "Reboot and sleep $patchcheck_sleep_time seconds\n"; |
2976 | reboot_to_good $patchcheck_sleep_time; | 2069 | reboot; |
2070 | start_monitor; | ||
2071 | wait_for_monitor $patchcheck_sleep_time; | ||
2072 | end_monitor; | ||
2977 | } | 2073 | } |
2978 | 2074 | ||
2979 | sub patchcheck { | 2075 | sub patchcheck { |
2980 | my ($i) = @_; | 2076 | my ($i) = @_; |
2981 | 2077 | ||
2982 | die "PATCHCHECK_START[$i] not defined\n" | 2078 | die "PATCHCHECK_START[$i] not defined\n" |
2983 | if (!defined($patchcheck_start)); | 2079 | if (!defined($opt{"PATCHCHECK_START[$i]"})); |
2984 | die "PATCHCHECK_TYPE[$i] not defined\n" | 2080 | die "PATCHCHECK_TYPE[$i] not defined\n" |
2985 | if (!defined($patchcheck_type)); | 2081 | if (!defined($opt{"PATCHCHECK_TYPE[$i]"})); |
2986 | 2082 | ||
2987 | my $start = $patchcheck_start; | 2083 | my $start = $opt{"PATCHCHECK_START[$i]"}; |
2988 | 2084 | ||
2989 | my $end = "HEAD"; | 2085 | my $end = "HEAD"; |
2990 | if (defined($patchcheck_end)) { | 2086 | if (defined($opt{"PATCHCHECK_END[$i]"})) { |
2991 | $end = $patchcheck_end; | 2087 | $end = $opt{"PATCHCHECK_END[$i]"}; |
2992 | } | 2088 | } |
2993 | 2089 | ||
2994 | # Get the true sha1's since we can use things like HEAD~3 | 2090 | # Get the true sha1's since we can use things like HEAD~3 |
2995 | $start = get_sha1($start); | 2091 | $start = get_sha1($start); |
2996 | $end = get_sha1($end); | 2092 | $end = get_sha1($end); |
2997 | 2093 | ||
2998 | my $type = $patchcheck_type; | 2094 | my $type = $opt{"PATCHCHECK_TYPE[$i]"}; |
2999 | 2095 | ||
3000 | # Can't have a test without having a test to run | 2096 | # Can't have a test without having a test to run |
3001 | if ($type eq "test" && !defined($run_test)) { | 2097 | if ($type eq "test" && !defined($run_test)) { |
@@ -3082,31 +2178,12 @@ sub patchcheck { | |||
3082 | } | 2178 | } |
3083 | 2179 | ||
3084 | my %depends; | 2180 | my %depends; |
3085 | my %depcount; | ||
3086 | my $iflevel = 0; | 2181 | my $iflevel = 0; |
3087 | my @ifdeps; | 2182 | my @ifdeps; |
3088 | 2183 | ||
3089 | # prevent recursion | 2184 | # prevent recursion |
3090 | my %read_kconfigs; | 2185 | my %read_kconfigs; |
3091 | 2186 | ||
3092 | sub add_dep { | ||
3093 | # $config depends on $dep | ||
3094 | my ($config, $dep) = @_; | ||
3095 | |||
3096 | if (defined($depends{$config})) { | ||
3097 | $depends{$config} .= " " . $dep; | ||
3098 | } else { | ||
3099 | $depends{$config} = $dep; | ||
3100 | } | ||
3101 | |||
3102 | # record the number of configs depending on $dep | ||
3103 | if (defined $depcount{$dep}) { | ||
3104 | $depcount{$dep}++; | ||
3105 | } else { | ||
3106 | $depcount{$dep} = 1; | ||
3107 | } | ||
3108 | } | ||
3109 | |||
3110 | # taken from streamline_config.pl | 2187 | # taken from streamline_config.pl |
3111 | sub read_kconfig { | 2188 | sub read_kconfig { |
3112 | my ($kconfig) = @_; | 2189 | my ($kconfig) = @_; |
@@ -3153,19 +2230,30 @@ sub read_kconfig { | |||
3153 | $config = $2; | 2230 | $config = $2; |
3154 | 2231 | ||
3155 | for (my $i = 0; $i < $iflevel; $i++) { | 2232 | for (my $i = 0; $i < $iflevel; $i++) { |
3156 | add_dep $config, $ifdeps[$i]; | 2233 | if ($i) { |
2234 | $depends{$config} .= " " . $ifdeps[$i]; | ||
2235 | } else { | ||
2236 | $depends{$config} = $ifdeps[$i]; | ||
2237 | } | ||
2238 | $state = "DEP"; | ||
3157 | } | 2239 | } |
3158 | 2240 | ||
3159 | # collect the depends for the config | 2241 | # collect the depends for the config |
3160 | } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { | 2242 | } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { |
3161 | 2243 | ||
3162 | add_dep $config, $1; | 2244 | if (defined($depends{$1})) { |
2245 | $depends{$config} .= " " . $1; | ||
2246 | } else { | ||
2247 | $depends{$config} = $1; | ||
2248 | } | ||
3163 | 2249 | ||
3164 | # Get the configs that select this config | 2250 | # Get the configs that select this config |
3165 | } elsif ($state eq "NEW" && /^\s*select\s+(\S+)/) { | 2251 | } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) { |
3166 | 2252 | if (defined($depends{$1})) { | |
3167 | # selected by depends on config | 2253 | $depends{$1} .= " " . $config; |
3168 | add_dep $1, $config; | 2254 | } else { |
2255 | $depends{$1} = $config; | ||
2256 | } | ||
3169 | 2257 | ||
3170 | # Check for if statements | 2258 | # Check for if statements |
3171 | } elsif (/^if\s+(.*\S)\s*$/) { | 2259 | } elsif (/^if\s+(.*\S)\s*$/) { |
@@ -3277,18 +2365,11 @@ sub make_new_config { | |||
3277 | close OUT; | 2365 | close OUT; |
3278 | } | 2366 | } |
3279 | 2367 | ||
3280 | sub chomp_config { | ||
3281 | my ($config) = @_; | ||
3282 | |||
3283 | $config =~ s/CONFIG_//; | ||
3284 | |||
3285 | return $config; | ||
3286 | } | ||
3287 | |||
3288 | sub get_depends { | 2368 | sub get_depends { |
3289 | my ($dep) = @_; | 2369 | my ($dep) = @_; |
3290 | 2370 | ||
3291 | my $kconfig = chomp_config $dep; | 2371 | my $kconfig = $dep; |
2372 | $kconfig =~ s/CONFIG_//; | ||
3292 | 2373 | ||
3293 | $dep = $depends{"$kconfig"}; | 2374 | $dep = $depends{"$kconfig"}; |
3294 | 2375 | ||
@@ -3338,7 +2419,8 @@ sub test_this_config { | |||
3338 | return undef; | 2419 | return undef; |
3339 | } | 2420 | } |
3340 | 2421 | ||
3341 | my $kconfig = chomp_config $config; | 2422 | my $kconfig = $config; |
2423 | $kconfig =~ s/CONFIG_//; | ||
3342 | 2424 | ||
3343 | # Test dependencies first | 2425 | # Test dependencies first |
3344 | if (defined($depends{"$kconfig"})) { | 2426 | if (defined($depends{"$kconfig"})) { |
@@ -3354,7 +2436,7 @@ sub test_this_config { | |||
3354 | } | 2436 | } |
3355 | 2437 | ||
3356 | # Remove this config from the list of configs | 2438 | # Remove this config from the list of configs |
3357 | # do a make olddefconfig and then read the resulting | 2439 | # do a make oldnoconfig and then read the resulting |
3358 | # .config to make sure it is missing the config that | 2440 | # .config to make sure it is missing the config that |
3359 | # we had before | 2441 | # we had before |
3360 | my %configs = %min_configs; | 2442 | my %configs = %min_configs; |
@@ -3376,12 +2458,6 @@ sub test_this_config { | |||
3376 | sub make_min_config { | 2458 | sub make_min_config { |
3377 | my ($i) = @_; | 2459 | my ($i) = @_; |
3378 | 2460 | ||
3379 | my $type = $minconfig_type; | ||
3380 | if ($type ne "boot" && $type ne "test") { | ||
3381 | fail "Invalid MIN_CONFIG_TYPE '$minconfig_type'\n" . | ||
3382 | " make_min_config works only with 'boot' and 'test'\n" and return; | ||
3383 | } | ||
3384 | |||
3385 | if (!defined($output_minconfig)) { | 2461 | if (!defined($output_minconfig)) { |
3386 | fail "OUTPUT_MIN_CONFIG not defined" and return; | 2462 | fail "OUTPUT_MIN_CONFIG not defined" and return; |
3387 | } | 2463 | } |
@@ -3391,15 +2467,8 @@ sub make_min_config { | |||
3391 | # that instead. | 2467 | # that instead. |
3392 | if (-f $output_minconfig && !$start_minconfig_defined) { | 2468 | if (-f $output_minconfig && !$start_minconfig_defined) { |
3393 | print "$output_minconfig exists\n"; | 2469 | print "$output_minconfig exists\n"; |
3394 | if (!defined($use_output_minconfig)) { | 2470 | if (read_yn " Use it as minconfig?") { |
3395 | if (read_yn " Use it as minconfig?") { | ||
3396 | $start_minconfig = $output_minconfig; | ||
3397 | } | ||
3398 | } elsif ($use_output_minconfig > 0) { | ||
3399 | doprint "Using $output_minconfig as MIN_CONFIG\n"; | ||
3400 | $start_minconfig = $output_minconfig; | 2471 | $start_minconfig = $output_minconfig; |
3401 | } else { | ||
3402 | doprint "Set to still use MIN_CONFIG as starting point\n"; | ||
3403 | } | 2472 | } |
3404 | } | 2473 | } |
3405 | 2474 | ||
@@ -3441,14 +2510,6 @@ sub make_min_config { | |||
3441 | 2510 | ||
3442 | my @config_keys = keys %min_configs; | 2511 | my @config_keys = keys %min_configs; |
3443 | 2512 | ||
3444 | # All configs need a depcount | ||
3445 | foreach my $config (@config_keys) { | ||
3446 | my $kconfig = chomp_config $config; | ||
3447 | if (!defined $depcount{$kconfig}) { | ||
3448 | $depcount{$kconfig} = 0; | ||
3449 | } | ||
3450 | } | ||
3451 | |||
3452 | # Remove anything that was set by the make allnoconfig | 2513 | # Remove anything that was set by the make allnoconfig |
3453 | # we shouldn't need them as they get set for us anyway. | 2514 | # we shouldn't need them as they get set for us anyway. |
3454 | foreach my $config (@config_keys) { | 2515 | foreach my $config (@config_keys) { |
@@ -3487,13 +2548,8 @@ sub make_min_config { | |||
3487 | # Now disable each config one by one and do a make oldconfig | 2548 | # Now disable each config one by one and do a make oldconfig |
3488 | # till we find a config that changes our list. | 2549 | # till we find a config that changes our list. |
3489 | 2550 | ||
3490 | my @test_configs = keys %min_configs; | ||
3491 | |||
3492 | # Sort keys by who is most dependent on | ||
3493 | @test_configs = sort { $depcount{chomp_config($b)} <=> $depcount{chomp_config($a)} } | ||
3494 | @test_configs ; | ||
3495 | |||
3496 | # Put configs that did not modify the config at the end. | 2551 | # Put configs that did not modify the config at the end. |
2552 | my @test_configs = keys %min_configs; | ||
3497 | my $reset = 1; | 2553 | my $reset = 1; |
3498 | for (my $i = 0; $i < $#test_configs; $i++) { | 2554 | for (my $i = 0; $i < $#test_configs; $i++) { |
3499 | if (!defined($nochange_config{$test_configs[0]})) { | 2555 | if (!defined($nochange_config{$test_configs[0]})) { |
@@ -3545,16 +2601,9 @@ sub make_min_config { | |||
3545 | $in_bisect = 1; | 2601 | $in_bisect = 1; |
3546 | 2602 | ||
3547 | my $failed = 0; | 2603 | my $failed = 0; |
3548 | build "oldconfig" or $failed = 1; | 2604 | build "oldconfig"; |
3549 | if (!$failed) { | 2605 | start_monitor_and_boot or $failed = 1; |
3550 | start_monitor_and_boot or $failed = 1; | 2606 | end_monitor; |
3551 | |||
3552 | if ($type eq "test" && !$failed) { | ||
3553 | do_run_test or $failed = 1; | ||
3554 | } | ||
3555 | |||
3556 | end_monitor; | ||
3557 | } | ||
3558 | 2607 | ||
3559 | $in_bisect = 0; | 2608 | $in_bisect = 0; |
3560 | 2609 | ||
@@ -3610,7 +2659,10 @@ sub make_min_config { | |||
3610 | } | 2659 | } |
3611 | 2660 | ||
3612 | doprint "Reboot and wait $sleep_time seconds\n"; | 2661 | doprint "Reboot and wait $sleep_time seconds\n"; |
3613 | reboot_to_good $sleep_time; | 2662 | reboot; |
2663 | start_monitor; | ||
2664 | wait_for_monitor $sleep_time; | ||
2665 | end_monitor; | ||
3614 | } | 2666 | } |
3615 | 2667 | ||
3616 | success $i; | 2668 | success $i; |
@@ -3632,27 +2684,13 @@ if ($#ARGV == 0) { | |||
3632 | } | 2684 | } |
3633 | 2685 | ||
3634 | if (! -f $ktest_config) { | 2686 | if (! -f $ktest_config) { |
3635 | $newconfig = 1; | ||
3636 | get_test_case; | ||
3637 | open(OUT, ">$ktest_config") or die "Can not create $ktest_config"; | 2687 | open(OUT, ">$ktest_config") or die "Can not create $ktest_config"; |
3638 | print OUT << "EOF" | 2688 | print OUT << "EOF" |
3639 | # Generated by ktest.pl | 2689 | # Generated by ktest.pl |
3640 | # | 2690 | # |
3641 | |||
3642 | # PWD is a ktest.pl variable that will result in the process working | ||
3643 | # directory that ktest.pl is executed in. | ||
3644 | |||
3645 | # THIS_DIR is automatically assigned the PWD of the path that generated | ||
3646 | # the config file. It is best to use this variable when assigning other | ||
3647 | # directory paths within this directory. This allows you to easily | ||
3648 | # move the test cases to other locations or to other machines. | ||
3649 | # | ||
3650 | THIS_DIR := $variable{"PWD"} | ||
3651 | |||
3652 | # Define each test with TEST_START | 2691 | # Define each test with TEST_START |
3653 | # The config options below it will override the defaults | 2692 | # The config options below it will override the defaults |
3654 | TEST_START | 2693 | TEST_START |
3655 | TEST_TYPE = $default{"TEST_TYPE"} | ||
3656 | 2694 | ||
3657 | DEFAULTS | 2695 | DEFAULTS |
3658 | EOF | 2696 | EOF |
@@ -3672,7 +2710,7 @@ if ($#new_configs >= 0) { | |||
3672 | open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config"; | 2710 | open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config"; |
3673 | foreach my $config (@new_configs) { | 2711 | foreach my $config (@new_configs) { |
3674 | print OUT "$config = $entered_configs{$config}\n"; | 2712 | print OUT "$config = $entered_configs{$config}\n"; |
3675 | $opt{$config} = process_variables($entered_configs{$config}); | 2713 | $opt{$config} = $entered_configs{$config}; |
3676 | } | 2714 | } |
3677 | } | 2715 | } |
3678 | 2716 | ||
@@ -3745,37 +2783,66 @@ sub set_test_option { | |||
3745 | # First we need to do is the builds | 2783 | # First we need to do is the builds |
3746 | for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | 2784 | for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { |
3747 | 2785 | ||
3748 | # Do not reboot on failing test options | ||
3749 | $no_reboot = 1; | ||
3750 | $reboot_success = 0; | ||
3751 | |||
3752 | $have_version = 0; | ||
3753 | |||
3754 | $iteration = $i; | 2786 | $iteration = $i; |
3755 | 2787 | ||
3756 | undef %force_config; | ||
3757 | |||
3758 | my $makecmd = set_test_option("MAKE_CMD", $i); | 2788 | my $makecmd = set_test_option("MAKE_CMD", $i); |
3759 | 2789 | ||
3760 | # Load all the options into their mapped variable names | 2790 | $machine = set_test_option("MACHINE", $i); |
3761 | foreach my $opt (keys %option_map) { | 2791 | $ssh_user = set_test_option("SSH_USER", $i); |
3762 | ${$option_map{$opt}} = set_test_option($opt, $i); | 2792 | $tmpdir = set_test_option("TMP_DIR", $i); |
3763 | } | 2793 | $outputdir = set_test_option("OUTPUT_DIR", $i); |
2794 | $builddir = set_test_option("BUILD_DIR", $i); | ||
2795 | $test_type = set_test_option("TEST_TYPE", $i); | ||
2796 | $build_type = set_test_option("BUILD_TYPE", $i); | ||
2797 | $build_options = set_test_option("BUILD_OPTIONS", $i); | ||
2798 | $pre_build = set_test_option("PRE_BUILD", $i); | ||
2799 | $post_build = set_test_option("POST_BUILD", $i); | ||
2800 | $pre_build_die = set_test_option("PRE_BUILD_DIE", $i); | ||
2801 | $post_build_die = set_test_option("POST_BUILD_DIE", $i); | ||
2802 | $power_cycle = set_test_option("POWER_CYCLE", $i); | ||
2803 | $reboot = set_test_option("REBOOT", $i); | ||
2804 | $noclean = set_test_option("BUILD_NOCLEAN", $i); | ||
2805 | $minconfig = set_test_option("MIN_CONFIG", $i); | ||
2806 | $output_minconfig = set_test_option("OUTPUT_MIN_CONFIG", $i); | ||
2807 | $start_minconfig = set_test_option("START_MIN_CONFIG", $i); | ||
2808 | $ignore_config = set_test_option("IGNORE_CONFIG", $i); | ||
2809 | $run_test = set_test_option("TEST", $i); | ||
2810 | $addconfig = set_test_option("ADD_CONFIG", $i); | ||
2811 | $reboot_type = set_test_option("REBOOT_TYPE", $i); | ||
2812 | $grub_menu = set_test_option("GRUB_MENU", $i); | ||
2813 | $post_install = set_test_option("POST_INSTALL", $i); | ||
2814 | $reboot_script = set_test_option("REBOOT_SCRIPT", $i); | ||
2815 | $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i); | ||
2816 | $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i); | ||
2817 | $die_on_failure = set_test_option("DIE_ON_FAILURE", $i); | ||
2818 | $power_off = set_test_option("POWER_OFF", $i); | ||
2819 | $powercycle_after_reboot = set_test_option("POWERCYCLE_AFTER_REBOOT", $i); | ||
2820 | $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i); | ||
2821 | $sleep_time = set_test_option("SLEEP_TIME", $i); | ||
2822 | $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i); | ||
2823 | $patchcheck_sleep_time = set_test_option("PATCHCHECK_SLEEP_TIME", $i); | ||
2824 | $ignore_warnings = set_test_option("IGNORE_WARNINGS", $i); | ||
2825 | $bisect_manual = set_test_option("BISECT_MANUAL", $i); | ||
2826 | $bisect_skip = set_test_option("BISECT_SKIP", $i); | ||
2827 | $config_bisect_good = set_test_option("CONFIG_BISECT_GOOD", $i); | ||
2828 | $store_failures = set_test_option("STORE_FAILURES", $i); | ||
2829 | $test_name = set_test_option("TEST_NAME", $i); | ||
2830 | $timeout = set_test_option("TIMEOUT", $i); | ||
2831 | $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); | ||
2832 | $console = set_test_option("CONSOLE", $i); | ||
2833 | $detect_triplefault = set_test_option("DETECT_TRIPLE_FAULT", $i); | ||
2834 | $success_line = set_test_option("SUCCESS_LINE", $i); | ||
2835 | $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i); | ||
2836 | $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i); | ||
2837 | $stop_test_after = set_test_option("STOP_TEST_AFTER", $i); | ||
2838 | $build_target = set_test_option("BUILD_TARGET", $i); | ||
2839 | $ssh_exec = set_test_option("SSH_EXEC", $i); | ||
2840 | $scp_to_target = set_test_option("SCP_TO_TARGET", $i); | ||
2841 | $target_image = set_test_option("TARGET_IMAGE", $i); | ||
2842 | $localversion = set_test_option("LOCALVERSION", $i); | ||
3764 | 2843 | ||
3765 | $start_minconfig_defined = 1; | 2844 | $start_minconfig_defined = 1; |
3766 | 2845 | ||
3767 | # The first test may override the PRE_KTEST option | ||
3768 | if (defined($pre_ktest) && $i == 1) { | ||
3769 | doprint "\n"; | ||
3770 | run_command $pre_ktest; | ||
3771 | } | ||
3772 | |||
3773 | # Any test can override the POST_KTEST option | ||
3774 | # The last test takes precedence. | ||
3775 | if (defined($post_ktest)) { | ||
3776 | $final_post_ktest = $post_ktest; | ||
3777 | } | ||
3778 | |||
3779 | if (!defined($start_minconfig)) { | 2846 | if (!defined($start_minconfig)) { |
3780 | $start_minconfig_defined = 0; | 2847 | $start_minconfig_defined = 0; |
3781 | $start_minconfig = $minconfig; | 2848 | $start_minconfig = $minconfig; |
@@ -3783,41 +2850,34 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3783 | 2850 | ||
3784 | chdir $builddir || die "can't change directory to $builddir"; | 2851 | chdir $builddir || die "can't change directory to $builddir"; |
3785 | 2852 | ||
3786 | foreach my $dir ($tmpdir, $outputdir) { | 2853 | if (!-d $tmpdir) { |
3787 | if (!-d $dir) { | 2854 | mkpath($tmpdir) or |
3788 | mkpath($dir) or | 2855 | die "can't create $tmpdir"; |
3789 | die "can't create $dir"; | ||
3790 | } | ||
3791 | } | 2856 | } |
3792 | 2857 | ||
3793 | $ENV{"SSH_USER"} = $ssh_user; | 2858 | $ENV{"SSH_USER"} = $ssh_user; |
3794 | $ENV{"MACHINE"} = $machine; | 2859 | $ENV{"MACHINE"} = $machine; |
3795 | 2860 | ||
2861 | $target = "$ssh_user\@$machine"; | ||
2862 | |||
3796 | $buildlog = "$tmpdir/buildlog-$machine"; | 2863 | $buildlog = "$tmpdir/buildlog-$machine"; |
3797 | $testlog = "$tmpdir/testlog-$machine"; | ||
3798 | $dmesg = "$tmpdir/dmesg-$machine"; | 2864 | $dmesg = "$tmpdir/dmesg-$machine"; |
3799 | $make = "$makecmd O=$outputdir"; | 2865 | $make = "$makecmd O=$outputdir"; |
3800 | $output_config = "$outputdir/.config"; | 2866 | $output_config = "$outputdir/.config"; |
3801 | 2867 | ||
3802 | if (!$buildonly) { | 2868 | if ($reboot_type eq "grub") { |
3803 | $target = "$ssh_user\@$machine"; | 2869 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); |
3804 | if ($reboot_type eq "grub") { | 2870 | } elsif (!defined($reboot_script)) { |
3805 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); | 2871 | dodie "REBOOT_SCRIPT not defined" |
3806 | } elsif ($reboot_type eq "grub2") { | ||
3807 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); | ||
3808 | dodie "GRUB_FILE not defined" if (!defined($grub_file)); | ||
3809 | } elsif ($reboot_type eq "syslinux") { | ||
3810 | dodie "SYSLINUX_LABEL not defined" if (!defined($syslinux_label)); | ||
3811 | } | ||
3812 | } | 2872 | } |
3813 | 2873 | ||
3814 | my $run_type = $build_type; | 2874 | my $run_type = $build_type; |
3815 | if ($test_type eq "patchcheck") { | 2875 | if ($test_type eq "patchcheck") { |
3816 | $run_type = $patchcheck_type; | 2876 | $run_type = $opt{"PATCHCHECK_TYPE[$i]"}; |
3817 | } elsif ($test_type eq "bisect") { | 2877 | } elsif ($test_type eq "bisect") { |
3818 | $run_type = $bisect_type; | 2878 | $run_type = $opt{"BISECT_TYPE[$i]"}; |
3819 | } elsif ($test_type eq "config_bisect") { | 2879 | } elsif ($test_type eq "config_bisect") { |
3820 | $run_type = $config_bisect_type; | 2880 | $run_type = $opt{"CONFIG_BISECT_TYPE[$i]"}; |
3821 | } | 2881 | } |
3822 | 2882 | ||
3823 | if ($test_type eq "make_min_config") { | 2883 | if ($test_type eq "make_min_config") { |
@@ -3829,19 +2889,11 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3829 | $run_type = "ERROR"; | 2889 | $run_type = "ERROR"; |
3830 | } | 2890 | } |
3831 | 2891 | ||
3832 | my $installme = ""; | ||
3833 | $installme = " no_install" if ($no_install); | ||
3834 | |||
3835 | doprint "\n\n"; | 2892 | doprint "\n\n"; |
3836 | doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type$installme\n\n"; | 2893 | doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type\n\n"; |
3837 | |||
3838 | if (defined($pre_test)) { | ||
3839 | run_command $pre_test; | ||
3840 | } | ||
3841 | 2894 | ||
3842 | unlink $dmesg; | 2895 | unlink $dmesg; |
3843 | unlink $buildlog; | 2896 | unlink $buildlog; |
3844 | unlink $testlog; | ||
3845 | 2897 | ||
3846 | if (defined($addconfig)) { | 2898 | if (defined($addconfig)) { |
3847 | my $min = $minconfig; | 2899 | my $min = $minconfig; |
@@ -3853,18 +2905,12 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3853 | $minconfig = "$tmpdir/add_config"; | 2905 | $minconfig = "$tmpdir/add_config"; |
3854 | } | 2906 | } |
3855 | 2907 | ||
2908 | my $checkout = $opt{"CHECKOUT[$i]"}; | ||
3856 | if (defined($checkout)) { | 2909 | if (defined($checkout)) { |
3857 | run_command "git checkout $checkout" or | 2910 | run_command "git checkout $checkout" or |
3858 | die "failed to checkout $checkout"; | 2911 | die "failed to checkout $checkout"; |
3859 | } | 2912 | } |
3860 | 2913 | ||
3861 | $no_reboot = 0; | ||
3862 | |||
3863 | # A test may opt to not reboot the box | ||
3864 | if ($reboot_on_success) { | ||
3865 | $reboot_success = 1; | ||
3866 | } | ||
3867 | |||
3868 | if ($test_type eq "bisect") { | 2914 | if ($test_type eq "bisect") { |
3869 | bisect $i; | 2915 | bisect $i; |
3870 | next; | 2916 | next; |
@@ -3883,13 +2929,6 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3883 | build $build_type or next; | 2929 | build $build_type or next; |
3884 | } | 2930 | } |
3885 | 2931 | ||
3886 | if ($test_type eq "install") { | ||
3887 | get_version; | ||
3888 | install; | ||
3889 | success $i; | ||
3890 | next; | ||
3891 | } | ||
3892 | |||
3893 | if ($test_type ne "build") { | 2932 | if ($test_type ne "build") { |
3894 | my $failed = 0; | 2933 | my $failed = 0; |
3895 | start_monitor_and_boot or $failed = 1; | 2934 | start_monitor_and_boot or $failed = 1; |
@@ -3904,20 +2943,12 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3904 | success $i; | 2943 | success $i; |
3905 | } | 2944 | } |
3906 | 2945 | ||
3907 | if (defined($final_post_ktest)) { | ||
3908 | run_command $final_post_ktest; | ||
3909 | } | ||
3910 | |||
3911 | if ($opt{"POWEROFF_ON_SUCCESS"}) { | 2946 | if ($opt{"POWEROFF_ON_SUCCESS"}) { |
3912 | halt; | 2947 | halt; |
3913 | } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) { | 2948 | } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) { |
3914 | reboot_to_good; | 2949 | reboot; |
3915 | } elsif (defined($switch_to_good)) { | ||
3916 | # still need to get to the good kernel | ||
3917 | run_command $switch_to_good; | ||
3918 | } | 2950 | } |
3919 | 2951 | ||
3920 | |||
3921 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; | 2952 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; |
3922 | 2953 | ||
3923 | exit 0; | 2954 | exit 0; |
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf index 4012e933034..b8bcd14b5a4 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf | |||
@@ -72,128 +72,6 @@ | |||
72 | # the same option name under the same test or as default | 72 | # the same option name under the same test or as default |
73 | # ktest will fail to execute, and no tests will run. | 73 | # ktest will fail to execute, and no tests will run. |
74 | # | 74 | # |
75 | # DEFAULTS OVERRIDE | ||
76 | # | ||
77 | # Options defined in the DEFAULTS section can not be duplicated | ||
78 | # even if they are defined in two different DEFAULT sections. | ||
79 | # This is done to catch mistakes where an option is added but | ||
80 | # the previous option was forgotten about and not commented. | ||
81 | # | ||
82 | # The OVERRIDE keyword can be added to a section to allow this | ||
83 | # section to override other DEFAULT sections values that have | ||
84 | # been defined previously. It will only override options that | ||
85 | # have been defined before its use. Options defined later | ||
86 | # in a non override section will still error. The same option | ||
87 | # can not be defined in the same section even if that section | ||
88 | # is marked OVERRIDE. | ||
89 | # | ||
90 | # | ||
91 | # | ||
92 | # Both TEST_START and DEFAULTS sections can also have the IF keyword | ||
93 | # The value after the IF must evaluate into a 0 or non 0 positive | ||
94 | # integer, and can use the config variables (explained below). | ||
95 | # | ||
96 | # DEFAULTS IF ${IS_X86_32} | ||
97 | # | ||
98 | # The above will process the DEFAULTS section if the config | ||
99 | # variable IS_X86_32 evaluates to a non zero positive integer | ||
100 | # otherwise if it evaluates to zero, it will act the same | ||
101 | # as if the SKIP keyword was used. | ||
102 | # | ||
103 | # The ELSE keyword can be used directly after a section with | ||
104 | # a IF statement. | ||
105 | # | ||
106 | # TEST_START IF ${RUN_NET_TESTS} | ||
107 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-network | ||
108 | # | ||
109 | # ELSE | ||
110 | # | ||
111 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-normal | ||
112 | # | ||
113 | # | ||
114 | # The ELSE keyword can also contain an IF statement to allow multiple | ||
115 | # if then else sections. But all the sections must be either | ||
116 | # DEFAULT or TEST_START, they can not be a mixture. | ||
117 | # | ||
118 | # TEST_START IF ${RUN_NET_TESTS} | ||
119 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-network | ||
120 | # | ||
121 | # ELSE IF ${RUN_DISK_TESTS} | ||
122 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-tests | ||
123 | # | ||
124 | # ELSE IF ${RUN_CPU_TESTS} | ||
125 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-cpu | ||
126 | # | ||
127 | # ELSE | ||
128 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-network | ||
129 | # | ||
130 | # The if statement may also have comparisons that will and for | ||
131 | # == and !=, strings may be used for both sides. | ||
132 | # | ||
133 | # BOX_TYPE := x86_32 | ||
134 | # | ||
135 | # DEFAULTS IF ${BOX_TYPE} == x86_32 | ||
136 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-32 | ||
137 | # ELSE | ||
138 | # BUILD_TYPE = useconfig:${CONFIG_DIR}/config-64 | ||
139 | # | ||
140 | # The DEFINED keyword can be used by the IF statements too. | ||
141 | # It returns true if the given config variable or option has been defined | ||
142 | # or false otherwise. | ||
143 | # | ||
144 | # | ||
145 | # DEFAULTS IF DEFINED USE_CC | ||
146 | # CC := ${USE_CC} | ||
147 | # ELSE | ||
148 | # CC := gcc | ||
149 | # | ||
150 | # | ||
151 | # As well as NOT DEFINED. | ||
152 | # | ||
153 | # DEFAULTS IF NOT DEFINED MAKE_CMD | ||
154 | # MAKE_CMD := make ARCH=x86 | ||
155 | # | ||
156 | # | ||
157 | # And/or ops (&&,||) may also be used to make complex conditionals. | ||
158 | # | ||
159 | # TEST_START IF (DEFINED ALL_TESTS || ${MYTEST} == boottest) && ${MACHINE} == gandalf | ||
160 | # | ||
161 | # Notice the use of parentheses. Without any parentheses the above would be | ||
162 | # processed the same as: | ||
163 | # | ||
164 | # TEST_START IF DEFINED ALL_TESTS || (${MYTEST} == boottest && ${MACHINE} == gandalf) | ||
165 | # | ||
166 | # | ||
167 | # | ||
168 | # INCLUDE file | ||
169 | # | ||
170 | # The INCLUDE keyword may be used in DEFAULT sections. This will | ||
171 | # read another config file and process that file as well. The included | ||
172 | # file can include other files, add new test cases or default | ||
173 | # statements. Config variables will be passed to these files and changes | ||
174 | # to config variables will be seen by top level config files. Including | ||
175 | # a file is processed just like the contents of the file was cut and pasted | ||
176 | # into the top level file, except, that include files that end with | ||
177 | # TEST_START sections will have that section ended at the end of | ||
178 | # the include file. That is, an included file is included followed | ||
179 | # by another DEFAULT keyword. | ||
180 | # | ||
181 | # Unlike other files referenced in this config, the file path does not need | ||
182 | # to be absolute. If the file does not start with '/', then the directory | ||
183 | # that the current config file was located in is used. If no config by the | ||
184 | # given name is found there, then the current directory is searched. | ||
185 | # | ||
186 | # INCLUDE myfile | ||
187 | # DEFAULT | ||
188 | # | ||
189 | # is the same as: | ||
190 | # | ||
191 | # INCLUDE myfile | ||
192 | # | ||
193 | # Note, if the include file does not contain a full path, the file is | ||
194 | # searched first by the location of the original include file, and then | ||
195 | # by the location that ktest.pl was executed in. | ||
196 | # | ||
197 | 75 | ||
198 | #### Config variables #### | 76 | #### Config variables #### |
199 | # | 77 | # |
@@ -332,18 +210,8 @@ | |||
332 | # from other linux builds on the system. | 210 | # from other linux builds on the system. |
333 | #LOCALVERSION = -test | 211 | #LOCALVERSION = -test |
334 | 212 | ||
335 | # For REBOOT_TYPE = grub2, you must specify where the grub.cfg | ||
336 | # file is. This is the file that is searched to find the menu | ||
337 | # option to boot to with GRUB_REBOOT | ||
338 | #GRUB_FILE = /boot/grub2/grub.cfg | ||
339 | |||
340 | # The tool for REBOOT_TYPE = grub2 to set the next reboot kernel | ||
341 | # to boot into (one shot mode). | ||
342 | # (default grub2_reboot) | ||
343 | #GRUB_REBOOT = grub2_reboot | ||
344 | |||
345 | # The grub title name for the test kernel to boot | 213 | # The grub title name for the test kernel to boot |
346 | # (Only mandatory if REBOOT_TYPE = grub or grub2) | 214 | # (Only mandatory if REBOOT_TYPE = grub) |
347 | # | 215 | # |
348 | # Note, ktest.pl will not update the grub menu.lst, you need to | 216 | # Note, ktest.pl will not update the grub menu.lst, you need to |
349 | # manually add an option for the test. ktest.pl will search | 217 | # manually add an option for the test. ktest.pl will search |
@@ -353,38 +221,10 @@ | |||
353 | # For example, if in the /boot/grub/menu.lst the test kernel title has: | 221 | # For example, if in the /boot/grub/menu.lst the test kernel title has: |
354 | # title Test Kernel | 222 | # title Test Kernel |
355 | # kernel vmlinuz-test | 223 | # kernel vmlinuz-test |
356 | # | ||
357 | # For grub2, a search of top level "menuentry"s are done. No | ||
358 | # submenu is searched. The menu is found by searching for the | ||
359 | # contents of GRUB_MENU in the line that starts with "menuentry". | ||
360 | # You may want to include the quotes around the option. For example: | ||
361 | # for: menuentry 'Test Kernel' | ||
362 | # do a: GRUB_MENU = 'Test Kernel' | ||
363 | # For customizing, add your entry in /etc/grub.d/40_custom. | ||
364 | # | ||
365 | #GRUB_MENU = Test Kernel | 224 | #GRUB_MENU = Test Kernel |
366 | 225 | ||
367 | # For REBOOT_TYPE = syslinux, the name of the syslinux executable | ||
368 | # (on the target) to use to set up the next reboot to boot the | ||
369 | # test kernel. | ||
370 | # (default extlinux) | ||
371 | #SYSLINUX = syslinux | ||
372 | |||
373 | # For REBOOT_TYPE = syslinux, the path that is passed to to the | ||
374 | # syslinux command where syslinux is installed. | ||
375 | # (default /boot/extlinux) | ||
376 | #SYSLINUX_PATH = /boot/syslinux | ||
377 | |||
378 | # For REBOOT_TYPE = syslinux, the syslinux label that references the | ||
379 | # test kernel in the syslinux config file. | ||
380 | # (default undefined) | ||
381 | #SYSLINUX_LABEL = "test-kernel" | ||
382 | |||
383 | # A script to reboot the target into the test kernel | 226 | # A script to reboot the target into the test kernel |
384 | # This and SWITCH_TO_TEST are about the same, except | 227 | # (Only mandatory if REBOOT_TYPE = script) |
385 | # SWITCH_TO_TEST is run even for REBOOT_TYPE = grub. | ||
386 | # This may be left undefined. | ||
387 | # (default undefined) | ||
388 | #REBOOT_SCRIPT = | 228 | #REBOOT_SCRIPT = |
389 | 229 | ||
390 | #### Optional Config Options (all have defaults) #### | 230 | #### Optional Config Options (all have defaults) #### |
@@ -411,30 +251,11 @@ | |||
411 | # DEFAULTS | 251 | # DEFAULTS |
412 | # DEFAULTS SKIP | 252 | # DEFAULTS SKIP |
413 | 253 | ||
414 | # If you want to execute some command before the first test runs | ||
415 | # you can set this option. Note, it can be set as a default option | ||
416 | # or an option in the first test case. All other test cases will | ||
417 | # ignore it. If both the default and first test have this option | ||
418 | # set, then the first test will take precedence. | ||
419 | # | ||
420 | # default (undefined) | ||
421 | #PRE_KTEST = ${SSH} ~/set_up_test | ||
422 | |||
423 | # If you want to execute some command after all the tests have | ||
424 | # completed, you can set this option. Note, it can be set as a | ||
425 | # default or any test case can override it. If multiple test cases | ||
426 | # set this option, then the last test case that set it will take | ||
427 | # precedence | ||
428 | # | ||
429 | # default (undefined) | ||
430 | #POST_KTEST = ${SSH} ~/dismantle_test | ||
431 | |||
432 | # The default test type (default test) | 254 | # The default test type (default test) |
433 | # The test types may be: | 255 | # The test types may be: |
434 | # build - only build the kernel, do nothing else | 256 | # build - only build the kernel, do nothing else |
435 | # install - build and install, but do nothing else (does not reboot) | 257 | # boot - build and boot the kernel |
436 | # boot - build, install, and boot the kernel | 258 | # test - build, boot and if TEST is set, run the test script |
437 | # test - build, boot and if TEST is set, run the test script | ||
438 | # (If TEST is not set, it defaults back to boot) | 259 | # (If TEST is not set, it defaults back to boot) |
439 | # bisect - Perform a bisect on the kernel (see BISECT_TYPE below) | 260 | # bisect - Perform a bisect on the kernel (see BISECT_TYPE below) |
440 | # patchcheck - Do a test on a series of commits in git (see PATCHCHECK below) | 261 | # patchcheck - Do a test on a series of commits in git (see PATCHCHECK below) |
@@ -461,14 +282,6 @@ | |||
461 | # (default "") | 282 | # (default "") |
462 | #BUILD_OPTIONS = -j20 | 283 | #BUILD_OPTIONS = -j20 |
463 | 284 | ||
464 | # If you need to do some special handling before installing | ||
465 | # you can add a script with this option. | ||
466 | # The environment variable KERNEL_VERSION will be set to the | ||
467 | # kernel version that is used. | ||
468 | # | ||
469 | # default (undefined) | ||
470 | #PRE_INSTALL = ssh user@target rm -rf '/lib/modules/*-test*' | ||
471 | |||
472 | # If you need an initrd, you can add a script or code here to install | 285 | # If you need an initrd, you can add a script or code here to install |
473 | # it. The environment variable KERNEL_VERSION will be set to the | 286 | # it. The environment variable KERNEL_VERSION will be set to the |
474 | # kernel version that is used. Remember to add the initrd line | 287 | # kernel version that is used. Remember to add the initrd line |
@@ -480,25 +293,6 @@ | |||
480 | # or on some systems: | 293 | # or on some systems: |
481 | #POST_INSTALL = ssh user@target /sbin/dracut -f /boot/initramfs-test.img $KERNEL_VERSION | 294 | #POST_INSTALL = ssh user@target /sbin/dracut -f /boot/initramfs-test.img $KERNEL_VERSION |
482 | 295 | ||
483 | # If for some reason you just want to boot the kernel and you do not | ||
484 | # want the test to install anything new. For example, you may just want | ||
485 | # to boot test the same kernel over and over and do not want to go through | ||
486 | # the hassle of installing anything, you can set this option to 1 | ||
487 | # (default 0) | ||
488 | #NO_INSTALL = 1 | ||
489 | |||
490 | # If there is a command that you want to run before the individual test | ||
491 | # case executes, then you can set this option | ||
492 | # | ||
493 | # default (undefined) | ||
494 | #PRE_TEST = ${SSH} reboot_to_special_kernel | ||
495 | |||
496 | # If there is a command you want to run after the individual test case | ||
497 | # completes, then you can set this option. | ||
498 | # | ||
499 | # default (undefined) | ||
500 | #POST_TEST = cd ${BUILD_DIR}; git reset --hard | ||
501 | |||
502 | # If there is a script that you require to run before the build is done | 296 | # If there is a script that you require to run before the build is done |
503 | # you can specify it with PRE_BUILD. | 297 | # you can specify it with PRE_BUILD. |
504 | # | 298 | # |
@@ -532,7 +326,7 @@ | |||
532 | #POST_BUILD_DIE = 1 | 326 | #POST_BUILD_DIE = 1 |
533 | 327 | ||
534 | # Way to reboot the box to the test kernel. | 328 | # Way to reboot the box to the test kernel. |
535 | # Only valid options so far are "grub", "grub2", "syslinux" and "script" | 329 | # Only valid options so far are "grub" and "script" |
536 | # (default grub) | 330 | # (default grub) |
537 | # If you specify grub, it will assume grub version 1 | 331 | # If you specify grub, it will assume grub version 1 |
538 | # and will search in /boot/grub/menu.lst for the title $GRUB_MENU | 332 | # and will search in /boot/grub/menu.lst for the title $GRUB_MENU |
@@ -540,38 +334,10 @@ | |||
540 | # your setup, then specify "script" and have a command or script | 334 | # your setup, then specify "script" and have a command or script |
541 | # specified in REBOOT_SCRIPT to boot to the target. | 335 | # specified in REBOOT_SCRIPT to boot to the target. |
542 | # | 336 | # |
543 | # For REBOOT_TYPE = grub2, you must define both GRUB_MENU and | ||
544 | # GRUB_FILE. | ||
545 | # | ||
546 | # For REBOOT_TYPE = syslinux, you must define SYSLINUX_LABEL, and | ||
547 | # perhaps modify SYSLINUX (default extlinux) and SYSLINUX_PATH | ||
548 | # (default /boot/extlinux) | ||
549 | # | ||
550 | # The entry in /boot/grub/menu.lst must be entered in manually. | 337 | # The entry in /boot/grub/menu.lst must be entered in manually. |
551 | # The test will not modify that file. | 338 | # The test will not modify that file. |
552 | #REBOOT_TYPE = grub | 339 | #REBOOT_TYPE = grub |
553 | 340 | ||
554 | # If you are using a machine that doesn't boot with grub, and | ||
555 | # perhaps gets its kernel from a remote server (tftp), then | ||
556 | # you can use this option to update the target image with the | ||
557 | # test image. | ||
558 | # | ||
559 | # You could also do the same with POST_INSTALL, but the difference | ||
560 | # between that option and this option is that POST_INSTALL runs | ||
561 | # after the install, where this one runs just before a reboot. | ||
562 | # (default undefined) | ||
563 | #SWITCH_TO_TEST = cp ${OUTPUT_DIR}/${BUILD_TARGET} ${TARGET_IMAGE} | ||
564 | |||
565 | # If you are using a machine that doesn't boot with grub, and | ||
566 | # perhaps gets its kernel from a remote server (tftp), then | ||
567 | # you can use this option to update the target image with the | ||
568 | # the known good image to reboot safely back into. | ||
569 | # | ||
570 | # This option holds a command that will execute before needing | ||
571 | # to reboot to a good known image. | ||
572 | # (default undefined) | ||
573 | #SWITCH_TO_GOOD = ssh ${SSH_USER}/${MACHINE} cp good_image ${TARGET_IMAGE} | ||
574 | |||
575 | # The min config that is needed to build for the machine | 341 | # The min config that is needed to build for the machine |
576 | # A nice way to create this is with the following: | 342 | # A nice way to create this is with the following: |
577 | # | 343 | # |
@@ -649,14 +415,6 @@ | |||
649 | # (default "login:") | 415 | # (default "login:") |
650 | #SUCCESS_LINE = login: | 416 | #SUCCESS_LINE = login: |
651 | 417 | ||
652 | # To speed up between reboots, defining a line that the | ||
653 | # default kernel produces that represents that the default | ||
654 | # kernel has successfully booted and can be used to pass | ||
655 | # a new test kernel to it. Otherwise ktest.pl will wait till | ||
656 | # SLEEP_TIME to continue. | ||
657 | # (default undefined) | ||
658 | #REBOOT_SUCCESS_LINE = login: | ||
659 | |||
660 | # In case the console constantly fills the screen, having | 418 | # In case the console constantly fills the screen, having |
661 | # a specified time to stop the test after success is recommended. | 419 | # a specified time to stop the test after success is recommended. |
662 | # (in seconds) | 420 | # (in seconds) |
@@ -693,12 +451,6 @@ | |||
693 | # (default undefined) | 451 | # (default undefined) |
694 | #STORE_FAILURES = /home/test/failures | 452 | #STORE_FAILURES = /home/test/failures |
695 | 453 | ||
696 | # Directory to store success directories on success. If this is not | ||
697 | # set, the .config, dmesg and bootlog will not be saved if a | ||
698 | # test succeeds. | ||
699 | # (default undefined) | ||
700 | #STORE_SUCCESSES = /home/test/successes | ||
701 | |||
702 | # Build without doing a make mrproper, or removing .config | 454 | # Build without doing a make mrproper, or removing .config |
703 | # (default 0) | 455 | # (default 0) |
704 | #BUILD_NOCLEAN = 0 | 456 | #BUILD_NOCLEAN = 0 |
@@ -728,8 +480,6 @@ | |||
728 | # another test. If a reboot to the reliable kernel happens, | 480 | # another test. If a reboot to the reliable kernel happens, |
729 | # we wait SLEEP_TIME for the console to stop producing output | 481 | # we wait SLEEP_TIME for the console to stop producing output |
730 | # before starting the next test. | 482 | # before starting the next test. |
731 | # | ||
732 | # You can speed up reboot times even more by setting REBOOT_SUCCESS_LINE. | ||
733 | # (default 60) | 483 | # (default 60) |
734 | #SLEEP_TIME = 60 | 484 | #SLEEP_TIME = 60 |
735 | 485 | ||
@@ -737,14 +487,6 @@ | |||
737 | # (default 60) | 487 | # (default 60) |
738 | #BISECT_SLEEP_TIME = 60 | 488 | #BISECT_SLEEP_TIME = 60 |
739 | 489 | ||
740 | # The max wait time (in seconds) for waiting for the console to finish. | ||
741 | # If for some reason, the console is outputting content without | ||
742 | # ever finishing, this will cause ktest to get stuck. This | ||
743 | # option is the max time ktest will wait for the monitor (console) | ||
744 | # to settle down before continuing. | ||
745 | # (default 1800) | ||
746 | #MAX_MONITOR_WAIT | ||
747 | |||
748 | # The time in between patch checks to sleep (in seconds) | 490 | # The time in between patch checks to sleep (in seconds) |
749 | # (default 60) | 491 | # (default 60) |
750 | #PATCHCHECK_SLEEP_TIME = 60 | 492 | #PATCHCHECK_SLEEP_TIME = 60 |
@@ -798,18 +540,10 @@ | |||
798 | # The variables SSH_USER, MACHINE and SSH_COMMAND are defined | 540 | # The variables SSH_USER, MACHINE and SSH_COMMAND are defined |
799 | #SSH_EXEC = ssh $SSH_USER@$MACHINE $SSH_COMMAND"; | 541 | #SSH_EXEC = ssh $SSH_USER@$MACHINE $SSH_COMMAND"; |
800 | 542 | ||
801 | # The way to copy a file to the target (install and modules) | 543 | # The way to copy a file to the target |
802 | # (default scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE) | 544 | # (default scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE) |
803 | # The variables SSH_USER, MACHINE are defined by the config | 545 | # The variables SSH_USER, MACHINE, SRC_FILE and DST_FILE are defined. |
804 | # SRC_FILE and DST_FILE are ktest internal variables and | 546 | #SCP_TO_TARGET = scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE |
805 | # should only have '$' and not the '${}' notation. | ||
806 | # (default scp $SRC_FILE ${SSH_USER}@${MACHINE}:$DST_FILE) | ||
807 | #SCP_TO_TARGET = echo skip scp for $SRC_FILE $DST_FILE | ||
808 | |||
809 | # If install needs to be different than modules, then this | ||
810 | # option will override the SCP_TO_TARGET for installation. | ||
811 | # (default ${SCP_TO_TARGET} ) | ||
812 | #SCP_TO_TARGET_INSTALL = scp $SRC_FILE tftp@tftpserver:$DST_FILE | ||
813 | 547 | ||
814 | # The nice way to reboot the target | 548 | # The nice way to reboot the target |
815 | # (default ssh $SSH_USER@$MACHINE reboot) | 549 | # (default ssh $SSH_USER@$MACHINE reboot) |
@@ -826,25 +560,6 @@ | |||
826 | # (default 1) | 560 | # (default 1) |
827 | #DETECT_TRIPLE_FAULT = 0 | 561 | #DETECT_TRIPLE_FAULT = 0 |
828 | 562 | ||
829 | # All options in the config file should be either used by ktest | ||
830 | # or could be used within a value of another option. If an option | ||
831 | # in the config file is not used, ktest will warn about it and ask | ||
832 | # if you want to continue. | ||
833 | # | ||
834 | # If you don't care if there are non-used options, enable this | ||
835 | # option. Be careful though, a non-used option is usually a sign | ||
836 | # of an option name being typed incorrectly. | ||
837 | # (default 0) | ||
838 | #IGNORE_UNUSED = 1 | ||
839 | |||
840 | # When testing a kernel that happens to have WARNINGs, and call | ||
841 | # traces, ktest.pl will detect these and fail a boot or test run | ||
842 | # due to warnings. By setting this option, ktest will ignore | ||
843 | # call traces, and will not fail a test if the kernel produces | ||
844 | # an oops. Use this option with care. | ||
845 | # (default 0) | ||
846 | #IGNORE_ERRORS = 1 | ||
847 | |||
848 | #### Per test run options #### | 563 | #### Per test run options #### |
849 | # The following options are only allowed in TEST_START sections. | 564 | # The following options are only allowed in TEST_START sections. |
850 | # They are ignored in the DEFAULTS sections. | 565 | # They are ignored in the DEFAULTS sections. |
@@ -1007,42 +722,6 @@ | |||
1007 | # BISECT_BAD with BISECT_CHECK = good or | 722 | # BISECT_BAD with BISECT_CHECK = good or |
1008 | # BISECT_CHECK = bad, respectively. | 723 | # BISECT_CHECK = bad, respectively. |
1009 | # | 724 | # |
1010 | # BISECT_RET_GOOD = 0 (optional, default undefined) | ||
1011 | # | ||
1012 | # In case the specificed test returns something other than just | ||
1013 | # 0 for good, and non-zero for bad, you can override 0 being | ||
1014 | # good by defining BISECT_RET_GOOD. | ||
1015 | # | ||
1016 | # BISECT_RET_BAD = 1 (optional, default undefined) | ||
1017 | # | ||
1018 | # In case the specificed test returns something other than just | ||
1019 | # 0 for good, and non-zero for bad, you can override non-zero being | ||
1020 | # bad by defining BISECT_RET_BAD. | ||
1021 | # | ||
1022 | # BISECT_RET_ABORT = 255 (optional, default undefined) | ||
1023 | # | ||
1024 | # If you need to abort the bisect if the test discovers something | ||
1025 | # that was wrong, you can define BISECT_RET_ABORT to be the error | ||
1026 | # code returned by the test in order to abort the bisect. | ||
1027 | # | ||
1028 | # BISECT_RET_SKIP = 2 (optional, default undefined) | ||
1029 | # | ||
1030 | # If the test detects that the current commit is neither good | ||
1031 | # nor bad, but something else happened (another bug detected) | ||
1032 | # you can specify BISECT_RET_SKIP to an error code that the | ||
1033 | # test returns when it should skip the current commit. | ||
1034 | # | ||
1035 | # BISECT_RET_DEFAULT = good (optional, default undefined) | ||
1036 | # | ||
1037 | # You can override the default of what to do when the above | ||
1038 | # options are not hit. This may be one of, "good", "bad", | ||
1039 | # "abort" or "skip" (without the quotes). | ||
1040 | # | ||
1041 | # Note, if you do not define any of the previous BISECT_RET_* | ||
1042 | # and define BISECT_RET_DEFAULT, all bisects results will do | ||
1043 | # what the BISECT_RET_DEFAULT has. | ||
1044 | # | ||
1045 | # | ||
1046 | # Example: | 725 | # Example: |
1047 | # TEST_START | 726 | # TEST_START |
1048 | # TEST_TYPE = bisect | 727 | # TEST_TYPE = bisect |
@@ -1127,17 +806,11 @@ | |||
1127 | # can specify it with CONFIG_BISECT_GOOD. Otherwise | 806 | # can specify it with CONFIG_BISECT_GOOD. Otherwise |
1128 | # the MIN_CONFIG is the base. | 807 | # the MIN_CONFIG is the base. |
1129 | # | 808 | # |
1130 | # CONFIG_BISECT_CHECK (optional) | ||
1131 | # Set this to 1 if you want to confirm that the config ktest | ||
1132 | # generates (the bad config with the min config) is still bad. | ||
1133 | # It may be that the min config fixes what broke the bad config | ||
1134 | # and the test will not return a result. | ||
1135 | # | ||
1136 | # Example: | 809 | # Example: |
1137 | # TEST_START | 810 | # TEST_START |
1138 | # TEST_TYPE = config_bisect | 811 | # TEST_TYPE = config_bisect |
1139 | # CONFIG_BISECT_TYPE = build | 812 | # CONFIG_BISECT_TYPE = build |
1140 | # CONFIG_BISECT = /home/test/config-bad | 813 | # CONFIG_BISECT = /home/test/¢onfig-bad |
1141 | # MIN_CONFIG = /home/test/config-min | 814 | # MIN_CONFIG = /home/test/config-min |
1142 | # BISECT_MANUAL = 1 | 815 | # BISECT_MANUAL = 1 |
1143 | # | 816 | # |
@@ -1199,26 +872,10 @@ | |||
1199 | # and will not be tested again in later runs. | 872 | # and will not be tested again in later runs. |
1200 | # (optional) | 873 | # (optional) |
1201 | # | 874 | # |
1202 | # MIN_CONFIG_TYPE can be either 'boot' or 'test'. With 'boot' it will | ||
1203 | # test if the created config can just boot the machine. If this is | ||
1204 | # set to 'test', then the TEST option must be defined and the created | ||
1205 | # config will not only boot the target, but also make sure that the | ||
1206 | # config lets the test succeed. This is useful to make sure the final | ||
1207 | # config that is generated allows network activity (ssh). | ||
1208 | # (optional) | ||
1209 | # | ||
1210 | # USE_OUTPUT_MIN_CONFIG set this to 1 if you do not want to be prompted | ||
1211 | # about using the OUTPUT_MIN_CONFIG as the MIN_CONFIG as the starting | ||
1212 | # point. Set it to 0 if you want to always just use the given MIN_CONFIG. | ||
1213 | # If it is not defined, it will prompt you to pick which config | ||
1214 | # to start with (MIN_CONFIG or OUTPUT_MIN_CONFIG). | ||
1215 | # | ||
1216 | # Example: | 875 | # Example: |
1217 | # | 876 | # |
1218 | # TEST_TYPE = make_min_config | 877 | # TEST_TYPE = make_min_config |
1219 | # OUTPUT_MIN_CONFIG = /path/to/config-new-min | 878 | # OUTPUT_MIN_CONFIG = /path/to/config-new-min |
1220 | # START_MIN_CONFIG = /path/to/config-min | 879 | # START_MIN_CONFIG = /path/to/config-min |
1221 | # IGNORE_CONFIG = /path/to/config-tested | 880 | # IGNORE_CONFIG = /path/to/config-tested |
1222 | # MIN_CONFIG_TYPE = test | ||
1223 | # TEST = ssh ${USER}@${MACHINE} echo hi | ||
1224 | # | 881 | # |
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile deleted file mode 100644 index 85baf11e2ac..00000000000 --- a/tools/testing/selftests/Makefile +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug | ||
2 | |||
3 | all: | ||
4 | for TARGET in $(TARGETS); do \ | ||
5 | make -C $$TARGET; \ | ||
6 | done; | ||
7 | |||
8 | run_tests: all | ||
9 | for TARGET in $(TARGETS); do \ | ||
10 | make -C $$TARGET run_tests; \ | ||
11 | done; | ||
12 | |||
13 | clean: | ||
14 | for TARGET in $(TARGETS); do \ | ||
15 | make -C $$TARGET clean; \ | ||
16 | done; | ||
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile deleted file mode 100644 index e18b42b254a..00000000000 --- a/tools/testing/selftests/breakpoints/Makefile +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | # Taken from perf makefile | ||
2 | uname_M := $(shell uname -m 2>/dev/null || echo not) | ||
3 | ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) | ||
4 | ifeq ($(ARCH),i386) | ||
5 | ARCH := x86 | ||
6 | endif | ||
7 | ifeq ($(ARCH),x86_64) | ||
8 | ARCH := x86 | ||
9 | endif | ||
10 | |||
11 | |||
12 | all: | ||
13 | ifeq ($(ARCH),x86) | ||
14 | gcc breakpoint_test.c -o breakpoint_test | ||
15 | else | ||
16 | echo "Not an x86 target, can't build breakpoints selftests" | ||
17 | endif | ||
18 | |||
19 | run_tests: | ||
20 | @./breakpoint_test || echo "breakpoints selftests: [FAIL]" | ||
21 | |||
22 | clean: | ||
23 | rm -fr breakpoint_test | ||
diff --git a/tools/testing/selftests/breakpoints/breakpoint_test.c b/tools/testing/selftests/breakpoints/breakpoint_test.c deleted file mode 100644 index a0743f3b2b5..00000000000 --- a/tools/testing/selftests/breakpoints/breakpoint_test.c +++ /dev/null | |||
@@ -1,394 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Red Hat, Inc., Frederic Weisbecker <fweisbec@redhat.com> | ||
3 | * | ||
4 | * Licensed under the terms of the GNU GPL License version 2 | ||
5 | * | ||
6 | * Selftests for breakpoints (and more generally the do_debug() path) in x86. | ||
7 | */ | ||
8 | |||
9 | |||
10 | #include <sys/ptrace.h> | ||
11 | #include <unistd.h> | ||
12 | #include <stddef.h> | ||
13 | #include <sys/user.h> | ||
14 | #include <stdio.h> | ||
15 | #include <stdlib.h> | ||
16 | #include <signal.h> | ||
17 | #include <sys/types.h> | ||
18 | #include <sys/wait.h> | ||
19 | |||
20 | |||
21 | /* Breakpoint access modes */ | ||
22 | enum { | ||
23 | BP_X = 1, | ||
24 | BP_RW = 2, | ||
25 | BP_W = 4, | ||
26 | }; | ||
27 | |||
28 | static pid_t child_pid; | ||
29 | |||
30 | /* | ||
31 | * Ensures the child and parent are always "talking" about | ||
32 | * the same test sequence. (ie: that we haven't forgotten | ||
33 | * to call check_trapped() somewhere). | ||
34 | */ | ||
35 | static int nr_tests; | ||
36 | |||
37 | static void set_breakpoint_addr(void *addr, int n) | ||
38 | { | ||
39 | int ret; | ||
40 | |||
41 | ret = ptrace(PTRACE_POKEUSER, child_pid, | ||
42 | offsetof(struct user, u_debugreg[n]), addr); | ||
43 | if (ret) { | ||
44 | perror("Can't set breakpoint addr\n"); | ||
45 | exit(-1); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | static void toggle_breakpoint(int n, int type, int len, | ||
50 | int local, int global, int set) | ||
51 | { | ||
52 | int ret; | ||
53 | |||
54 | int xtype, xlen; | ||
55 | unsigned long vdr7, dr7; | ||
56 | |||
57 | switch (type) { | ||
58 | case BP_X: | ||
59 | xtype = 0; | ||
60 | break; | ||
61 | case BP_W: | ||
62 | xtype = 1; | ||
63 | break; | ||
64 | case BP_RW: | ||
65 | xtype = 3; | ||
66 | break; | ||
67 | } | ||
68 | |||
69 | switch (len) { | ||
70 | case 1: | ||
71 | xlen = 0; | ||
72 | break; | ||
73 | case 2: | ||
74 | xlen = 4; | ||
75 | break; | ||
76 | case 4: | ||
77 | xlen = 0xc; | ||
78 | break; | ||
79 | case 8: | ||
80 | xlen = 8; | ||
81 | break; | ||
82 | } | ||
83 | |||
84 | dr7 = ptrace(PTRACE_PEEKUSER, child_pid, | ||
85 | offsetof(struct user, u_debugreg[7]), 0); | ||
86 | |||
87 | vdr7 = (xlen | xtype) << 16; | ||
88 | vdr7 <<= 4 * n; | ||
89 | |||
90 | if (local) { | ||
91 | vdr7 |= 1 << (2 * n); | ||
92 | vdr7 |= 1 << 8; | ||
93 | } | ||
94 | if (global) { | ||
95 | vdr7 |= 2 << (2 * n); | ||
96 | vdr7 |= 1 << 9; | ||
97 | } | ||
98 | |||
99 | if (set) | ||
100 | dr7 |= vdr7; | ||
101 | else | ||
102 | dr7 &= ~vdr7; | ||
103 | |||
104 | ret = ptrace(PTRACE_POKEUSER, child_pid, | ||
105 | offsetof(struct user, u_debugreg[7]), dr7); | ||
106 | if (ret) { | ||
107 | perror("Can't set dr7"); | ||
108 | exit(-1); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | /* Dummy variables to test read/write accesses */ | ||
113 | static unsigned long long dummy_var[4]; | ||
114 | |||
115 | /* Dummy functions to test execution accesses */ | ||
116 | static void dummy_func(void) { } | ||
117 | static void dummy_func1(void) { } | ||
118 | static void dummy_func2(void) { } | ||
119 | static void dummy_func3(void) { } | ||
120 | |||
121 | static void (*dummy_funcs[])(void) = { | ||
122 | dummy_func, | ||
123 | dummy_func1, | ||
124 | dummy_func2, | ||
125 | dummy_func3, | ||
126 | }; | ||
127 | |||
128 | static int trapped; | ||
129 | |||
130 | static void check_trapped(void) | ||
131 | { | ||
132 | /* | ||
133 | * If we haven't trapped, wake up the parent | ||
134 | * so that it notices the failure. | ||
135 | */ | ||
136 | if (!trapped) | ||
137 | kill(getpid(), SIGUSR1); | ||
138 | trapped = 0; | ||
139 | |||
140 | nr_tests++; | ||
141 | } | ||
142 | |||
143 | static void write_var(int len) | ||
144 | { | ||
145 | char *pcval; short *psval; int *pival; long long *plval; | ||
146 | int i; | ||
147 | |||
148 | for (i = 0; i < 4; i++) { | ||
149 | switch (len) { | ||
150 | case 1: | ||
151 | pcval = (char *)&dummy_var[i]; | ||
152 | *pcval = 0xff; | ||
153 | break; | ||
154 | case 2: | ||
155 | psval = (short *)&dummy_var[i]; | ||
156 | *psval = 0xffff; | ||
157 | break; | ||
158 | case 4: | ||
159 | pival = (int *)&dummy_var[i]; | ||
160 | *pival = 0xffffffff; | ||
161 | break; | ||
162 | case 8: | ||
163 | plval = (long long *)&dummy_var[i]; | ||
164 | *plval = 0xffffffffffffffffLL; | ||
165 | break; | ||
166 | } | ||
167 | check_trapped(); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | static void read_var(int len) | ||
172 | { | ||
173 | char cval; short sval; int ival; long long lval; | ||
174 | int i; | ||
175 | |||
176 | for (i = 0; i < 4; i++) { | ||
177 | switch (len) { | ||
178 | case 1: | ||
179 | cval = *(char *)&dummy_var[i]; | ||
180 | break; | ||
181 | case 2: | ||
182 | sval = *(short *)&dummy_var[i]; | ||
183 | break; | ||
184 | case 4: | ||
185 | ival = *(int *)&dummy_var[i]; | ||
186 | break; | ||
187 | case 8: | ||
188 | lval = *(long long *)&dummy_var[i]; | ||
189 | break; | ||
190 | } | ||
191 | check_trapped(); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Do the r/w/x accesses to trigger the breakpoints. And run | ||
197 | * the usual traps. | ||
198 | */ | ||
199 | static void trigger_tests(void) | ||
200 | { | ||
201 | int len, local, global, i; | ||
202 | char val; | ||
203 | int ret; | ||
204 | |||
205 | ret = ptrace(PTRACE_TRACEME, 0, NULL, 0); | ||
206 | if (ret) { | ||
207 | perror("Can't be traced?\n"); | ||
208 | return; | ||
209 | } | ||
210 | |||
211 | /* Wake up father so that it sets up the first test */ | ||
212 | kill(getpid(), SIGUSR1); | ||
213 | |||
214 | /* Test instruction breakpoints */ | ||
215 | for (local = 0; local < 2; local++) { | ||
216 | for (global = 0; global < 2; global++) { | ||
217 | if (!local && !global) | ||
218 | continue; | ||
219 | |||
220 | for (i = 0; i < 4; i++) { | ||
221 | dummy_funcs[i](); | ||
222 | check_trapped(); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /* Test write watchpoints */ | ||
228 | for (len = 1; len <= sizeof(long); len <<= 1) { | ||
229 | for (local = 0; local < 2; local++) { | ||
230 | for (global = 0; global < 2; global++) { | ||
231 | if (!local && !global) | ||
232 | continue; | ||
233 | write_var(len); | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | |||
238 | /* Test read/write watchpoints (on read accesses) */ | ||
239 | for (len = 1; len <= sizeof(long); len <<= 1) { | ||
240 | for (local = 0; local < 2; local++) { | ||
241 | for (global = 0; global < 2; global++) { | ||
242 | if (!local && !global) | ||
243 | continue; | ||
244 | read_var(len); | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /* Icebp trap */ | ||
250 | asm(".byte 0xf1\n"); | ||
251 | check_trapped(); | ||
252 | |||
253 | /* Int 3 trap */ | ||
254 | asm("int $3\n"); | ||
255 | check_trapped(); | ||
256 | |||
257 | kill(getpid(), SIGUSR1); | ||
258 | } | ||
259 | |||
260 | static void check_success(const char *msg) | ||
261 | { | ||
262 | const char *msg2; | ||
263 | int child_nr_tests; | ||
264 | int status; | ||
265 | |||
266 | /* Wait for the child to SIGTRAP */ | ||
267 | wait(&status); | ||
268 | |||
269 | msg2 = "Failed"; | ||
270 | |||
271 | if (WSTOPSIG(status) == SIGTRAP) { | ||
272 | child_nr_tests = ptrace(PTRACE_PEEKDATA, child_pid, | ||
273 | &nr_tests, 0); | ||
274 | if (child_nr_tests == nr_tests) | ||
275 | msg2 = "Ok"; | ||
276 | if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1)) { | ||
277 | perror("Can't poke\n"); | ||
278 | exit(-1); | ||
279 | } | ||
280 | } | ||
281 | |||
282 | nr_tests++; | ||
283 | |||
284 | printf("%s [%s]\n", msg, msg2); | ||
285 | } | ||
286 | |||
287 | static void launch_instruction_breakpoints(char *buf, int local, int global) | ||
288 | { | ||
289 | int i; | ||
290 | |||
291 | for (i = 0; i < 4; i++) { | ||
292 | set_breakpoint_addr(dummy_funcs[i], i); | ||
293 | toggle_breakpoint(i, BP_X, 1, local, global, 1); | ||
294 | ptrace(PTRACE_CONT, child_pid, NULL, 0); | ||
295 | sprintf(buf, "Test breakpoint %d with local: %d global: %d", | ||
296 | i, local, global); | ||
297 | check_success(buf); | ||
298 | toggle_breakpoint(i, BP_X, 1, local, global, 0); | ||
299 | } | ||
300 | } | ||
301 | |||
302 | static void launch_watchpoints(char *buf, int mode, int len, | ||
303 | int local, int global) | ||
304 | { | ||
305 | const char *mode_str; | ||
306 | int i; | ||
307 | |||
308 | if (mode == BP_W) | ||
309 | mode_str = "write"; | ||
310 | else | ||
311 | mode_str = "read"; | ||
312 | |||
313 | for (i = 0; i < 4; i++) { | ||
314 | set_breakpoint_addr(&dummy_var[i], i); | ||
315 | toggle_breakpoint(i, mode, len, local, global, 1); | ||
316 | ptrace(PTRACE_CONT, child_pid, NULL, 0); | ||
317 | sprintf(buf, "Test %s watchpoint %d with len: %d local: " | ||
318 | "%d global: %d", mode_str, i, len, local, global); | ||
319 | check_success(buf); | ||
320 | toggle_breakpoint(i, mode, len, local, global, 0); | ||
321 | } | ||
322 | } | ||
323 | |||
324 | /* Set the breakpoints and check the child successfully trigger them */ | ||
325 | static void launch_tests(void) | ||
326 | { | ||
327 | char buf[1024]; | ||
328 | int len, local, global, i; | ||
329 | |||
330 | /* Instruction breakpoints */ | ||
331 | for (local = 0; local < 2; local++) { | ||
332 | for (global = 0; global < 2; global++) { | ||
333 | if (!local && !global) | ||
334 | continue; | ||
335 | launch_instruction_breakpoints(buf, local, global); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | /* Write watchpoint */ | ||
340 | for (len = 1; len <= sizeof(long); len <<= 1) { | ||
341 | for (local = 0; local < 2; local++) { | ||
342 | for (global = 0; global < 2; global++) { | ||
343 | if (!local && !global) | ||
344 | continue; | ||
345 | launch_watchpoints(buf, BP_W, len, | ||
346 | local, global); | ||
347 | } | ||
348 | } | ||
349 | } | ||
350 | |||
351 | /* Read-Write watchpoint */ | ||
352 | for (len = 1; len <= sizeof(long); len <<= 1) { | ||
353 | for (local = 0; local < 2; local++) { | ||
354 | for (global = 0; global < 2; global++) { | ||
355 | if (!local && !global) | ||
356 | continue; | ||
357 | launch_watchpoints(buf, BP_RW, len, | ||
358 | local, global); | ||
359 | } | ||
360 | } | ||
361 | } | ||
362 | |||
363 | /* Icebp traps */ | ||
364 | ptrace(PTRACE_CONT, child_pid, NULL, 0); | ||
365 | check_success("Test icebp"); | ||
366 | |||
367 | /* Int 3 traps */ | ||
368 | ptrace(PTRACE_CONT, child_pid, NULL, 0); | ||
369 | check_success("Test int 3 trap"); | ||
370 | |||
371 | ptrace(PTRACE_CONT, child_pid, NULL, 0); | ||
372 | } | ||
373 | |||
374 | int main(int argc, char **argv) | ||
375 | { | ||
376 | pid_t pid; | ||
377 | int ret; | ||
378 | |||
379 | pid = fork(); | ||
380 | if (!pid) { | ||
381 | trigger_tests(); | ||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | child_pid = pid; | ||
386 | |||
387 | wait(NULL); | ||
388 | |||
389 | launch_tests(); | ||
390 | |||
391 | wait(NULL); | ||
392 | |||
393 | return 0; | ||
394 | } | ||
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile deleted file mode 100644 index 12657a5e4bf..00000000000 --- a/tools/testing/selftests/cpu-hotplug/Makefile +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | all: | ||
2 | |||
3 | run_tests: | ||
4 | @./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]" | ||
5 | |||
6 | clean: | ||
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh deleted file mode 100644 index bdde7cf428b..00000000000 --- a/tools/testing/selftests/cpu-hotplug/on-off-test.sh +++ /dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | SYSFS= | ||
4 | |||
5 | prerequisite() | ||
6 | { | ||
7 | msg="skip all tests:" | ||
8 | |||
9 | if [ $UID != 0 ]; then | ||
10 | echo $msg must be run as root >&2 | ||
11 | exit 0 | ||
12 | fi | ||
13 | |||
14 | SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` | ||
15 | |||
16 | if [ ! -d "$SYSFS" ]; then | ||
17 | echo $msg sysfs is not mounted >&2 | ||
18 | exit 0 | ||
19 | fi | ||
20 | |||
21 | if ! ls $SYSFS/devices/system/cpu/cpu* > /dev/null 2>&1; then | ||
22 | echo $msg cpu hotplug is not supported >&2 | ||
23 | exit 0 | ||
24 | fi | ||
25 | } | ||
26 | |||
27 | # | ||
28 | # list all hot-pluggable CPUs | ||
29 | # | ||
30 | hotpluggable_cpus() | ||
31 | { | ||
32 | local state=${1:-.\*} | ||
33 | |||
34 | for cpu in $SYSFS/devices/system/cpu/cpu*; do | ||
35 | if [ -f $cpu/online ] && grep -q $state $cpu/online; then | ||
36 | echo ${cpu##/*/cpu} | ||
37 | fi | ||
38 | done | ||
39 | } | ||
40 | |||
41 | hotplaggable_offline_cpus() | ||
42 | { | ||
43 | hotpluggable_cpus 0 | ||
44 | } | ||
45 | |||
46 | hotpluggable_online_cpus() | ||
47 | { | ||
48 | hotpluggable_cpus 1 | ||
49 | } | ||
50 | |||
51 | cpu_is_online() | ||
52 | { | ||
53 | grep -q 1 $SYSFS/devices/system/cpu/cpu$1/online | ||
54 | } | ||
55 | |||
56 | cpu_is_offline() | ||
57 | { | ||
58 | grep -q 0 $SYSFS/devices/system/cpu/cpu$1/online | ||
59 | } | ||
60 | |||
61 | online_cpu() | ||
62 | { | ||
63 | echo 1 > $SYSFS/devices/system/cpu/cpu$1/online | ||
64 | } | ||
65 | |||
66 | offline_cpu() | ||
67 | { | ||
68 | echo 0 > $SYSFS/devices/system/cpu/cpu$1/online | ||
69 | } | ||
70 | |||
71 | online_cpu_expect_success() | ||
72 | { | ||
73 | local cpu=$1 | ||
74 | |||
75 | if ! online_cpu $cpu; then | ||
76 | echo $FUNCNAME $cpu: unexpected fail >&2 | ||
77 | elif ! cpu_is_online $cpu; then | ||
78 | echo $FUNCNAME $cpu: unexpected offline >&2 | ||
79 | fi | ||
80 | } | ||
81 | |||
82 | online_cpu_expect_fail() | ||
83 | { | ||
84 | local cpu=$1 | ||
85 | |||
86 | if online_cpu $cpu 2> /dev/null; then | ||
87 | echo $FUNCNAME $cpu: unexpected success >&2 | ||
88 | elif ! cpu_is_offline $cpu; then | ||
89 | echo $FUNCNAME $cpu: unexpected online >&2 | ||
90 | fi | ||
91 | } | ||
92 | |||
93 | offline_cpu_expect_success() | ||
94 | { | ||
95 | local cpu=$1 | ||
96 | |||
97 | if ! offline_cpu $cpu; then | ||
98 | echo $FUNCNAME $cpu: unexpected fail >&2 | ||
99 | elif ! cpu_is_offline $cpu; then | ||
100 | echo $FUNCNAME $cpu: unexpected offline >&2 | ||
101 | fi | ||
102 | } | ||
103 | |||
104 | offline_cpu_expect_fail() | ||
105 | { | ||
106 | local cpu=$1 | ||
107 | |||
108 | if offline_cpu $cpu 2> /dev/null; then | ||
109 | echo $FUNCNAME $cpu: unexpected success >&2 | ||
110 | elif ! cpu_is_online $cpu; then | ||
111 | echo $FUNCNAME $cpu: unexpected offline >&2 | ||
112 | fi | ||
113 | } | ||
114 | |||
115 | error=-12 | ||
116 | priority=0 | ||
117 | |||
118 | while getopts e:hp: opt; do | ||
119 | case $opt in | ||
120 | e) | ||
121 | error=$OPTARG | ||
122 | ;; | ||
123 | h) | ||
124 | echo "Usage $0 [ -e errno ] [ -p notifier-priority ]" | ||
125 | exit | ||
126 | ;; | ||
127 | p) | ||
128 | priority=$OPTARG | ||
129 | ;; | ||
130 | esac | ||
131 | done | ||
132 | |||
133 | if ! [ "$error" -ge -4095 -a "$error" -lt 0 ]; then | ||
134 | echo "error code must be -4095 <= errno < 0" >&2 | ||
135 | exit 1 | ||
136 | fi | ||
137 | |||
138 | prerequisite | ||
139 | |||
140 | # | ||
141 | # Online all hot-pluggable CPUs | ||
142 | # | ||
143 | for cpu in `hotplaggable_offline_cpus`; do | ||
144 | online_cpu_expect_success $cpu | ||
145 | done | ||
146 | |||
147 | # | ||
148 | # Offline all hot-pluggable CPUs | ||
149 | # | ||
150 | for cpu in `hotpluggable_online_cpus`; do | ||
151 | offline_cpu_expect_success $cpu | ||
152 | done | ||
153 | |||
154 | # | ||
155 | # Online all hot-pluggable CPUs again | ||
156 | # | ||
157 | for cpu in `hotplaggable_offline_cpus`; do | ||
158 | online_cpu_expect_success $cpu | ||
159 | done | ||
160 | |||
161 | # | ||
162 | # Test with cpu notifier error injection | ||
163 | # | ||
164 | |||
165 | DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3 }'` | ||
166 | NOTIFIER_ERR_INJECT_DIR=$DEBUGFS/notifier-error-inject/cpu | ||
167 | |||
168 | prerequisite_extra() | ||
169 | { | ||
170 | msg="skip extra tests:" | ||
171 | |||
172 | /sbin/modprobe -q -r cpu-notifier-error-inject | ||
173 | /sbin/modprobe -q cpu-notifier-error-inject priority=$priority | ||
174 | |||
175 | if [ ! -d "$DEBUGFS" ]; then | ||
176 | echo $msg debugfs is not mounted >&2 | ||
177 | exit 0 | ||
178 | fi | ||
179 | |||
180 | if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then | ||
181 | echo $msg cpu-notifier-error-inject module is not available >&2 | ||
182 | exit 0 | ||
183 | fi | ||
184 | } | ||
185 | |||
186 | prerequisite_extra | ||
187 | |||
188 | # | ||
189 | # Offline all hot-pluggable CPUs | ||
190 | # | ||
191 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error | ||
192 | for cpu in `hotpluggable_online_cpus`; do | ||
193 | offline_cpu_expect_success $cpu | ||
194 | done | ||
195 | |||
196 | # | ||
197 | # Test CPU hot-add error handling (offline => online) | ||
198 | # | ||
199 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error | ||
200 | for cpu in `hotplaggable_offline_cpus`; do | ||
201 | online_cpu_expect_fail $cpu | ||
202 | done | ||
203 | |||
204 | # | ||
205 | # Online all hot-pluggable CPUs | ||
206 | # | ||
207 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error | ||
208 | for cpu in `hotplaggable_offline_cpus`; do | ||
209 | online_cpu_expect_success $cpu | ||
210 | done | ||
211 | |||
212 | # | ||
213 | # Test CPU hot-remove error handling (online => offline) | ||
214 | # | ||
215 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error | ||
216 | for cpu in `hotpluggable_online_cpus`; do | ||
217 | offline_cpu_expect_fail $cpu | ||
218 | done | ||
219 | |||
220 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error | ||
221 | /sbin/modprobe -q -r cpu-notifier-error-inject | ||
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile deleted file mode 100644 index 5386fd7c43a..00000000000 --- a/tools/testing/selftests/ipc/Makefile +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | uname_M := $(shell uname -m 2>/dev/null || echo not) | ||
2 | ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) | ||
3 | ifeq ($(ARCH),i386) | ||
4 | ARCH := X86 | ||
5 | CFLAGS := -DCONFIG_X86_32 -D__i386__ | ||
6 | endif | ||
7 | ifeq ($(ARCH),x86_64) | ||
8 | ARCH := X86 | ||
9 | CFLAGS := -DCONFIG_X86_64 -D__x86_64__ | ||
10 | endif | ||
11 | |||
12 | CFLAGS += -I../../../../usr/include/ | ||
13 | |||
14 | all: | ||
15 | ifeq ($(ARCH),X86) | ||
16 | gcc $(CFLAGS) msgque.c -o msgque_test | ||
17 | else | ||
18 | echo "Not an x86 target, can't build msgque selftest" | ||
19 | endif | ||
20 | |||
21 | run_tests: all | ||
22 | ./msgque_test | ||
23 | |||
24 | clean: | ||
25 | rm -fr ./msgque_test | ||
diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c deleted file mode 100644 index d66418237d2..00000000000 --- a/tools/testing/selftests/ipc/msgque.c +++ /dev/null | |||
@@ -1,246 +0,0 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <stdio.h> | ||
3 | #include <string.h> | ||
4 | #include <errno.h> | ||
5 | #include <linux/msg.h> | ||
6 | #include <fcntl.h> | ||
7 | |||
8 | #define MAX_MSG_SIZE 32 | ||
9 | |||
10 | struct msg1 { | ||
11 | int msize; | ||
12 | long mtype; | ||
13 | char mtext[MAX_MSG_SIZE]; | ||
14 | }; | ||
15 | |||
16 | #define TEST_STRING "Test sysv5 msg" | ||
17 | #define MSG_TYPE 1 | ||
18 | |||
19 | #define ANOTHER_TEST_STRING "Yet another test sysv5 msg" | ||
20 | #define ANOTHER_MSG_TYPE 26538 | ||
21 | |||
22 | struct msgque_data { | ||
23 | key_t key; | ||
24 | int msq_id; | ||
25 | int qbytes; | ||
26 | int qnum; | ||
27 | int mode; | ||
28 | struct msg1 *messages; | ||
29 | }; | ||
30 | |||
31 | int restore_queue(struct msgque_data *msgque) | ||
32 | { | ||
33 | int fd, ret, id, i; | ||
34 | char buf[32]; | ||
35 | |||
36 | fd = open("/proc/sys/kernel/msg_next_id", O_WRONLY); | ||
37 | if (fd == -1) { | ||
38 | printf("Failed to open /proc/sys/kernel/msg_next_id\n"); | ||
39 | return -errno; | ||
40 | } | ||
41 | sprintf(buf, "%d", msgque->msq_id); | ||
42 | |||
43 | ret = write(fd, buf, strlen(buf)); | ||
44 | if (ret != strlen(buf)) { | ||
45 | printf("Failed to write to /proc/sys/kernel/msg_next_id\n"); | ||
46 | return -errno; | ||
47 | } | ||
48 | |||
49 | id = msgget(msgque->key, msgque->mode | IPC_CREAT | IPC_EXCL); | ||
50 | if (id == -1) { | ||
51 | printf("Failed to create queue\n"); | ||
52 | return -errno; | ||
53 | } | ||
54 | |||
55 | if (id != msgque->msq_id) { | ||
56 | printf("Restored queue has wrong id (%d instead of %d)\n", | ||
57 | id, msgque->msq_id); | ||
58 | ret = -EFAULT; | ||
59 | goto destroy; | ||
60 | } | ||
61 | |||
62 | for (i = 0; i < msgque->qnum; i++) { | ||
63 | if (msgsnd(msgque->msq_id, &msgque->messages[i].mtype, | ||
64 | msgque->messages[i].msize, IPC_NOWAIT) != 0) { | ||
65 | printf("msgsnd failed (%m)\n"); | ||
66 | ret = -errno; | ||
67 | goto destroy; | ||
68 | }; | ||
69 | } | ||
70 | return 0; | ||
71 | |||
72 | destroy: | ||
73 | if (msgctl(id, IPC_RMID, 0)) | ||
74 | printf("Failed to destroy queue: %d\n", -errno); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | int check_and_destroy_queue(struct msgque_data *msgque) | ||
79 | { | ||
80 | struct msg1 message; | ||
81 | int cnt = 0, ret; | ||
82 | |||
83 | while (1) { | ||
84 | ret = msgrcv(msgque->msq_id, &message.mtype, MAX_MSG_SIZE, | ||
85 | 0, IPC_NOWAIT); | ||
86 | if (ret < 0) { | ||
87 | if (errno == ENOMSG) | ||
88 | break; | ||
89 | printf("Failed to read IPC message: %m\n"); | ||
90 | ret = -errno; | ||
91 | goto err; | ||
92 | } | ||
93 | if (ret != msgque->messages[cnt].msize) { | ||
94 | printf("Wrong message size: %d (expected %d)\n", ret, | ||
95 | msgque->messages[cnt].msize); | ||
96 | ret = -EINVAL; | ||
97 | goto err; | ||
98 | } | ||
99 | if (message.mtype != msgque->messages[cnt].mtype) { | ||
100 | printf("Wrong message type\n"); | ||
101 | ret = -EINVAL; | ||
102 | goto err; | ||
103 | } | ||
104 | if (memcmp(message.mtext, msgque->messages[cnt].mtext, ret)) { | ||
105 | printf("Wrong message content\n"); | ||
106 | ret = -EINVAL; | ||
107 | goto err; | ||
108 | } | ||
109 | cnt++; | ||
110 | } | ||
111 | |||
112 | if (cnt != msgque->qnum) { | ||
113 | printf("Wrong message number\n"); | ||
114 | ret = -EINVAL; | ||
115 | goto err; | ||
116 | } | ||
117 | |||
118 | ret = 0; | ||
119 | err: | ||
120 | if (msgctl(msgque->msq_id, IPC_RMID, 0)) { | ||
121 | printf("Failed to destroy queue: %d\n", -errno); | ||
122 | return -errno; | ||
123 | } | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | int dump_queue(struct msgque_data *msgque) | ||
128 | { | ||
129 | struct msqid64_ds ds; | ||
130 | int kern_id; | ||
131 | int i, ret; | ||
132 | |||
133 | for (kern_id = 0; kern_id < 256; kern_id++) { | ||
134 | ret = msgctl(kern_id, MSG_STAT, &ds); | ||
135 | if (ret < 0) { | ||
136 | if (errno == -EINVAL) | ||
137 | continue; | ||
138 | printf("Failed to get stats for IPC queue with id %d\n", | ||
139 | kern_id); | ||
140 | return -errno; | ||
141 | } | ||
142 | |||
143 | if (ret == msgque->msq_id) | ||
144 | break; | ||
145 | } | ||
146 | |||
147 | msgque->messages = malloc(sizeof(struct msg1) * ds.msg_qnum); | ||
148 | if (msgque->messages == NULL) { | ||
149 | printf("Failed to get stats for IPC queue\n"); | ||
150 | return -ENOMEM; | ||
151 | } | ||
152 | |||
153 | msgque->qnum = ds.msg_qnum; | ||
154 | msgque->mode = ds.msg_perm.mode; | ||
155 | msgque->qbytes = ds.msg_qbytes; | ||
156 | |||
157 | for (i = 0; i < msgque->qnum; i++) { | ||
158 | ret = msgrcv(msgque->msq_id, &msgque->messages[i].mtype, | ||
159 | MAX_MSG_SIZE, i, IPC_NOWAIT | MSG_COPY); | ||
160 | if (ret < 0) { | ||
161 | printf("Failed to copy IPC message: %m (%d)\n", errno); | ||
162 | return -errno; | ||
163 | } | ||
164 | msgque->messages[i].msize = ret; | ||
165 | } | ||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | int fill_msgque(struct msgque_data *msgque) | ||
170 | { | ||
171 | struct msg1 msgbuf; | ||
172 | |||
173 | msgbuf.mtype = MSG_TYPE; | ||
174 | memcpy(msgbuf.mtext, TEST_STRING, sizeof(TEST_STRING)); | ||
175 | if (msgsnd(msgque->msq_id, &msgbuf.mtype, sizeof(TEST_STRING), | ||
176 | IPC_NOWAIT) != 0) { | ||
177 | printf("First message send failed (%m)\n"); | ||
178 | return -errno; | ||
179 | }; | ||
180 | |||
181 | msgbuf.mtype = ANOTHER_MSG_TYPE; | ||
182 | memcpy(msgbuf.mtext, ANOTHER_TEST_STRING, sizeof(ANOTHER_TEST_STRING)); | ||
183 | if (msgsnd(msgque->msq_id, &msgbuf.mtype, sizeof(ANOTHER_TEST_STRING), | ||
184 | IPC_NOWAIT) != 0) { | ||
185 | printf("Second message send failed (%m)\n"); | ||
186 | return -errno; | ||
187 | }; | ||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | int main(int argc, char **argv) | ||
192 | { | ||
193 | int msg, pid, err; | ||
194 | struct msgque_data msgque; | ||
195 | |||
196 | msgque.key = ftok(argv[0], 822155650); | ||
197 | if (msgque.key == -1) { | ||
198 | printf("Can't make key\n"); | ||
199 | return -errno; | ||
200 | } | ||
201 | |||
202 | msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666); | ||
203 | if (msgque.msq_id == -1) { | ||
204 | printf("Can't create queue\n"); | ||
205 | goto err_out; | ||
206 | } | ||
207 | |||
208 | err = fill_msgque(&msgque); | ||
209 | if (err) { | ||
210 | printf("Failed to fill queue\n"); | ||
211 | goto err_destroy; | ||
212 | } | ||
213 | |||
214 | err = dump_queue(&msgque); | ||
215 | if (err) { | ||
216 | printf("Failed to dump queue\n"); | ||
217 | goto err_destroy; | ||
218 | } | ||
219 | |||
220 | err = check_and_destroy_queue(&msgque); | ||
221 | if (err) { | ||
222 | printf("Failed to check and destroy queue\n"); | ||
223 | goto err_out; | ||
224 | } | ||
225 | |||
226 | err = restore_queue(&msgque); | ||
227 | if (err) { | ||
228 | printf("Failed to restore queue\n"); | ||
229 | goto err_destroy; | ||
230 | } | ||
231 | |||
232 | err = check_and_destroy_queue(&msgque); | ||
233 | if (err) { | ||
234 | printf("Failed to test queue\n"); | ||
235 | goto err_out; | ||
236 | } | ||
237 | return 0; | ||
238 | |||
239 | err_destroy: | ||
240 | if (msgctl(msgque.msq_id, IPC_RMID, 0)) { | ||
241 | printf("Failed to destroy queue: %d\n", -errno); | ||
242 | return -errno; | ||
243 | } | ||
244 | err_out: | ||
245 | return err; | ||
246 | } | ||
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile deleted file mode 100644 index 56eb5523dbb..00000000000 --- a/tools/testing/selftests/kcmp/Makefile +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | uname_M := $(shell uname -m 2>/dev/null || echo not) | ||
2 | ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) | ||
3 | ifeq ($(ARCH),i386) | ||
4 | ARCH := X86 | ||
5 | CFLAGS := -DCONFIG_X86_32 -D__i386__ | ||
6 | endif | ||
7 | ifeq ($(ARCH),x86_64) | ||
8 | ARCH := X86 | ||
9 | CFLAGS := -DCONFIG_X86_64 -D__x86_64__ | ||
10 | endif | ||
11 | |||
12 | CFLAGS += -I../../../../arch/x86/include/generated/ | ||
13 | CFLAGS += -I../../../../include/ | ||
14 | CFLAGS += -I../../../../usr/include/ | ||
15 | CFLAGS += -I../../../../arch/x86/include/ | ||
16 | |||
17 | all: | ||
18 | ifeq ($(ARCH),X86) | ||
19 | gcc $(CFLAGS) kcmp_test.c -o kcmp_test | ||
20 | else | ||
21 | echo "Not an x86 target, can't build kcmp selftest" | ||
22 | endif | ||
23 | |||
24 | run_tests: all | ||
25 | @./kcmp_test || echo "kcmp_test: [FAIL]" | ||
26 | |||
27 | clean: | ||
28 | rm -fr ./run_test | ||
29 | rm -fr ./test-file | ||
diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c deleted file mode 100644 index fa4f1b37e04..00000000000 --- a/tools/testing/selftests/kcmp/kcmp_test.c +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | #define _GNU_SOURCE | ||
2 | |||
3 | #include <stdio.h> | ||
4 | #include <stdlib.h> | ||
5 | #include <signal.h> | ||
6 | #include <limits.h> | ||
7 | #include <unistd.h> | ||
8 | #include <errno.h> | ||
9 | #include <string.h> | ||
10 | #include <fcntl.h> | ||
11 | |||
12 | #include <linux/unistd.h> | ||
13 | #include <linux/kcmp.h> | ||
14 | |||
15 | #include <sys/syscall.h> | ||
16 | #include <sys/types.h> | ||
17 | #include <sys/stat.h> | ||
18 | #include <sys/wait.h> | ||
19 | |||
20 | static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2) | ||
21 | { | ||
22 | return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2); | ||
23 | } | ||
24 | |||
25 | int main(int argc, char **argv) | ||
26 | { | ||
27 | const char kpath[] = "kcmp-test-file"; | ||
28 | int pid1, pid2; | ||
29 | int fd1, fd2; | ||
30 | int status; | ||
31 | |||
32 | fd1 = open(kpath, O_RDWR | O_CREAT | O_TRUNC, 0644); | ||
33 | pid1 = getpid(); | ||
34 | |||
35 | if (fd1 < 0) { | ||
36 | perror("Can't create file"); | ||
37 | exit(1); | ||
38 | } | ||
39 | |||
40 | pid2 = fork(); | ||
41 | if (pid2 < 0) { | ||
42 | perror("fork failed"); | ||
43 | exit(1); | ||
44 | } | ||
45 | |||
46 | if (!pid2) { | ||
47 | int pid2 = getpid(); | ||
48 | int ret; | ||
49 | |||
50 | fd2 = open(kpath, O_RDWR, 0644); | ||
51 | if (fd2 < 0) { | ||
52 | perror("Can't open file"); | ||
53 | exit(1); | ||
54 | } | ||
55 | |||
56 | /* An example of output and arguments */ | ||
57 | printf("pid1: %6d pid2: %6d FD: %2ld FILES: %2ld VM: %2ld " | ||
58 | "FS: %2ld SIGHAND: %2ld IO: %2ld SYSVSEM: %2ld " | ||
59 | "INV: %2ld\n", | ||
60 | pid1, pid2, | ||
61 | sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd2), | ||
62 | sys_kcmp(pid1, pid2, KCMP_FILES, 0, 0), | ||
63 | sys_kcmp(pid1, pid2, KCMP_VM, 0, 0), | ||
64 | sys_kcmp(pid1, pid2, KCMP_FS, 0, 0), | ||
65 | sys_kcmp(pid1, pid2, KCMP_SIGHAND, 0, 0), | ||
66 | sys_kcmp(pid1, pid2, KCMP_IO, 0, 0), | ||
67 | sys_kcmp(pid1, pid2, KCMP_SYSVSEM, 0, 0), | ||
68 | |||
69 | /* This one should fail */ | ||
70 | sys_kcmp(pid1, pid2, KCMP_TYPES + 1, 0, 0)); | ||
71 | |||
72 | /* This one should return same fd */ | ||
73 | ret = sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd1); | ||
74 | if (ret) { | ||
75 | printf("FAIL: 0 expected but %d returned (%s)\n", | ||
76 | ret, strerror(errno)); | ||
77 | ret = -1; | ||
78 | } else | ||
79 | printf("PASS: 0 returned as expected\n"); | ||
80 | |||
81 | /* Compare with self */ | ||
82 | ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0); | ||
83 | if (ret) { | ||
84 | printf("FAIL: 0 expected but %li returned (%s)\n", | ||
85 | ret, strerror(errno)); | ||
86 | ret = -1; | ||
87 | } else | ||
88 | printf("PASS: 0 returned as expected\n"); | ||
89 | |||
90 | exit(ret); | ||
91 | } | ||
92 | |||
93 | waitpid(pid2, &status, P_ALL); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile deleted file mode 100644 index 0f49c3f5f58..00000000000 --- a/tools/testing/selftests/memory-hotplug/Makefile +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | all: | ||
2 | |||
3 | run_tests: | ||
4 | @./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]" | ||
5 | |||
6 | clean: | ||
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/on-off-test.sh deleted file mode 100644 index a2816f63154..00000000000 --- a/tools/testing/selftests/memory-hotplug/on-off-test.sh +++ /dev/null | |||
@@ -1,230 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | SYSFS= | ||
4 | |||
5 | prerequisite() | ||
6 | { | ||
7 | msg="skip all tests:" | ||
8 | |||
9 | if [ $UID != 0 ]; then | ||
10 | echo $msg must be run as root >&2 | ||
11 | exit 0 | ||
12 | fi | ||
13 | |||
14 | SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` | ||
15 | |||
16 | if [ ! -d "$SYSFS" ]; then | ||
17 | echo $msg sysfs is not mounted >&2 | ||
18 | exit 0 | ||
19 | fi | ||
20 | |||
21 | if ! ls $SYSFS/devices/system/memory/memory* > /dev/null 2>&1; then | ||
22 | echo $msg memory hotplug is not supported >&2 | ||
23 | exit 0 | ||
24 | fi | ||
25 | } | ||
26 | |||
27 | # | ||
28 | # list all hot-pluggable memory | ||
29 | # | ||
30 | hotpluggable_memory() | ||
31 | { | ||
32 | local state=${1:-.\*} | ||
33 | |||
34 | for memory in $SYSFS/devices/system/memory/memory*; do | ||
35 | if grep -q 1 $memory/removable && | ||
36 | grep -q $state $memory/state; then | ||
37 | echo ${memory##/*/memory} | ||
38 | fi | ||
39 | done | ||
40 | } | ||
41 | |||
42 | hotplaggable_offline_memory() | ||
43 | { | ||
44 | hotpluggable_memory offline | ||
45 | } | ||
46 | |||
47 | hotpluggable_online_memory() | ||
48 | { | ||
49 | hotpluggable_memory online | ||
50 | } | ||
51 | |||
52 | memory_is_online() | ||
53 | { | ||
54 | grep -q online $SYSFS/devices/system/memory/memory$1/state | ||
55 | } | ||
56 | |||
57 | memory_is_offline() | ||
58 | { | ||
59 | grep -q offline $SYSFS/devices/system/memory/memory$1/state | ||
60 | } | ||
61 | |||
62 | online_memory() | ||
63 | { | ||
64 | echo online > $SYSFS/devices/system/memory/memory$1/state | ||
65 | } | ||
66 | |||
67 | offline_memory() | ||
68 | { | ||
69 | echo offline > $SYSFS/devices/system/memory/memory$1/state | ||
70 | } | ||
71 | |||
72 | online_memory_expect_success() | ||
73 | { | ||
74 | local memory=$1 | ||
75 | |||
76 | if ! online_memory $memory; then | ||
77 | echo $FUNCNAME $memory: unexpected fail >&2 | ||
78 | elif ! memory_is_online $memory; then | ||
79 | echo $FUNCNAME $memory: unexpected offline >&2 | ||
80 | fi | ||
81 | } | ||
82 | |||
83 | online_memory_expect_fail() | ||
84 | { | ||
85 | local memory=$1 | ||
86 | |||
87 | if online_memory $memory 2> /dev/null; then | ||
88 | echo $FUNCNAME $memory: unexpected success >&2 | ||
89 | elif ! memory_is_offline $memory; then | ||
90 | echo $FUNCNAME $memory: unexpected online >&2 | ||
91 | fi | ||
92 | } | ||
93 | |||
94 | offline_memory_expect_success() | ||
95 | { | ||
96 | local memory=$1 | ||
97 | |||
98 | if ! offline_memory $memory; then | ||
99 | echo $FUNCNAME $memory: unexpected fail >&2 | ||
100 | elif ! memory_is_offline $memory; then | ||
101 | echo $FUNCNAME $memory: unexpected offline >&2 | ||
102 | fi | ||
103 | } | ||
104 | |||
105 | offline_memory_expect_fail() | ||
106 | { | ||
107 | local memory=$1 | ||
108 | |||
109 | if offline_memory $memory 2> /dev/null; then | ||
110 | echo $FUNCNAME $memory: unexpected success >&2 | ||
111 | elif ! memory_is_online $memory; then | ||
112 | echo $FUNCNAME $memory: unexpected offline >&2 | ||
113 | fi | ||
114 | } | ||
115 | |||
116 | error=-12 | ||
117 | priority=0 | ||
118 | ratio=10 | ||
119 | |||
120 | while getopts e:hp:r: opt; do | ||
121 | case $opt in | ||
122 | e) | ||
123 | error=$OPTARG | ||
124 | ;; | ||
125 | h) | ||
126 | echo "Usage $0 [ -e errno ] [ -p notifier-priority ] [ -r percent-of-memory-to-offline ]" | ||
127 | exit | ||
128 | ;; | ||
129 | p) | ||
130 | priority=$OPTARG | ||
131 | ;; | ||
132 | r) | ||
133 | ratio=$OPTARG | ||
134 | ;; | ||
135 | esac | ||
136 | done | ||
137 | |||
138 | if ! [ "$error" -ge -4095 -a "$error" -lt 0 ]; then | ||
139 | echo "error code must be -4095 <= errno < 0" >&2 | ||
140 | exit 1 | ||
141 | fi | ||
142 | |||
143 | prerequisite | ||
144 | |||
145 | # | ||
146 | # Online all hot-pluggable memory | ||
147 | # | ||
148 | for memory in `hotplaggable_offline_memory`; do | ||
149 | online_memory_expect_success $memory | ||
150 | done | ||
151 | |||
152 | # | ||
153 | # Offline $ratio percent of hot-pluggable memory | ||
154 | # | ||
155 | for memory in `hotpluggable_online_memory`; do | ||
156 | if [ $((RANDOM % 100)) -lt $ratio ]; then | ||
157 | offline_memory_expect_success $memory | ||
158 | fi | ||
159 | done | ||
160 | |||
161 | # | ||
162 | # Online all hot-pluggable memory again | ||
163 | # | ||
164 | for memory in `hotplaggable_offline_memory`; do | ||
165 | online_memory_expect_success $memory | ||
166 | done | ||
167 | |||
168 | # | ||
169 | # Test with memory notifier error injection | ||
170 | # | ||
171 | |||
172 | DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3 }'` | ||
173 | NOTIFIER_ERR_INJECT_DIR=$DEBUGFS/notifier-error-inject/memory | ||
174 | |||
175 | prerequisite_extra() | ||
176 | { | ||
177 | msg="skip extra tests:" | ||
178 | |||
179 | /sbin/modprobe -q -r memory-notifier-error-inject | ||
180 | /sbin/modprobe -q memory-notifier-error-inject priority=$priority | ||
181 | |||
182 | if [ ! -d "$DEBUGFS" ]; then | ||
183 | echo $msg debugfs is not mounted >&2 | ||
184 | exit 0 | ||
185 | fi | ||
186 | |||
187 | if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then | ||
188 | echo $msg memory-notifier-error-inject module is not available >&2 | ||
189 | exit 0 | ||
190 | fi | ||
191 | } | ||
192 | |||
193 | prerequisite_extra | ||
194 | |||
195 | # | ||
196 | # Offline $ratio percent of hot-pluggable memory | ||
197 | # | ||
198 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error | ||
199 | for memory in `hotpluggable_online_memory`; do | ||
200 | if [ $((RANDOM % 100)) -lt $ratio ]; then | ||
201 | offline_memory_expect_success $memory | ||
202 | fi | ||
203 | done | ||
204 | |||
205 | # | ||
206 | # Test memory hot-add error handling (offline => online) | ||
207 | # | ||
208 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error | ||
209 | for memory in `hotplaggable_offline_memory`; do | ||
210 | online_memory_expect_fail $memory | ||
211 | done | ||
212 | |||
213 | # | ||
214 | # Online all hot-pluggable memory | ||
215 | # | ||
216 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error | ||
217 | for memory in `hotplaggable_offline_memory`; do | ||
218 | online_memory_expect_success $memory | ||
219 | done | ||
220 | |||
221 | # | ||
222 | # Test memory hot-remove error handling (online => offline) | ||
223 | # | ||
224 | echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error | ||
225 | for memory in `hotpluggable_online_memory`; do | ||
226 | offline_memory_expect_fail $memory | ||
227 | done | ||
228 | |||
229 | echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error | ||
230 | /sbin/modprobe -q -r memory-notifier-error-inject | ||
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile deleted file mode 100644 index 218a122c795..00000000000 --- a/tools/testing/selftests/mqueue/Makefile +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | all: | ||
2 | gcc -O2 -lrt mq_open_tests.c -o mq_open_tests | ||
3 | gcc -O2 -lrt -lpthread -lpopt -o mq_perf_tests mq_perf_tests.c | ||
4 | |||
5 | run_tests: | ||
6 | @./mq_open_tests /test1 || echo "mq_open_tests: [FAIL]" | ||
7 | @./mq_perf_tests || echo "mq_perf_tests: [FAIL]" | ||
8 | |||
9 | clean: | ||
10 | rm -f mq_open_tests mq_perf_tests | ||
diff --git a/tools/testing/selftests/mqueue/mq_open_tests.c b/tools/testing/selftests/mqueue/mq_open_tests.c deleted file mode 100644 index 711cc292304..00000000000 --- a/tools/testing/selftests/mqueue/mq_open_tests.c +++ /dev/null | |||
@@ -1,492 +0,0 @@ | |||
1 | /* | ||
2 | * This application is Copyright 2012 Red Hat, Inc. | ||
3 | * Doug Ledford <dledford@redhat.com> | ||
4 | * | ||
5 | * mq_open_tests is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, version 3. | ||
8 | * | ||
9 | * mq_open_tests is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * For the full text of the license, see <http://www.gnu.org/licenses/>. | ||
15 | * | ||
16 | * mq_open_tests.c | ||
17 | * Tests the various situations that should either succeed or fail to | ||
18 | * open a posix message queue and then reports whether or not they | ||
19 | * did as they were supposed to. | ||
20 | * | ||
21 | */ | ||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <unistd.h> | ||
25 | #include <fcntl.h> | ||
26 | #include <string.h> | ||
27 | #include <limits.h> | ||
28 | #include <errno.h> | ||
29 | #include <sys/types.h> | ||
30 | #include <sys/time.h> | ||
31 | #include <sys/resource.h> | ||
32 | #include <sys/stat.h> | ||
33 | #include <mqueue.h> | ||
34 | |||
35 | static char *usage = | ||
36 | "Usage:\n" | ||
37 | " %s path\n" | ||
38 | "\n" | ||
39 | " path Path name of the message queue to create\n" | ||
40 | "\n" | ||
41 | " Note: this program must be run as root in order to enable all tests\n" | ||
42 | "\n"; | ||
43 | |||
44 | char *DEF_MSGS = "/proc/sys/fs/mqueue/msg_default"; | ||
45 | char *DEF_MSGSIZE = "/proc/sys/fs/mqueue/msgsize_default"; | ||
46 | char *MAX_MSGS = "/proc/sys/fs/mqueue/msg_max"; | ||
47 | char *MAX_MSGSIZE = "/proc/sys/fs/mqueue/msgsize_max"; | ||
48 | |||
49 | int default_settings; | ||
50 | struct rlimit saved_limits, cur_limits; | ||
51 | int saved_def_msgs, saved_def_msgsize, saved_max_msgs, saved_max_msgsize; | ||
52 | int cur_def_msgs, cur_def_msgsize, cur_max_msgs, cur_max_msgsize; | ||
53 | FILE *def_msgs, *def_msgsize, *max_msgs, *max_msgsize; | ||
54 | char *queue_path; | ||
55 | mqd_t queue = -1; | ||
56 | |||
57 | static inline void __set(FILE *stream, int value, char *err_msg); | ||
58 | void shutdown(int exit_val, char *err_cause, int line_no); | ||
59 | static inline int get(FILE *stream); | ||
60 | static inline void set(FILE *stream, int value); | ||
61 | static inline void getr(int type, struct rlimit *rlim); | ||
62 | static inline void setr(int type, struct rlimit *rlim); | ||
63 | void validate_current_settings(); | ||
64 | static inline void test_queue(struct mq_attr *attr, struct mq_attr *result); | ||
65 | static inline int test_queue_fail(struct mq_attr *attr, struct mq_attr *result); | ||
66 | |||
67 | static inline void __set(FILE *stream, int value, char *err_msg) | ||
68 | { | ||
69 | rewind(stream); | ||
70 | if (fprintf(stream, "%d", value) < 0) | ||
71 | perror(err_msg); | ||
72 | } | ||
73 | |||
74 | |||
75 | void shutdown(int exit_val, char *err_cause, int line_no) | ||
76 | { | ||
77 | static int in_shutdown = 0; | ||
78 | |||
79 | /* In case we get called recursively by a set() call below */ | ||
80 | if (in_shutdown++) | ||
81 | return; | ||
82 | |||
83 | seteuid(0); | ||
84 | |||
85 | if (queue != -1) | ||
86 | if (mq_close(queue)) | ||
87 | perror("mq_close() during shutdown"); | ||
88 | if (queue_path) | ||
89 | /* | ||
90 | * Be silent if this fails, if we cleaned up already it's | ||
91 | * expected to fail | ||
92 | */ | ||
93 | mq_unlink(queue_path); | ||
94 | if (default_settings) { | ||
95 | if (saved_def_msgs) | ||
96 | __set(def_msgs, saved_def_msgs, | ||
97 | "failed to restore saved_def_msgs"); | ||
98 | if (saved_def_msgsize) | ||
99 | __set(def_msgsize, saved_def_msgsize, | ||
100 | "failed to restore saved_def_msgsize"); | ||
101 | } | ||
102 | if (saved_max_msgs) | ||
103 | __set(max_msgs, saved_max_msgs, | ||
104 | "failed to restore saved_max_msgs"); | ||
105 | if (saved_max_msgsize) | ||
106 | __set(max_msgsize, saved_max_msgsize, | ||
107 | "failed to restore saved_max_msgsize"); | ||
108 | if (exit_val) | ||
109 | error(exit_val, errno, "%s at %d", err_cause, line_no); | ||
110 | exit(0); | ||
111 | } | ||
112 | |||
113 | static inline int get(FILE *stream) | ||
114 | { | ||
115 | int value; | ||
116 | rewind(stream); | ||
117 | if (fscanf(stream, "%d", &value) != 1) | ||
118 | shutdown(4, "Error reading /proc entry", __LINE__ - 1); | ||
119 | return value; | ||
120 | } | ||
121 | |||
122 | static inline void set(FILE *stream, int value) | ||
123 | { | ||
124 | int new_value; | ||
125 | |||
126 | rewind(stream); | ||
127 | if (fprintf(stream, "%d", value) < 0) | ||
128 | return shutdown(5, "Failed writing to /proc file", | ||
129 | __LINE__ - 1); | ||
130 | new_value = get(stream); | ||
131 | if (new_value != value) | ||
132 | return shutdown(5, "We didn't get what we wrote to /proc back", | ||
133 | __LINE__ - 1); | ||
134 | } | ||
135 | |||
136 | static inline void getr(int type, struct rlimit *rlim) | ||
137 | { | ||
138 | if (getrlimit(type, rlim)) | ||
139 | shutdown(6, "getrlimit()", __LINE__ - 1); | ||
140 | } | ||
141 | |||
142 | static inline void setr(int type, struct rlimit *rlim) | ||
143 | { | ||
144 | if (setrlimit(type, rlim)) | ||
145 | shutdown(7, "setrlimit()", __LINE__ - 1); | ||
146 | } | ||
147 | |||
148 | void validate_current_settings() | ||
149 | { | ||
150 | int rlim_needed; | ||
151 | |||
152 | if (cur_limits.rlim_cur < 4096) { | ||
153 | printf("Current rlimit value for POSIX message queue bytes is " | ||
154 | "unreasonably low,\nincreasing.\n\n"); | ||
155 | cur_limits.rlim_cur = 8192; | ||
156 | cur_limits.rlim_max = 16384; | ||
157 | setr(RLIMIT_MSGQUEUE, &cur_limits); | ||
158 | } | ||
159 | |||
160 | if (default_settings) { | ||
161 | rlim_needed = (cur_def_msgs + 1) * (cur_def_msgsize + 1 + | ||
162 | 2 * sizeof(void *)); | ||
163 | if (rlim_needed > cur_limits.rlim_cur) { | ||
164 | printf("Temporarily lowering default queue parameters " | ||
165 | "to something that will work\n" | ||
166 | "with the current rlimit values.\n\n"); | ||
167 | set(def_msgs, 10); | ||
168 | cur_def_msgs = 10; | ||
169 | set(def_msgsize, 128); | ||
170 | cur_def_msgsize = 128; | ||
171 | } | ||
172 | } else { | ||
173 | rlim_needed = (cur_max_msgs + 1) * (cur_max_msgsize + 1 + | ||
174 | 2 * sizeof(void *)); | ||
175 | if (rlim_needed > cur_limits.rlim_cur) { | ||
176 | printf("Temporarily lowering maximum queue parameters " | ||
177 | "to something that will work\n" | ||
178 | "with the current rlimit values in case this is " | ||
179 | "a kernel that ties the default\n" | ||
180 | "queue parameters to the maximum queue " | ||
181 | "parameters.\n\n"); | ||
182 | set(max_msgs, 10); | ||
183 | cur_max_msgs = 10; | ||
184 | set(max_msgsize, 128); | ||
185 | cur_max_msgsize = 128; | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * test_queue - Test opening a queue, shutdown if we fail. This should | ||
192 | * only be called in situations that should never fail. We clean up | ||
193 | * after ourselves and return the queue attributes in *result. | ||
194 | */ | ||
195 | static inline void test_queue(struct mq_attr *attr, struct mq_attr *result) | ||
196 | { | ||
197 | int flags = O_RDWR | O_EXCL | O_CREAT; | ||
198 | int perms = DEFFILEMODE; | ||
199 | |||
200 | if ((queue = mq_open(queue_path, flags, perms, attr)) == -1) | ||
201 | shutdown(1, "mq_open()", __LINE__); | ||
202 | if (mq_getattr(queue, result)) | ||
203 | shutdown(1, "mq_getattr()", __LINE__); | ||
204 | if (mq_close(queue)) | ||
205 | shutdown(1, "mq_close()", __LINE__); | ||
206 | queue = -1; | ||
207 | if (mq_unlink(queue_path)) | ||
208 | shutdown(1, "mq_unlink()", __LINE__); | ||
209 | } | ||
210 | |||
211 | /* | ||
212 | * Same as test_queue above, but failure is not fatal. | ||
213 | * Returns: | ||
214 | * 0 - Failed to create a queue | ||
215 | * 1 - Created a queue, attributes in *result | ||
216 | */ | ||
217 | static inline int test_queue_fail(struct mq_attr *attr, struct mq_attr *result) | ||
218 | { | ||
219 | int flags = O_RDWR | O_EXCL | O_CREAT; | ||
220 | int perms = DEFFILEMODE; | ||
221 | |||
222 | if ((queue = mq_open(queue_path, flags, perms, attr)) == -1) | ||
223 | return 0; | ||
224 | if (mq_getattr(queue, result)) | ||
225 | shutdown(1, "mq_getattr()", __LINE__); | ||
226 | if (mq_close(queue)) | ||
227 | shutdown(1, "mq_close()", __LINE__); | ||
228 | queue = -1; | ||
229 | if (mq_unlink(queue_path)) | ||
230 | shutdown(1, "mq_unlink()", __LINE__); | ||
231 | return 1; | ||
232 | } | ||
233 | |||
234 | int main(int argc, char *argv[]) | ||
235 | { | ||
236 | struct mq_attr attr, result; | ||
237 | |||
238 | if (argc != 2) { | ||
239 | fprintf(stderr, "Must pass a valid queue name\n\n"); | ||
240 | fprintf(stderr, usage, argv[0]); | ||
241 | exit(1); | ||
242 | } | ||
243 | |||
244 | /* | ||
245 | * Although we can create a msg queue with a non-absolute path name, | ||
246 | * unlink will fail. So, if the name doesn't start with a /, add one | ||
247 | * when we save it. | ||
248 | */ | ||
249 | if (*argv[1] == '/') | ||
250 | queue_path = strdup(argv[1]); | ||
251 | else { | ||
252 | queue_path = malloc(strlen(argv[1]) + 2); | ||
253 | if (!queue_path) { | ||
254 | perror("malloc()"); | ||
255 | exit(1); | ||
256 | } | ||
257 | queue_path[0] = '/'; | ||
258 | queue_path[1] = 0; | ||
259 | strcat(queue_path, argv[1]); | ||
260 | } | ||
261 | |||
262 | if (getuid() != 0) { | ||
263 | fprintf(stderr, "Not running as root, but almost all tests " | ||
264 | "require root in order to modify\nsystem settings. " | ||
265 | "Exiting.\n"); | ||
266 | exit(1); | ||
267 | } | ||
268 | |||
269 | /* Find out what files there are for us to make tweaks in */ | ||
270 | def_msgs = fopen(DEF_MSGS, "r+"); | ||
271 | def_msgsize = fopen(DEF_MSGSIZE, "r+"); | ||
272 | max_msgs = fopen(MAX_MSGS, "r+"); | ||
273 | max_msgsize = fopen(MAX_MSGSIZE, "r+"); | ||
274 | |||
275 | if (!max_msgs) | ||
276 | shutdown(2, "Failed to open msg_max", __LINE__); | ||
277 | if (!max_msgsize) | ||
278 | shutdown(2, "Failed to open msgsize_max", __LINE__); | ||
279 | if (def_msgs || def_msgsize) | ||
280 | default_settings = 1; | ||
281 | |||
282 | /* Load up the current system values for everything we can */ | ||
283 | getr(RLIMIT_MSGQUEUE, &saved_limits); | ||
284 | cur_limits = saved_limits; | ||
285 | if (default_settings) { | ||
286 | saved_def_msgs = cur_def_msgs = get(def_msgs); | ||
287 | saved_def_msgsize = cur_def_msgsize = get(def_msgsize); | ||
288 | } | ||
289 | saved_max_msgs = cur_max_msgs = get(max_msgs); | ||
290 | saved_max_msgsize = cur_max_msgsize = get(max_msgsize); | ||
291 | |||
292 | /* Tell the user our initial state */ | ||
293 | printf("\nInitial system state:\n"); | ||
294 | printf("\tUsing queue path:\t\t%s\n", queue_path); | ||
295 | printf("\tRLIMIT_MSGQUEUE(soft):\t\t%d\n", saved_limits.rlim_cur); | ||
296 | printf("\tRLIMIT_MSGQUEUE(hard):\t\t%d\n", saved_limits.rlim_max); | ||
297 | printf("\tMaximum Message Size:\t\t%d\n", saved_max_msgsize); | ||
298 | printf("\tMaximum Queue Size:\t\t%d\n", saved_max_msgs); | ||
299 | if (default_settings) { | ||
300 | printf("\tDefault Message Size:\t\t%d\n", saved_def_msgsize); | ||
301 | printf("\tDefault Queue Size:\t\t%d\n", saved_def_msgs); | ||
302 | } else { | ||
303 | printf("\tDefault Message Size:\t\tNot Supported\n"); | ||
304 | printf("\tDefault Queue Size:\t\tNot Supported\n"); | ||
305 | } | ||
306 | printf("\n"); | ||
307 | |||
308 | validate_current_settings(); | ||
309 | |||
310 | printf("Adjusted system state for testing:\n"); | ||
311 | printf("\tRLIMIT_MSGQUEUE(soft):\t\t%d\n", cur_limits.rlim_cur); | ||
312 | printf("\tRLIMIT_MSGQUEUE(hard):\t\t%d\n", cur_limits.rlim_max); | ||
313 | printf("\tMaximum Message Size:\t\t%d\n", cur_max_msgsize); | ||
314 | printf("\tMaximum Queue Size:\t\t%d\n", cur_max_msgs); | ||
315 | if (default_settings) { | ||
316 | printf("\tDefault Message Size:\t\t%d\n", cur_def_msgsize); | ||
317 | printf("\tDefault Queue Size:\t\t%d\n", cur_def_msgs); | ||
318 | } | ||
319 | |||
320 | printf("\n\nTest series 1, behavior when no attr struct " | ||
321 | "passed to mq_open:\n"); | ||
322 | if (!default_settings) { | ||
323 | test_queue(NULL, &result); | ||
324 | printf("Given sane system settings, mq_open without an attr " | ||
325 | "struct succeeds:\tPASS\n"); | ||
326 | if (result.mq_maxmsg != cur_max_msgs || | ||
327 | result.mq_msgsize != cur_max_msgsize) { | ||
328 | printf("Kernel does not support setting the default " | ||
329 | "mq attributes,\nbut also doesn't tie the " | ||
330 | "defaults to the maximums:\t\t\tPASS\n"); | ||
331 | } else { | ||
332 | set(max_msgs, ++cur_max_msgs); | ||
333 | set(max_msgsize, ++cur_max_msgsize); | ||
334 | test_queue(NULL, &result); | ||
335 | if (result.mq_maxmsg == cur_max_msgs && | ||
336 | result.mq_msgsize == cur_max_msgsize) | ||
337 | printf("Kernel does not support setting the " | ||
338 | "default mq attributes and\n" | ||
339 | "also ties system wide defaults to " | ||
340 | "the system wide maximums:\t\t" | ||
341 | "FAIL\n"); | ||
342 | else | ||
343 | printf("Kernel does not support setting the " | ||
344 | "default mq attributes,\n" | ||
345 | "but also doesn't tie the defaults to " | ||
346 | "the maximums:\t\t\tPASS\n"); | ||
347 | } | ||
348 | } else { | ||
349 | printf("Kernel supports setting defaults separately from " | ||
350 | "maximums:\t\tPASS\n"); | ||
351 | /* | ||
352 | * While we are here, go ahead and test that the kernel | ||
353 | * properly follows the default settings | ||
354 | */ | ||
355 | test_queue(NULL, &result); | ||
356 | printf("Given sane values, mq_open without an attr struct " | ||
357 | "succeeds:\t\tPASS\n"); | ||
358 | if (result.mq_maxmsg != cur_def_msgs || | ||
359 | result.mq_msgsize != cur_def_msgsize) | ||
360 | printf("Kernel supports setting defaults, but does " | ||
361 | "not actually honor them:\tFAIL\n\n"); | ||
362 | else { | ||
363 | set(def_msgs, ++cur_def_msgs); | ||
364 | set(def_msgsize, ++cur_def_msgsize); | ||
365 | /* In case max was the same as the default */ | ||
366 | set(max_msgs, ++cur_max_msgs); | ||
367 | set(max_msgsize, ++cur_max_msgsize); | ||
368 | test_queue(NULL, &result); | ||
369 | if (result.mq_maxmsg != cur_def_msgs || | ||
370 | result.mq_msgsize != cur_def_msgsize) | ||
371 | printf("Kernel supports setting defaults, but " | ||
372 | "does not actually honor them:\t" | ||
373 | "FAIL\n"); | ||
374 | else | ||
375 | printf("Kernel properly honors default setting " | ||
376 | "knobs:\t\t\t\tPASS\n"); | ||
377 | } | ||
378 | set(def_msgs, cur_max_msgs + 1); | ||
379 | cur_def_msgs = cur_max_msgs + 1; | ||
380 | set(def_msgsize, cur_max_msgsize + 1); | ||
381 | cur_def_msgsize = cur_max_msgsize + 1; | ||
382 | if (cur_def_msgs * (cur_def_msgsize + 2 * sizeof(void *)) >= | ||
383 | cur_limits.rlim_cur) { | ||
384 | cur_limits.rlim_cur = (cur_def_msgs + 2) * | ||
385 | (cur_def_msgsize + 2 * sizeof(void *)); | ||
386 | cur_limits.rlim_max = 2 * cur_limits.rlim_cur; | ||
387 | setr(RLIMIT_MSGQUEUE, &cur_limits); | ||
388 | } | ||
389 | if (test_queue_fail(NULL, &result)) { | ||
390 | if (result.mq_maxmsg == cur_max_msgs && | ||
391 | result.mq_msgsize == cur_max_msgsize) | ||
392 | printf("Kernel properly limits default values " | ||
393 | "to lesser of default/max:\t\tPASS\n"); | ||
394 | else | ||
395 | printf("Kernel does not properly set default " | ||
396 | "queue parameters when\ndefaults > " | ||
397 | "max:\t\t\t\t\t\t\t\tFAIL\n"); | ||
398 | } else | ||
399 | printf("Kernel fails to open mq because defaults are " | ||
400 | "greater than maximums:\tFAIL\n"); | ||
401 | set(def_msgs, --cur_def_msgs); | ||
402 | set(def_msgsize, --cur_def_msgsize); | ||
403 | cur_limits.rlim_cur = cur_limits.rlim_max = cur_def_msgs * | ||
404 | cur_def_msgsize; | ||
405 | setr(RLIMIT_MSGQUEUE, &cur_limits); | ||
406 | if (test_queue_fail(NULL, &result)) | ||
407 | printf("Kernel creates queue even though defaults " | ||
408 | "would exceed\nrlimit setting:" | ||
409 | "\t\t\t\t\t\t\t\tFAIL\n"); | ||
410 | else | ||
411 | printf("Kernel properly fails to create queue when " | ||
412 | "defaults would\nexceed rlimit:" | ||
413 | "\t\t\t\t\t\t\t\tPASS\n"); | ||
414 | } | ||
415 | |||
416 | /* | ||
417 | * Test #2 - open with an attr struct that exceeds rlimit | ||
418 | */ | ||
419 | printf("\n\nTest series 2, behavior when attr struct is " | ||
420 | "passed to mq_open:\n"); | ||
421 | cur_max_msgs = 32; | ||
422 | cur_max_msgsize = cur_limits.rlim_max >> 4; | ||
423 | set(max_msgs, cur_max_msgs); | ||
424 | set(max_msgsize, cur_max_msgsize); | ||
425 | attr.mq_maxmsg = cur_max_msgs; | ||
426 | attr.mq_msgsize = cur_max_msgsize; | ||
427 | if (test_queue_fail(&attr, &result)) | ||
428 | printf("Queue open in excess of rlimit max when euid = 0 " | ||
429 | "succeeded:\t\tFAIL\n"); | ||
430 | else | ||
431 | printf("Queue open in excess of rlimit max when euid = 0 " | ||
432 | "failed:\t\tPASS\n"); | ||
433 | attr.mq_maxmsg = cur_max_msgs + 1; | ||
434 | attr.mq_msgsize = 10; | ||
435 | if (test_queue_fail(&attr, &result)) | ||
436 | printf("Queue open with mq_maxmsg > limit when euid = 0 " | ||
437 | "succeeded:\t\tPASS\n"); | ||
438 | else | ||
439 | printf("Queue open with mq_maxmsg > limit when euid = 0 " | ||
440 | "failed:\t\tFAIL\n"); | ||
441 | attr.mq_maxmsg = 1; | ||
442 | attr.mq_msgsize = cur_max_msgsize + 1; | ||
443 | if (test_queue_fail(&attr, &result)) | ||
444 | printf("Queue open with mq_msgsize > limit when euid = 0 " | ||
445 | "succeeded:\t\tPASS\n"); | ||
446 | else | ||
447 | printf("Queue open with mq_msgsize > limit when euid = 0 " | ||
448 | "failed:\t\tFAIL\n"); | ||
449 | attr.mq_maxmsg = 65536; | ||
450 | attr.mq_msgsize = 65536; | ||
451 | if (test_queue_fail(&attr, &result)) | ||
452 | printf("Queue open with total size > 2GB when euid = 0 " | ||
453 | "succeeded:\t\tFAIL\n"); | ||
454 | else | ||
455 | printf("Queue open with total size > 2GB when euid = 0 " | ||
456 | "failed:\t\t\tPASS\n"); | ||
457 | seteuid(99); | ||
458 | attr.mq_maxmsg = cur_max_msgs; | ||
459 | attr.mq_msgsize = cur_max_msgsize; | ||
460 | if (test_queue_fail(&attr, &result)) | ||
461 | printf("Queue open in excess of rlimit max when euid = 99 " | ||
462 | "succeeded:\t\tFAIL\n"); | ||
463 | else | ||
464 | printf("Queue open in excess of rlimit max when euid = 99 " | ||
465 | "failed:\t\tPASS\n"); | ||
466 | attr.mq_maxmsg = cur_max_msgs + 1; | ||
467 | attr.mq_msgsize = 10; | ||
468 | if (test_queue_fail(&attr, &result)) | ||
469 | printf("Queue open with mq_maxmsg > limit when euid = 99 " | ||
470 | "succeeded:\t\tFAIL\n"); | ||
471 | else | ||
472 | printf("Queue open with mq_maxmsg > limit when euid = 99 " | ||
473 | "failed:\t\tPASS\n"); | ||
474 | attr.mq_maxmsg = 1; | ||
475 | attr.mq_msgsize = cur_max_msgsize + 1; | ||
476 | if (test_queue_fail(&attr, &result)) | ||
477 | printf("Queue open with mq_msgsize > limit when euid = 99 " | ||
478 | "succeeded:\t\tFAIL\n"); | ||
479 | else | ||
480 | printf("Queue open with mq_msgsize > limit when euid = 99 " | ||
481 | "failed:\t\tPASS\n"); | ||
482 | attr.mq_maxmsg = 65536; | ||
483 | attr.mq_msgsize = 65536; | ||
484 | if (test_queue_fail(&attr, &result)) | ||
485 | printf("Queue open with total size > 2GB when euid = 99 " | ||
486 | "succeeded:\t\tFAIL\n"); | ||
487 | else | ||
488 | printf("Queue open with total size > 2GB when euid = 99 " | ||
489 | "failed:\t\t\tPASS\n"); | ||
490 | |||
491 | shutdown(0,"",0); | ||
492 | } | ||
diff --git a/tools/testing/selftests/mqueue/mq_perf_tests.c b/tools/testing/selftests/mqueue/mq_perf_tests.c deleted file mode 100644 index 2fadd4b9704..00000000000 --- a/tools/testing/selftests/mqueue/mq_perf_tests.c +++ /dev/null | |||
@@ -1,741 +0,0 @@ | |||
1 | /* | ||
2 | * This application is Copyright 2012 Red Hat, Inc. | ||
3 | * Doug Ledford <dledford@redhat.com> | ||
4 | * | ||
5 | * mq_perf_tests is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, version 3. | ||
8 | * | ||
9 | * mq_perf_tests is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * For the full text of the license, see <http://www.gnu.org/licenses/>. | ||
15 | * | ||
16 | * mq_perf_tests.c | ||
17 | * Tests various types of message queue workloads, concentrating on those | ||
18 | * situations that invole large message sizes, large message queue depths, | ||
19 | * or both, and reports back useful metrics about kernel message queue | ||
20 | * performance. | ||
21 | * | ||
22 | */ | ||
23 | #define _GNU_SOURCE | ||
24 | #include <stdio.h> | ||
25 | #include <stdlib.h> | ||
26 | #include <unistd.h> | ||
27 | #include <fcntl.h> | ||
28 | #include <string.h> | ||
29 | #include <limits.h> | ||
30 | #include <errno.h> | ||
31 | #include <signal.h> | ||
32 | #include <pthread.h> | ||
33 | #include <sched.h> | ||
34 | #include <sys/types.h> | ||
35 | #include <sys/time.h> | ||
36 | #include <sys/resource.h> | ||
37 | #include <sys/stat.h> | ||
38 | #include <mqueue.h> | ||
39 | #include <popt.h> | ||
40 | |||
41 | static char *usage = | ||
42 | "Usage:\n" | ||
43 | " %s [-c #[,#..] -f] path\n" | ||
44 | "\n" | ||
45 | " -c # Skip most tests and go straight to a high queue depth test\n" | ||
46 | " and then run that test continuously (useful for running at\n" | ||
47 | " the same time as some other workload to see how much the\n" | ||
48 | " cache thrashing caused by adding messages to a very deep\n" | ||
49 | " queue impacts the performance of other programs). The number\n" | ||
50 | " indicates which CPU core we should bind the process to during\n" | ||
51 | " the run. If you have more than one physical CPU, then you\n" | ||
52 | " will need one copy per physical CPU package, and you should\n" | ||
53 | " specify the CPU cores to pin ourself to via a comma separated\n" | ||
54 | " list of CPU values.\n" | ||
55 | " -f Only usable with continuous mode. Pin ourself to the CPUs\n" | ||
56 | " as requested, then instead of looping doing a high mq\n" | ||
57 | " workload, just busy loop. This will allow us to lock up a\n" | ||
58 | " single CPU just like we normally would, but without actually\n" | ||
59 | " thrashing the CPU cache. This is to make it easier to get\n" | ||
60 | " comparable numbers from some other workload running on the\n" | ||
61 | " other CPUs. One set of numbers with # CPUs locked up running\n" | ||
62 | " an mq workload, and another set of numbers with those same\n" | ||
63 | " CPUs locked away from the test workload, but not doing\n" | ||
64 | " anything to trash the cache like the mq workload might.\n" | ||
65 | " path Path name of the message queue to create\n" | ||
66 | "\n" | ||
67 | " Note: this program must be run as root in order to enable all tests\n" | ||
68 | "\n"; | ||
69 | |||
70 | char *MAX_MSGS = "/proc/sys/fs/mqueue/msg_max"; | ||
71 | char *MAX_MSGSIZE = "/proc/sys/fs/mqueue/msgsize_max"; | ||
72 | |||
73 | #define min(a, b) ((a) < (b) ? (a) : (b)) | ||
74 | #define MAX_CPUS 64 | ||
75 | char *cpu_option_string; | ||
76 | int cpus_to_pin[MAX_CPUS]; | ||
77 | int num_cpus_to_pin; | ||
78 | pthread_t cpu_threads[MAX_CPUS]; | ||
79 | pthread_t main_thread; | ||
80 | cpu_set_t *cpu_set; | ||
81 | int cpu_set_size; | ||
82 | int cpus_online; | ||
83 | |||
84 | #define MSG_SIZE 16 | ||
85 | #define TEST1_LOOPS 10000000 | ||
86 | #define TEST2_LOOPS 100000 | ||
87 | int continuous_mode; | ||
88 | int continuous_mode_fake; | ||
89 | |||
90 | struct rlimit saved_limits, cur_limits; | ||
91 | int saved_max_msgs, saved_max_msgsize; | ||
92 | int cur_max_msgs, cur_max_msgsize; | ||
93 | FILE *max_msgs, *max_msgsize; | ||
94 | int cur_nice; | ||
95 | char *queue_path = "/mq_perf_tests"; | ||
96 | mqd_t queue = -1; | ||
97 | struct mq_attr result; | ||
98 | int mq_prio_max; | ||
99 | |||
100 | const struct poptOption options[] = { | ||
101 | { | ||
102 | .longName = "continuous", | ||
103 | .shortName = 'c', | ||
104 | .argInfo = POPT_ARG_STRING, | ||
105 | .arg = &cpu_option_string, | ||
106 | .val = 'c', | ||
107 | .descrip = "Run continuous tests at a high queue depth in " | ||
108 | "order to test the effects of cache thrashing on " | ||
109 | "other tasks on the system. This test is intended " | ||
110 | "to be run on one core of each physical CPU while " | ||
111 | "some other CPU intensive task is run on all the other " | ||
112 | "cores of that same physical CPU and the other task " | ||
113 | "is timed. It is assumed that the process of adding " | ||
114 | "messages to the message queue in a tight loop will " | ||
115 | "impact that other task to some degree. Once the " | ||
116 | "tests are performed in this way, you should then " | ||
117 | "re-run the tests using fake mode in order to check " | ||
118 | "the difference in time required to perform the CPU " | ||
119 | "intensive task", | ||
120 | .argDescrip = "cpu[,cpu]", | ||
121 | }, | ||
122 | { | ||
123 | .longName = "fake", | ||
124 | .shortName = 'f', | ||
125 | .argInfo = POPT_ARG_NONE, | ||
126 | .arg = &continuous_mode_fake, | ||
127 | .val = 0, | ||
128 | .descrip = "Tie up the CPUs that we would normally tie up in" | ||
129 | "continuous mode, but don't actually do any mq stuff, " | ||
130 | "just keep the CPU busy so it can't be used to process " | ||
131 | "system level tasks as this would free up resources on " | ||
132 | "the other CPU cores and skew the comparison between " | ||
133 | "the no-mqueue work and mqueue work tests", | ||
134 | .argDescrip = NULL, | ||
135 | }, | ||
136 | { | ||
137 | .longName = "path", | ||
138 | .shortName = 'p', | ||
139 | .argInfo = POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT, | ||
140 | .arg = &queue_path, | ||
141 | .val = 'p', | ||
142 | .descrip = "The name of the path to use in the mqueue " | ||
143 | "filesystem for our tests", | ||
144 | .argDescrip = "pathname", | ||
145 | }, | ||
146 | POPT_AUTOHELP | ||
147 | POPT_TABLEEND | ||
148 | }; | ||
149 | |||
150 | static inline void __set(FILE *stream, int value, char *err_msg); | ||
151 | void shutdown(int exit_val, char *err_cause, int line_no); | ||
152 | void sig_action_SIGUSR1(int signum, siginfo_t *info, void *context); | ||
153 | void sig_action(int signum, siginfo_t *info, void *context); | ||
154 | static inline int get(FILE *stream); | ||
155 | static inline void set(FILE *stream, int value); | ||
156 | static inline int try_set(FILE *stream, int value); | ||
157 | static inline void getr(int type, struct rlimit *rlim); | ||
158 | static inline void setr(int type, struct rlimit *rlim); | ||
159 | static inline void open_queue(struct mq_attr *attr); | ||
160 | void increase_limits(void); | ||
161 | |||
162 | static inline void __set(FILE *stream, int value, char *err_msg) | ||
163 | { | ||
164 | rewind(stream); | ||
165 | if (fprintf(stream, "%d", value) < 0) | ||
166 | perror(err_msg); | ||
167 | } | ||
168 | |||
169 | |||
170 | void shutdown(int exit_val, char *err_cause, int line_no) | ||
171 | { | ||
172 | static int in_shutdown = 0; | ||
173 | int errno_at_shutdown = errno; | ||
174 | int i; | ||
175 | |||
176 | /* In case we get called by multiple threads or from an sighandler */ | ||
177 | if (in_shutdown++) | ||
178 | return; | ||
179 | |||
180 | for (i = 0; i < num_cpus_to_pin; i++) | ||
181 | if (cpu_threads[i]) { | ||
182 | pthread_kill(cpu_threads[i], SIGUSR1); | ||
183 | pthread_join(cpu_threads[i], NULL); | ||
184 | } | ||
185 | |||
186 | if (queue != -1) | ||
187 | if (mq_close(queue)) | ||
188 | perror("mq_close() during shutdown"); | ||
189 | if (queue_path) | ||
190 | /* | ||
191 | * Be silent if this fails, if we cleaned up already it's | ||
192 | * expected to fail | ||
193 | */ | ||
194 | mq_unlink(queue_path); | ||
195 | if (saved_max_msgs) | ||
196 | __set(max_msgs, saved_max_msgs, | ||
197 | "failed to restore saved_max_msgs"); | ||
198 | if (saved_max_msgsize) | ||
199 | __set(max_msgsize, saved_max_msgsize, | ||
200 | "failed to restore saved_max_msgsize"); | ||
201 | if (exit_val) | ||
202 | error(exit_val, errno_at_shutdown, "%s at %d", | ||
203 | err_cause, line_no); | ||
204 | exit(0); | ||
205 | } | ||
206 | |||
207 | void sig_action_SIGUSR1(int signum, siginfo_t *info, void *context) | ||
208 | { | ||
209 | if (pthread_self() != main_thread) | ||
210 | pthread_exit(0); | ||
211 | else { | ||
212 | fprintf(stderr, "Caught signal %d in SIGUSR1 handler, " | ||
213 | "exiting\n", signum); | ||
214 | shutdown(0, "", 0); | ||
215 | fprintf(stderr, "\n\nReturned from shutdown?!?!\n\n"); | ||
216 | exit(0); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | void sig_action(int signum, siginfo_t *info, void *context) | ||
221 | { | ||
222 | if (pthread_self() != main_thread) | ||
223 | pthread_kill(main_thread, signum); | ||
224 | else { | ||
225 | fprintf(stderr, "Caught signal %d, exiting\n", signum); | ||
226 | shutdown(0, "", 0); | ||
227 | fprintf(stderr, "\n\nReturned from shutdown?!?!\n\n"); | ||
228 | exit(0); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | static inline int get(FILE *stream) | ||
233 | { | ||
234 | int value; | ||
235 | rewind(stream); | ||
236 | if (fscanf(stream, "%d", &value) != 1) | ||
237 | shutdown(4, "Error reading /proc entry", __LINE__); | ||
238 | return value; | ||
239 | } | ||
240 | |||
241 | static inline void set(FILE *stream, int value) | ||
242 | { | ||
243 | int new_value; | ||
244 | |||
245 | rewind(stream); | ||
246 | if (fprintf(stream, "%d", value) < 0) | ||
247 | return shutdown(5, "Failed writing to /proc file", __LINE__); | ||
248 | new_value = get(stream); | ||
249 | if (new_value != value) | ||
250 | return shutdown(5, "We didn't get what we wrote to /proc back", | ||
251 | __LINE__); | ||
252 | } | ||
253 | |||
254 | static inline int try_set(FILE *stream, int value) | ||
255 | { | ||
256 | int new_value; | ||
257 | |||
258 | rewind(stream); | ||
259 | fprintf(stream, "%d", value); | ||
260 | new_value = get(stream); | ||
261 | return new_value == value; | ||
262 | } | ||
263 | |||
264 | static inline void getr(int type, struct rlimit *rlim) | ||
265 | { | ||
266 | if (getrlimit(type, rlim)) | ||
267 | shutdown(6, "getrlimit()", __LINE__); | ||
268 | } | ||
269 | |||
270 | static inline void setr(int type, struct rlimit *rlim) | ||
271 | { | ||
272 | if (setrlimit(type, rlim)) | ||
273 | shutdown(7, "setrlimit()", __LINE__); | ||
274 | } | ||
275 | |||
276 | /** | ||
277 | * open_queue - open the global queue for testing | ||
278 | * @attr - An attr struct specifying the desired queue traits | ||
279 | * @result - An attr struct that lists the actual traits the queue has | ||
280 | * | ||
281 | * This open is not allowed to fail, failure will result in an orderly | ||
282 | * shutdown of the program. The global queue_path is used to set what | ||
283 | * queue to open, the queue descriptor is saved in the global queue | ||
284 | * variable. | ||
285 | */ | ||
286 | static inline void open_queue(struct mq_attr *attr) | ||
287 | { | ||
288 | int flags = O_RDWR | O_EXCL | O_CREAT | O_NONBLOCK; | ||
289 | int perms = DEFFILEMODE; | ||
290 | |||
291 | queue = mq_open(queue_path, flags, perms, attr); | ||
292 | if (queue == -1) | ||
293 | shutdown(1, "mq_open()", __LINE__); | ||
294 | if (mq_getattr(queue, &result)) | ||
295 | shutdown(1, "mq_getattr()", __LINE__); | ||
296 | printf("\n\tQueue %s created:\n", queue_path); | ||
297 | printf("\t\tmq_flags:\t\t\t%s\n", result.mq_flags & O_NONBLOCK ? | ||
298 | "O_NONBLOCK" : "(null)"); | ||
299 | printf("\t\tmq_maxmsg:\t\t\t%d\n", result.mq_maxmsg); | ||
300 | printf("\t\tmq_msgsize:\t\t\t%d\n", result.mq_msgsize); | ||
301 | printf("\t\tmq_curmsgs:\t\t\t%d\n", result.mq_curmsgs); | ||
302 | } | ||
303 | |||
304 | void *fake_cont_thread(void *arg) | ||
305 | { | ||
306 | int i; | ||
307 | |||
308 | for (i = 0; i < num_cpus_to_pin; i++) | ||
309 | if (cpu_threads[i] == pthread_self()) | ||
310 | break; | ||
311 | printf("\tStarted fake continuous mode thread %d on CPU %d\n", i, | ||
312 | cpus_to_pin[i]); | ||
313 | while (1) | ||
314 | ; | ||
315 | } | ||
316 | |||
317 | void *cont_thread(void *arg) | ||
318 | { | ||
319 | char buff[MSG_SIZE]; | ||
320 | int i, priority; | ||
321 | |||
322 | for (i = 0; i < num_cpus_to_pin; i++) | ||
323 | if (cpu_threads[i] == pthread_self()) | ||
324 | break; | ||
325 | printf("\tStarted continuous mode thread %d on CPU %d\n", i, | ||
326 | cpus_to_pin[i]); | ||
327 | while (1) { | ||
328 | while (mq_send(queue, buff, sizeof(buff), 0) == 0) | ||
329 | ; | ||
330 | mq_receive(queue, buff, sizeof(buff), &priority); | ||
331 | } | ||
332 | } | ||
333 | |||
334 | #define drain_queue() \ | ||
335 | while (mq_receive(queue, buff, MSG_SIZE, &prio_in) == MSG_SIZE) | ||
336 | |||
337 | #define do_untimed_send() \ | ||
338 | do { \ | ||
339 | if (mq_send(queue, buff, MSG_SIZE, prio_out)) \ | ||
340 | shutdown(3, "Test send failure", __LINE__); \ | ||
341 | } while (0) | ||
342 | |||
343 | #define do_send_recv() \ | ||
344 | do { \ | ||
345 | clock_gettime(clock, &start); \ | ||
346 | if (mq_send(queue, buff, MSG_SIZE, prio_out)) \ | ||
347 | shutdown(3, "Test send failure", __LINE__); \ | ||
348 | clock_gettime(clock, &middle); \ | ||
349 | if (mq_receive(queue, buff, MSG_SIZE, &prio_in) != MSG_SIZE) \ | ||
350 | shutdown(3, "Test receive failure", __LINE__); \ | ||
351 | clock_gettime(clock, &end); \ | ||
352 | nsec = ((middle.tv_sec - start.tv_sec) * 1000000000) + \ | ||
353 | (middle.tv_nsec - start.tv_nsec); \ | ||
354 | send_total.tv_nsec += nsec; \ | ||
355 | if (send_total.tv_nsec >= 1000000000) { \ | ||
356 | send_total.tv_sec++; \ | ||
357 | send_total.tv_nsec -= 1000000000; \ | ||
358 | } \ | ||
359 | nsec = ((end.tv_sec - middle.tv_sec) * 1000000000) + \ | ||
360 | (end.tv_nsec - middle.tv_nsec); \ | ||
361 | recv_total.tv_nsec += nsec; \ | ||
362 | if (recv_total.tv_nsec >= 1000000000) { \ | ||
363 | recv_total.tv_sec++; \ | ||
364 | recv_total.tv_nsec -= 1000000000; \ | ||
365 | } \ | ||
366 | } while (0) | ||
367 | |||
368 | struct test { | ||
369 | char *desc; | ||
370 | void (*func)(int *); | ||
371 | }; | ||
372 | |||
373 | void const_prio(int *prio) | ||
374 | { | ||
375 | return; | ||
376 | } | ||
377 | |||
378 | void inc_prio(int *prio) | ||
379 | { | ||
380 | if (++*prio == mq_prio_max) | ||
381 | *prio = 0; | ||
382 | } | ||
383 | |||
384 | void dec_prio(int *prio) | ||
385 | { | ||
386 | if (--*prio < 0) | ||
387 | *prio = mq_prio_max - 1; | ||
388 | } | ||
389 | |||
390 | void random_prio(int *prio) | ||
391 | { | ||
392 | *prio = random() % mq_prio_max; | ||
393 | } | ||
394 | |||
395 | struct test test2[] = { | ||
396 | {"\n\tTest #2a: Time send/recv message, queue full, constant prio\n", | ||
397 | const_prio}, | ||
398 | {"\n\tTest #2b: Time send/recv message, queue full, increasing prio\n", | ||
399 | inc_prio}, | ||
400 | {"\n\tTest #2c: Time send/recv message, queue full, decreasing prio\n", | ||
401 | dec_prio}, | ||
402 | {"\n\tTest #2d: Time send/recv message, queue full, random prio\n", | ||
403 | random_prio}, | ||
404 | {NULL, NULL} | ||
405 | }; | ||
406 | |||
407 | /** | ||
408 | * Tests to perform (all done with MSG_SIZE messages): | ||
409 | * | ||
410 | * 1) Time to add/remove message with 0 messages on queue | ||
411 | * 1a) with constant prio | ||
412 | * 2) Time to add/remove message when queue close to capacity: | ||
413 | * 2a) with constant prio | ||
414 | * 2b) with increasing prio | ||
415 | * 2c) with decreasing prio | ||
416 | * 2d) with random prio | ||
417 | * 3) Test limits of priorities honored (double check _SC_MQ_PRIO_MAX) | ||
418 | */ | ||
419 | void *perf_test_thread(void *arg) | ||
420 | { | ||
421 | char buff[MSG_SIZE]; | ||
422 | int prio_out, prio_in; | ||
423 | int i; | ||
424 | clockid_t clock; | ||
425 | pthread_t *t; | ||
426 | struct timespec res, start, middle, end, send_total, recv_total; | ||
427 | unsigned long long nsec; | ||
428 | struct test *cur_test; | ||
429 | |||
430 | t = &cpu_threads[0]; | ||
431 | printf("\n\tStarted mqueue performance test thread on CPU %d\n", | ||
432 | cpus_to_pin[0]); | ||
433 | mq_prio_max = sysconf(_SC_MQ_PRIO_MAX); | ||
434 | if (mq_prio_max == -1) | ||
435 | shutdown(2, "sysconf(_SC_MQ_PRIO_MAX)", __LINE__); | ||
436 | if (pthread_getcpuclockid(cpu_threads[0], &clock) != 0) | ||
437 | shutdown(2, "pthread_getcpuclockid", __LINE__); | ||
438 | |||
439 | if (clock_getres(clock, &res)) | ||
440 | shutdown(2, "clock_getres()", __LINE__); | ||
441 | |||
442 | printf("\t\tMax priorities:\t\t\t%d\n", mq_prio_max); | ||
443 | printf("\t\tClock resolution:\t\t%d nsec%s\n", res.tv_nsec, | ||
444 | res.tv_nsec > 1 ? "s" : ""); | ||
445 | |||
446 | |||
447 | |||
448 | printf("\n\tTest #1: Time send/recv message, queue empty\n"); | ||
449 | printf("\t\t(%d iterations)\n", TEST1_LOOPS); | ||
450 | prio_out = 0; | ||
451 | send_total.tv_sec = 0; | ||
452 | send_total.tv_nsec = 0; | ||
453 | recv_total.tv_sec = 0; | ||
454 | recv_total.tv_nsec = 0; | ||
455 | for (i = 0; i < TEST1_LOOPS; i++) | ||
456 | do_send_recv(); | ||
457 | printf("\t\tSend msg:\t\t\t%d.%ds total time\n", | ||
458 | send_total.tv_sec, send_total.tv_nsec); | ||
459 | nsec = ((unsigned long long)send_total.tv_sec * 1000000000 + | ||
460 | send_total.tv_nsec) / TEST1_LOOPS; | ||
461 | printf("\t\t\t\t\t\t%d nsec/msg\n", nsec); | ||
462 | printf("\t\tRecv msg:\t\t\t%d.%ds total time\n", | ||
463 | recv_total.tv_sec, recv_total.tv_nsec); | ||
464 | nsec = ((unsigned long long)recv_total.tv_sec * 1000000000 + | ||
465 | recv_total.tv_nsec) / TEST1_LOOPS; | ||
466 | printf("\t\t\t\t\t\t%d nsec/msg\n", nsec); | ||
467 | |||
468 | |||
469 | for (cur_test = test2; cur_test->desc != NULL; cur_test++) { | ||
470 | printf(cur_test->desc); | ||
471 | printf("\t\t(%d iterations)\n", TEST2_LOOPS); | ||
472 | prio_out = 0; | ||
473 | send_total.tv_sec = 0; | ||
474 | send_total.tv_nsec = 0; | ||
475 | recv_total.tv_sec = 0; | ||
476 | recv_total.tv_nsec = 0; | ||
477 | printf("\t\tFilling queue..."); | ||
478 | fflush(stdout); | ||
479 | clock_gettime(clock, &start); | ||
480 | for (i = 0; i < result.mq_maxmsg - 1; i++) { | ||
481 | do_untimed_send(); | ||
482 | cur_test->func(&prio_out); | ||
483 | } | ||
484 | clock_gettime(clock, &end); | ||
485 | nsec = ((unsigned long long)(end.tv_sec - start.tv_sec) * | ||
486 | 1000000000) + (end.tv_nsec - start.tv_nsec); | ||
487 | printf("done.\t\t%lld.%llds\n", nsec / 1000000000, | ||
488 | nsec % 1000000000); | ||
489 | printf("\t\tTesting..."); | ||
490 | fflush(stdout); | ||
491 | for (i = 0; i < TEST2_LOOPS; i++) { | ||
492 | do_send_recv(); | ||
493 | cur_test->func(&prio_out); | ||
494 | } | ||
495 | printf("done.\n"); | ||
496 | printf("\t\tSend msg:\t\t\t%d.%ds total time\n", | ||
497 | send_total.tv_sec, send_total.tv_nsec); | ||
498 | nsec = ((unsigned long long)send_total.tv_sec * 1000000000 + | ||
499 | send_total.tv_nsec) / TEST2_LOOPS; | ||
500 | printf("\t\t\t\t\t\t%d nsec/msg\n", nsec); | ||
501 | printf("\t\tRecv msg:\t\t\t%d.%ds total time\n", | ||
502 | recv_total.tv_sec, recv_total.tv_nsec); | ||
503 | nsec = ((unsigned long long)recv_total.tv_sec * 1000000000 + | ||
504 | recv_total.tv_nsec) / TEST2_LOOPS; | ||
505 | printf("\t\t\t\t\t\t%d nsec/msg\n", nsec); | ||
506 | printf("\t\tDraining queue..."); | ||
507 | fflush(stdout); | ||
508 | clock_gettime(clock, &start); | ||
509 | drain_queue(); | ||
510 | clock_gettime(clock, &end); | ||
511 | nsec = ((unsigned long long)(end.tv_sec - start.tv_sec) * | ||
512 | 1000000000) + (end.tv_nsec - start.tv_nsec); | ||
513 | printf("done.\t\t%lld.%llds\n", nsec / 1000000000, | ||
514 | nsec % 1000000000); | ||
515 | } | ||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | void increase_limits(void) | ||
520 | { | ||
521 | cur_limits.rlim_cur = RLIM_INFINITY; | ||
522 | cur_limits.rlim_max = RLIM_INFINITY; | ||
523 | setr(RLIMIT_MSGQUEUE, &cur_limits); | ||
524 | while (try_set(max_msgs, cur_max_msgs += 10)) | ||
525 | ; | ||
526 | cur_max_msgs = get(max_msgs); | ||
527 | while (try_set(max_msgsize, cur_max_msgsize += 1024)) | ||
528 | ; | ||
529 | cur_max_msgsize = get(max_msgsize); | ||
530 | if (setpriority(PRIO_PROCESS, 0, -20) != 0) | ||
531 | shutdown(2, "setpriority()", __LINE__); | ||
532 | cur_nice = -20; | ||
533 | } | ||
534 | |||
535 | int main(int argc, char *argv[]) | ||
536 | { | ||
537 | struct mq_attr attr; | ||
538 | char *option, *next_option; | ||
539 | int i, cpu; | ||
540 | struct sigaction sa; | ||
541 | poptContext popt_context; | ||
542 | char rc; | ||
543 | void *retval; | ||
544 | |||
545 | main_thread = pthread_self(); | ||
546 | num_cpus_to_pin = 0; | ||
547 | |||
548 | if (sysconf(_SC_NPROCESSORS_ONLN) == -1) { | ||
549 | perror("sysconf(_SC_NPROCESSORS_ONLN)"); | ||
550 | exit(1); | ||
551 | } | ||
552 | cpus_online = min(MAX_CPUS, sysconf(_SC_NPROCESSORS_ONLN)); | ||
553 | cpu_set = CPU_ALLOC(cpus_online); | ||
554 | if (cpu_set == NULL) { | ||
555 | perror("CPU_ALLOC()"); | ||
556 | exit(1); | ||
557 | } | ||
558 | cpu_set_size = CPU_ALLOC_SIZE(cpus_online); | ||
559 | CPU_ZERO_S(cpu_set_size, cpu_set); | ||
560 | |||
561 | popt_context = poptGetContext(NULL, argc, (const char **)argv, | ||
562 | options, 0); | ||
563 | |||
564 | while ((rc = poptGetNextOpt(popt_context)) > 0) { | ||
565 | switch (rc) { | ||
566 | case 'c': | ||
567 | continuous_mode = 1; | ||
568 | option = cpu_option_string; | ||
569 | do { | ||
570 | next_option = strchr(option, ','); | ||
571 | if (next_option) | ||
572 | *next_option = '\0'; | ||
573 | cpu = atoi(option); | ||
574 | if (cpu >= cpus_online) | ||
575 | fprintf(stderr, "CPU %d exceeds " | ||
576 | "cpus online, ignoring.\n", | ||
577 | cpu); | ||
578 | else | ||
579 | cpus_to_pin[num_cpus_to_pin++] = cpu; | ||
580 | if (next_option) | ||
581 | option = ++next_option; | ||
582 | } while (next_option && num_cpus_to_pin < MAX_CPUS); | ||
583 | /* Double check that they didn't give us the same CPU | ||
584 | * more than once */ | ||
585 | for (cpu = 0; cpu < num_cpus_to_pin; cpu++) { | ||
586 | if (CPU_ISSET_S(cpus_to_pin[cpu], cpu_set_size, | ||
587 | cpu_set)) { | ||
588 | fprintf(stderr, "Any given CPU may " | ||
589 | "only be given once.\n"); | ||
590 | exit(1); | ||
591 | } else | ||
592 | CPU_SET_S(cpus_to_pin[cpu], | ||
593 | cpu_set_size, cpu_set); | ||
594 | } | ||
595 | break; | ||
596 | case 'p': | ||
597 | /* | ||
598 | * Although we can create a msg queue with a | ||
599 | * non-absolute path name, unlink will fail. So, | ||
600 | * if the name doesn't start with a /, add one | ||
601 | * when we save it. | ||
602 | */ | ||
603 | option = queue_path; | ||
604 | if (*option != '/') { | ||
605 | queue_path = malloc(strlen(option) + 2); | ||
606 | if (!queue_path) { | ||
607 | perror("malloc()"); | ||
608 | exit(1); | ||
609 | } | ||
610 | queue_path[0] = '/'; | ||
611 | queue_path[1] = 0; | ||
612 | strcat(queue_path, option); | ||
613 | free(option); | ||
614 | } | ||
615 | break; | ||
616 | } | ||
617 | } | ||
618 | |||
619 | if (continuous_mode && num_cpus_to_pin == 0) { | ||
620 | fprintf(stderr, "Must pass at least one CPU to continuous " | ||
621 | "mode.\n"); | ||
622 | poptPrintUsage(popt_context, stderr, 0); | ||
623 | exit(1); | ||
624 | } else if (!continuous_mode) { | ||
625 | num_cpus_to_pin = 1; | ||
626 | cpus_to_pin[0] = cpus_online - 1; | ||
627 | } | ||
628 | |||
629 | if (getuid() != 0) { | ||
630 | fprintf(stderr, "Not running as root, but almost all tests " | ||
631 | "require root in order to modify\nsystem settings. " | ||
632 | "Exiting.\n"); | ||
633 | exit(1); | ||
634 | } | ||
635 | |||
636 | max_msgs = fopen(MAX_MSGS, "r+"); | ||
637 | max_msgsize = fopen(MAX_MSGSIZE, "r+"); | ||
638 | if (!max_msgs) | ||
639 | shutdown(2, "Failed to open msg_max", __LINE__); | ||
640 | if (!max_msgsize) | ||
641 | shutdown(2, "Failed to open msgsize_max", __LINE__); | ||
642 | |||
643 | /* Load up the current system values for everything we can */ | ||
644 | getr(RLIMIT_MSGQUEUE, &saved_limits); | ||
645 | cur_limits = saved_limits; | ||
646 | saved_max_msgs = cur_max_msgs = get(max_msgs); | ||
647 | saved_max_msgsize = cur_max_msgsize = get(max_msgsize); | ||
648 | errno = 0; | ||
649 | cur_nice = getpriority(PRIO_PROCESS, 0); | ||
650 | if (errno) | ||
651 | shutdown(2, "getpriority()", __LINE__); | ||
652 | |||
653 | /* Tell the user our initial state */ | ||
654 | printf("\nInitial system state:\n"); | ||
655 | printf("\tUsing queue path:\t\t\t%s\n", queue_path); | ||
656 | printf("\tRLIMIT_MSGQUEUE(soft):\t\t\t%d\n", saved_limits.rlim_cur); | ||
657 | printf("\tRLIMIT_MSGQUEUE(hard):\t\t\t%d\n", saved_limits.rlim_max); | ||
658 | printf("\tMaximum Message Size:\t\t\t%d\n", saved_max_msgsize); | ||
659 | printf("\tMaximum Queue Size:\t\t\t%d\n", saved_max_msgs); | ||
660 | printf("\tNice value:\t\t\t\t%d\n", cur_nice); | ||
661 | printf("\n"); | ||
662 | |||
663 | increase_limits(); | ||
664 | |||
665 | printf("Adjusted system state for testing:\n"); | ||
666 | if (cur_limits.rlim_cur == RLIM_INFINITY) { | ||
667 | printf("\tRLIMIT_MSGQUEUE(soft):\t\t\t(unlimited)\n"); | ||
668 | printf("\tRLIMIT_MSGQUEUE(hard):\t\t\t(unlimited)\n"); | ||
669 | } else { | ||
670 | printf("\tRLIMIT_MSGQUEUE(soft):\t\t\t%d\n", | ||
671 | cur_limits.rlim_cur); | ||
672 | printf("\tRLIMIT_MSGQUEUE(hard):\t\t\t%d\n", | ||
673 | cur_limits.rlim_max); | ||
674 | } | ||
675 | printf("\tMaximum Message Size:\t\t\t%d\n", cur_max_msgsize); | ||
676 | printf("\tMaximum Queue Size:\t\t\t%d\n", cur_max_msgs); | ||
677 | printf("\tNice value:\t\t\t\t%d\n", cur_nice); | ||
678 | printf("\tContinuous mode:\t\t\t(%s)\n", continuous_mode ? | ||
679 | (continuous_mode_fake ? "fake mode" : "enabled") : | ||
680 | "disabled"); | ||
681 | printf("\tCPUs to pin:\t\t\t\t%d", cpus_to_pin[0]); | ||
682 | for (cpu = 1; cpu < num_cpus_to_pin; cpu++) | ||
683 | printf(",%d", cpus_to_pin[cpu]); | ||
684 | printf("\n"); | ||
685 | |||
686 | sa.sa_sigaction = sig_action_SIGUSR1; | ||
687 | sigemptyset(&sa.sa_mask); | ||
688 | sigaddset(&sa.sa_mask, SIGHUP); | ||
689 | sigaddset(&sa.sa_mask, SIGINT); | ||
690 | sigaddset(&sa.sa_mask, SIGQUIT); | ||
691 | sigaddset(&sa.sa_mask, SIGTERM); | ||
692 | sa.sa_flags = SA_SIGINFO; | ||
693 | if (sigaction(SIGUSR1, &sa, NULL) == -1) | ||
694 | shutdown(1, "sigaction(SIGUSR1)", __LINE__); | ||
695 | sa.sa_sigaction = sig_action; | ||
696 | if (sigaction(SIGHUP, &sa, NULL) == -1) | ||
697 | shutdown(1, "sigaction(SIGHUP)", __LINE__); | ||
698 | if (sigaction(SIGINT, &sa, NULL) == -1) | ||
699 | shutdown(1, "sigaction(SIGINT)", __LINE__); | ||
700 | if (sigaction(SIGQUIT, &sa, NULL) == -1) | ||
701 | shutdown(1, "sigaction(SIGQUIT)", __LINE__); | ||
702 | if (sigaction(SIGTERM, &sa, NULL) == -1) | ||
703 | shutdown(1, "sigaction(SIGTERM)", __LINE__); | ||
704 | |||
705 | if (!continuous_mode_fake) { | ||
706 | attr.mq_flags = O_NONBLOCK; | ||
707 | attr.mq_maxmsg = cur_max_msgs; | ||
708 | attr.mq_msgsize = MSG_SIZE; | ||
709 | open_queue(&attr); | ||
710 | } | ||
711 | for (i = 0; i < num_cpus_to_pin; i++) { | ||
712 | pthread_attr_t thread_attr; | ||
713 | void *thread_func; | ||
714 | |||
715 | if (continuous_mode_fake) | ||
716 | thread_func = &fake_cont_thread; | ||
717 | else if (continuous_mode) | ||
718 | thread_func = &cont_thread; | ||
719 | else | ||
720 | thread_func = &perf_test_thread; | ||
721 | |||
722 | CPU_ZERO_S(cpu_set_size, cpu_set); | ||
723 | CPU_SET_S(cpus_to_pin[i], cpu_set_size, cpu_set); | ||
724 | pthread_attr_init(&thread_attr); | ||
725 | pthread_attr_setaffinity_np(&thread_attr, cpu_set_size, | ||
726 | cpu_set); | ||
727 | if (pthread_create(&cpu_threads[i], &thread_attr, thread_func, | ||
728 | NULL)) | ||
729 | shutdown(1, "pthread_create()", __LINE__); | ||
730 | pthread_attr_destroy(&thread_attr); | ||
731 | } | ||
732 | |||
733 | if (!continuous_mode) { | ||
734 | pthread_join(cpu_threads[0], &retval); | ||
735 | shutdown((long)retval, "perf_test_thread()", __LINE__); | ||
736 | } else { | ||
737 | while (1) | ||
738 | sleep(1); | ||
739 | } | ||
740 | shutdown(0, "", 0); | ||
741 | } | ||
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile deleted file mode 100644 index 436d2e81868..00000000000 --- a/tools/testing/selftests/vm/Makefile +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | # Makefile for vm selftests | ||
2 | |||
3 | CC = $(CROSS_COMPILE)gcc | ||
4 | CFLAGS = -Wall | ||
5 | |||
6 | all: hugepage-mmap hugepage-shm map_hugetlb thuge-gen | ||
7 | %: %.c | ||
8 | $(CC) $(CFLAGS) -o $@ $^ | ||
9 | |||
10 | run_tests: all | ||
11 | @/bin/sh ./run_vmtests || echo "vmtests: [FAIL]" | ||
12 | |||
13 | clean: | ||
14 | $(RM) hugepage-mmap hugepage-shm map_hugetlb | ||
diff --git a/tools/testing/selftests/vm/hugepage-mmap.c b/tools/testing/selftests/vm/hugepage-mmap.c deleted file mode 100644 index a10f310d236..00000000000 --- a/tools/testing/selftests/vm/hugepage-mmap.c +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | /* | ||
2 | * hugepage-mmap: | ||
3 | * | ||
4 | * Example of using huge page memory in a user application using the mmap | ||
5 | * system call. Before running this application, make sure that the | ||
6 | * administrator has mounted the hugetlbfs filesystem (on some directory | ||
7 | * like /mnt) using the command mount -t hugetlbfs nodev /mnt. In this | ||
8 | * example, the app is requesting memory of size 256MB that is backed by | ||
9 | * huge pages. | ||
10 | * | ||
11 | * For the ia64 architecture, the Linux kernel reserves Region number 4 for | ||
12 | * huge pages. That means that if one requires a fixed address, a huge page | ||
13 | * aligned address starting with 0x800000... will be required. If a fixed | ||
14 | * address is not required, the kernel will select an address in the proper | ||
15 | * range. | ||
16 | * Other architectures, such as ppc64, i386 or x86_64 are not so constrained. | ||
17 | */ | ||
18 | |||
19 | #include <stdlib.h> | ||
20 | #include <stdio.h> | ||
21 | #include <unistd.h> | ||
22 | #include <sys/mman.h> | ||
23 | #include <fcntl.h> | ||
24 | |||
25 | #define FILE_NAME "huge/hugepagefile" | ||
26 | #define LENGTH (256UL*1024*1024) | ||
27 | #define PROTECTION (PROT_READ | PROT_WRITE) | ||
28 | |||
29 | /* Only ia64 requires this */ | ||
30 | #ifdef __ia64__ | ||
31 | #define ADDR (void *)(0x8000000000000000UL) | ||
32 | #define FLAGS (MAP_SHARED | MAP_FIXED) | ||
33 | #else | ||
34 | #define ADDR (void *)(0x0UL) | ||
35 | #define FLAGS (MAP_SHARED) | ||
36 | #endif | ||
37 | |||
38 | static void check_bytes(char *addr) | ||
39 | { | ||
40 | printf("First hex is %x\n", *((unsigned int *)addr)); | ||
41 | } | ||
42 | |||
43 | static void write_bytes(char *addr) | ||
44 | { | ||
45 | unsigned long i; | ||
46 | |||
47 | for (i = 0; i < LENGTH; i++) | ||
48 | *(addr + i) = (char)i; | ||
49 | } | ||
50 | |||
51 | static int read_bytes(char *addr) | ||
52 | { | ||
53 | unsigned long i; | ||
54 | |||
55 | check_bytes(addr); | ||
56 | for (i = 0; i < LENGTH; i++) | ||
57 | if (*(addr + i) != (char)i) { | ||
58 | printf("Mismatch at %lu\n", i); | ||
59 | return 1; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | int main(void) | ||
65 | { | ||
66 | void *addr; | ||
67 | int fd, ret; | ||
68 | |||
69 | fd = open(FILE_NAME, O_CREAT | O_RDWR, 0755); | ||
70 | if (fd < 0) { | ||
71 | perror("Open failed"); | ||
72 | exit(1); | ||
73 | } | ||
74 | |||
75 | addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, fd, 0); | ||
76 | if (addr == MAP_FAILED) { | ||
77 | perror("mmap"); | ||
78 | unlink(FILE_NAME); | ||
79 | exit(1); | ||
80 | } | ||
81 | |||
82 | printf("Returned address is %p\n", addr); | ||
83 | check_bytes(addr); | ||
84 | write_bytes(addr); | ||
85 | ret = read_bytes(addr); | ||
86 | |||
87 | munmap(addr, LENGTH); | ||
88 | close(fd); | ||
89 | unlink(FILE_NAME); | ||
90 | |||
91 | return ret; | ||
92 | } | ||
diff --git a/tools/testing/selftests/vm/hugepage-shm.c b/tools/testing/selftests/vm/hugepage-shm.c deleted file mode 100644 index 0d0ef4fc0c0..00000000000 --- a/tools/testing/selftests/vm/hugepage-shm.c +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | /* | ||
2 | * hugepage-shm: | ||
3 | * | ||
4 | * Example of using huge page memory in a user application using Sys V shared | ||
5 | * memory system calls. In this example the app is requesting 256MB of | ||
6 | * memory that is backed by huge pages. The application uses the flag | ||
7 | * SHM_HUGETLB in the shmget system call to inform the kernel that it is | ||
8 | * requesting huge pages. | ||
9 | * | ||
10 | * For the ia64 architecture, the Linux kernel reserves Region number 4 for | ||
11 | * huge pages. That means that if one requires a fixed address, a huge page | ||
12 | * aligned address starting with 0x800000... will be required. If a fixed | ||
13 | * address is not required, the kernel will select an address in the proper | ||
14 | * range. | ||
15 | * Other architectures, such as ppc64, i386 or x86_64 are not so constrained. | ||
16 | * | ||
17 | * Note: The default shared memory limit is quite low on many kernels, | ||
18 | * you may need to increase it via: | ||
19 | * | ||
20 | * echo 268435456 > /proc/sys/kernel/shmmax | ||
21 | * | ||
22 | * This will increase the maximum size per shared memory segment to 256MB. | ||
23 | * The other limit that you will hit eventually is shmall which is the | ||
24 | * total amount of shared memory in pages. To set it to 16GB on a system | ||
25 | * with a 4kB pagesize do: | ||
26 | * | ||
27 | * echo 4194304 > /proc/sys/kernel/shmall | ||
28 | */ | ||
29 | |||
30 | #include <stdlib.h> | ||
31 | #include <stdio.h> | ||
32 | #include <sys/types.h> | ||
33 | #include <sys/ipc.h> | ||
34 | #include <sys/shm.h> | ||
35 | #include <sys/mman.h> | ||
36 | |||
37 | #ifndef SHM_HUGETLB | ||
38 | #define SHM_HUGETLB 04000 | ||
39 | #endif | ||
40 | |||
41 | #define LENGTH (256UL*1024*1024) | ||
42 | |||
43 | #define dprintf(x) printf(x) | ||
44 | |||
45 | /* Only ia64 requires this */ | ||
46 | #ifdef __ia64__ | ||
47 | #define ADDR (void *)(0x8000000000000000UL) | ||
48 | #define SHMAT_FLAGS (SHM_RND) | ||
49 | #else | ||
50 | #define ADDR (void *)(0x0UL) | ||
51 | #define SHMAT_FLAGS (0) | ||
52 | #endif | ||
53 | |||
54 | int main(void) | ||
55 | { | ||
56 | int shmid; | ||
57 | unsigned long i; | ||
58 | char *shmaddr; | ||
59 | |||
60 | shmid = shmget(2, LENGTH, SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W); | ||
61 | if (shmid < 0) { | ||
62 | perror("shmget"); | ||
63 | exit(1); | ||
64 | } | ||
65 | printf("shmid: 0x%x\n", shmid); | ||
66 | |||
67 | shmaddr = shmat(shmid, ADDR, SHMAT_FLAGS); | ||
68 | if (shmaddr == (char *)-1) { | ||
69 | perror("Shared memory attach failure"); | ||
70 | shmctl(shmid, IPC_RMID, NULL); | ||
71 | exit(2); | ||
72 | } | ||
73 | printf("shmaddr: %p\n", shmaddr); | ||
74 | |||
75 | dprintf("Starting the writes:\n"); | ||
76 | for (i = 0; i < LENGTH; i++) { | ||
77 | shmaddr[i] = (char)(i); | ||
78 | if (!(i % (1024 * 1024))) | ||
79 | dprintf("."); | ||
80 | } | ||
81 | dprintf("\n"); | ||
82 | |||
83 | dprintf("Starting the Check..."); | ||
84 | for (i = 0; i < LENGTH; i++) | ||
85 | if (shmaddr[i] != (char)i) { | ||
86 | printf("\nIndex %lu mismatched\n", i); | ||
87 | exit(3); | ||
88 | } | ||
89 | dprintf("Done.\n"); | ||
90 | |||
91 | if (shmdt((const void *)shmaddr) != 0) { | ||
92 | perror("Detach failure"); | ||
93 | shmctl(shmid, IPC_RMID, NULL); | ||
94 | exit(4); | ||
95 | } | ||
96 | |||
97 | shmctl(shmid, IPC_RMID, NULL); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c deleted file mode 100644 index ac56639dd4a..00000000000 --- a/tools/testing/selftests/vm/map_hugetlb.c +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /* | ||
2 | * Example of using hugepage memory in a user application using the mmap | ||
3 | * system call with MAP_HUGETLB flag. Before running this program make | ||
4 | * sure the administrator has allocated enough default sized huge pages | ||
5 | * to cover the 256 MB allocation. | ||
6 | * | ||
7 | * For ia64 architecture, Linux kernel reserves Region number 4 for hugepages. | ||
8 | * That means the addresses starting with 0x800000... will need to be | ||
9 | * specified. Specifying a fixed address is not required on ppc64, i386 | ||
10 | * or x86_64. | ||
11 | */ | ||
12 | #include <stdlib.h> | ||
13 | #include <stdio.h> | ||
14 | #include <unistd.h> | ||
15 | #include <sys/mman.h> | ||
16 | #include <fcntl.h> | ||
17 | |||
18 | #define LENGTH (256UL*1024*1024) | ||
19 | #define PROTECTION (PROT_READ | PROT_WRITE) | ||
20 | |||
21 | #ifndef MAP_HUGETLB | ||
22 | #define MAP_HUGETLB 0x40000 /* arch specific */ | ||
23 | #endif | ||
24 | |||
25 | /* Only ia64 requires this */ | ||
26 | #ifdef __ia64__ | ||
27 | #define ADDR (void *)(0x8000000000000000UL) | ||
28 | #define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_FIXED) | ||
29 | #else | ||
30 | #define ADDR (void *)(0x0UL) | ||
31 | #define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB) | ||
32 | #endif | ||
33 | |||
34 | static void check_bytes(char *addr) | ||
35 | { | ||
36 | printf("First hex is %x\n", *((unsigned int *)addr)); | ||
37 | } | ||
38 | |||
39 | static void write_bytes(char *addr) | ||
40 | { | ||
41 | unsigned long i; | ||
42 | |||
43 | for (i = 0; i < LENGTH; i++) | ||
44 | *(addr + i) = (char)i; | ||
45 | } | ||
46 | |||
47 | static int read_bytes(char *addr) | ||
48 | { | ||
49 | unsigned long i; | ||
50 | |||
51 | check_bytes(addr); | ||
52 | for (i = 0; i < LENGTH; i++) | ||
53 | if (*(addr + i) != (char)i) { | ||
54 | printf("Mismatch at %lu\n", i); | ||
55 | return 1; | ||
56 | } | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | int main(void) | ||
61 | { | ||
62 | void *addr; | ||
63 | int ret; | ||
64 | |||
65 | addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, 0, 0); | ||
66 | if (addr == MAP_FAILED) { | ||
67 | perror("mmap"); | ||
68 | exit(1); | ||
69 | } | ||
70 | |||
71 | printf("Returned address is %p\n", addr); | ||
72 | check_bytes(addr); | ||
73 | write_bytes(addr); | ||
74 | ret = read_bytes(addr); | ||
75 | |||
76 | munmap(addr, LENGTH); | ||
77 | |||
78 | return ret; | ||
79 | } | ||
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests deleted file mode 100644 index 4c53cae6c27..00000000000 --- a/tools/testing/selftests/vm/run_vmtests +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | #please run as root | ||
3 | |||
4 | #we need 256M, below is the size in kB | ||
5 | needmem=262144 | ||
6 | mnt=./huge | ||
7 | |||
8 | #get pagesize and freepages from /proc/meminfo | ||
9 | while read name size unit; do | ||
10 | if [ "$name" = "HugePages_Free:" ]; then | ||
11 | freepgs=$size | ||
12 | fi | ||
13 | if [ "$name" = "Hugepagesize:" ]; then | ||
14 | pgsize=$size | ||
15 | fi | ||
16 | done < /proc/meminfo | ||
17 | |||
18 | #set proper nr_hugepages | ||
19 | if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then | ||
20 | nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` | ||
21 | needpgs=`expr $needmem / $pgsize` | ||
22 | if [ $freepgs -lt $needpgs ]; then | ||
23 | lackpgs=$(( $needpgs - $freepgs )) | ||
24 | echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages | ||
25 | if [ $? -ne 0 ]; then | ||
26 | echo "Please run this test as root" | ||
27 | exit 1 | ||
28 | fi | ||
29 | fi | ||
30 | else | ||
31 | echo "no hugetlbfs support in kernel?" | ||
32 | exit 1 | ||
33 | fi | ||
34 | |||
35 | mkdir $mnt | ||
36 | mount -t hugetlbfs none $mnt | ||
37 | |||
38 | echo "--------------------" | ||
39 | echo "running hugepage-mmap" | ||
40 | echo "--------------------" | ||
41 | ./hugepage-mmap | ||
42 | if [ $? -ne 0 ]; then | ||
43 | echo "[FAIL]" | ||
44 | else | ||
45 | echo "[PASS]" | ||
46 | fi | ||
47 | |||
48 | shmmax=`cat /proc/sys/kernel/shmmax` | ||
49 | shmall=`cat /proc/sys/kernel/shmall` | ||
50 | echo 268435456 > /proc/sys/kernel/shmmax | ||
51 | echo 4194304 > /proc/sys/kernel/shmall | ||
52 | echo "--------------------" | ||
53 | echo "running hugepage-shm" | ||
54 | echo "--------------------" | ||
55 | ./hugepage-shm | ||
56 | if [ $? -ne 0 ]; then | ||
57 | echo "[FAIL]" | ||
58 | else | ||
59 | echo "[PASS]" | ||
60 | fi | ||
61 | echo $shmmax > /proc/sys/kernel/shmmax | ||
62 | echo $shmall > /proc/sys/kernel/shmall | ||
63 | |||
64 | echo "--------------------" | ||
65 | echo "running map_hugetlb" | ||
66 | echo "--------------------" | ||
67 | ./map_hugetlb | ||
68 | if [ $? -ne 0 ]; then | ||
69 | echo "[FAIL]" | ||
70 | else | ||
71 | echo "[PASS]" | ||
72 | fi | ||
73 | |||
74 | #cleanup | ||
75 | umount $mnt | ||
76 | rm -rf $mnt | ||
77 | echo $nr_hugepgs > /proc/sys/vm/nr_hugepages | ||
diff --git a/tools/testing/selftests/vm/thuge-gen.c b/tools/testing/selftests/vm/thuge-gen.c deleted file mode 100644 index c87957295f7..00000000000 --- a/tools/testing/selftests/vm/thuge-gen.c +++ /dev/null | |||
@@ -1,254 +0,0 @@ | |||
1 | /* Test selecting other page sizes for mmap/shmget. | ||
2 | |||
3 | Before running this huge pages for each huge page size must have been | ||
4 | reserved. | ||
5 | For large pages beyond MAX_ORDER (like 1GB on x86) boot options must be used. | ||
6 | Also shmmax must be increased. | ||
7 | And you need to run as root to work around some weird permissions in shm. | ||
8 | And nothing using huge pages should run in parallel. | ||
9 | When the program aborts you may need to clean up the shm segments with | ||
10 | ipcrm -m by hand, like this | ||
11 | sudo ipcs | awk '$1 == "0x00000000" {print $2}' | xargs -n1 sudo ipcrm -m | ||
12 | (warning this will remove all if someone else uses them) */ | ||
13 | |||
14 | #define _GNU_SOURCE 1 | ||
15 | #include <sys/mman.h> | ||
16 | #include <stdlib.h> | ||
17 | #include <stdio.h> | ||
18 | #include <sys/ipc.h> | ||
19 | #include <sys/shm.h> | ||
20 | #include <sys/stat.h> | ||
21 | #include <glob.h> | ||
22 | #include <assert.h> | ||
23 | #include <unistd.h> | ||
24 | #include <stdarg.h> | ||
25 | #include <string.h> | ||
26 | |||
27 | #define err(x) perror(x), exit(1) | ||
28 | |||
29 | #define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT) | ||
30 | #define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT) | ||
31 | #define MAP_HUGE_SHIFT 26 | ||
32 | #define MAP_HUGE_MASK 0x3f | ||
33 | #define MAP_HUGETLB 0x40000 | ||
34 | |||
35 | #define SHM_HUGETLB 04000 /* segment will use huge TLB pages */ | ||
36 | #define SHM_HUGE_SHIFT 26 | ||
37 | #define SHM_HUGE_MASK 0x3f | ||
38 | #define SHM_HUGE_2MB (21 << SHM_HUGE_SHIFT) | ||
39 | #define SHM_HUGE_1GB (30 << SHM_HUGE_SHIFT) | ||
40 | |||
41 | #define NUM_PAGESIZES 5 | ||
42 | |||
43 | #define NUM_PAGES 4 | ||
44 | |||
45 | #define Dprintf(fmt...) // printf(fmt) | ||
46 | |||
47 | unsigned long page_sizes[NUM_PAGESIZES]; | ||
48 | int num_page_sizes; | ||
49 | |||
50 | int ilog2(unsigned long v) | ||
51 | { | ||
52 | int l = 0; | ||
53 | while ((1UL << l) < v) | ||
54 | l++; | ||
55 | return l; | ||
56 | } | ||
57 | |||
58 | void find_pagesizes(void) | ||
59 | { | ||
60 | glob_t g; | ||
61 | int i; | ||
62 | glob("/sys/kernel/mm/hugepages/hugepages-*kB", 0, NULL, &g); | ||
63 | assert(g.gl_pathc <= NUM_PAGESIZES); | ||
64 | for (i = 0; i < g.gl_pathc; i++) { | ||
65 | sscanf(g.gl_pathv[i], "/sys/kernel/mm/hugepages/hugepages-%lukB", | ||
66 | &page_sizes[i]); | ||
67 | page_sizes[i] <<= 10; | ||
68 | printf("Found %luMB\n", page_sizes[i] >> 20); | ||
69 | } | ||
70 | num_page_sizes = g.gl_pathc; | ||
71 | globfree(&g); | ||
72 | } | ||
73 | |||
74 | unsigned long default_huge_page_size(void) | ||
75 | { | ||
76 | unsigned long hps = 0; | ||
77 | char *line = NULL; | ||
78 | size_t linelen = 0; | ||
79 | FILE *f = fopen("/proc/meminfo", "r"); | ||
80 | if (!f) | ||
81 | return 0; | ||
82 | while (getline(&line, &linelen, f) > 0) { | ||
83 | if (sscanf(line, "Hugepagesize: %lu kB", &hps) == 1) { | ||
84 | hps <<= 10; | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | free(line); | ||
89 | return hps; | ||
90 | } | ||
91 | |||
92 | void show(unsigned long ps) | ||
93 | { | ||
94 | char buf[100]; | ||
95 | if (ps == getpagesize()) | ||
96 | return; | ||
97 | printf("%luMB: ", ps >> 20); | ||
98 | fflush(stdout); | ||
99 | snprintf(buf, sizeof buf, | ||
100 | "cat /sys/kernel/mm/hugepages/hugepages-%lukB/free_hugepages", | ||
101 | ps >> 10); | ||
102 | system(buf); | ||
103 | } | ||
104 | |||
105 | unsigned long read_sysfs(int warn, char *fmt, ...) | ||
106 | { | ||
107 | char *line = NULL; | ||
108 | size_t linelen = 0; | ||
109 | char buf[100]; | ||
110 | FILE *f; | ||
111 | va_list ap; | ||
112 | unsigned long val = 0; | ||
113 | |||
114 | va_start(ap, fmt); | ||
115 | vsnprintf(buf, sizeof buf, fmt, ap); | ||
116 | va_end(ap); | ||
117 | |||
118 | f = fopen(buf, "r"); | ||
119 | if (!f) { | ||
120 | if (warn) | ||
121 | printf("missing %s\n", buf); | ||
122 | return 0; | ||
123 | } | ||
124 | if (getline(&line, &linelen, f) > 0) { | ||
125 | sscanf(line, "%lu", &val); | ||
126 | } | ||
127 | fclose(f); | ||
128 | free(line); | ||
129 | return val; | ||
130 | } | ||
131 | |||
132 | unsigned long read_free(unsigned long ps) | ||
133 | { | ||
134 | return read_sysfs(ps != getpagesize(), | ||
135 | "/sys/kernel/mm/hugepages/hugepages-%lukB/free_hugepages", | ||
136 | ps >> 10); | ||
137 | } | ||
138 | |||
139 | void test_mmap(unsigned long size, unsigned flags) | ||
140 | { | ||
141 | char *map; | ||
142 | unsigned long before, after; | ||
143 | int err; | ||
144 | |||
145 | before = read_free(size); | ||
146 | map = mmap(NULL, size*NUM_PAGES, PROT_READ|PROT_WRITE, | ||
147 | MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB|flags, 0, 0); | ||
148 | |||
149 | if (map == (char *)-1) err("mmap"); | ||
150 | memset(map, 0xff, size*NUM_PAGES); | ||
151 | after = read_free(size); | ||
152 | Dprintf("before %lu after %lu diff %ld size %lu\n", | ||
153 | before, after, before - after, size); | ||
154 | assert(size == getpagesize() || (before - after) == NUM_PAGES); | ||
155 | show(size); | ||
156 | err = munmap(map, size); | ||
157 | assert(!err); | ||
158 | } | ||
159 | |||
160 | void test_shmget(unsigned long size, unsigned flags) | ||
161 | { | ||
162 | int id; | ||
163 | unsigned long before, after; | ||
164 | int err; | ||
165 | |||
166 | before = read_free(size); | ||
167 | id = shmget(IPC_PRIVATE, size * NUM_PAGES, IPC_CREAT|0600|flags); | ||
168 | if (id < 0) err("shmget"); | ||
169 | |||
170 | struct shm_info i; | ||
171 | if (shmctl(id, SHM_INFO, (void *)&i) < 0) err("shmctl"); | ||
172 | Dprintf("alloc %lu res %lu\n", i.shm_tot, i.shm_rss); | ||
173 | |||
174 | |||
175 | Dprintf("id %d\n", id); | ||
176 | char *map = shmat(id, NULL, 0600); | ||
177 | if (map == (char*)-1) err("shmat"); | ||
178 | |||
179 | shmctl(id, IPC_RMID, NULL); | ||
180 | |||
181 | memset(map, 0xff, size*NUM_PAGES); | ||
182 | after = read_free(size); | ||
183 | |||
184 | Dprintf("before %lu after %lu diff %ld size %lu\n", | ||
185 | before, after, before - after, size); | ||
186 | assert(size == getpagesize() || (before - after) == NUM_PAGES); | ||
187 | show(size); | ||
188 | err = shmdt(map); | ||
189 | assert(!err); | ||
190 | } | ||
191 | |||
192 | void sanity_checks(void) | ||
193 | { | ||
194 | int i; | ||
195 | unsigned long largest = getpagesize(); | ||
196 | |||
197 | for (i = 0; i < num_page_sizes; i++) { | ||
198 | if (page_sizes[i] > largest) | ||
199 | largest = page_sizes[i]; | ||
200 | |||
201 | if (read_free(page_sizes[i]) < NUM_PAGES) { | ||
202 | printf("Not enough huge pages for page size %lu MB, need %u\n", | ||
203 | page_sizes[i] >> 20, | ||
204 | NUM_PAGES); | ||
205 | exit(0); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | if (read_sysfs(0, "/proc/sys/kernel/shmmax") < NUM_PAGES * largest) { | ||
210 | printf("Please do echo %lu > /proc/sys/kernel/shmmax", largest * NUM_PAGES); | ||
211 | exit(0); | ||
212 | } | ||
213 | |||
214 | #if defined(__x86_64__) | ||
215 | if (largest != 1U<<30) { | ||
216 | printf("No GB pages available on x86-64\n" | ||
217 | "Please boot with hugepagesz=1G hugepages=%d\n", NUM_PAGES); | ||
218 | exit(0); | ||
219 | } | ||
220 | #endif | ||
221 | } | ||
222 | |||
223 | int main(void) | ||
224 | { | ||
225 | int i; | ||
226 | unsigned default_hps = default_huge_page_size(); | ||
227 | |||
228 | find_pagesizes(); | ||
229 | |||
230 | sanity_checks(); | ||
231 | |||
232 | for (i = 0; i < num_page_sizes; i++) { | ||
233 | unsigned long ps = page_sizes[i]; | ||
234 | int arg = ilog2(ps) << MAP_HUGE_SHIFT; | ||
235 | printf("Testing %luMB mmap with shift %x\n", ps >> 20, arg); | ||
236 | test_mmap(ps, MAP_HUGETLB | arg); | ||
237 | } | ||
238 | printf("Testing default huge mmap\n"); | ||
239 | test_mmap(default_hps, SHM_HUGETLB); | ||
240 | |||
241 | puts("Testing non-huge shmget"); | ||
242 | test_shmget(getpagesize(), 0); | ||
243 | |||
244 | for (i = 0; i < num_page_sizes; i++) { | ||
245 | unsigned long ps = page_sizes[i]; | ||
246 | int arg = ilog2(ps) << SHM_HUGE_SHIFT; | ||
247 | printf("Testing %luMB shmget with shift %x\n", ps >> 20, arg); | ||
248 | test_shmget(ps, SHM_HUGETLB | arg); | ||
249 | } | ||
250 | puts("default huge shmget"); | ||
251 | test_shmget(default_hps, SHM_HUGETLB); | ||
252 | |||
253 | return 0; | ||
254 | } | ||