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, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include "testsuite.h"
29 static noreturn
int modprobe_show_depends(const struct test
*t
)
31 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
32 const char *const args
[] = {
34 "--show-depends", "btusb",
38 test_spawn_prog(progname
, args
);
41 static DEFINE_TEST(modprobe_show_depends
,
42 .description
= "check if output for modprobe --show-depends is correct for loaded modules",
44 [TC_UNAME_R
] = "4.4.4",
45 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/show-depends",
48 .out
= TESTSUITE_ROOTFS
"test-modprobe/show-depends/correct.txt",
51 static noreturn
int modprobe_show_depends2(const struct test
*t
)
53 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
54 const char *const args
[] = {
56 "--show-depends", "psmouse",
60 test_spawn_prog(progname
, args
);
63 static DEFINE_TEST(modprobe_show_depends2
,
64 .description
= "check if output for modprobe --show-depends is correct",
66 [TC_UNAME_R
] = "4.4.4",
67 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/show-depends",
70 .out
= TESTSUITE_ROOTFS
"test-modprobe/show-depends/correct-psmouse.txt",
74 static noreturn
int modprobe_show_alias_to_none(const struct test
*t
)
76 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
77 const char *const args
[] = {
79 "--show-depends", "--ignore-install", "--quiet", "psmouse",
83 test_spawn_prog(progname
, args
);
86 static DEFINE_TEST(modprobe_show_alias_to_none
,
87 .description
= "check if modprobe --show-depends doesn't explode with an alias to nothing",
89 [TC_UNAME_R
] = "4.4.4",
90 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/alias-to-none",
93 .out
= TESTSUITE_ROOTFS
"test-modprobe/show-depends/correct-psmouse.txt",
99 static noreturn
int modprobe_builtin(const struct test
*t
)
101 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
102 const char *const args
[] = {
108 test_spawn_prog(progname
, args
);
111 static DEFINE_TEST(modprobe_builtin
,
112 .description
= "check if modprobe return 0 for builtin",
114 [TC_UNAME_R
] = "4.4.4",
115 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/builtin",
118 static noreturn
int modprobe_softdep_loop(const struct test
*t
)
120 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
121 const char *const args
[] = {
127 test_spawn_prog(progname
, args
);
130 static DEFINE_TEST(modprobe_softdep_loop
,
131 .description
= "check if modprobe breaks softdep loop",
133 [TC_UNAME_R
] = "4.4.4",
134 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/softdep-loop",
135 [TC_INIT_MODULE_RETCODES
] = "",
137 .modules_loaded
= "btusb,bluetooth",
140 static noreturn
int modprobe_install_cmd_loop(const struct test
*t
)
142 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
143 const char *const args
[] = {
149 test_spawn_prog(progname
, args
);
152 static DEFINE_TEST(modprobe_install_cmd_loop
,
153 .description
= "check if modprobe breaks install-commands loop",
155 [TC_UNAME_R
] = "4.4.4",
156 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/install-cmd-loop",
157 [TC_INIT_MODULE_RETCODES
] = "",
159 .env_vars
= (const struct keyval
[]) {
160 { "MODPROBE", ABS_TOP_BUILDDIR
"/tools/modprobe" },
163 .modules_loaded
= "snd,snd-pcm",
166 static noreturn
int modprobe_param_kcmdline(const struct test
*t
)
168 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
169 const char *const args
[] = {
171 "--show-depends", "psmouse",
175 test_spawn_prog(progname
, args
);
178 static DEFINE_TEST(modprobe_param_kcmdline
,
179 .description
= "check if params from kcmdline are passed in fact passed to (f)init_module call",
181 [TC_UNAME_R
] = "4.4.4",
182 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline",
185 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline/correct.txt",
187 .modules_loaded
= "",
190 static noreturn
int modprobe_param_kcmdline2(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 static DEFINE_TEST(modprobe_param_kcmdline2
,
203 .description
= "check if params with no value are parsed correctly from kcmdline",
205 [TC_UNAME_R
] = "4.4.4",
206 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline2",
209 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline2/correct.txt",
211 .modules_loaded
= "",
214 static noreturn
int modprobe_param_kcmdline3(const struct test
*t
)
216 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
217 const char *const args
[] = {
223 test_spawn_prog(progname
, args
);
226 static DEFINE_TEST(modprobe_param_kcmdline3
,
227 .description
= "check if unrelated strings in kcmdline are correctly ignored",
229 [TC_UNAME_R
] = "4.4.4",
230 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline3",
233 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline3/correct.txt",
235 .modules_loaded
= "",
238 static noreturn
int modprobe_param_kcmdline4(const struct test
*t
)
240 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
241 const char *const args
[] = {
247 test_spawn_prog(progname
, args
);
250 static DEFINE_TEST(modprobe_param_kcmdline4
,
251 .description
= "check if unrelated strings in kcmdline are correctly ignored",
253 [TC_UNAME_R
] = "4.4.4",
254 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline4",
257 .out
= TESTSUITE_ROOTFS
"test-modprobe/module-param-kcmdline4/correct.txt",
259 .modules_loaded
= "",
262 static noreturn
int modprobe_force(const struct test
*t
)
264 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
265 const char *const args
[] = {
267 "--force", "psmouse",
271 test_spawn_prog(progname
, args
);
274 static DEFINE_TEST(modprobe_force
,
275 .description
= "check modprobe --force",
277 [TC_UNAME_R
] = "4.4.4",
278 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/force",
279 [TC_INIT_MODULE_RETCODES
] = "",
281 .modules_loaded
= "psmouse",
284 static noreturn
int modprobe_oldkernel(const struct test
*t
)
286 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
287 const char *const args
[] = {
293 test_spawn_prog(progname
, args
);
296 static DEFINE_TEST(modprobe_oldkernel
,
297 .description
= "check modprobe --force",
299 [TC_UNAME_R
] = "3.3.3",
300 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/oldkernel",
301 [TC_INIT_MODULE_RETCODES
] = "",
303 .modules_loaded
= "psmouse",
306 static noreturn
int modprobe_oldkernel_force(const struct test
*t
)
308 const char *progname
= ABS_TOP_BUILDDIR
"/tools/modprobe";
309 const char *const args
[] = {
311 "--force", "psmouse",
315 test_spawn_prog(progname
, args
);
318 static DEFINE_TEST(modprobe_oldkernel_force
,
319 .description
= "check modprobe --force",
321 [TC_UNAME_R
] = "3.3.3",
322 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modprobe/oldkernel-force",
323 [TC_INIT_MODULE_RETCODES
] = "",
325 .modules_loaded
= "psmouse",
329 static const struct test
*tests
[] = {
330 &smodprobe_show_depends
,
331 &smodprobe_show_depends2
,
332 &smodprobe_show_alias_to_none
,
334 &smodprobe_softdep_loop
,
335 &smodprobe_install_cmd_loop
,
336 &smodprobe_param_kcmdline
,
337 &smodprobe_param_kcmdline2
,
338 &smodprobe_param_kcmdline3
,
339 &smodprobe_param_kcmdline4
,
341 &smodprobe_oldkernel
,
342 &smodprobe_oldkernel_force
,
346 TESTSUITE_MAIN(tests
);