]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-daemon.c
Merge pull request #2792 from ronnychevalier/rc/tests_movev2
[thirdparty/systemd.git] / src / test / test-daemon.c
1 /***
2 This file is part of systemd.
3
4 Copyright 2010 Lennart Poettering
5
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20 #include <unistd.h>
21
22 #include "sd-daemon.h"
23
24 #include "strv.h"
25
26 int main(int argc, char*argv[]) {
27 _cleanup_strv_free_ char **l = NULL;
28 int n, i;
29
30 n = sd_listen_fds_with_names(false, &l);
31 if (n < 0) {
32 log_error_errno(n, "Failed to get listening fds: %m");
33 return EXIT_FAILURE;
34 }
35
36 for (i = 0; i < n; i++)
37 log_info("fd=%i name=%s\n", SD_LISTEN_FDS_START + i, l[i]);
38
39 sd_notify(0,
40 "STATUS=Starting up");
41 sleep(1);
42
43 sd_notify(0,
44 "STATUS=Running\n"
45 "READY=1");
46 sleep(1);
47
48 sd_notify(0,
49 "STATUS=Reloading\n"
50 "RELOADING=1");
51 sleep(1);
52
53 sd_notify(0,
54 "STATUS=Running\n"
55 "READY=1");
56 sleep(1);
57
58 sd_notify(0,
59 "STATUS=Quitting\n"
60 "STOPPING=1");
61 sleep(1);
62
63 return EXIT_SUCCESS;
64 }