]>
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, |
5278396d | 86 | .description = "check if modprobe --show-depends doesn't explode with an alias to nothing", |
5278396d LDM |
87 | .config = { |
88 | [TC_UNAME_R] = "4.4.4", | |
89 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/alias-to-none", | |
90 | }, | |
91 | .output = { | |
bf0b87f4 | 92 | .out = TESTSUITE_ROOTFS "test-modprobe/alias-to-none/correct.txt", |
88ac4084 MM |
93 | }, |
94 | .modules_loaded = "", | |
95 | ); | |
5278396d LDM |
96 | |
97 | ||
d96ca9c4 | 98 | static noreturn int modprobe_builtin(const struct test *t) |
a7f5300d | 99 | { |
b6adccd6 | 100 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
a7f5300d LDM |
101 | const char *const args[] = { |
102 | progname, | |
103 | "unix", | |
104 | NULL, | |
105 | }; | |
106 | ||
107 | test_spawn_prog(progname, args); | |
108 | exit(EXIT_FAILURE); | |
109 | } | |
f1155c15 | 110 | DEFINE_TEST(modprobe_builtin, |
a7f5300d | 111 | .description = "check if modprobe return 0 for builtin", |
a7f5300d LDM |
112 | .config = { |
113 | [TC_UNAME_R] = "4.4.4", | |
114 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/builtin", | |
115 | }); | |
116 | ||
ade6b25c LDM |
117 | static noreturn int modprobe_builtin_lookup_only(const struct test *t) |
118 | { | |
119 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
120 | const char *const args[] = { | |
121 | progname, | |
122 | "-R", "unix", | |
123 | NULL, | |
124 | }; | |
125 | ||
126 | test_spawn_prog(progname, args); | |
127 | exit(EXIT_FAILURE); | |
128 | } | |
129 | DEFINE_TEST(modprobe_builtin_lookup_only, | |
130 | .description = "check if modprobe -R correctly returns the builtin module", | |
131 | .config = { | |
132 | [TC_UNAME_R] = "4.4.4", | |
133 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/builtin", | |
134 | }, | |
135 | .output = { | |
136 | .out = TESTSUITE_ROOTFS "test-modprobe/builtin/correct.txt", | |
137 | }); | |
138 | ||
d96ca9c4 | 139 | static noreturn int modprobe_softdep_loop(const struct test *t) |
a6976f8b | 140 | { |
b6adccd6 | 141 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
a6976f8b LDM |
142 | const char *const args[] = { |
143 | progname, | |
1e128242 | 144 | "mod-loop-b", |
a6976f8b LDM |
145 | NULL, |
146 | }; | |
147 | ||
148 | test_spawn_prog(progname, args); | |
149 | exit(EXIT_FAILURE); | |
150 | } | |
f1155c15 | 151 | DEFINE_TEST(modprobe_softdep_loop, |
a6976f8b LDM |
152 | .description = "check if modprobe breaks softdep loop", |
153 | .config = { | |
154 | [TC_UNAME_R] = "4.4.4", | |
155 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/softdep-loop", | |
156 | [TC_INIT_MODULE_RETCODES] = "", | |
88ac4084 | 157 | }, |
1e128242 | 158 | .modules_loaded = "mod-loop-a,mod-loop-b", |
88ac4084 | 159 | ); |
a6976f8b | 160 | |
d96ca9c4 | 161 | static noreturn int modprobe_install_cmd_loop(const struct test *t) |
01d9ee64 | 162 | { |
b6adccd6 | 163 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
01d9ee64 LDM |
164 | const char *const args[] = { |
165 | progname, | |
621ac887 | 166 | "mod-loop-a", |
01d9ee64 LDM |
167 | NULL, |
168 | }; | |
169 | ||
170 | test_spawn_prog(progname, args); | |
171 | exit(EXIT_FAILURE); | |
172 | } | |
f1155c15 | 173 | DEFINE_TEST(modprobe_install_cmd_loop, |
9b01fd2e | 174 | .description = "check if modprobe breaks install-commands loop", |
01d9ee64 LDM |
175 | .config = { |
176 | [TC_UNAME_R] = "4.4.4", | |
177 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/install-cmd-loop", | |
178 | [TC_INIT_MODULE_RETCODES] = "", | |
179 | }, | |
180 | .env_vars = (const struct keyval[]) { | |
b6adccd6 | 181 | { "MODPROBE", ABS_TOP_BUILDDIR "/tools/modprobe" }, |
01d9ee64 LDM |
182 | { } |
183 | }, | |
621ac887 | 184 | .modules_loaded = "mod-loop-b,mod-loop-a", |
01d9ee64 LDM |
185 | ); |
186 | ||
d96ca9c4 | 187 | static noreturn int modprobe_param_kcmdline(const struct test *t) |
ea225b98 LDM |
188 | { |
189 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
190 | const char *const args[] = { | |
191 | progname, | |
246d67d4 | 192 | "--show-depends", "mod-simple", |
ea225b98 LDM |
193 | NULL, |
194 | }; | |
195 | ||
196 | test_spawn_prog(progname, args); | |
197 | exit(EXIT_FAILURE); | |
198 | } | |
f1155c15 | 199 | DEFINE_TEST(modprobe_param_kcmdline, |
55f8286f | 200 | .description = "check if params from kcmdline are passed to (f)init_module call", |
ea225b98 LDM |
201 | .config = { |
202 | [TC_UNAME_R] = "4.4.4", | |
203 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline", | |
204 | }, | |
205 | .output = { | |
bd4e7340 | 206 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline/correct.txt", |
88ac4084 MM |
207 | }, |
208 | .modules_loaded = "", | |
209 | ); | |
ea225b98 | 210 | |
55bcc4a5 LDM |
211 | static noreturn int modprobe_param_kcmdline2(const struct test *t) |
212 | { | |
213 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
214 | const char *const args[] = { | |
215 | progname, | |
216 | "-c", | |
217 | NULL, | |
218 | }; | |
219 | ||
220 | test_spawn_prog(progname, args); | |
221 | exit(EXIT_FAILURE); | |
222 | } | |
f1155c15 | 223 | DEFINE_TEST(modprobe_param_kcmdline2, |
55bcc4a5 LDM |
224 | .description = "check if params with no value are parsed correctly from kcmdline", |
225 | .config = { | |
226 | [TC_UNAME_R] = "4.4.4", | |
227 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2", | |
228 | }, | |
229 | .output = { | |
230 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2/correct.txt", | |
231 | }, | |
232 | .modules_loaded = "", | |
233 | ); | |
234 | ||
42149024 LDM |
235 | static noreturn int modprobe_param_kcmdline3(const struct test *t) |
236 | { | |
237 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
238 | const char *const args[] = { | |
239 | progname, | |
240 | "-c", | |
241 | NULL, | |
242 | }; | |
243 | ||
244 | test_spawn_prog(progname, args); | |
245 | exit(EXIT_FAILURE); | |
246 | } | |
f1155c15 | 247 | DEFINE_TEST(modprobe_param_kcmdline3, |
42149024 LDM |
248 | .description = "check if unrelated strings in kcmdline are correctly ignored", |
249 | .config = { | |
250 | [TC_UNAME_R] = "4.4.4", | |
251 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3", | |
252 | }, | |
253 | .output = { | |
254 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3/correct.txt", | |
255 | }, | |
256 | .modules_loaded = "", | |
257 | ); | |
258 | ||
49776627 LDM |
259 | static noreturn int modprobe_param_kcmdline4(const struct test *t) |
260 | { | |
261 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
262 | const char *const args[] = { | |
263 | progname, | |
264 | "-c", | |
265 | NULL, | |
266 | }; | |
267 | ||
268 | test_spawn_prog(progname, args); | |
269 | exit(EXIT_FAILURE); | |
270 | } | |
f1155c15 | 271 | DEFINE_TEST(modprobe_param_kcmdline4, |
49776627 LDM |
272 | .description = "check if unrelated strings in kcmdline are correctly ignored", |
273 | .config = { | |
274 | [TC_UNAME_R] = "4.4.4", | |
275 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4", | |
276 | }, | |
277 | .output = { | |
278 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4/correct.txt", | |
279 | }, | |
280 | .modules_loaded = "", | |
281 | ); | |
282 | ||
ded0bebc LDM |
283 | static noreturn int modprobe_param_kcmdline5(const struct test *t) |
284 | { | |
285 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
286 | const char *const args[] = { | |
287 | progname, | |
288 | "-c", | |
289 | NULL, | |
290 | }; | |
291 | ||
292 | test_spawn_prog(progname, args); | |
293 | exit(EXIT_FAILURE); | |
294 | } | |
295 | DEFINE_TEST(modprobe_param_kcmdline5, | |
296 | .description = "check if params with spaces are parsed correctly from kcmdline", | |
297 | .config = { | |
298 | [TC_UNAME_R] = "4.4.4", | |
299 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline5", | |
300 | }, | |
301 | .output = { | |
302 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline5/correct.txt", | |
303 | }, | |
304 | .modules_loaded = "", | |
305 | ); | |
306 | ||
307 | ||
2ce5de0a MM |
308 | static noreturn int modprobe_force(const struct test *t) |
309 | { | |
310 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
311 | const char *const args[] = { | |
312 | progname, | |
a1a13690 | 313 | "--force", "mod-simple", |
2ce5de0a MM |
314 | NULL, |
315 | }; | |
316 | ||
317 | test_spawn_prog(progname, args); | |
318 | exit(EXIT_FAILURE); | |
319 | } | |
f1155c15 | 320 | DEFINE_TEST(modprobe_force, |
2ce5de0a MM |
321 | .description = "check modprobe --force", |
322 | .config = { | |
323 | [TC_UNAME_R] = "4.4.4", | |
324 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/force", | |
325 | [TC_INIT_MODULE_RETCODES] = "", | |
326 | }, | |
a1a13690 | 327 | .modules_loaded = "mod-simple", |
2ce5de0a MM |
328 | ); |
329 | ||
be29c40e MM |
330 | static noreturn int modprobe_oldkernel(const struct test *t) |
331 | { | |
332 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
333 | const char *const args[] = { | |
334 | progname, | |
33c11852 | 335 | "mod-simple", |
be29c40e MM |
336 | NULL, |
337 | }; | |
338 | ||
339 | test_spawn_prog(progname, args); | |
340 | exit(EXIT_FAILURE); | |
341 | } | |
f1155c15 | 342 | DEFINE_TEST(modprobe_oldkernel, |
33c11852 | 343 | .description = "check modprobe with kernel without finit_module()", |
be29c40e MM |
344 | .config = { |
345 | [TC_UNAME_R] = "3.3.3", | |
346 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel", | |
347 | [TC_INIT_MODULE_RETCODES] = "", | |
348 | }, | |
33c11852 | 349 | .modules_loaded = "mod-simple", |
be29c40e MM |
350 | ); |
351 | ||
352 | static noreturn int modprobe_oldkernel_force(const struct test *t) | |
353 | { | |
354 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
355 | const char *const args[] = { | |
356 | progname, | |
33c11852 | 357 | "--force", "mod-simple", |
be29c40e MM |
358 | NULL, |
359 | }; | |
360 | ||
361 | test_spawn_prog(progname, args); | |
362 | exit(EXIT_FAILURE); | |
363 | } | |
f1155c15 | 364 | DEFINE_TEST(modprobe_oldkernel_force, |
33c11852 | 365 | .description = "check modprobe --force with kernel without finit_module()", |
be29c40e MM |
366 | .config = { |
367 | [TC_UNAME_R] = "3.3.3", | |
368 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel-force", | |
369 | [TC_INIT_MODULE_RETCODES] = "", | |
370 | }, | |
33c11852 | 371 | .modules_loaded = "mod-simple", |
be29c40e MM |
372 | ); |
373 | ||
43289820 | 374 | TESTSUITE_MAIN(); |