]>
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 | ||
d96ca9c4 | 216 | static noreturn int modprobe_param_kcmdline(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 | } | |
f1155c15 | 228 | DEFINE_TEST(modprobe_param_kcmdline, |
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 | |
55bcc4a5 LDM |
240 | static noreturn int modprobe_param_kcmdline2(const struct test *t) |
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 | } | |
f1155c15 | 252 | DEFINE_TEST(modprobe_param_kcmdline2, |
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 | ||
42149024 LDM |
264 | static noreturn int modprobe_param_kcmdline3(const struct test *t) |
265 | { | |
266 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
267 | const char *const args[] = { | |
268 | progname, | |
269 | "-c", | |
270 | NULL, | |
271 | }; | |
272 | ||
273 | test_spawn_prog(progname, args); | |
274 | exit(EXIT_FAILURE); | |
275 | } | |
f1155c15 | 276 | DEFINE_TEST(modprobe_param_kcmdline3, |
42149024 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-kcmdline3", | |
281 | }, | |
282 | .output = { | |
283 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3/correct.txt", | |
284 | }, | |
285 | .modules_loaded = "", | |
286 | ); | |
287 | ||
49776627 LDM |
288 | static noreturn int modprobe_param_kcmdline4(const struct test *t) |
289 | { | |
290 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
291 | const char *const args[] = { | |
292 | progname, | |
293 | "-c", | |
294 | NULL, | |
295 | }; | |
296 | ||
297 | test_spawn_prog(progname, args); | |
298 | exit(EXIT_FAILURE); | |
299 | } | |
f1155c15 | 300 | DEFINE_TEST(modprobe_param_kcmdline4, |
49776627 LDM |
301 | .description = "check if unrelated strings in kcmdline are correctly ignored", |
302 | .config = { | |
303 | [TC_UNAME_R] = "4.4.4", | |
304 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4", | |
305 | }, | |
306 | .output = { | |
307 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4/correct.txt", | |
308 | }, | |
309 | .modules_loaded = "", | |
310 | ); | |
311 | ||
ded0bebc LDM |
312 | static noreturn int modprobe_param_kcmdline5(const struct test *t) |
313 | { | |
314 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
315 | const char *const args[] = { | |
316 | progname, | |
317 | "-c", | |
318 | NULL, | |
319 | }; | |
320 | ||
321 | test_spawn_prog(progname, args); | |
322 | exit(EXIT_FAILURE); | |
323 | } | |
324 | DEFINE_TEST(modprobe_param_kcmdline5, | |
325 | .description = "check if params with spaces are parsed correctly from kcmdline", | |
326 | .config = { | |
327 | [TC_UNAME_R] = "4.4.4", | |
328 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline5", | |
329 | }, | |
330 | .output = { | |
331 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline5/correct.txt", | |
332 | }, | |
333 | .modules_loaded = "", | |
334 | ); | |
335 | ||
336 | ||
3c1073e1 LDM |
337 | static noreturn int modprobe_param_kcmdline6(const struct test *t) |
338 | { | |
339 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
340 | const char *const args[] = { | |
341 | progname, | |
342 | "-c", | |
343 | NULL, | |
344 | }; | |
345 | ||
346 | test_spawn_prog(progname, args); | |
347 | exit(EXIT_FAILURE); | |
348 | } | |
349 | DEFINE_TEST(modprobe_param_kcmdline6, | |
350 | .description = "check if dots on other parts of kcmdline don't confuse our parser", | |
351 | .config = { | |
352 | [TC_UNAME_R] = "4.4.4", | |
353 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6", | |
354 | }, | |
355 | .output = { | |
356 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6/correct.txt", | |
357 | }, | |
358 | .modules_loaded = "", | |
359 | ); | |
360 | ||
361 | ||
d3a1fe67 LDM |
362 | static noreturn int modprobe_param_kcmdline7(const struct test *t) |
363 | { | |
364 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
365 | const char *const args[] = { | |
366 | progname, | |
367 | "-c", | |
368 | NULL, | |
369 | }; | |
370 | ||
371 | test_spawn_prog(progname, args); | |
372 | exit(EXIT_FAILURE); | |
373 | } | |
374 | DEFINE_TEST(modprobe_param_kcmdline7, | |
375 | .description = "check if dots on other parts of kcmdline don't confuse our parser", | |
376 | .config = { | |
377 | [TC_UNAME_R] = "4.4.4", | |
378 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline7", | |
379 | }, | |
380 | .output = { | |
381 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline7/correct.txt", | |
382 | }, | |
383 | .modules_loaded = "", | |
384 | ); | |
385 | ||
386 | ||
387 | static noreturn int modprobe_param_kcmdline8(const struct test *t) | |
388 | { | |
389 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
390 | const char *const args[] = { | |
391 | progname, | |
392 | "-c", | |
393 | NULL, | |
394 | }; | |
395 | ||
396 | test_spawn_prog(progname, args); | |
397 | exit(EXIT_FAILURE); | |
398 | } | |
399 | DEFINE_TEST(modprobe_param_kcmdline8, | |
400 | .description = "check if dots on other parts of kcmdline don't confuse our parser", | |
401 | .config = { | |
402 | [TC_UNAME_R] = "4.4.4", | |
403 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline8", | |
404 | }, | |
405 | .output = { | |
406 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline8/correct.txt", | |
407 | }, | |
408 | .modules_loaded = "", | |
409 | ); | |
410 | ||
411 | ||
2ce5de0a MM |
412 | static noreturn int modprobe_force(const struct test *t) |
413 | { | |
414 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
415 | const char *const args[] = { | |
416 | progname, | |
a1a13690 | 417 | "--force", "mod-simple", |
2ce5de0a MM |
418 | NULL, |
419 | }; | |
420 | ||
421 | test_spawn_prog(progname, args); | |
422 | exit(EXIT_FAILURE); | |
423 | } | |
f1155c15 | 424 | DEFINE_TEST(modprobe_force, |
2ce5de0a MM |
425 | .description = "check modprobe --force", |
426 | .config = { | |
427 | [TC_UNAME_R] = "4.4.4", | |
428 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/force", | |
429 | [TC_INIT_MODULE_RETCODES] = "", | |
430 | }, | |
a1a13690 | 431 | .modules_loaded = "mod-simple", |
2ce5de0a MM |
432 | ); |
433 | ||
be29c40e MM |
434 | static noreturn int modprobe_oldkernel(const struct test *t) |
435 | { | |
436 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
437 | const char *const args[] = { | |
438 | progname, | |
33c11852 | 439 | "mod-simple", |
be29c40e MM |
440 | NULL, |
441 | }; | |
442 | ||
443 | test_spawn_prog(progname, args); | |
444 | exit(EXIT_FAILURE); | |
445 | } | |
f1155c15 | 446 | DEFINE_TEST(modprobe_oldkernel, |
33c11852 | 447 | .description = "check modprobe with kernel without finit_module()", |
be29c40e MM |
448 | .config = { |
449 | [TC_UNAME_R] = "3.3.3", | |
450 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel", | |
451 | [TC_INIT_MODULE_RETCODES] = "", | |
452 | }, | |
33c11852 | 453 | .modules_loaded = "mod-simple", |
be29c40e MM |
454 | ); |
455 | ||
456 | static noreturn int modprobe_oldkernel_force(const struct test *t) | |
457 | { | |
458 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
459 | const char *const args[] = { | |
460 | progname, | |
33c11852 | 461 | "--force", "mod-simple", |
be29c40e MM |
462 | NULL, |
463 | }; | |
464 | ||
465 | test_spawn_prog(progname, args); | |
466 | exit(EXIT_FAILURE); | |
467 | } | |
f1155c15 | 468 | DEFINE_TEST(modprobe_oldkernel_force, |
33c11852 | 469 | .description = "check modprobe --force with kernel without finit_module()", |
be29c40e MM |
470 | .config = { |
471 | [TC_UNAME_R] = "3.3.3", | |
472 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel-force", | |
473 | [TC_INIT_MODULE_RETCODES] = "", | |
474 | }, | |
33c11852 | 475 | .modules_loaded = "mod-simple", |
be29c40e MM |
476 | ); |
477 | ||
df492f5c YK |
478 | static noreturn int modprobe_external(const struct test *t) |
479 | { | |
480 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
481 | const char *const args[] = { | |
482 | progname, | |
483 | "mod-simple", | |
484 | NULL, | |
485 | }; | |
486 | ||
487 | test_spawn_prog(progname, args); | |
488 | exit(EXIT_FAILURE); | |
489 | } | |
490 | DEFINE_TEST(modprobe_external, | |
491 | .description = "check modprobe able to load external module", | |
492 | .config = { | |
493 | [TC_UNAME_R] = "4.4.4", | |
494 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/external", | |
495 | [TC_INIT_MODULE_RETCODES] = "", | |
496 | }, | |
497 | .modules_loaded = "mod-simple", | |
498 | ); | |
499 | ||
43289820 | 500 | TESTSUITE_MAIN(); |