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

systemd / systemd / 18052125394

26 Sep 2025 11:00PM UTC coverage: 72.224% (+0.02%) from 72.205%
18052125394

push

github

YHNdnzj
pam_systemd: correct alignment

Follow-up for cf2630aca

303350 of 420010 relevant lines covered (72.22%)

1058085.05 hits per line

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

93.02
/src/test/test-libmount.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "alloc-util.h"
4
#include "escape.h"
5
#include "fd-util.h"
6
#include "libmount-util.h"
7
#include "tests.h"
8

9
static void test_libmount_unescaping_one(
4✔
10
                const char *title,
11
                const char *string,
12
                bool may_fail,
13
                const char *expected_source,
14
                const char *expected_target) {
15
        /* A test for libmount really */
16
        int r;
4✔
17

18
        log_info("/* %s %s */", __func__, title);
4✔
19

20
        _cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
4✔
21
        _cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
×
22
        _cleanup_fclose_ FILE *f = NULL;
4✔
23

24
        f = fmemopen((char*) string, strlen(string), "r");
4✔
25
        assert_se(f);
4✔
26

27
        assert_se(libmount_parse_mountinfo(f, &table, &iter) >= 0);
4✔
28

29
        struct libmnt_fs *fs;
4✔
30
        const char *source, *target;
4✔
31
        _cleanup_free_ char *x = NULL, *cs = NULL, *s = NULL, *ct = NULL, *t = NULL;
4✔
32

33
        /* We allow this call and the checks below to fail in some cases. See the case definitions below. */
34

35
        r = sym_mnt_table_next_fs(table, iter, &fs);
4✔
36
        if (r != 0 && may_fail) {
4✔
37
                log_error_errno(r, "mnt_table_next_fs failed: %m");
×
38
                return;
×
39
        }
40
        assert_se(r == 0);
4✔
41

42
        assert_se(x = cescape(string));
4✔
43

44
        assert_se(source = sym_mnt_fs_get_source(fs));
4✔
45
        assert_se(target = sym_mnt_fs_get_target(fs));
4✔
46

47
        assert_se(cs = cescape(source));
4✔
48
        assert_se(ct = cescape(target));
4✔
49

50
        assert_se(cunescape(source, UNESCAPE_RELAX, &s) >= 0);
4✔
51
        assert_se(cunescape(target, UNESCAPE_RELAX, &t) >= 0);
4✔
52

53
        log_info("from '%s'", x);
4✔
54
        log_info("source: '%s'", source);
4✔
55
        log_info("source: '%s'", cs);
4✔
56
        log_info("source: '%s'", s);
4✔
57
        log_info("expected: '%s'", strna(expected_source));
8✔
58
        log_info("target: '%s'", target);
4✔
59
        log_info("target: '%s'", ct);
4✔
60
        log_info("target: '%s'", t);
4✔
61
        log_info("expected: '%s'", strna(expected_target));
8✔
62

63
        assert_se(may_fail || streq(source, expected_source));
4✔
64
        assert_se(may_fail || streq(target, expected_target));
2✔
65

66
        assert_se(sym_mnt_table_next_fs(table, iter, &fs) == 1);
4✔
67
}
68

69
TEST(libmount_unescaping) {
1✔
70
        test_libmount_unescaping_one(
1✔
71
                        "escaped space + utf8",
72
                        "729 38 0:59 / /tmp/„zupa\\040zębowa” rw,relatime shared:395 - tmpfs die\\040Brühe rw,seclabel",
73
                        false,
74
                        "die Brühe",
75
                        "/tmp/„zupa zębowa”"
76
        );
77

78
        test_libmount_unescaping_one(
1✔
79
                        "escaped newline",
80
                        "729 38 0:59 / /tmp/x\\012y rw,relatime shared:395 - tmpfs newline rw,seclabel",
81
                        false,
82
                        "newline",
83
                        "/tmp/x\ny"
84
        );
85

86
        /* The result of "mount -t tmpfs '' /tmp/emptysource".
87
         * This will fail with libmount <= v2.33.
88
         * See https://github.com/karelzak/util-linux/commit/18a52a5094.
89
         */
90
        test_libmount_unescaping_one(
1✔
91
                        "empty source",
92
                        "760 38 0:60 / /tmp/emptysource rw,relatime shared:410 - tmpfs  rw,seclabel",
93
                        true,
94
                        "",
95
                        "/tmp/emptysource"
96
        );
97

98
        /* The kernel leaves \r as is.
99
         * Also see https://github.com/karelzak/util-linux/issues/780.
100
         */
101
        test_libmount_unescaping_one(
1✔
102
                        "foo\\rbar",
103
                        "790 38 0:61 / /tmp/foo\rbar rw,relatime shared:425 - tmpfs tmpfs rw,seclabel",
104
                        true,
105
                        "tmpfs",
106
                        "/tmp/foo\rbar"
107
        );
108
}
1✔
109

110
DEFINE_TEST_MAIN(LOG_DEBUG);
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