]> git.ipfire.org Git - thirdparty/kmod.git/blame - testsuite/test-depmod.c
testsuite: depmod: add override test
[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
e0ff310d 28#ifdef ENABLE_ZLIB
2a38870e 29#define MODULES_ORDER_UNAME "4.4.4"
b0c9fc85
LDM
30#define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-compressed"
31#define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS "/lib/modules/" MODULES_ORDER_UNAME
d96ca9c4 32static noreturn int depmod_modules_order_for_compressed(const struct test *t)
b0c9fc85 33{
b6adccd6 34 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
b0c9fc85
LDM
35 const char *const args[] = {
36 progname,
37 NULL,
38 };
39
40 test_spawn_prog(progname, args);
41 exit(EXIT_FAILURE);
42}
43289820 43
f1155c15 44DEFINE_TEST(depmod_modules_order_for_compressed,
b0c9fc85
LDM
45 .description = "check if depmod let aliases in right order when using compressed modules",
46 .config = {
47 [TC_UNAME_R] = MODULES_ORDER_UNAME,
48 [TC_ROOTFS] = MODULES_ORDER_ROOTFS,
49 },
50 .output = {
51 .files = (const struct keyval[]) {
52 { MODULES_ORDER_LIB_MODULES "/correct-modules.alias",
53 MODULES_ORDER_LIB_MODULES "/modules.alias" },
54 { }
55 },
56 });
43289820 57#endif
b0c9fc85 58
aa0abec7
LDM
59#define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple"
60static noreturn int depmod_search_order_simple(const struct test *t)
61{
62 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
63 const char *const args[] = {
64 progname,
65 NULL,
66 };
67
68 test_spawn_prog(progname, args);
69 exit(EXIT_FAILURE);
70}
f1155c15 71DEFINE_TEST(depmod_search_order_simple,
aa0abec7
LDM
72 .description = "check if depmod honor search order in config",
73 .config = {
74 [TC_UNAME_R] = "4.4.4",
75 [TC_ROOTFS] = SEARCH_ORDER_SIMPLE_ROOTFS,
76 },
77 .output = {
78 .files = (const struct keyval[]) {
79 { SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
80 SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/modules.dep" },
81 { }
82 },
83 });
84
ad7f1757
LDM
85#define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix"
86static noreturn int depmod_search_order_same_prefix(const struct test *t)
87{
88 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
89 const char *const args[] = {
90 progname,
91 NULL,
92 };
93
94 test_spawn_prog(progname, args);
95 exit(EXIT_FAILURE);
96}
f1155c15 97DEFINE_TEST(depmod_search_order_same_prefix,
ad7f1757
LDM
98 .description = "check if depmod honor search order in config with same prefix",
99 .config = {
100 [TC_UNAME_R] = "4.4.4",
101 [TC_ROOTFS] = SEARCH_ORDER_SAME_PREFIX_ROOTFS,
102 },
103 .output = {
104 .files = (const struct keyval[]) {
105 { SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
106 SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/modules.dep" },
107 { }
108 },
109 });
110
8183cfa9
LDM
111#define DETECT_LOOP_ROOTFS TESTSUITE_ROOTFS "test-depmod/detect-loop"
112static noreturn int depmod_detect_loop(const struct test *t)
113{
114 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
115 const char *const args[] = {
116 progname,
117 NULL,
118 };
119
120 test_spawn_prog(progname, args);
121 exit(EXIT_FAILURE);
122}
f1155c15 123DEFINE_TEST(depmod_detect_loop,
8183cfa9
LDM
124 .description = "check if depmod detects module loops correctly",
125 .config = {
126 [TC_UNAME_R] = "4.4.4",
127 [TC_ROOTFS] = DETECT_LOOP_ROOTFS,
128 },
129 .expected_fail = true,
7a2d0e61
LDM
130 .output = {
131 .err = DETECT_LOOP_ROOTFS "/correct.txt",
132 });
8183cfa9 133
df492f5c
YK
134#define SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-first"
135static noreturn int depmod_search_order_external_first(const struct test *t)
136{
137 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
138 const char *const args[] = {
139 progname,
140 NULL,
141 };
142
143 test_spawn_prog(progname, args);
144 exit(EXIT_FAILURE);
145}
146DEFINE_TEST(depmod_search_order_external_first,
147 .description = "check if depmod honor external keyword with higher priority",
148 .config = {
149 [TC_UNAME_R] = "4.4.4",
150 [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS,
151 },
152 .output = {
153 .files = (const struct keyval[]) {
154 { SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
155 SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/modules.dep" },
156 { }
157 },
158 });
159
160#define SEARCH_ORDER_EXTERNAL_LAST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-last"
161static noreturn int depmod_search_order_external_last(const struct test *t)
162{
163 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
164 const char *const args[] = {
165 progname,
166 NULL,
167 };
168
169 test_spawn_prog(progname, args);
170 exit(EXIT_FAILURE);
171}
172DEFINE_TEST(depmod_search_order_external_last,
173 .description = "check if depmod honor external keyword with lower priority",
174 .config = {
175 [TC_UNAME_R] = "4.4.4",
176 [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_LAST_ROOTFS,
177 },
178 .output = {
179 .files = (const struct keyval[]) {
180 { SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
181 SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/modules.dep" },
182 { }
183 },
184 });
185
809b9fb6
YK
186#define SEARCH_ORDER_OVERRIDE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-override"
187static noreturn int depmod_search_order_override(const struct test *t)
188{
189 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
190 const char *const args[] = {
191 progname,
192 NULL,
193 };
194
195 test_spawn_prog(progname, args);
196 exit(EXIT_FAILURE);
197}
198DEFINE_TEST(depmod_search_order_override,
199 .description = "check if depmod honor override keyword",
200 .config = {
201 [TC_UNAME_R] = "4.4.4",
202 [TC_ROOTFS] = SEARCH_ORDER_OVERRIDE_ROOTFS,
203 },
204 .output = {
205 .files = (const struct keyval[]) {
206 { SEARCH_ORDER_OVERRIDE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
207 SEARCH_ORDER_OVERRIDE_ROOTFS "/lib/modules/4.4.4/modules.dep" },
208 { }
209 },
210 });
211
43289820 212TESTSUITE_MAIN();