• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 14895667988

07 May 2025 08:57PM UTC coverage: 72.225% (-0.007%) from 72.232%
14895667988

push

github

yuwata
network: log_link_message_debug_errno() automatically append %m if necessary

Follow-up for d28746ef5.
Fixes CID#1609753.

0 of 1 new or added line in 1 file covered. (0.0%)

20297 existing lines in 338 files now uncovered.

297407 of 411780 relevant lines covered (72.22%)

695716.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.22
/src/test/test-conf-parser.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "conf-parser.h"
4
#include "fd-util.h"
5
#include "fileio.h"
6
#include "fs-util.h"
7
#include "log.h"
8
#include "macro.h"
9
#include "mkdir.h"
10
#include "rm-rf.h"
11
#include "string-util.h"
12
#include "strv.h"
13
#include "tests.h"
14
#include "tmpfile-util.h"
15
#include "user-util.h"
16

17
static void test_config_parse_path_one(const char *rvalue, const char *expected) {
7✔
18
        _cleanup_free_ char *path = NULL;
14✔
19

20
        ASSERT_OK(config_parse_path("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &path, NULL));
7✔
21
        ASSERT_STREQ(expected, path);
7✔
22
}
7✔
23

24
static void test_config_parse_log_level_one(const char *rvalue, int expected) {
3✔
25
        int log_level = 0;
3✔
26

27
        ASSERT_OK(config_parse_log_level("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &log_level, NULL));
3✔
28
        ASSERT_EQ(expected, log_level);
3✔
29
}
3✔
30

31
static void test_config_parse_log_facility_one(const char *rvalue, int expected) {
3✔
32
        int log_facility = 0;
3✔
33

34
        ASSERT_OK(config_parse_log_facility("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &log_facility, NULL));
3✔
35
        ASSERT_EQ(expected, log_facility);
3✔
36
}
3✔
37

38
static void test_config_parse_iec_size_one(const char *rvalue, size_t expected) {
9✔
39
        size_t iec_size = 0;
9✔
40

41
        ASSERT_OK(config_parse_iec_size("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &iec_size, NULL));
9✔
42
        ASSERT_EQ(expected, iec_size);
9✔
43
}
9✔
44

45
static void test_config_parse_si_uint64_one(const char *rvalue, uint64_t expected) {
9✔
46
        uint64_t si_uint64 = 0;
9✔
47

48
        ASSERT_OK(config_parse_si_uint64("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &si_uint64, NULL));
9✔
49
        ASSERT_EQ(expected, si_uint64);
9✔
50
}
9✔
51

52
static void test_config_parse_int_one(const char *rvalue, int expected) {
7✔
53
        int v = -1;
7✔
54

55
        ASSERT_OK(config_parse_int("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
7✔
56
        ASSERT_EQ(expected, v);
7✔
57
}
7✔
58

59
static void test_config_parse_unsigned_one(const char *rvalue, unsigned expected) {
7✔
60
        unsigned v = 0;
7✔
61

62
        ASSERT_OK(config_parse_unsigned("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
7✔
63
        ASSERT_EQ(expected, v);
7✔
64
}
7✔
65

66
static void test_config_parse_strv_one(const char *rvalue, bool filter_duplicates, char **expected) {
12✔
67
        _cleanup_strv_free_ char **strv = NULL;
12✔
68

69
        ASSERT_OK(config_parse_strv("unit", "filename", 1, "section", 1, "lvalue", filter_duplicates, rvalue, &strv, NULL));
12✔
70
        ASSERT_TRUE(strv_equal(expected, strv));
12✔
71
}
12✔
72

73
static void test_config_parse_mode_one(const char *rvalue, mode_t expected) {
7✔
74
        mode_t v = 0;
7✔
75

76
        ASSERT_OK(config_parse_mode("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
7✔
77
        ASSERT_EQ(expected, v);
7✔
78
}
7✔
79

80
static void test_config_parse_sec_one(const char *rvalue, usec_t expected) {
7✔
81
        usec_t v = 0;
7✔
82

83
        ASSERT_OK(config_parse_sec("unit", "filename", 1, "section", 1, "lvalue", 0, rvalue, &v, NULL));
7✔
84
        ASSERT_EQ(expected, v);
7✔
85
}
7✔
86

87
static void test_config_parse_nsec_one(const char *rvalue, nsec_t expected) {
7✔
88
        nsec_t v = 0;
7✔
89

90
        ASSERT_OK(config_parse_nsec("unit", "filename", 1, "nsection", 1, "lvalue", 0, rvalue, &v, NULL));
7✔
91
        ASSERT_EQ(expected, v);
7✔
92
}
7✔
93

94
static void test_config_parse_iec_uint64_one(const char *rvalue, uint64_t expected) {
2✔
95
        uint64_t v = 0;
2✔
96

97
        ASSERT_OK(config_parse_iec_uint64("unit", "filename", 1, "nsection", 1, "lvalue", 0, rvalue, &v, NULL));
2✔
98
        ASSERT_EQ(expected, v);
2✔
99
}
2✔
100

101
TEST(config_parse_path) {
1✔
102
        test_config_parse_path_one("/path", "/path");
1✔
103
        test_config_parse_path_one("/path//////////", "/path");
1✔
104
        test_config_parse_path_one("///path/foo///bar////bar//", "/path/foo/bar/bar");
1✔
105
        test_config_parse_path_one("/path//./////hogehoge///.", "/path/hogehoge");
1✔
106
        test_config_parse_path_one("/path/\xc3\x80", "/path/\xc3\x80");
1✔
107

108
        test_config_parse_path_one("not_absolute/path", NULL);
1✔
109
        test_config_parse_path_one("/path/\xc3\x7f", NULL);
1✔
110
}
1✔
111

112
TEST(config_parse_log_level) {
1✔
113
        test_config_parse_log_level_one("debug", LOG_DEBUG);
1✔
114
        test_config_parse_log_level_one("info", LOG_INFO);
1✔
115

116
        test_config_parse_log_level_one("garbage", 0);
1✔
117
}
1✔
118

119
TEST(config_parse_log_facility) {
1✔
120
        test_config_parse_log_facility_one("mail", LOG_MAIL);
1✔
121
        test_config_parse_log_facility_one("user", LOG_USER);
1✔
122

123
        test_config_parse_log_facility_one("garbage", 0);
1✔
124
}
1✔
125

126
TEST(config_parse_iec_size) {
1✔
127
        test_config_parse_iec_size_one("1024", 1024);
1✔
128
        test_config_parse_iec_size_one("2K", 2048);
1✔
129
        test_config_parse_iec_size_one("10M", 10 * 1024 * 1024);
1✔
130
        test_config_parse_iec_size_one("1G", 1 * 1024 * 1024 * 1024);
1✔
131
        test_config_parse_iec_size_one("0G", 0);
1✔
132
        test_config_parse_iec_size_one("0", 0);
1✔
133

134
        test_config_parse_iec_size_one("-982", 0);
1✔
135
        test_config_parse_iec_size_one("49874444198739873000000G", 0);
1✔
136
        test_config_parse_iec_size_one("garbage", 0);
1✔
137
}
1✔
138

139
TEST(config_parse_si_uint64) {
1✔
140
        test_config_parse_si_uint64_one("1024", 1024);
1✔
141
        test_config_parse_si_uint64_one("2K", 2000);
1✔
142
        test_config_parse_si_uint64_one("10M", 10 * 1000 * 1000);
1✔
143
        test_config_parse_si_uint64_one("1G", 1 * 1000 * 1000 * 1000);
1✔
144
        test_config_parse_si_uint64_one("0G", 0);
1✔
145
        test_config_parse_si_uint64_one("0", 0);
1✔
146

147
        test_config_parse_si_uint64_one("-982", 0);
1✔
148
        test_config_parse_si_uint64_one("49874444198739873000000G", 0);
1✔
149
        test_config_parse_si_uint64_one("garbage", 0);
1✔
150
}
1✔
151

152
TEST(config_parse_int) {
1✔
153
        test_config_parse_int_one("1024", 1024);
1✔
154
        test_config_parse_int_one("-1024", -1024);
1✔
155
        test_config_parse_int_one("0", 0);
1✔
156

157
        test_config_parse_int_one("99999999999999999999999999999999999999999999999999999999", -1);
1✔
158
        test_config_parse_int_one("-99999999999999999999999999999999999999999999999999999999", -1);
1✔
159
        test_config_parse_int_one("1G", -1);
1✔
160
        test_config_parse_int_one("garbage", -1);
1✔
161
}
1✔
162

163
TEST(config_parse_unsigned) {
1✔
164
        test_config_parse_unsigned_one("10241024", 10241024);
1✔
165
        test_config_parse_unsigned_one("1024", 1024);
1✔
166
        test_config_parse_unsigned_one("0", 0);
1✔
167

168
        test_config_parse_unsigned_one("99999999999999999999999999999999999999999999999999999999", 0);
1✔
169
        test_config_parse_unsigned_one("1G", 0);
1✔
170
        test_config_parse_unsigned_one("garbage", 0);
1✔
171
        test_config_parse_unsigned_one("1000garbage", 0);
1✔
172
}
1✔
173

174
TEST(config_parse_strv) {
1✔
175
        test_config_parse_strv_one("", false, STRV_MAKE_EMPTY);
1✔
176
        test_config_parse_strv_one("foo", false, STRV_MAKE("foo"));
1✔
177
        test_config_parse_strv_one("foo bar foo", false, STRV_MAKE("foo", "bar", "foo"));
1✔
178
        test_config_parse_strv_one("\"foo bar\" foo", false, STRV_MAKE("foo bar", "foo"));
1✔
179
        test_config_parse_strv_one("\xc3\x80", false, STRV_MAKE("\xc3\x80"));
1✔
180
        test_config_parse_strv_one("\xc3\x7f", false, STRV_MAKE("\xc3\x7f"));
1✔
181

182
        test_config_parse_strv_one("", true, STRV_MAKE_EMPTY);
1✔
183
        test_config_parse_strv_one("foo", true, STRV_MAKE("foo"));
1✔
184
        test_config_parse_strv_one("foo bar foo", true, STRV_MAKE("foo", "bar"));
1✔
185
        test_config_parse_strv_one("\"foo bar\" foo", true, STRV_MAKE("foo bar", "foo"));
1✔
186
        test_config_parse_strv_one("\xc3\x80", true, STRV_MAKE("\xc3\x80"));
1✔
187
        test_config_parse_strv_one("\xc3\x7f", true, STRV_MAKE("\xc3\x7f"));
1✔
188
}
1✔
189

190
TEST(config_parse_mode) {
1✔
191
        test_config_parse_mode_one("777", 0777);
1✔
192
        test_config_parse_mode_one("644", 0644);
1✔
193

194
        test_config_parse_mode_one("-777", 0);
1✔
195
        test_config_parse_mode_one("999", 0);
1✔
196
        test_config_parse_mode_one("garbage", 0);
1✔
197
        test_config_parse_mode_one("777garbage", 0);
1✔
198
        test_config_parse_mode_one("777 garbage", 0);
1✔
199
}
1✔
200

201
TEST(config_parse_sec) {
1✔
202
        test_config_parse_sec_one("1", 1 * USEC_PER_SEC);
1✔
203
        test_config_parse_sec_one("1s", 1 * USEC_PER_SEC);
1✔
204
        test_config_parse_sec_one("100ms", 100 * USEC_PER_MSEC);
1✔
205
        test_config_parse_sec_one("5min 20s", 5 * 60 * USEC_PER_SEC + 20 * USEC_PER_SEC);
1✔
206

207
        test_config_parse_sec_one("-1", 0);
1✔
208
        test_config_parse_sec_one("10foo", 0);
1✔
209
        test_config_parse_sec_one("garbage", 0);
1✔
210
}
1✔
211

212
TEST(config_parse_nsec) {
1✔
213
        test_config_parse_nsec_one("1", 1);
1✔
214
        test_config_parse_nsec_one("1s", 1 * NSEC_PER_SEC);
1✔
215
        test_config_parse_nsec_one("100ms", 100 * NSEC_PER_MSEC);
1✔
216
        test_config_parse_nsec_one("5min 20s", 5 * 60 * NSEC_PER_SEC + 20 * NSEC_PER_SEC);
1✔
217

218
        test_config_parse_nsec_one("-1", 0);
1✔
219
        test_config_parse_nsec_one("10foo", 0);
1✔
220
        test_config_parse_nsec_one("garbage", 0);
1✔
221
}
1✔
222

223
TEST(config_parse_iec_uint64) {
1✔
224
        test_config_parse_iec_uint64_one("4M", UINT64_C(4 * 1024 * 1024));
1✔
225
        test_config_parse_iec_uint64_one("4.5M", UINT64_C((4 * 1024 + 512) * 1024));
1✔
226
}
1✔
227

228
#define x10(x) x x x x x x x x x x
229
#define x100(x) x10(x10(x))
230
#define x1000(x) x10(x100(x))
231

232
static const char* const config_file[] = {
233
        "[Section]\n"
234
        "setting1=1\n",
235

236
        "[Section]\n"
237
        "setting1=1",        /* no terminating newline */
238

239
        "\n\n\n\n[Section]\n\n\n"
240
        "setting1=1",        /* some whitespace, no terminating newline */
241

242
        "[Section]\n"
243
        "[Section]\n"
244
        "setting1=1\n"
245
        "setting1=    2 \t\n"
246
        "setting1=    1\n",  /* repeated settings */
247

248
        "[Section]\n"
249
        "[Section]\n"
250
        "setting1=1\n"
251
        "setting1=2\\\n"
252
        "   \n"              /* empty line breaks continuation */
253
        "setting1=1\n",      /* repeated settings */
254

255
        "[Section]\n"
256
        "setting1=1\\\n"     /* normal continuation */
257
        "2\\\n"
258
        "3\n",
259

260
        "[Section]\n"
261
        "#hogehoge\\\n"      /* continuation is ignored in comment */
262
        "setting1=1\\\n"     /* normal continuation */
263
        "2\\\n"
264
        "3\n",
265

266
        "[Section]\n"
267
        "setting1=1\\\n"     /* normal continuation */
268
        "#hogehoge\\\n"      /* commented out line in continuation is ignored */
269
        "2\\\n"
270
        "3\n",
271

272
        "[Section]\n"
273
        "   #hogehoge\\\n"   /* whitespaces before comments */
274
        "   setting1=1\\\n"  /* whitespaces before key */
275
        "2\\\n"
276
        "3\n",
277

278
        "[Section]\n"
279
        "   setting1=1\\\n"  /* whitespaces before key */
280
        "   #hogehoge\\\n"   /* commented out line prefixed with whitespaces in continuation */
281
        "2\\\n"
282
        "3\n",
283

284
        "[Section]\n"
285
        "setting1=1\\\n"     /* continuation with extra trailing backslash at the end */
286
        "2\\\n"
287
        "3\\\n",
288

289
        "[Section]\n"
290
        "setting1=1\\\\\\\n" /* continuation with trailing escape symbols */
291
        "\\\\2\n",           /* note that C requires one level of escaping, so the
292
                              * parser gets "…1 BS BS BS NL BS BS 2 NL", which
293
                              * it translates into "…1 BS BS SP BS BS 2" */
294

295
        "\n[Section]\n\n"
296
        "setting1="          /* a line above LINE_MAX length */
297
        x1000("ABCD")
298
        "\n",
299

300
        "[Section]\n"
301
        "setting1="          /* a line above LINE_MAX length, with continuation */
302
        x1000("ABCD") "\\\n"
303
        "foobar",
304

305
        "[Section]\n"
306
        "setting1="          /* a line above LINE_MAX length, with continuation */
307
        x1000("ABCD") "\\\n" /* and an extra trailing backslash */
308
        "foobar\\\n",
309

310
        "[Section]\n"
311
        "setting1="          /* a line above the allowed limit: 9 + 1050000 + 1 */
312
        x1000(x1000("x") x10("abcde")) "\n",
313

314
        "[Section]\n"
315
        "setting1="          /* many continuation lines, together above the limit */
316
        x1000(x1000("x") x10("abcde") "\\\n") "xxx",
317

318
        "[Section]\n"
319
        "setting1=2\n"
320
        "[NoWarnSection]\n"
321
        "setting1=3\n"
322
        "[WarnSection]\n"
323
        "setting1=3\n"
324
        "[X-Section]\n"
325
        "setting1=3\n",
326
};
327

328
static void test_config_parse_one(unsigned i, const char *s) {
18✔
UNCOV
329
        _cleanup_(unlink_tempfilep) char name[] = "/tmp/test-conf-parser.XXXXXX";
×
330
        _cleanup_fclose_ FILE *f = NULL;
18✔
331
        _cleanup_free_ char *setting1 = NULL;
18✔
332
        int r;
18✔
333

334
        const ConfigTableItem items[] = {
18✔
335
                { "Section", "setting1",  config_parse_string,   0, &setting1},
336
                {}
337
        };
338

339
        log_info("== %s[%u] ==", __func__, i);
18✔
340

341
        assert_se(fmkostemp_safe(name, "r+", &f) == 0);
18✔
342
        assert_se(fwrite(s, strlen(s), 1, f) == 1);
18✔
343
        rewind(f);
18✔
344

345
        /*
346
        int config_parse(const char *unit,
347
                         const char *filename,
348
                         FILE *f,
349
                         const char *sections,
350
                         ConfigItemLookup lookup,
351
                         const void *table,
352
                         ConfigParseFlags flags,
353
                         void *userdata,
354
                         struct stat *ret_stat);
355
        */
356

357
        r = config_parse(NULL, name, f,
18✔
358
                         "Section\0"
359
                         "-NoWarnSection\0",
360
                         config_item_table_lookup, items,
361
                         CONFIG_PARSE_WARN,
362
                         NULL,
363
                         NULL);
364

365
        switch (i) {
18✔
366
        case 0 ... 4:
5✔
367
                assert_se(r == 1);
5✔
368
                ASSERT_STREQ(setting1, "1");
5✔
369
                break;
370

371
        case 5 ... 10:
6✔
372
                assert_se(r == 1);
6✔
373
                ASSERT_STREQ(setting1, "1 2 3");
6✔
374
                break;
375

376
        case 11:
1✔
377
                assert_se(r == 1);
1✔
378
                ASSERT_STREQ(setting1, "1\\\\ \\\\2");
1✔
379
                break;
380

381
        case 12:
1✔
382
                assert_se(r == 1);
1✔
383
                ASSERT_STREQ(setting1, x1000("ABCD"));
1✔
384
                break;
385

386
        case 13 ... 14:
2✔
387
                assert_se(r == 1);
2✔
388
                ASSERT_STREQ(setting1, x1000("ABCD") " foobar");
2✔
389
                break;
390

391
        case 15 ... 16:
2✔
392
                assert_se(r == -ENOBUFS);
2✔
393
                ASSERT_NULL(setting1);
2✔
394
                break;
395

396
        case 17:
1✔
397
                assert_se(r == 1);
1✔
398
                ASSERT_STREQ(setting1, "2");
1✔
399
                break;
400
        }
401
}
18✔
402

403
TEST(config_parse) {
1✔
404
        for (unsigned i = 0; i < ELEMENTSOF(config_file); i++)
19✔
405
                test_config_parse_one(i, config_file[i]);
18✔
406
}
1✔
407

408
TEST(config_parse_standard_file_with_dropins_full) {
1✔
UNCOV
409
        _cleanup_(rm_rf_physical_and_freep) char *root = NULL;
×
410
        _cleanup_close_ int rfd = -EBADF;
1✔
411
        int r;
1✔
412

413
        ASSERT_OK(rfd = mkdtemp_open("/tmp/test-config-parse-XXXXXX", 0, &root));
1✔
414
        assert_se(mkdir_p_root(root, "/etc/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
415
        assert_se(mkdir_p_root(root, "/run/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
416
        assert_se(mkdir_p_root(root, "/usr/lib/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
417
        assert_se(mkdir_p_root(root, "/usr/local/lib/kernel/install.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
418

419
        assert_se(write_string_file_at(rfd, "usr/lib/kernel/install.conf",         /* this one is ignored */
1✔
420
                                       "A=!!!", WRITE_STRING_FILE_CREATE) == 0);
421
        assert_se(write_string_file_at(rfd, "usr/local/lib/kernel/install.conf",
1✔
422
                                       "A=aaa", WRITE_STRING_FILE_CREATE) == 0);
423
        assert_se(write_string_file_at(rfd, "usr/local/lib/kernel/install.conf.d/drop1.conf",
1✔
424
                                       "B=bbb", WRITE_STRING_FILE_CREATE) == 0);
425
        assert_se(write_string_file_at(rfd, "usr/local/lib/kernel/install.conf.d/drop2.conf",
1✔
426
                                       "C=c1", WRITE_STRING_FILE_CREATE) == 0);
427
        assert_se(write_string_file_at(rfd, "usr/lib/kernel/install.conf.d/drop2.conf",   /* this one is ignored */
1✔
428
                                       "C=c2", WRITE_STRING_FILE_CREATE) == 0);
429
        assert_se(write_string_file_at(rfd, "run/kernel/install.conf.d/drop3.conf",
1✔
430
                                       "D=ddd", WRITE_STRING_FILE_CREATE) == 0);
431
        assert_se(write_string_file_at(rfd, "etc/kernel/install.conf.d/drop4.conf",
1✔
432
                                       "E=eee", WRITE_STRING_FILE_CREATE) == 0);
433

434
        _cleanup_free_ char *A = NULL, *B = NULL, *C = NULL, *D = NULL, *E = NULL, *F = NULL;
1✔
435
        _cleanup_strv_free_ char **dropins = NULL;
1✔
436

437
        const ConfigTableItem items[] = {
1✔
438
                { NULL, "A",  config_parse_string,   0, &A},
439
                { NULL, "B",  config_parse_string,   0, &B},
440
                { NULL, "C",  config_parse_string,   0, &C},
441
                { NULL, "D",  config_parse_string,   0, &D},
442
                { NULL, "E",  config_parse_string,   0, &E},
443
                { NULL, "F",  config_parse_string,   0, &F},
444
                {}
445
        };
446

447
        r = config_parse_standard_file_with_dropins_full(
1✔
448
                        root, "kernel/install.conf",
449
                        /* sections= */ NULL,
450
                        config_item_table_lookup, items,
451
                        CONFIG_PARSE_WARN,
452
                        /* userdata= */ NULL,
453
                        /* ret_stats_by_path= */ NULL,
454
                        /* ret_dropin_files= */ &dropins);
455
        assert_se(r >= 0);
1✔
456
        ASSERT_STREQ(A, "aaa");
1✔
457
        ASSERT_STREQ(B, "bbb");
1✔
458
        ASSERT_STREQ(C, "c1");
1✔
459
        ASSERT_STREQ(D, "ddd");
1✔
460
        ASSERT_STREQ(E, "eee");
1✔
461
        ASSERT_STREQ(F, NULL);
1✔
462

463
        A = mfree(A);
1✔
464
        B = mfree(B);
1✔
465
        C = mfree(C);
1✔
466
        D = mfree(D);
1✔
467
        E = mfree(E);
1✔
468

469
        assert_se(strv_length(dropins) == 4);
1✔
470

471
        /* Make sure that we follow symlinks */
472
        assert_se(mkdir_p_root(root, "/etc/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
473
        assert_se(mkdir_p_root(root, "/run/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
474
        assert_se(mkdir_p_root(root, "/usr/lib/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
475
        assert_se(mkdir_p_root(root, "/usr/local/lib/kernel/install2.conf.d", UID_INVALID, GID_INVALID, 0755));
1✔
476

477
        /* (Those symlinks are only useful relative to <root>. */
478
        assert_se(symlinkat("/usr/lib/kernel/install.conf", rfd, "usr/lib/kernel/install2.conf") == 0);
1✔
479
        assert_se(symlinkat("/usr/local/lib/kernel/install.conf", rfd, "usr/local/lib/kernel/install2.conf") == 0);
1✔
480
        assert_se(symlinkat("/usr/local/lib/kernel/install.conf.d/drop1.conf", rfd, "usr/local/lib/kernel/install2.conf.d/drop1.conf") == 0);
1✔
481
        assert_se(symlinkat("/usr/local/lib/kernel/install.conf.d/drop2.conf", rfd, "usr/local/lib/kernel/install2.conf.d/drop2.conf") == 0);
1✔
482
        assert_se(symlinkat("/usr/lib/kernel/install.conf.d/drop2.conf", rfd, "usr/lib/kernel/install2.conf.d/drop2.conf") == 0);
1✔
483
        assert_se(symlinkat("/run/kernel/install.conf.d/drop3.conf", rfd, "run/kernel/install2.conf.d/drop3.conf") == 0);
1✔
484
        assert_se(symlinkat("/etc/kernel/install.conf.d/drop4.conf", rfd, "etc/kernel/install2.conf.d/drop4.conf") == 0);
1✔
485

486
        r = config_parse_standard_file_with_dropins_full(
1✔
487
                        root, "kernel/install2.conf",
488
                        /* sections= */ NULL,
489
                        config_item_table_lookup, items,
490
                        CONFIG_PARSE_WARN,
491
                        /* userdata= */ NULL,
492
                        /* ret_stats_by_path= */ NULL,
493
                        /* ret_dropin_files= */ NULL);
494
        assert_se(r >= 0);
1✔
495
        ASSERT_STREQ(A, "aaa");
1✔
496
        ASSERT_STREQ(B, "bbb");
1✔
497
        ASSERT_STREQ(C, "c1");
1✔
498
        ASSERT_STREQ(D, "ddd");
1✔
499
        ASSERT_STREQ(E, "eee");
1✔
500
        ASSERT_STREQ(F, NULL);
1✔
501
}
1✔
502

503
DEFINE_TEST_MAIN(LOG_INFO);
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc