]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-conf-parser.c
ci: enable arm64 runner for build/unit jobs
[thirdparty/systemd.git] / src / test / test-conf-parser.c
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
0763adbe 2
4f18ff2e
YW
3#include <unistd.h>
4
0763adbe 5#include "conf-parser.h"
e3f46367 6#include "fd-util.h"
e7e52ff9 7#include "fileio.h"
07630cea 8#include "log.h"
e7e52ff9 9#include "mkdir.h"
63be834d 10#include "rm-rf.h"
0763adbe 11#include "strv.h"
4f7452a8 12#include "tests.h"
fa34123c 13#include "time-util.h"
e4de7287 14#include "tmpfile-util.h"
0763adbe
RC
15
16static void test_config_parse_path_one(const char *rvalue, const char *expected) {
a12807aa 17 _cleanup_free_ char *path = NULL;
0763adbe 18
7094e6d9 19 ASSERT_OK(config_parse_path("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &path, NULL));
c79e88b3 20 ASSERT_STREQ(expected, path);
0763adbe
RC
21}
22
23static void test_config_parse_log_level_one(const char *rvalue, int expected) {
24 int log_level = 0;
25
7094e6d9
YW
26 ASSERT_OK(config_parse_log_level("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &log_level, NULL));
27 ASSERT_EQ(expected, log_level);
0763adbe
RC
28}
29
30static void test_config_parse_log_facility_one(const char *rvalue, int expected) {
31 int log_facility = 0;
32
7094e6d9
YW
33 ASSERT_OK(config_parse_log_facility("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &log_facility, NULL));
34 ASSERT_EQ(expected, log_facility);
0763adbe
RC
35}
36
37static void test_config_parse_iec_size_one(const char *rvalue, size_t expected) {
38 size_t iec_size = 0;
39
7094e6d9
YW
40 ASSERT_OK(config_parse_iec_size("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &iec_size, NULL));
41 ASSERT_EQ(expected, iec_size);
0763adbe
RC
42}
43
50299121
YW
44static void test_config_parse_si_uint64_one(const char *rvalue, uint64_t expected) {
45 uint64_t si_uint64 = 0;
0763adbe 46
7094e6d9
YW
47 ASSERT_OK(config_parse_si_uint64("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &si_uint64, NULL));
48 ASSERT_EQ(expected, si_uint64);
0763adbe
RC
49}
50
51static void test_config_parse_int_one(const char *rvalue, int expected) {
52 int v = -1;
53
7094e6d9
YW
54 ASSERT_OK(config_parse_int("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
55 ASSERT_EQ(expected, v);
0763adbe
RC
56}
57
58static void test_config_parse_unsigned_one(const char *rvalue, unsigned expected) {
59 unsigned v = 0;
60
7094e6d9
YW
61 ASSERT_OK(config_parse_unsigned("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
62 ASSERT_EQ(expected, v);
0763adbe
RC
63}
64
c33aacdc 65static void test_config_parse_strv_one(const char *rvalue, bool filter_duplicates, char **expected) {
a12807aa 66 _cleanup_strv_free_ char **strv = NULL;
0763adbe 67
7094e6d9
YW
68 ASSERT_OK(config_parse_strv("unit", "filename", 1, "section", 1, "lvalue", filter_duplicates, rvalue, &strv, NULL));
69 ASSERT_TRUE(strv_equal(expected, strv));
0763adbe
RC
70}
71
72static void test_config_parse_mode_one(const char *rvalue, mode_t expected) {
73 mode_t v = 0;
74
7094e6d9
YW
75 ASSERT_OK(config_parse_mode("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
76 ASSERT_EQ(expected, v);
0763adbe
RC
77}
78
79static void test_config_parse_sec_one(const char *rvalue, usec_t expected) {
80 usec_t v = 0;
81
7094e6d9
YW
82 ASSERT_OK(config_parse_sec("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
83 ASSERT_EQ(expected, v);
0763adbe
RC
84}
85
86static void test_config_parse_nsec_one(const char *rvalue, nsec_t expected) {
87 nsec_t v = 0;
88
7094e6d9
YW
89 ASSERT_OK(config_parse_nsec("unit", "filename", 1, "nsection", 1, "lvalue", 0, rvalue, &v, NULL));
90 ASSERT_EQ(expected, v);
91}
92
93static void test_config_parse_iec_uint64_one(const char *rvalue, uint64_t expected) {
94 uint64_t v = 0;
95
96 ASSERT_OK(config_parse_iec_uint64("unit", "filename", 1, "nsection", 1, "lvalue", 0, rvalue, &v, NULL));
97 ASSERT_EQ(expected, v);
0763adbe
RC
98}
99
4f7452a8 100TEST(config_parse_path) {
0763adbe
RC
101 test_config_parse_path_one("/path", "/path");
102 test_config_parse_path_one("/path//////////", "/path");
103 test_config_parse_path_one("///path/foo///bar////bar//", "/path/foo/bar/bar");
cd4f53c5 104 test_config_parse_path_one("/path//./////hogehoge///.", "/path/hogehoge");
d5ade2d6 105 test_config_parse_path_one("/path/\xc3\x80", "/path/\xc3\x80");
0763adbe
RC
106
107 test_config_parse_path_one("not_absolute/path", NULL);
d5ade2d6 108 test_config_parse_path_one("/path/\xc3\x7f", NULL);
0763adbe
RC
109}
110
4f7452a8 111TEST(config_parse_log_level) {
0763adbe
RC
112 test_config_parse_log_level_one("debug", LOG_DEBUG);
113 test_config_parse_log_level_one("info", LOG_INFO);
114
115 test_config_parse_log_level_one("garbage", 0);
116}
117
4f7452a8 118TEST(config_parse_log_facility) {
0763adbe
RC
119 test_config_parse_log_facility_one("mail", LOG_MAIL);
120 test_config_parse_log_facility_one("user", LOG_USER);
121
122 test_config_parse_log_facility_one("garbage", 0);
123}
124
4f7452a8 125TEST(config_parse_iec_size) {
0763adbe
RC
126 test_config_parse_iec_size_one("1024", 1024);
127 test_config_parse_iec_size_one("2K", 2048);
128 test_config_parse_iec_size_one("10M", 10 * 1024 * 1024);
129 test_config_parse_iec_size_one("1G", 1 * 1024 * 1024 * 1024);
130 test_config_parse_iec_size_one("0G", 0);
131 test_config_parse_iec_size_one("0", 0);
132
133 test_config_parse_iec_size_one("-982", 0);
134 test_config_parse_iec_size_one("49874444198739873000000G", 0);
135 test_config_parse_iec_size_one("garbage", 0);
136}
137
4f7452a8 138TEST(config_parse_si_uint64) {
50299121
YW
139 test_config_parse_si_uint64_one("1024", 1024);
140 test_config_parse_si_uint64_one("2K", 2000);
141 test_config_parse_si_uint64_one("10M", 10 * 1000 * 1000);
142 test_config_parse_si_uint64_one("1G", 1 * 1000 * 1000 * 1000);
143 test_config_parse_si_uint64_one("0G", 0);
144 test_config_parse_si_uint64_one("0", 0);
145
146 test_config_parse_si_uint64_one("-982", 0);
147 test_config_parse_si_uint64_one("49874444198739873000000G", 0);
148 test_config_parse_si_uint64_one("garbage", 0);
0763adbe
RC
149}
150
4f7452a8 151TEST(config_parse_int) {
0763adbe
RC
152 test_config_parse_int_one("1024", 1024);
153 test_config_parse_int_one("-1024", -1024);
154 test_config_parse_int_one("0", 0);
155
156 test_config_parse_int_one("99999999999999999999999999999999999999999999999999999999", -1);
157 test_config_parse_int_one("-99999999999999999999999999999999999999999999999999999999", -1);
158 test_config_parse_int_one("1G", -1);
159 test_config_parse_int_one("garbage", -1);
160}
161
4f7452a8 162TEST(config_parse_unsigned) {
0763adbe
RC
163 test_config_parse_unsigned_one("10241024", 10241024);
164 test_config_parse_unsigned_one("1024", 1024);
165 test_config_parse_unsigned_one("0", 0);
166
167 test_config_parse_unsigned_one("99999999999999999999999999999999999999999999999999999999", 0);
168 test_config_parse_unsigned_one("1G", 0);
169 test_config_parse_unsigned_one("garbage", 0);
170 test_config_parse_unsigned_one("1000garbage", 0);
171}
172
4f7452a8 173TEST(config_parse_strv) {
e47fb4ab 174 test_config_parse_strv_one("", false, STRV_EMPTY);
c33aacdc
YW
175 test_config_parse_strv_one("foo", false, STRV_MAKE("foo"));
176 test_config_parse_strv_one("foo bar foo", false, STRV_MAKE("foo", "bar", "foo"));
177 test_config_parse_strv_one("\"foo bar\" foo", false, STRV_MAKE("foo bar", "foo"));
178 test_config_parse_strv_one("\xc3\x80", false, STRV_MAKE("\xc3\x80"));
179 test_config_parse_strv_one("\xc3\x7f", false, STRV_MAKE("\xc3\x7f"));
180
e47fb4ab 181 test_config_parse_strv_one("", true, STRV_EMPTY);
c33aacdc
YW
182 test_config_parse_strv_one("foo", true, STRV_MAKE("foo"));
183 test_config_parse_strv_one("foo bar foo", true, STRV_MAKE("foo", "bar"));
184 test_config_parse_strv_one("\"foo bar\" foo", true, STRV_MAKE("foo bar", "foo"));
185 test_config_parse_strv_one("\xc3\x80", true, STRV_MAKE("\xc3\x80"));
186 test_config_parse_strv_one("\xc3\x7f", true, STRV_MAKE("\xc3\x7f"));
0763adbe
RC
187}
188
4f7452a8 189TEST(config_parse_mode) {
0763adbe
RC
190 test_config_parse_mode_one("777", 0777);
191 test_config_parse_mode_one("644", 0644);
192
193 test_config_parse_mode_one("-777", 0);
194 test_config_parse_mode_one("999", 0);
195 test_config_parse_mode_one("garbage", 0);
196 test_config_parse_mode_one("777garbage", 0);
197 test_config_parse_mode_one("777 garbage", 0);
198}
199
4f7452a8 200TEST(config_parse_sec) {
0763adbe
RC
201 test_config_parse_sec_one("1", 1 * USEC_PER_SEC);
202 test_config_parse_sec_one("1s", 1 * USEC_PER_SEC);
203 test_config_parse_sec_one("100ms", 100 * USEC_PER_MSEC);
204 test_config_parse_sec_one("5min 20s", 5 * 60 * USEC_PER_SEC + 20 * USEC_PER_SEC);
205
206 test_config_parse_sec_one("-1", 0);
207 test_config_parse_sec_one("10foo", 0);
208 test_config_parse_sec_one("garbage", 0);
209}
210
4f7452a8 211TEST(config_parse_nsec) {
0763adbe
RC
212 test_config_parse_nsec_one("1", 1);
213 test_config_parse_nsec_one("1s", 1 * NSEC_PER_SEC);
214 test_config_parse_nsec_one("100ms", 100 * NSEC_PER_MSEC);
215 test_config_parse_nsec_one("5min 20s", 5 * 60 * NSEC_PER_SEC + 20 * NSEC_PER_SEC);
216
217 test_config_parse_nsec_one("-1", 0);
218 test_config_parse_nsec_one("10foo", 0);
219 test_config_parse_nsec_one("garbage", 0);
220}
221
4f7452a8 222TEST(config_parse_iec_uint64) {
7094e6d9
YW
223 test_config_parse_iec_uint64_one("4M", UINT64_C(4 * 1024 * 1024));
224 test_config_parse_iec_uint64_one("4.5M", UINT64_C((4 * 1024 + 512) * 1024));
f55211db
RC
225}
226
8f313f4f
ZJS
227#define x10(x) x x x x x x x x x x
228#define x100(x) x10(x10(x))
229#define x1000(x) x10(x100(x))
230
e3f46367
ZJS
231static const char* const config_file[] = {
232 "[Section]\n"
233 "setting1=1\n",
234
235 "[Section]\n"
236 "setting1=1", /* no terminating newline */
237
238 "\n\n\n\n[Section]\n\n\n"
239 "setting1=1", /* some whitespace, no terminating newline */
240
241 "[Section]\n"
242 "[Section]\n"
243 "setting1=1\n"
b9d9fbe4
ZJS
244 "setting1= 2 \t\n"
245 "setting1= 1\n", /* repeated settings */
e3f46367 246
3d5d346a
YW
247 "[Section]\n"
248 "[Section]\n"
249 "setting1=1\n"
250 "setting1=2\\\n"
251 " \n" /* empty line breaks continuation */
252 "setting1=1\n", /* repeated settings */
253
e3f46367
ZJS
254 "[Section]\n"
255 "setting1=1\\\n" /* normal continuation */
256 "2\\\n"
257 "3\n",
258
9adbfeb3
YW
259 "[Section]\n"
260 "#hogehoge\\\n" /* continuation is ignored in comment */
261 "setting1=1\\\n" /* normal continuation */
262 "2\\\n"
263 "3\n",
264
265 "[Section]\n"
266 "setting1=1\\\n" /* normal continuation */
267 "#hogehoge\\\n" /* commented out line in continuation is ignored */
268 "2\\\n"
269 "3\n",
270
ff650ffe
YW
271 "[Section]\n"
272 " #hogehoge\\\n" /* whitespaces before comments */
273 " setting1=1\\\n" /* whitespaces before key */
274 "2\\\n"
275 "3\n",
276
277 "[Section]\n"
278 " setting1=1\\\n" /* whitespaces before key */
279 " #hogehoge\\\n" /* commented out line prefixed with whitespaces in continuation */
280 "2\\\n"
281 "3\n",
282
4f29e0db
FB
283 "[Section]\n"
284 "setting1=1\\\n" /* continuation with extra trailing backslash at the end */
285 "2\\\n"
286 "3\\\n",
287
e3f46367
ZJS
288 "[Section]\n"
289 "setting1=1\\\\\\\n" /* continuation with trailing escape symbols */
290 "\\\\2\n", /* note that C requires one level of escaping, so the
291 * parser gets "…1 BS BS BS NL BS BS 2 NL", which
292 * it translates into "…1 BS BS SP BS BS 2" */
8f313f4f
ZJS
293
294 "\n[Section]\n\n"
295 "setting1=" /* a line above LINE_MAX length */
296 x1000("ABCD")
297 "\n",
298
299 "[Section]\n"
300 "setting1=" /* a line above LINE_MAX length, with continuation */
301 x1000("ABCD") "\\\n"
302 "foobar",
303
4f29e0db
FB
304 "[Section]\n"
305 "setting1=" /* a line above LINE_MAX length, with continuation */
306 x1000("ABCD") "\\\n" /* and an extra trailing backslash */
307 "foobar\\\n",
308
8f313f4f
ZJS
309 "[Section]\n"
310 "setting1=" /* a line above the allowed limit: 9 + 1050000 + 1 */
311 x1000(x1000("x") x10("abcde")) "\n",
312
313 "[Section]\n"
314 "setting1=" /* many continuation lines, together above the limit */
315 x1000(x1000("x") x10("abcde") "\\\n") "xxx",
ddeb3f5d
ZJS
316
317 "[Section]\n"
318 "setting1=2\n"
319 "[NoWarnSection]\n"
320 "setting1=3\n"
321 "[WarnSection]\n"
322 "setting1=3\n"
323 "[X-Section]\n"
324 "setting1=3\n",
e3f46367
ZJS
325};
326
4f7452a8 327static void test_config_parse_one(unsigned i, const char *s) {
627d2bac 328 _cleanup_(unlink_tempfilep) char name[] = "/tmp/test-conf-parser.XXXXXX";
e3f46367
ZJS
329 _cleanup_fclose_ FILE *f = NULL;
330 _cleanup_free_ char *setting1 = NULL;
d8351049 331 int r;
e3f46367
ZJS
332
333 const ConfigTableItem items[] = {
334 { "Section", "setting1", config_parse_string, 0, &setting1},
335 {}
336 };
337
c0f86d66 338 log_info("== %s[%u] ==", __func__, i);
e3f46367 339
d8351049
ZJS
340 assert_se(fmkostemp_safe(name, "r+", &f) == 0);
341 assert_se(fwrite(s, strlen(s), 1, f) == 1);
342 rewind(f);
e3f46367
ZJS
343
344 /*
345 int config_parse(const char *unit,
346 const char *filename,
347 FILE *f,
348 const char *sections,
349 ConfigItemLookup lookup,
350 const void *table,
ddeb3f5d 351 ConfigParseFlags flags,
4f9ff96a 352 void *userdata,
3dea4701 353 struct stat *ret_stat);
e3f46367
ZJS
354 */
355
356 r = config_parse(NULL, name, f,
4f9ff96a
LP
357 "Section\0"
358 "-NoWarnSection\0",
e3f46367 359 config_item_table_lookup, items,
4f9ff96a
LP
360 CONFIG_PARSE_WARN,
361 NULL,
362 NULL);
e3f46367
ZJS
363
364 switch (i) {
3d5d346a 365 case 0 ... 4:
8b8024f1 366 assert_se(r == 1);
c79e88b3 367 ASSERT_STREQ(setting1, "1");
e3f46367
ZJS
368 break;
369
3d5d346a 370 case 5 ... 10:
8b8024f1 371 assert_se(r == 1);
c79e88b3 372 ASSERT_STREQ(setting1, "1 2 3");
e3f46367
ZJS
373 break;
374
3d5d346a 375 case 11:
8b8024f1 376 assert_se(r == 1);
c79e88b3 377 ASSERT_STREQ(setting1, "1\\\\ \\\\2");
e3f46367 378 break;
8f313f4f 379
3d5d346a 380 case 12:
8b8024f1 381 assert_se(r == 1);
c79e88b3 382 ASSERT_STREQ(setting1, x1000("ABCD"));
8f313f4f
ZJS
383 break;
384
3d5d346a 385 case 13 ... 14:
8b8024f1 386 assert_se(r == 1);
c79e88b3 387 ASSERT_STREQ(setting1, x1000("ABCD") " foobar");
8f313f4f
ZJS
388 break;
389
3d5d346a 390 case 15 ... 16:
8f313f4f 391 assert_se(r == -ENOBUFS);
5152b845 392 ASSERT_NULL(setting1);
8f313f4f 393 break;
ddeb3f5d
ZJS
394
395 case 17:
8b8024f1 396 assert_se(r == 1);
c79e88b3 397 ASSERT_STREQ(setting1, "2");
ddeb3f5d 398 break;
e3f46367
ZJS
399 }
400}
401
4f7452a8
JJ
402TEST(config_parse) {
403 for (unsigned i = 0; i < ELEMENTSOF(config_file); i++)
404 test_config_parse_one(i, config_file[i]);
0763adbe 405}
4f7452a8 406
e7e52ff9 407TEST(config_parse_standard_file_with_dropins_full) {
63be834d 408 _cleanup_(rm_rf_physical_and_freep) char *root = NULL;
e7e52ff9
ZJS
409 _cleanup_close_ int rfd = -EBADF;
410 int r;
411
d9000d70 412 ASSERT_OK(rfd = mkdtemp_open("/tmp/test-config-parse-XXXXXX", 0, &root));
34c3d574
MS
413 assert_se(mkdir_p_root(root, "/etc/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
414 assert_se(mkdir_p_root(root, "/run/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
415 assert_se(mkdir_p_root(root, "/usr/lib/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
416 assert_se(mkdir_p_root(root, "/usr/local/lib/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
e7e52ff9 417
e7e52ff9
ZJS
418 assert_se(write_string_file_at(rfd, "usr/lib/kernel/install.conf", /* this one is ignored */
419 "A=!!!", WRITE_STRING_FILE_CREATE) == 0);
420 assert_se(write_string_file_at(rfd, "usr/local/lib/kernel/install.conf",
421 "A=aaa", WRITE_STRING_FILE_CREATE) == 0);
422 assert_se(write_string_file_at(rfd, "usr/local/lib/kernel/install.conf.d/drop1.conf",
423 "B=bbb", WRITE_STRING_FILE_CREATE) == 0);
424 assert_se(write_string_file_at(rfd, "usr/local/lib/kernel/install.conf.d/drop2.conf",
425 "C=c1", WRITE_STRING_FILE_CREATE) == 0);
426 assert_se(write_string_file_at(rfd, "usr/lib/kernel/install.conf.d/drop2.conf", /* this one is ignored */
427 "C=c2", WRITE_STRING_FILE_CREATE) == 0);
428 assert_se(write_string_file_at(rfd, "run/kernel/install.conf.d/drop3.conf",
429 "D=ddd", WRITE_STRING_FILE_CREATE) == 0);
430 assert_se(write_string_file_at(rfd, "etc/kernel/install.conf.d/drop4.conf",
431 "E=eee", WRITE_STRING_FILE_CREATE) == 0);
432
433 _cleanup_free_ char *A = NULL, *B = NULL, *C = NULL, *D = NULL, *E = NULL, *F = NULL;
434 _cleanup_strv_free_ char **dropins = NULL;
435
436 const ConfigTableItem items[] = {
437 { NULL, "A", config_parse_string, 0, &A},
438 { NULL, "B", config_parse_string, 0, &B},
439 { NULL, "C", config_parse_string, 0, &C},
440 { NULL, "D", config_parse_string, 0, &D},
441 { NULL, "E", config_parse_string, 0, &E},
442 { NULL, "F", config_parse_string, 0, &F},
443 {}
444 };
445
446 r = config_parse_standard_file_with_dropins_full(
447 root, "kernel/install.conf",
448 /* sections= */ NULL,
449 config_item_table_lookup, items,
450 CONFIG_PARSE_WARN,
451 /* userdata= */ NULL,
452 /* ret_stats_by_path= */ NULL,
453 /* ret_dropin_files= */ &dropins);
454 assert_se(r >= 0);
c79e88b3
IK
455 ASSERT_STREQ(A, "aaa");
456 ASSERT_STREQ(B, "bbb");
457 ASSERT_STREQ(C, "c1");
458 ASSERT_STREQ(D, "ddd");
459 ASSERT_STREQ(E, "eee");
460 ASSERT_STREQ(F, NULL);
e7e52ff9
ZJS
461
462 A = mfree(A);
463 B = mfree(B);
464 C = mfree(C);
465 D = mfree(D);
466 E = mfree(E);
467
468 assert_se(strv_length(dropins) == 4);
469
470 /* Make sure that we follow symlinks */
34c3d574
MS
471 assert_se(mkdir_p_root(root, "/etc/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
472 assert_se(mkdir_p_root(root, "/run/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
473 assert_se(mkdir_p_root(root, "/usr/lib/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
474 assert_se(mkdir_p_root(root, "/usr/local/lib/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
e7e52ff9
ZJS
475
476 /* (Those symlinks are only useful relative to <root>. */
477 assert_se(symlinkat("/usr/lib/kernel/install.conf", rfd, "usr/lib/kernel/install2.conf") == 0);
478 assert_se(symlinkat("/usr/local/lib/kernel/install.conf", rfd, "usr/local/lib/kernel/install2.conf") == 0);
479 assert_se(symlinkat("/usr/local/lib/kernel/install.conf.d/drop1.conf", rfd, "usr/local/lib/kernel/install2.conf.d/drop1.conf") == 0);
480 assert_se(symlinkat("/usr/local/lib/kernel/install.conf.d/drop2.conf", rfd, "usr/local/lib/kernel/install2.conf.d/drop2.conf") == 0);
481 assert_se(symlinkat("/usr/lib/kernel/install.conf.d/drop2.conf", rfd, "usr/lib/kernel/install2.conf.d/drop2.conf") == 0);
482 assert_se(symlinkat("/run/kernel/install.conf.d/drop3.conf", rfd, "run/kernel/install2.conf.d/drop3.conf") == 0);
483 assert_se(symlinkat("/etc/kernel/install.conf.d/drop4.conf", rfd, "etc/kernel/install2.conf.d/drop4.conf") == 0);
484
485 r = config_parse_standard_file_with_dropins_full(
486 root, "kernel/install2.conf",
487 /* sections= */ NULL,
488 config_item_table_lookup, items,
489 CONFIG_PARSE_WARN,
490 /* userdata= */ NULL,
491 /* ret_stats_by_path= */ NULL,
492 /* ret_dropin_files= */ NULL);
493 assert_se(r >= 0);
c79e88b3
IK
494 ASSERT_STREQ(A, "aaa");
495 ASSERT_STREQ(B, "bbb");
496 ASSERT_STREQ(C, "c1");
497 ASSERT_STREQ(D, "ddd");
498 ASSERT_STREQ(E, "eee");
499 ASSERT_STREQ(F, NULL);
e7e52ff9
ZJS
500}
501
4f7452a8 502DEFINE_TEST_MAIN(LOG_INFO);