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

systemd / systemd / 26546993077

27 May 2026 08:34PM UTC coverage: 72.995% (+0.3%) from 72.667%
26546993077

push

github

bluca
test-pressure: set timeout to make not wait forever

If this runs on a slow or busy machine, then we may not get enough
pressure to trigger the event sources. In such case, the test does not
finish. It is problematic when the test is _not_ run with 'meson test',
e.g. debian/ubuntu CIs.

Let's introduce a timeout for each event loop, and skip test cases
gracefully.

8 of 12 new or added lines in 1 file covered. (66.67%)

19671 existing lines in 226 files now uncovered.

337119 of 461841 relevant lines covered (72.99%)

1326365.62 hits per line

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

88.89
/src/basic/sort-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <stdlib.h>
4

5
#include "alloc-util.h"
6
#include "sort-util.h"
7

8
/* hey glibc, APIs with callbacks without a user pointer are so useless */
9
void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
6,878✔
10
                 comparison_userdata_fn_t compar, void *arg) {
11
        size_t l, u, idx;
6,878✔
12
        const void *p;
6,878✔
13
        int comparison;
6,878✔
14

15
        assert(!size_multiply_overflow(nmemb, size));
6,878✔
16

17
        l = 0;
18
        u = nmemb;
19
        while (l < u) {
18,410✔
20
                idx = (l + u) / 2;
11,540✔
21
                p = (const uint8_t*) base + idx * size;
11,540✔
22
                comparison = compar(key, p, arg);
11,540✔
23
                if (comparison < 0)
11,540✔
24
                        u = idx;
25
                else if (comparison > 0)
8,246✔
26
                        l = idx + 1;
8,238✔
27
                else
28
                        return (void *)p;
29
        }
30
        return NULL;
31
}
32

33
void* bsearch_safe_internal(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
7,482,456✔
34
        /**
35
        * Normal bsearch requires base to be nonnull. Here were require
36
        * that only if nmemb > 0.
37
        */
38

39
        if (nmemb <= 0)
7,482,456✔
40
                return NULL;
41

42
        assert(base);
7,381,412✔
43
        return (void*) bsearch(key, base, nmemb, size, compar);
7,482,456✔
44
}
45

46
void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
4,195,476✔
47
        /**
48
         * Normal qsort requires base to be nonnull. Here were require
49
         * that only if nmemb > 0.
50
         */
51

52
        if (nmemb <= 1)
4,195,476✔
53
                return;
54

55
        assert(base);
2,125,300✔
56
        qsort(base, nmemb, size, compar);
2,125,300✔
57
}
58

59
void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata) {
312,135✔
60
        if (nmemb <= 1)
312,135✔
61
                return;
62

63
        assert(base);
21,714✔
64
        qsort_r(base, nmemb, size, compar, userdata);
21,714✔
65
}
66

67
int cmp_int(const int *a, const int *b) {
608,720✔
68
        /* This is called from qsort()s inner loops. Correctly implemented qsort will never pass NULL so we
69
           just suppress the check via POINTER_MAY_BE_NULL instead of assert() to avoid the runtime cost. */
70
        POINTER_MAY_BE_NULL(a);
608,720✔
71
        POINTER_MAY_BE_NULL(b);
608,720✔
72

73
        return CMP(*a, *b);
608,720✔
74
}
75

76
int cmp_uint16(const uint16_t *a, const uint16_t *b) {
2,901✔
77
        /* This is called from qsort()s inner loops. Correctly implemented qsort will never pass NULL so we
78
           just suppress the check via POINTER_MAY_BE_NULL instead of assert() to avoid the runtime cost. */
79
        POINTER_MAY_BE_NULL(a);
2,901✔
80
        POINTER_MAY_BE_NULL(b);
2,901✔
81

82
        return CMP(*a, *b);
2,901✔
83
}
84

UNCOV
85
int cmp_unsigned(const unsigned *a, const unsigned *b) {
×
86
        /* This is called from qsort()s inner loops. Correctly implemented qsort will never pass NULL so we
87
           just suppress the check via POINTER_MAY_BE_NULL instead of assert() to avoid the runtime cost. */
UNCOV
88
        POINTER_MAY_BE_NULL(a);
×
UNCOV
89
        POINTER_MAY_BE_NULL(b);
×
90

UNCOV
91
        return CMP(*a, *b);
×
92
}
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