LCOV - code coverage report
Current view: top level - test - test-daemon.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 18 23 78.3 %
Date: 2019-08-22 15:41:25 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <unistd.h>
       4             : 
       5             : #include "sd-daemon.h"
       6             : 
       7             : #include "parse-util.h"
       8             : #include "strv.h"
       9             : #include "time-util.h"
      10             : 
      11           1 : int main(int argc, char *argv[]) {
      12           1 :         _cleanup_strv_free_ char **l = NULL;
      13             :         int n, i;
      14           1 :         usec_t duration = USEC_PER_SEC / 10;
      15             : 
      16           1 :         if (argc >= 2) {
      17             :                 unsigned x;
      18             : 
      19           0 :                 assert_se(safe_atou(argv[1], &x) >= 0);
      20           0 :                 duration = x * USEC_PER_SEC;
      21             :         }
      22             : 
      23           1 :         n = sd_listen_fds_with_names(false, &l);
      24           1 :         if (n < 0) {
      25           0 :                 log_error_errno(n, "Failed to get listening fds: %m");
      26           0 :                 return EXIT_FAILURE;
      27             :         }
      28             : 
      29           1 :         for (i = 0; i < n; i++)
      30           0 :                 log_info("fd=%i name=%s\n", SD_LISTEN_FDS_START + i, l[i]);
      31             : 
      32           1 :         sd_notify(0,
      33             :                   "STATUS=Starting up");
      34           1 :         usleep(duration);
      35             : 
      36           1 :         sd_notify(0,
      37             :                   "STATUS=Running\n"
      38             :                   "READY=1");
      39           1 :         usleep(duration);
      40             : 
      41           1 :         sd_notify(0,
      42             :                   "STATUS=Reloading\n"
      43             :                   "RELOADING=1");
      44           1 :         usleep(duration);
      45             : 
      46           1 :         sd_notify(0,
      47             :                   "STATUS=Running\n"
      48             :                   "READY=1");
      49           1 :         usleep(duration);
      50             : 
      51           1 :         sd_notify(0,
      52             :                   "STATUS=Quitting\n"
      53             :                   "STOPPING=1");
      54           1 :         usleep(duration);
      55             : 
      56           1 :         return EXIT_SUCCESS;
      57             : }

Generated by: LCOV version 1.14