]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-daemon.c
Merge pull request #8417 from brauner/2018-03-09/add_bind_mount_fallback_to_private_d...
[thirdparty/systemd.git] / src / test / test-daemon.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 This file is part of systemd.
4
5 Copyright 2010 Lennart Poettering
6 ***/
7
8 #include <unistd.h>
9
10 #include "sd-daemon.h"
11
12 #include "parse-util.h"
13 #include "strv.h"
14
15 int main(int argc, char*argv[]) {
16 _cleanup_strv_free_ char **l = NULL;
17 int n, i;
18 usec_t duration = USEC_PER_SEC / 10;
19
20 if (argc >= 2) {
21 unsigned x;
22
23 assert_se(safe_atou(argv[1], &x) >= 0);
24 duration = x * USEC_PER_SEC;
25 }
26
27 n = sd_listen_fds_with_names(false, &l);
28 if (n < 0) {
29 log_error_errno(n, "Failed to get listening fds: %m");
30 return EXIT_FAILURE;
31 }
32
33 for (i = 0; i < n; i++)
34 log_info("fd=%i name=%s\n", SD_LISTEN_FDS_START + i, l[i]);
35
36 sd_notify(0,
37 "STATUS=Starting up");
38 usleep(duration);
39
40 sd_notify(0,
41 "STATUS=Running\n"
42 "READY=1");
43 usleep(duration);
44
45 sd_notify(0,
46 "STATUS=Reloading\n"
47 "RELOADING=1");
48 usleep(duration);
49
50 sd_notify(0,
51 "STATUS=Running\n"
52 "READY=1");
53 usleep(duration);
54
55 sd_notify(0,
56 "STATUS=Quitting\n"
57 "STOPPING=1");
58 usleep(duration);
59
60 return EXIT_SUCCESS;
61 }