2 * Copyright (C) 2012-2013 ProFUSION embedded systems
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.
9 * This program 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
26 #include "testsuite.h"
28 static noreturn
int modprobe_show_depends(const struct test
*t
)
30 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
31 const char *const args
[] = {
33 "--show-depends", "mod-loop-a",
37 test_spawn_prog(progname
, args
);
40 DEFINE_TEST(modprobe_show_depends
,
41 .description
= "check if output for modprobe --show-depends is correct for loaded modules",
43 [TC_UNAME_R
] = "4.4.4",
44 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/show-depends",
47 .out
= TESTSUITE_ROOTFS
"test-modprobe/show-depends/correct.txt",
50 static noreturn
int modprobe_show_depends2(const struct test
*t
)
52 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
53 const char *const args
[] = {
55 "--show-depends", "mod-simple",
59 test_spawn_prog(progname
, args
);
62 DEFINE_TEST(modprobe_show_depends2
,
63 .description
= "check if output for modprobe --show-depends is correct",
65 [TC_UNAME_R
] = "4.4.4",
66 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/show-depends",
69 .out
= TESTSUITE_ROOTFS
"test-modprobe/show-depends/correct-mod-simple.txt",
73 static noreturn
int modprobe_show_alias_to_none(const struct test
*t
)
75 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
76 const char *const args
[] = {
78 "--show-depends", "--ignore-install", "--quiet", "mod-simple",
82 test_spawn_prog(progname
, args
);
85 DEFINE_TEST(modprobe_show_alias_to_none
,
86 #if defined(KMOD_SYSCONFDIR_NOT_ETC)
89 .description
= "check if modprobe --show-depends doesn't explode with an alias to nothing",
91 [TC_UNAME_R
] = "4.4.4",
92 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/alias-to-none",
95 .out
= TESTSUITE_ROOTFS
"test-modprobe/alias-to-none/correct.txt",
101 static noreturn
int modprobe_show_exports(const struct test
*t
)
103 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
104 const char *const args
[] = {
106 "--show-exports", "--quiet", "/mod-loop-a.ko",
110 test_spawn_prog(progname
, args
);
113 DEFINE_TEST(modprobe_show_exports
,
114 .description
= "check if modprobe --show-depends doesn't explode with an alias to nothing",
116 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/show-exports",
119 .out
= TESTSUITE_ROOTFS
"test-modprobe/show-exports/correct.txt",
124 static noreturn
int modprobe_builtin(const struct test
*t
)
126 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
127 const char *const args
[] = {
133 test_spawn_prog(progname
, args
);
136 DEFINE_TEST(modprobe_builtin
,
137 .description
= "check if modprobe return 0 for builtin",
139 [TC_UNAME_R
] = "4.4.4",
140 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/builtin",
143 static noreturn
int modprobe_builtin_lookup_only(const struct test
*t
)
145 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
146 const char *const args
[] = {
152 test_spawn_prog(progname
, args
);
155 DEFINE_TEST(modprobe_builtin_lookup_only
,
156 .description
= "check if modprobe -R correctly returns the builtin module",
158 [TC_UNAME_R
] = "4.4.4",
159 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/builtin",
162 .out
= TESTSUITE_ROOTFS
"test-modprobe/builtin/correct.txt",
165 static noreturn
int modprobe_softdep_loop(const struct test
*t
)
167 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
168 const char *const args
[] = {
174 test_spawn_prog(progname
, args
);
177 DEFINE_TEST(modprobe_softdep_loop
,
178 #if defined(KMOD_SYSCONFDIR_NOT_ETC)
181 .description
= "check if modprobe breaks softdep loop",
183 [TC_UNAME_R
] = "4.4.4",
184 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/softdep-loop",
185 [TC_INIT_MODULE_RETCODES
] = "",
187 .modules_loaded
= "mod-loop-a,mod-loop-b",
190 static noreturn
int modprobe_install_cmd_loop(const struct test
*t
)
192 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
193 const char *const args
[] = {
199 test_spawn_prog(progname
, args
);
202 DEFINE_TEST(modprobe_install_cmd_loop
,
203 .description
= "check if modprobe breaks install-commands loop",
205 [TC_UNAME_R
] = "4.4.4",
206 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/install-cmd-loop",
207 [TC_INIT_MODULE_RETCODES
] = "",
209 .env_vars
= (const struct keyval
[]) {
210 { "MODPROBE", ABS_TOP_BUILDDIR
"/tools/modprobe" },
213 .modules_loaded
= "mod-loop-b,mod-loop-a",
216 static noreturn
int modprobe_param_kcmdline_show_deps(const struct test
*t
)
218 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
219 const char *const args
[] = {
221 "--show-depends", "mod-simple",
225 test_spawn_prog(progname
, args
);
228 DEFINE_TEST(modprobe_param_kcmdline_show_deps
,
229 .description
= "check if params from kcmdline are passed to (f)init_module call",
231 [TC_UNAME_R
] = "4.4.4",
232 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline",
235 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline/correct.txt",
237 .modules_loaded
= "",
240 static noreturn
int modprobe_param_kcmdline(const struct test
*t
)
242 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
243 const char *const args
[] = {
249 test_spawn_prog(progname
, args
);
252 DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline2
, modprobe_param_kcmdline
,
253 .description
= "check if params with no value are parsed correctly from kcmdline",
255 [TC_UNAME_R
] = "4.4.4",
256 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline2",
259 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline2/correct.txt",
261 .modules_loaded
= "",
264 DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline3
, modprobe_param_kcmdline
,
265 .description
= "check if unrelated strings in kcmdline are correctly ignored",
267 [TC_UNAME_R
] = "4.4.4",
268 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline3",
271 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline3/correct.txt",
273 .modules_loaded
= "",
276 DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline4
, modprobe_param_kcmdline
,
277 .description
= "check if unrelated strings in kcmdline are correctly ignored",
279 [TC_UNAME_R
] = "4.4.4",
280 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline4",
283 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline4/correct.txt",
285 .modules_loaded
= "",
288 DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline5
, modprobe_param_kcmdline
,
289 .description
= "check if params with spaces are parsed correctly from kcmdline",
291 [TC_UNAME_R
] = "4.4.4",
292 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline5",
295 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline5/correct.txt",
297 .modules_loaded
= "",
300 DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline6
, modprobe_param_kcmdline
,
301 .description
= "check if dots on other parts of kcmdline don't confuse our parser",
303 [TC_UNAME_R
] = "4.4.4",
304 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline6",
307 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline6/correct.txt",
309 .modules_loaded
= "",
312 DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline7
, modprobe_param_kcmdline
,
313 .description
= "check if dots on other parts of kcmdline don't confuse our parser",
315 [TC_UNAME_R
] = "4.4.4",
316 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline7",
319 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline7/correct.txt",
321 .modules_loaded
= "",
324 DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline8
, modprobe_param_kcmdline
,
325 .description
= "check if dots on other parts of kcmdline don't confuse our parser",
327 [TC_UNAME_R
] = "4.4.4",
328 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline8",
331 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline8/correct.txt",
333 .modules_loaded
= "",
337 static noreturn
int modprobe_force(const struct test
*t
)
339 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
340 const char *const args
[] = {
342 "--force", "mod-simple",
346 test_spawn_prog(progname
, args
);
349 DEFINE_TEST(modprobe_force
,
350 .description
= "check modprobe --force",
352 [TC_UNAME_R
] = "4.4.4",
353 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/force",
354 [TC_INIT_MODULE_RETCODES
] = "",
356 .modules_loaded
= "mod-simple",
359 static noreturn
int modprobe_oldkernel(const struct test
*t
)
361 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
362 const char *const args
[] = {
368 test_spawn_prog(progname
, args
);
371 DEFINE_TEST(modprobe_oldkernel
,
372 .description
= "check modprobe with kernel without finit_module()",
374 [TC_UNAME_R
] = "3.3.3",
375 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/oldkernel",
376 [TC_INIT_MODULE_RETCODES
] = "",
378 .modules_loaded
= "mod-simple",
381 static noreturn
int modprobe_oldkernel_force(const struct test
*t
)
383 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
384 const char *const args
[] = {
386 "--force", "mod-simple",
390 test_spawn_prog(progname
, args
);
393 DEFINE_TEST(modprobe_oldkernel_force
,
394 .description
= "check modprobe --force with kernel without finit_module()",
396 [TC_UNAME_R
] = "3.3.3",
397 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/oldkernel-force",
398 [TC_INIT_MODULE_RETCODES
] = "",
400 .modules_loaded
= "mod-simple",
403 static noreturn
int modprobe_external(const struct test
*t
)
405 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
406 const char *const args
[] = {
412 test_spawn_prog(progname
, args
);
415 DEFINE_TEST(modprobe_external
,
416 .description
= "check modprobe able to load external module",
418 [TC_UNAME_R
] = "4.4.4",
419 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/external",
420 [TC_INIT_MODULE_RETCODES
] = "",
422 .modules_loaded
= "mod-simple",
425 static noreturn
int modprobe_module_from_abspath(const struct test
*t
)
427 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
428 const char *const args
[] = {
430 "/home/foo/mod-simple.ko",
434 test_spawn_prog(progname
, args
);
437 DEFINE_TEST(modprobe_module_from_abspath
,
438 .description
= "check modprobe able to load module given as an absolute path",
440 [TC_UNAME_R
] = "4.4.4",
441 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-from-abspath",
442 [TC_INIT_MODULE_RETCODES
] = "",
444 .modules_loaded
= "mod-simple",
447 static noreturn
int modprobe_module_from_relpath(const struct test
*t
)
449 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
450 const char *const args
[] = {
456 if (chdir("/home/foo") != 0) {
457 perror("failed to change into /home/foo");
461 test_spawn_prog(progname
, args
);
464 DEFINE_TEST(modprobe_module_from_relpath
,
465 .description
= "check modprobe able to load module given as a relative path",
467 [TC_UNAME_R
] = "4.4.4",
468 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-from-relpath",
469 [TC_INIT_MODULE_RETCODES
] = "",
472 .modules_loaded
= "mod-simple",