]> git.ipfire.org Git - thirdparty/kmod.git/blame - testsuite/test-depmod.c
depmod: Introduce outdir option
[thirdparty/kmod.git] / testsuite / test-depmod.c
CommitLineData
b0c9fc85 1/*
e6b0e49b 2 * Copyright (C) 2012-2013 ProFUSION embedded systems
b0c9fc85
LDM
3 *
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.
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 GNU
12 * Lesser General Public License for more details.
13 *
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/>.
b0c9fc85
LDM
16 */
17
b0c9fc85 18#include <errno.h>
b0c9fc85 19#include <inttypes.h>
c2e4286b
LDM
20#include <stddef.h>
21#include <stdio.h>
22#include <stdlib.h>
b0c9fc85 23#include <string.h>
c2e4286b 24#include <unistd.h>
b0c9fc85
LDM
25
26#include "testsuite.h"
27
2a38870e 28#define MODULES_ORDER_UNAME "4.4.4"
b0c9fc85
LDM
29#define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-compressed"
30#define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS "/lib/modules/" MODULES_ORDER_UNAME
d96ca9c4 31static noreturn int depmod_modules_order_for_compressed(const struct test *t)
b0c9fc85 32{
b6adccd6 33 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
b0c9fc85
LDM
34 const char *const args[] = {
35 progname,
36 NULL,
37 };
38
39 test_spawn_prog(progname, args);
40 exit(EXIT_FAILURE);
41}
43289820 42
f1155c15 43DEFINE_TEST(depmod_modules_order_for_compressed,
847247a4
MB
44#if defined(KMOD_SYSCONFDIR_NOT_ETC)
45 .skip = true,
46#endif
b0c9fc85
LDM
47 .description = "check if depmod let aliases in right order when using compressed modules",
48 .config = {
49 [TC_UNAME_R] = MODULES_ORDER_UNAME,
50 [TC_ROOTFS] = MODULES_ORDER_ROOTFS,
51 },
52 .output = {
53 .files = (const struct keyval[]) {
54 { MODULES_ORDER_LIB_MODULES "/correct-modules.alias",
55 MODULES_ORDER_LIB_MODULES "/modules.alias" },
56 { }
57 },
58 });
59
1712a154
EV
60#define MODULES_OUTDIR_UNAME "4.4.4"
61#define MODULES_OUTDIR_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-outdir"
62#define MODULES_OUTDIR_LIB_MODULES_OUTPUT MODULES_OUTDIR_ROOTFS "/outdir/lib/modules/" MODULES_OUTDIR_UNAME
63#define MODULES_OUTDIR_LIB_MODULES_INPUT MODULES_OUTDIR_ROOTFS "/lib/modules/" MODULES_OUTDIR_UNAME
64static noreturn int depmod_modules_outdir(const struct test *t)
65{
66 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
67 const char *const args[] = {
68 progname,
69 "--outdir", MODULES_OUTDIR_ROOTFS "/outdir/",
70 NULL,
71 };
72
73 test_spawn_prog(progname, args);
74 exit(EXIT_FAILURE);
75}
76
77DEFINE_TEST(depmod_modules_outdir,
78#if defined(KMOD_SYSCONFDIR_NOT_ETC)
79 .skip = true,
80#endif
81 .description = "check if depmod honours the outdir option",
82 .config = {
83 [TC_UNAME_R] = MODULES_OUTDIR_UNAME,
84 [TC_ROOTFS] = MODULES_OUTDIR_ROOTFS,
85 },
86 .output = {
87 .files = (const struct keyval[]) {
88 { MODULES_OUTDIR_LIB_MODULES_OUTPUT "/modules.dep",
89 MODULES_OUTDIR_ROOTFS "/correct-modules.dep" },
90 { MODULES_OUTDIR_LIB_MODULES_OUTPUT "/modules.alias",
91 MODULES_OUTDIR_ROOTFS "/correct-modules.alias" },
92 { }
93 },
94 });
95
aa0abec7
LDM
96#define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple"
97static noreturn int depmod_search_order_simple(const struct test *t)
98{
99 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
100 const char *const args[] = {
101 progname,
102 NULL,
103 };
104
105 test_spawn_prog(progname, args);
106 exit(EXIT_FAILURE);
107}
f1155c15 108DEFINE_TEST(depmod_search_order_simple,
aa0abec7
LDM
109 .description = "check if depmod honor search order in config",
110 .config = {
111 [TC_UNAME_R] = "4.4.4",
112 [TC_ROOTFS] = SEARCH_ORDER_SIMPLE_ROOTFS,
113 },
114 .output = {
115 .files = (const struct keyval[]) {
116 { SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
117 SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/modules.dep" },
118 { }
119 },
120 });
121
ad7f1757
LDM
122#define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix"
123static noreturn int depmod_search_order_same_prefix(const struct test *t)
124{
125 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
126 const char *const args[] = {
127 progname,
128 NULL,
129 };
130
131 test_spawn_prog(progname, args);
132 exit(EXIT_FAILURE);
133}
f1155c15 134DEFINE_TEST(depmod_search_order_same_prefix,
ad7f1757
LDM
135 .description = "check if depmod honor search order in config with same prefix",
136 .config = {
137 [TC_UNAME_R] = "4.4.4",
138 [TC_ROOTFS] = SEARCH_ORDER_SAME_PREFIX_ROOTFS,
139 },
140 .output = {
141 .files = (const struct keyval[]) {
142 { SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
143 SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/modules.dep" },
144 { }
145 },
146 });
147
8183cfa9
LDM
148#define DETECT_LOOP_ROOTFS TESTSUITE_ROOTFS "test-depmod/detect-loop"
149static noreturn int depmod_detect_loop(const struct test *t)
150{
151 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
152 const char *const args[] = {
153 progname,
154 NULL,
155 };
156
157 test_spawn_prog(progname, args);
158 exit(EXIT_FAILURE);
159}
f1155c15 160DEFINE_TEST(depmod_detect_loop,
847247a4
MB
161#if defined(KMOD_SYSCONFDIR_NOT_ETC)
162 .skip = true,
163#endif
8183cfa9
LDM
164 .description = "check if depmod detects module loops correctly",
165 .config = {
166 [TC_UNAME_R] = "4.4.4",
167 [TC_ROOTFS] = DETECT_LOOP_ROOTFS,
168 },
169 .expected_fail = true,
7a2d0e61
LDM
170 .output = {
171 .err = DETECT_LOOP_ROOTFS "/correct.txt",
172 });
8183cfa9 173
df492f5c
YK
174#define SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-first"
175static noreturn int depmod_search_order_external_first(const struct test *t)
176{
177 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
178 const char *const args[] = {
179 progname,
180 NULL,
181 };
182
183 test_spawn_prog(progname, args);
184 exit(EXIT_FAILURE);
185}
186DEFINE_TEST(depmod_search_order_external_first,
847247a4
MB
187#if defined(KMOD_SYSCONFDIR_NOT_ETC)
188 .skip = true,
189#endif
df492f5c
YK
190 .description = "check if depmod honor external keyword with higher priority",
191 .config = {
192 [TC_UNAME_R] = "4.4.4",
193 [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS,
194 },
195 .output = {
196 .files = (const struct keyval[]) {
197 { SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
198 SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/modules.dep" },
199 { }
200 },
201 });
202
203#define SEARCH_ORDER_EXTERNAL_LAST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-last"
204static noreturn int depmod_search_order_external_last(const struct test *t)
205{
206 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
207 const char *const args[] = {
208 progname,
209 NULL,
210 };
211
212 test_spawn_prog(progname, args);
213 exit(EXIT_FAILURE);
214}
215DEFINE_TEST(depmod_search_order_external_last,
216 .description = "check if depmod honor external keyword with lower priority",
217 .config = {
218 [TC_UNAME_R] = "4.4.4",
219 [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_LAST_ROOTFS,
220 },
221 .output = {
222 .files = (const struct keyval[]) {
223 { SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
224 SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/modules.dep" },
225 { }
226 },
227 });
228
809b9fb6
YK
229#define SEARCH_ORDER_OVERRIDE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-override"
230static noreturn int depmod_search_order_override(const struct test *t)
231{
232 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
233 const char *const args[] = {
234 progname,
235 NULL,
236 };
237
238 test_spawn_prog(progname, args);
239 exit(EXIT_FAILURE);
240}
241DEFINE_TEST(depmod_search_order_override,
847247a4
MB
242#if defined(KMOD_SYSCONFDIR_NOT_ETC)
243 .skip = true,
244#endif
809b9fb6
YK
245 .description = "check if depmod honor override keyword",
246 .config = {
247 [TC_UNAME_R] = "4.4.4",
248 [TC_ROOTFS] = SEARCH_ORDER_OVERRIDE_ROOTFS,
249 },
250 .output = {
251 .files = (const struct keyval[]) {
252 { SEARCH_ORDER_OVERRIDE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
253 SEARCH_ORDER_OVERRIDE_ROOTFS "/lib/modules/4.4.4/modules.dep" },
254 { }
255 },
256 });
257
43289820 258TESTSUITE_MAIN();