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

systemd / systemd / 15199265962

22 May 2025 09:40PM UTC coverage: 72.061% (-0.02%) from 72.079%
15199265962

push

github

bluca
tests: fix TEST-74-AUX-UTILS.varlinkctl.sh (#37562)

per Daan's explanation:
other subtests running as testuser apparently use systemd-run --user
--machine testuser@.host which turns user tracking in logind into "by
pin" mode. when the last pinning session exits it terminates the user.

299156 of 415145 relevant lines covered (72.06%)

703915.84 hits per line

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

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

3
#include <fcntl.h>
4
#include <sys/wait.h>
5
#include <unistd.h>
6

7
#include "async.h"
8
#include "fs-util.h"
9
#include "path-util.h"
10
#include "pidref.h"
11
#include "process-util.h"
12
#include "rm-rf.h"
13
#include "signal-util.h"
14
#include "tests.h"
15
#include "time-util.h"
16
#include "tmpfile-util.h"
17

18
TEST(asynchronous_sync) {
1✔
19
        _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
1✔
20
        ASSERT_OK(asynchronous_sync(&pidref));
1✔
21
        ASSERT_OK(pidref_wait_for_terminate(&pidref, /* ret= */ NULL));
1✔
22
}
1✔
23

24
static void wait_fd_closed(int fd) {
2✔
25
        for (unsigned trial = 0; trial < 100; trial++) {
2✔
26
                usleep_safe(100 * USEC_PER_MSEC);
2✔
27
                if (fcntl(fd, F_GETFD) < 0) {
2✔
28
                        assert_se(errno == EBADF);
2✔
29
                        return;
2✔
30
                }
31
        }
32

33
        assert_not_reached();
×
34
}
35

36
TEST(asynchronous_close) {
1✔
37
        _cleanup_(unlink_tempfilep) char name[] = "/tmp/test-asynchronous_close.XXXXXX";
1✔
38
        int fd, r;
1✔
39

40
        fd = mkostemp_safe(name);
1✔
41
        ASSERT_OK(fd);
1✔
42
        asynchronous_close(fd);
1✔
43
        wait_fd_closed(fd);
1✔
44

45
        r = safe_fork("(subreaper)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGKILL|FORK_LOG|FORK_WAIT, NULL);
1✔
46
        ASSERT_OK(r);
2✔
47

48
        if (r == 0) {
2✔
49
                /* child */
50

51
                ASSERT_OK(make_reaper_process(true));
1✔
52

53
                fd = open("/dev/null", O_RDONLY|O_CLOEXEC);
1✔
54
                ASSERT_OK(fd);
1✔
55
                asynchronous_close(fd);
1✔
56
                wait_fd_closed(fd);
1✔
57

58
                _exit(EXIT_SUCCESS);
1✔
59
        }
60
}
1✔
61

62
static void wait_rm_rf(const char *path) {
1✔
63
        for (unsigned trial = 0; trial < 100; trial++) {
1✔
64
                usleep_safe(100 * USEC_PER_MSEC);
1✔
65
                if (access(path, F_OK) < 0) {
1✔
66
                        assert_se(errno == ENOENT);
1✔
67
                        return;
1✔
68
                }
69
        }
70

71
        assert_not_reached();
×
72
}
73

74
TEST(asynchronous_rm_rf) {
1✔
75
        _cleanup_free_ char *t = NULL, *k = NULL;
×
76
        int r;
1✔
77

78
        ASSERT_OK(mkdtemp_malloc(NULL, &t));
1✔
79
        assert_se(k = path_join(t, "somefile"));
1✔
80
        ASSERT_OK(touch(k));
1✔
81
        ASSERT_OK(asynchronous_rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL));
1✔
82
        wait_rm_rf(t);
1✔
83

84
        /* Do this once more, from a subreaper. Which is nice, because we can watch the async child even
85
         * though detached */
86

87
        r = safe_fork("(subreaper)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGTERM|FORK_REOPEN_LOG|FORK_LOG|FORK_WAIT, NULL);
1✔
88
        ASSERT_OK(r);
2✔
89

90
        if (r == 0) {
2✔
91
                _cleanup_free_ char *tt = NULL, *kk = NULL;
×
92

93
                /* child */
94

95
                ASSERT_OK(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD));
1✔
96
                ASSERT_OK(make_reaper_process(true));
1✔
97

98
                ASSERT_OK(mkdtemp_malloc(NULL, &tt));
1✔
99
                assert_se(kk = path_join(tt, "somefile"));
1✔
100
                ASSERT_OK(touch(kk));
1✔
101
                ASSERT_OK(asynchronous_rm_rf(tt, REMOVE_ROOT|REMOVE_PHYSICAL));
1✔
102

103
                for (;;) {
×
104
                        siginfo_t si = {};
1✔
105

106
                        ASSERT_OK_ERRNO(waitid(P_ALL, 0, &si, WEXITED));
1✔
107

108
                        if (access(tt, F_OK) < 0) {
1✔
109
                                assert_se(errno == ENOENT);
1✔
110
                                break;
1✔
111
                        }
112

113
                        /* wasn't the rm_rf() call. let's wait longer */
114
                }
115

116
                _exit(EXIT_SUCCESS);
1✔
117
        }
118
}
1✔
119

120
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