LCOV - code coverage report
Current view: top level - test - test-watchdog.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 17 18 94.4 %
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 <string.h>
       4             : #include <unistd.h>
       5             : 
       6             : #include "log.h"
       7             : #include "tests.h"
       8             : #include "watchdog.h"
       9             : 
      10           1 : int main(int argc, char *argv[]) {
      11             :         usec_t t;
      12             :         unsigned i, count;
      13             :         int r;
      14             :         bool slow;
      15             : 
      16           1 :         test_setup_logging(LOG_DEBUG);
      17             : 
      18           1 :         slow = slow_tests_enabled();
      19             : 
      20           1 :         t = slow ? 10 * USEC_PER_SEC : 1 * USEC_PER_SEC;
      21           1 :         count = slow ? 5 : 3;
      22             : 
      23           1 :         r = watchdog_set_timeout(&t);
      24           1 :         if (r < 0)
      25           1 :                 log_warning_errno(r, "Failed to open watchdog: %m");
      26           1 :         if (r == -EPERM)
      27           0 :                 t = 0;
      28             : 
      29           4 :         for (i = 0; i < count; i++) {
      30           3 :                 log_info("Pinging...");
      31           3 :                 r = watchdog_ping();
      32           3 :                 if (r < 0)
      33           3 :                         log_warning_errno(r, "Failed to ping watchdog: %m");
      34             : 
      35           3 :                 usleep(t/2);
      36             :         }
      37             : 
      38           1 :         watchdog_close(true);
      39           1 :         return 0;
      40             : }

Generated by: LCOV version 1.14