]>
Commit | Line | Data |
---|---|---|
976ea8c3 | 1 | /* |
e6b0e49b | 2 | * Copyright (C) 2012-2013 ProFUSION embedded systems |
976ea8c3 | 3 | * |
e1b1ab24 LDM |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public | |
6 | * License as published by the Free Software Foundation; either | |
7 | * version 2.1 of the License, or (at your option) any later version. | |
976ea8c3 LDM |
8 | * |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
e1b1ab24 LDM |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. | |
976ea8c3 | 13 | * |
e1b1ab24 | 14 | * You should have received a copy of the GNU Lesser General Public |
dea2dfee | 15 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
976ea8c3 LDM |
16 | */ |
17 | ||
976ea8c3 | 18 | #include <errno.h> |
976ea8c3 | 19 | #include <inttypes.h> |
c2e4286b LDM |
20 | #include <stddef.h> |
21 | #include <stdio.h> | |
22 | #include <stdlib.h> | |
976ea8c3 | 23 | #include <string.h> |
c2e4286b | 24 | #include <unistd.h> |
976ea8c3 LDM |
25 | |
26 | #include "testsuite.h" | |
27 | ||
d96ca9c4 | 28 | static noreturn int modprobe_show_depends(const struct test *t) |
976ea8c3 | 29 | { |
b6adccd6 | 30 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
976ea8c3 LDM |
31 | const char *const args[] = { |
32 | progname, | |
eeb62700 | 33 | "--show-depends", "mod-loop-a", |
976ea8c3 LDM |
34 | NULL, |
35 | }; | |
36 | ||
37 | test_spawn_prog(progname, args); | |
38 | exit(EXIT_FAILURE); | |
39 | } | |
f1155c15 | 40 | DEFINE_TEST(modprobe_show_depends, |
976ea8c3 LDM |
41 | .description = "check if output for modprobe --show-depends is correct for loaded modules", |
42 | .config = { | |
43 | [TC_UNAME_R] = "4.4.4", | |
44 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/show-depends", | |
45 | }, | |
46 | .output = { | |
bd4e7340 | 47 | .out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct.txt", |
976ea8c3 LDM |
48 | }); |
49 | ||
d96ca9c4 | 50 | static noreturn int modprobe_show_depends2(const struct test *t) |
976ea8c3 | 51 | { |
b6adccd6 | 52 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
976ea8c3 LDM |
53 | const char *const args[] = { |
54 | progname, | |
eeb62700 | 55 | "--show-depends", "mod-simple", |
976ea8c3 LDM |
56 | NULL, |
57 | }; | |
58 | ||
59 | test_spawn_prog(progname, args); | |
60 | exit(EXIT_FAILURE); | |
61 | } | |
f1155c15 | 62 | DEFINE_TEST(modprobe_show_depends2, |
976ea8c3 LDM |
63 | .description = "check if output for modprobe --show-depends is correct", |
64 | .config = { | |
65 | [TC_UNAME_R] = "4.4.4", | |
66 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/show-depends", | |
67 | }, | |
68 | .output = { | |
eeb62700 | 69 | .out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-mod-simple.txt", |
976ea8c3 | 70 | }); |
a7f5300d | 71 | |
5278396d | 72 | |
d96ca9c4 | 73 | static noreturn int modprobe_show_alias_to_none(const struct test *t) |
5278396d | 74 | { |
b6adccd6 | 75 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
5278396d LDM |
76 | const char *const args[] = { |
77 | progname, | |
bf0b87f4 | 78 | "--show-depends", "--ignore-install", "--quiet", "mod-simple", |
5278396d LDM |
79 | NULL, |
80 | }; | |
81 | ||
82 | test_spawn_prog(progname, args); | |
83 | exit(EXIT_FAILURE); | |
84 | } | |
f1155c15 | 85 | DEFINE_TEST(modprobe_show_alias_to_none, |
847247a4 MB |
86 | #if defined(KMOD_SYSCONFDIR_NOT_ETC) |
87 | .skip = true, | |
88 | #endif | |
5278396d | 89 | .description = "check if modprobe --show-depends doesn't explode with an alias to nothing", |
5278396d LDM |
90 | .config = { |
91 | [TC_UNAME_R] = "4.4.4", | |
92 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/alias-to-none", | |
93 | }, | |
94 | .output = { | |
bf0b87f4 | 95 | .out = TESTSUITE_ROOTFS "test-modprobe/alias-to-none/correct.txt", |
88ac4084 MM |
96 | }, |
97 | .modules_loaded = "", | |
98 | ); | |
5278396d LDM |
99 | |
100 | ||
068729e3 LDM |
101 | static noreturn int modprobe_show_exports(const struct test *t) |
102 | { | |
103 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
104 | const char *const args[] = { | |
105 | progname, | |
106 | "--show-exports", "--quiet", "/mod-loop-a.ko", | |
107 | NULL, | |
108 | }; | |
109 | ||
110 | test_spawn_prog(progname, args); | |
111 | exit(EXIT_FAILURE); | |
112 | } | |
113 | DEFINE_TEST(modprobe_show_exports, | |
114 | .description = "check if modprobe --show-depends doesn't explode with an alias to nothing", | |
115 | .config = { | |
116 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/show-exports", | |
117 | }, | |
118 | .output = { | |
119 | .out = TESTSUITE_ROOTFS "test-modprobe/show-exports/correct.txt", | |
eb862179 | 120 | .regex = true, |
068729e3 LDM |
121 | }); |
122 | ||
123 | ||
d96ca9c4 | 124 | static noreturn int modprobe_builtin(const struct test *t) |
a7f5300d | 125 | { |
b6adccd6 | 126 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
a7f5300d LDM |
127 | const char *const args[] = { |
128 | progname, | |
129 | "unix", | |
130 | NULL, | |
131 | }; | |
132 | ||
133 | test_spawn_prog(progname, args); | |
134 | exit(EXIT_FAILURE); | |
135 | } | |
f1155c15 | 136 | DEFINE_TEST(modprobe_builtin, |
a7f5300d | 137 | .description = "check if modprobe return 0 for builtin", |
a7f5300d LDM |
138 | .config = { |
139 | [TC_UNAME_R] = "4.4.4", | |
140 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/builtin", | |
141 | }); | |
142 | ||
ade6b25c LDM |
143 | static noreturn int modprobe_builtin_lookup_only(const struct test *t) |
144 | { | |
145 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
146 | const char *const args[] = { | |
147 | progname, | |
148 | "-R", "unix", | |
149 | NULL, | |
150 | }; | |
151 | ||
152 | test_spawn_prog(progname, args); | |
153 | exit(EXIT_FAILURE); | |
154 | } | |
155 | DEFINE_TEST(modprobe_builtin_lookup_only, | |
156 | .description = "check if modprobe -R correctly returns the builtin module", | |
157 | .config = { | |
158 | [TC_UNAME_R] = "4.4.4", | |
159 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/builtin", | |
160 | }, | |
161 | .output = { | |
162 | .out = TESTSUITE_ROOTFS "test-modprobe/builtin/correct.txt", | |
163 | }); | |
164 | ||
d96ca9c4 | 165 | static noreturn int modprobe_softdep_loop(const struct test *t) |
a6976f8b | 166 | { |
b6adccd6 | 167 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
a6976f8b LDM |
168 | const char *const args[] = { |
169 | progname, | |
1e128242 | 170 | "mod-loop-b", |
a6976f8b LDM |
171 | NULL, |
172 | }; | |
173 | ||
174 | test_spawn_prog(progname, args); | |
175 | exit(EXIT_FAILURE); | |
176 | } | |
f1155c15 | 177 | DEFINE_TEST(modprobe_softdep_loop, |
847247a4 MB |
178 | #if defined(KMOD_SYSCONFDIR_NOT_ETC) |
179 | .skip = true, | |
180 | #endif | |
a6976f8b LDM |
181 | .description = "check if modprobe breaks softdep loop", |
182 | .config = { | |
183 | [TC_UNAME_R] = "4.4.4", | |
184 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/softdep-loop", | |
185 | [TC_INIT_MODULE_RETCODES] = "", | |
88ac4084 | 186 | }, |
1e128242 | 187 | .modules_loaded = "mod-loop-a,mod-loop-b", |
88ac4084 | 188 | ); |
a6976f8b | 189 | |
d96ca9c4 | 190 | static noreturn int modprobe_install_cmd_loop(const struct test *t) |
01d9ee64 | 191 | { |
b6adccd6 | 192 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
01d9ee64 LDM |
193 | const char *const args[] = { |
194 | progname, | |
621ac887 | 195 | "mod-loop-a", |
01d9ee64 LDM |
196 | NULL, |
197 | }; | |
198 | ||
199 | test_spawn_prog(progname, args); | |
200 | exit(EXIT_FAILURE); | |
201 | } | |
f1155c15 | 202 | DEFINE_TEST(modprobe_install_cmd_loop, |
9b01fd2e | 203 | .description = "check if modprobe breaks install-commands loop", |
01d9ee64 LDM |
204 | .config = { |
205 | [TC_UNAME_R] = "4.4.4", | |
206 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/install-cmd-loop", | |
207 | [TC_INIT_MODULE_RETCODES] = "", | |
208 | }, | |
209 | .env_vars = (const struct keyval[]) { | |
b6adccd6 | 210 | { "MODPROBE", ABS_TOP_BUILDDIR "/tools/modprobe" }, |
01d9ee64 LDM |
211 | { } |
212 | }, | |
621ac887 | 213 | .modules_loaded = "mod-loop-b,mod-loop-a", |
01d9ee64 LDM |
214 | ); |
215 | ||
d8b31c34 | 216 | static noreturn int modprobe_param_kcmdline_show_deps(const struct test *t) |
ea225b98 LDM |
217 | { |
218 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
219 | const char *const args[] = { | |
220 | progname, | |
246d67d4 | 221 | "--show-depends", "mod-simple", |
ea225b98 LDM |
222 | NULL, |
223 | }; | |
224 | ||
225 | test_spawn_prog(progname, args); | |
226 | exit(EXIT_FAILURE); | |
227 | } | |
d8b31c34 | 228 | DEFINE_TEST(modprobe_param_kcmdline_show_deps, |
55f8286f | 229 | .description = "check if params from kcmdline are passed to (f)init_module call", |
ea225b98 LDM |
230 | .config = { |
231 | [TC_UNAME_R] = "4.4.4", | |
232 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline", | |
233 | }, | |
234 | .output = { | |
bd4e7340 | 235 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline/correct.txt", |
88ac4084 MM |
236 | }, |
237 | .modules_loaded = "", | |
238 | ); | |
ea225b98 | 239 | |
d8b31c34 | 240 | static noreturn int modprobe_param_kcmdline(const struct test *t) |
55bcc4a5 LDM |
241 | { |
242 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
243 | const char *const args[] = { | |
244 | progname, | |
245 | "-c", | |
246 | NULL, | |
247 | }; | |
248 | ||
249 | test_spawn_prog(progname, args); | |
250 | exit(EXIT_FAILURE); | |
251 | } | |
d8b31c34 | 252 | DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline2, modprobe_param_kcmdline, |
55bcc4a5 LDM |
253 | .description = "check if params with no value are parsed correctly from kcmdline", |
254 | .config = { | |
255 | [TC_UNAME_R] = "4.4.4", | |
256 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2", | |
257 | }, | |
258 | .output = { | |
259 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2/correct.txt", | |
260 | }, | |
261 | .modules_loaded = "", | |
262 | ); | |
263 | ||
d8b31c34 | 264 | DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline3, modprobe_param_kcmdline, |
42149024 LDM |
265 | .description = "check if unrelated strings in kcmdline are correctly ignored", |
266 | .config = { | |
267 | [TC_UNAME_R] = "4.4.4", | |
268 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3", | |
269 | }, | |
270 | .output = { | |
271 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3/correct.txt", | |
272 | }, | |
273 | .modules_loaded = "", | |
274 | ); | |
275 | ||
d8b31c34 | 276 | DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline4, modprobe_param_kcmdline, |
49776627 LDM |
277 | .description = "check if unrelated strings in kcmdline are correctly ignored", |
278 | .config = { | |
279 | [TC_UNAME_R] = "4.4.4", | |
280 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4", | |
281 | }, | |
282 | .output = { | |
283 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4/correct.txt", | |
284 | }, | |
285 | .modules_loaded = "", | |
286 | ); | |
287 | ||
d8b31c34 | 288 | DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline5, modprobe_param_kcmdline, |
ded0bebc LDM |
289 | .description = "check if params with spaces are parsed correctly from kcmdline", |
290 | .config = { | |
291 | [TC_UNAME_R] = "4.4.4", | |
292 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline5", | |
293 | }, | |
294 | .output = { | |
295 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline5/correct.txt", | |
296 | }, | |
297 | .modules_loaded = "", | |
298 | ); | |
299 | ||
d8b31c34 | 300 | DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline6, modprobe_param_kcmdline, |
3c1073e1 LDM |
301 | .description = "check if dots on other parts of kcmdline don't confuse our parser", |
302 | .config = { | |
303 | [TC_UNAME_R] = "4.4.4", | |
304 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6", | |
305 | }, | |
306 | .output = { | |
307 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6/correct.txt", | |
308 | }, | |
309 | .modules_loaded = "", | |
310 | ); | |
311 | ||
d8b31c34 | 312 | DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline7, modprobe_param_kcmdline, |
d3a1fe67 LDM |
313 | .description = "check if dots on other parts of kcmdline don't confuse our parser", |
314 | .config = { | |
315 | [TC_UNAME_R] = "4.4.4", | |
316 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline7", | |
317 | }, | |
318 | .output = { | |
319 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline7/correct.txt", | |
320 | }, | |
321 | .modules_loaded = "", | |
322 | ); | |
323 | ||
d8b31c34 | 324 | DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline8, modprobe_param_kcmdline, |
d3a1fe67 LDM |
325 | .description = "check if dots on other parts of kcmdline don't confuse our parser", |
326 | .config = { | |
327 | [TC_UNAME_R] = "4.4.4", | |
328 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline8", | |
329 | }, | |
330 | .output = { | |
331 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline8/correct.txt", | |
332 | }, | |
333 | .modules_loaded = "", | |
334 | ); | |
335 | ||
336 | ||
2ce5de0a MM |
337 | static noreturn int modprobe_force(const struct test *t) |
338 | { | |
339 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
340 | const char *const args[] = { | |
341 | progname, | |
a1a13690 | 342 | "--force", "mod-simple", |
2ce5de0a MM |
343 | NULL, |
344 | }; | |
345 | ||
346 | test_spawn_prog(progname, args); | |
347 | exit(EXIT_FAILURE); | |
348 | } | |
f1155c15 | 349 | DEFINE_TEST(modprobe_force, |
2ce5de0a MM |
350 | .description = "check modprobe --force", |
351 | .config = { | |
352 | [TC_UNAME_R] = "4.4.4", | |
353 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/force", | |
354 | [TC_INIT_MODULE_RETCODES] = "", | |
355 | }, | |
a1a13690 | 356 | .modules_loaded = "mod-simple", |
2ce5de0a MM |
357 | ); |
358 | ||
be29c40e MM |
359 | static noreturn int modprobe_oldkernel(const struct test *t) |
360 | { | |
361 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
362 | const char *const args[] = { | |
363 | progname, | |
33c11852 | 364 | "mod-simple", |
be29c40e MM |
365 | NULL, |
366 | }; | |
367 | ||
368 | test_spawn_prog(progname, args); | |
369 | exit(EXIT_FAILURE); | |
370 | } | |
f1155c15 | 371 | DEFINE_TEST(modprobe_oldkernel, |
33c11852 | 372 | .description = "check modprobe with kernel without finit_module()", |
be29c40e MM |
373 | .config = { |
374 | [TC_UNAME_R] = "3.3.3", | |
375 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel", | |
376 | [TC_INIT_MODULE_RETCODES] = "", | |
377 | }, | |
33c11852 | 378 | .modules_loaded = "mod-simple", |
be29c40e MM |
379 | ); |
380 | ||
381 | static noreturn int modprobe_oldkernel_force(const struct test *t) | |
382 | { | |
383 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
384 | const char *const args[] = { | |
385 | progname, | |
33c11852 | 386 | "--force", "mod-simple", |
be29c40e MM |
387 | NULL, |
388 | }; | |
389 | ||
390 | test_spawn_prog(progname, args); | |
391 | exit(EXIT_FAILURE); | |
392 | } | |
f1155c15 | 393 | DEFINE_TEST(modprobe_oldkernel_force, |
33c11852 | 394 | .description = "check modprobe --force with kernel without finit_module()", |
be29c40e MM |
395 | .config = { |
396 | [TC_UNAME_R] = "3.3.3", | |
397 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel-force", | |
398 | [TC_INIT_MODULE_RETCODES] = "", | |
399 | }, | |
33c11852 | 400 | .modules_loaded = "mod-simple", |
be29c40e MM |
401 | ); |
402 | ||
df492f5c YK |
403 | static noreturn int modprobe_external(const struct test *t) |
404 | { | |
405 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
406 | const char *const args[] = { | |
407 | progname, | |
408 | "mod-simple", | |
409 | NULL, | |
410 | }; | |
411 | ||
412 | test_spawn_prog(progname, args); | |
413 | exit(EXIT_FAILURE); | |
414 | } | |
415 | DEFINE_TEST(modprobe_external, | |
416 | .description = "check modprobe able to load external module", | |
417 | .config = { | |
418 | [TC_UNAME_R] = "4.4.4", | |
419 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/external", | |
420 | [TC_INIT_MODULE_RETCODES] = "", | |
421 | }, | |
422 | .modules_loaded = "mod-simple", | |
423 | ); | |
424 | ||
43289820 | 425 | TESTSUITE_MAIN(); |