]>
Commit | Line | Data |
---|---|---|
976ea8c3 LDM |
1 | /* |
2 | * Copyright (C) 2012 ProFUSION embedded systems | |
3 | * | |
4 | * This program is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 2 of the License, or | |
7 | * (at your option) any later version. | |
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 | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
18 | #include <stdio.h> | |
19 | #include <stdlib.h> | |
20 | #include <stddef.h> | |
21 | #include <errno.h> | |
22 | #include <unistd.h> | |
23 | #include <inttypes.h> | |
24 | #include <string.h> | |
25 | ||
26 | #include "testsuite.h" | |
27 | ||
32d29b35 | 28 | static __noreturn int modprobe_show_depends(const struct test *t) |
976ea8c3 LDM |
29 | { |
30 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
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 | } | |
40 | static DEFINE_TEST(modprobe_show_depends, | |
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 = { | |
47 | .stdout = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct.txt", | |
48 | }); | |
49 | ||
32d29b35 | 50 | static __noreturn int modprobe_show_depends2(const struct test *t) |
976ea8c3 LDM |
51 | { |
52 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
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 | } | |
62 | static DEFINE_TEST(modprobe_show_depends2, | |
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 = { | |
69 | .stdout = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-psmouse.txt", | |
70 | }); | |
a7f5300d LDM |
71 | |
72 | static __noreturn int modprobe_builtin(const struct test *t) | |
73 | { | |
74 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
75 | const char *const args[] = { | |
76 | progname, | |
77 | "unix", | |
78 | NULL, | |
79 | }; | |
80 | ||
81 | test_spawn_prog(progname, args); | |
82 | exit(EXIT_FAILURE); | |
83 | } | |
84 | static DEFINE_TEST(modprobe_builtin, | |
85 | .description = "check if modprobe return 0 for builtin", | |
a7f5300d LDM |
86 | .config = { |
87 | [TC_UNAME_R] = "4.4.4", | |
88 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/builtin", | |
89 | }); | |
90 | ||
a6976f8b LDM |
91 | static __noreturn int modprobe_softdep_loop(const struct test *t) |
92 | { | |
93 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
94 | const char *const args[] = { | |
95 | progname, | |
96 | "bluetooth", | |
97 | NULL, | |
98 | }; | |
99 | ||
100 | test_spawn_prog(progname, args); | |
101 | exit(EXIT_FAILURE); | |
102 | } | |
103 | static DEFINE_TEST(modprobe_softdep_loop, | |
104 | .description = "check if modprobe breaks softdep loop", | |
105 | .config = { | |
106 | [TC_UNAME_R] = "4.4.4", | |
107 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/softdep-loop", | |
108 | [TC_INIT_MODULE_RETCODES] = "", | |
109 | }); | |
110 | ||
01d9ee64 LDM |
111 | static __noreturn int modprobe_install_cmd_loop(const struct test *t) |
112 | { | |
113 | const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; | |
114 | const char *const args[] = { | |
115 | progname, | |
116 | "snd-pcm", | |
117 | NULL, | |
118 | }; | |
119 | ||
120 | test_spawn_prog(progname, args); | |
121 | exit(EXIT_FAILURE); | |
122 | } | |
123 | static DEFINE_TEST(modprobe_install_cmd_loop, | |
9b01fd2e | 124 | .description = "check if modprobe breaks install-commands loop", |
01d9ee64 LDM |
125 | .config = { |
126 | [TC_UNAME_R] = "4.4.4", | |
127 | [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/install-cmd-loop", | |
128 | [TC_INIT_MODULE_RETCODES] = "", | |
129 | }, | |
130 | .env_vars = (const struct keyval[]) { | |
131 | { "MODPROBE", ABS_TOP_BUILDDIR "/tools/modprobe" }, | |
132 | { } | |
133 | }, | |
134 | ); | |
135 | ||
976ea8c3 LDM |
136 | static const struct test *tests[] = { |
137 | &smodprobe_show_depends, | |
138 | &smodprobe_show_depends2, | |
a7f5300d | 139 | &smodprobe_builtin, |
a6976f8b | 140 | &smodprobe_softdep_loop, |
01d9ee64 | 141 | &smodprobe_install_cmd_loop, |
976ea8c3 LDM |
142 | NULL, |
143 | }; | |
144 | ||
145 | TESTSUITE_MAIN(tests); |