]>
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, | |
33 | "--show-depends", "btusb", | |
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, | |
55 | "--show-depends", "psmouse", | |
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 = { | |
bd4e7340 | 69 | .out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-psmouse.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, | |
78 | "--show-depends", "--ignore-install", "--quiet", "psmouse", | |
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 = { | |
bd4e7340 | 92 | .out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-psmouse.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 | ||
d96ca9c4 | 117 | static noreturn int modprobe_softdep_loop(const struct test *t) |
a6976f8b | 118 | { |
b6adccd6 | 119 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
a6976f8b LDM |
120 | const char *const args[] = { |
121 | progname, | |
122 | "bluetooth", | |
123 | NULL, | |
124 | }; | |
125 | ||
126 | test_spawn_prog(progname, args); | |
127 | exit(EXIT_FAILURE); | |
128 | } | |
f1155c15 | 129 | DEFINE_TEST(modprobe_softdep_loop, |
a6976f8b LDM |
130 | .description = "check if modprobe breaks softdep loop", |
131 | .config = { | |
132 | [TC_UNAME_R] = "4.4.4", | |
133 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/softdep-loop", | |
134 | [TC_INIT_MODULE_RETCODES] = "", | |
88ac4084 MM |
135 | }, |
136 | .modules_loaded = "btusb,bluetooth", | |
137 | ); | |
a6976f8b | 138 | |
d96ca9c4 | 139 | static noreturn int modprobe_install_cmd_loop(const struct test *t) |
01d9ee64 | 140 | { |
b6adccd6 | 141 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; |
01d9ee64 LDM |
142 | const char *const args[] = { |
143 | progname, | |
144 | "snd-pcm", | |
145 | NULL, | |
146 | }; | |
147 | ||
148 | test_spawn_prog(progname, args); | |
149 | exit(EXIT_FAILURE); | |
150 | } | |
f1155c15 | 151 | DEFINE_TEST(modprobe_install_cmd_loop, |
9b01fd2e | 152 | .description = "check if modprobe breaks install-commands loop", |
01d9ee64 LDM |
153 | .config = { |
154 | [TC_UNAME_R] = "4.4.4", | |
155 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/install-cmd-loop", | |
156 | [TC_INIT_MODULE_RETCODES] = "", | |
157 | }, | |
158 | .env_vars = (const struct keyval[]) { | |
b6adccd6 | 159 | { "MODPROBE", ABS_TOP_BUILDDIR "/tools/modprobe" }, |
01d9ee64 LDM |
160 | { } |
161 | }, | |
88ac4084 | 162 | .modules_loaded = "snd,snd-pcm", |
01d9ee64 LDM |
163 | ); |
164 | ||
d96ca9c4 | 165 | static noreturn int modprobe_param_kcmdline(const struct test *t) |
ea225b98 LDM |
166 | { |
167 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
168 | const char *const args[] = { | |
169 | progname, | |
170 | "--show-depends", "psmouse", | |
171 | NULL, | |
172 | }; | |
173 | ||
174 | test_spawn_prog(progname, args); | |
175 | exit(EXIT_FAILURE); | |
176 | } | |
f1155c15 | 177 | DEFINE_TEST(modprobe_param_kcmdline, |
bad84a9e | 178 | .description = "check if params from kcmdline are passed in fact passed to (f)init_module call", |
ea225b98 LDM |
179 | .config = { |
180 | [TC_UNAME_R] = "4.4.4", | |
181 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline", | |
182 | }, | |
183 | .output = { | |
bd4e7340 | 184 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline/correct.txt", |
88ac4084 MM |
185 | }, |
186 | .modules_loaded = "", | |
187 | ); | |
ea225b98 | 188 | |
55bcc4a5 LDM |
189 | static noreturn int modprobe_param_kcmdline2(const struct test *t) |
190 | { | |
191 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
192 | const char *const args[] = { | |
193 | progname, | |
194 | "-c", | |
195 | NULL, | |
196 | }; | |
197 | ||
198 | test_spawn_prog(progname, args); | |
199 | exit(EXIT_FAILURE); | |
200 | } | |
f1155c15 | 201 | DEFINE_TEST(modprobe_param_kcmdline2, |
55bcc4a5 LDM |
202 | .description = "check if params with no value are parsed correctly from kcmdline", |
203 | .config = { | |
204 | [TC_UNAME_R] = "4.4.4", | |
205 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2", | |
206 | }, | |
207 | .output = { | |
208 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2/correct.txt", | |
209 | }, | |
210 | .modules_loaded = "", | |
211 | ); | |
212 | ||
42149024 LDM |
213 | static noreturn int modprobe_param_kcmdline3(const struct test *t) |
214 | { | |
215 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
216 | const char *const args[] = { | |
217 | progname, | |
218 | "-c", | |
219 | NULL, | |
220 | }; | |
221 | ||
222 | test_spawn_prog(progname, args); | |
223 | exit(EXIT_FAILURE); | |
224 | } | |
f1155c15 | 225 | DEFINE_TEST(modprobe_param_kcmdline3, |
42149024 LDM |
226 | .description = "check if unrelated strings in kcmdline are correctly ignored", |
227 | .config = { | |
228 | [TC_UNAME_R] = "4.4.4", | |
229 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3", | |
230 | }, | |
231 | .output = { | |
232 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3/correct.txt", | |
233 | }, | |
234 | .modules_loaded = "", | |
235 | ); | |
236 | ||
49776627 LDM |
237 | static noreturn int modprobe_param_kcmdline4(const struct test *t) |
238 | { | |
239 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
240 | const char *const args[] = { | |
241 | progname, | |
242 | "-c", | |
243 | NULL, | |
244 | }; | |
245 | ||
246 | test_spawn_prog(progname, args); | |
247 | exit(EXIT_FAILURE); | |
248 | } | |
f1155c15 | 249 | DEFINE_TEST(modprobe_param_kcmdline4, |
49776627 LDM |
250 | .description = "check if unrelated strings in kcmdline are correctly ignored", |
251 | .config = { | |
252 | [TC_UNAME_R] = "4.4.4", | |
253 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4", | |
254 | }, | |
255 | .output = { | |
256 | .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4/correct.txt", | |
257 | }, | |
258 | .modules_loaded = "", | |
259 | ); | |
260 | ||
2ce5de0a MM |
261 | static noreturn int modprobe_force(const struct test *t) |
262 | { | |
263 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
264 | const char *const args[] = { | |
265 | progname, | |
266 | "--force", "psmouse", | |
267 | NULL, | |
268 | }; | |
269 | ||
270 | test_spawn_prog(progname, args); | |
271 | exit(EXIT_FAILURE); | |
272 | } | |
f1155c15 | 273 | DEFINE_TEST(modprobe_force, |
2ce5de0a MM |
274 | .description = "check modprobe --force", |
275 | .config = { | |
276 | [TC_UNAME_R] = "4.4.4", | |
277 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/force", | |
278 | [TC_INIT_MODULE_RETCODES] = "", | |
279 | }, | |
280 | .modules_loaded = "psmouse", | |
281 | ); | |
282 | ||
be29c40e MM |
283 | static noreturn int modprobe_oldkernel(const struct test *t) |
284 | { | |
285 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
286 | const char *const args[] = { | |
287 | progname, | |
288 | "psmouse", | |
289 | NULL, | |
290 | }; | |
291 | ||
292 | test_spawn_prog(progname, args); | |
293 | exit(EXIT_FAILURE); | |
294 | } | |
f1155c15 | 295 | DEFINE_TEST(modprobe_oldkernel, |
be29c40e MM |
296 | .description = "check modprobe --force", |
297 | .config = { | |
298 | [TC_UNAME_R] = "3.3.3", | |
299 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel", | |
300 | [TC_INIT_MODULE_RETCODES] = "", | |
301 | }, | |
302 | .modules_loaded = "psmouse", | |
303 | ); | |
304 | ||
305 | static noreturn int modprobe_oldkernel_force(const struct test *t) | |
306 | { | |
307 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
308 | const char *const args[] = { | |
309 | progname, | |
310 | "--force", "psmouse", | |
311 | NULL, | |
312 | }; | |
313 | ||
314 | test_spawn_prog(progname, args); | |
315 | exit(EXIT_FAILURE); | |
316 | } | |
f1155c15 | 317 | DEFINE_TEST(modprobe_oldkernel_force, |
be29c40e MM |
318 | .description = "check modprobe --force", |
319 | .config = { | |
320 | [TC_UNAME_R] = "3.3.3", | |
321 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel-force", | |
322 | [TC_INIT_MODULE_RETCODES] = "", | |
323 | }, | |
324 | .modules_loaded = "psmouse", | |
325 | ); | |
326 | ||
43289820 | 327 | TESTSUITE_MAIN(); |