LCOV - code coverage report
Current view: top level - journal - test-journal-enum.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 14 14 100.0 %
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 <stdio.h>
       4             : 
       5             : #include "sd-journal.h"
       6             : 
       7             : #include "journal-internal.h"
       8             : #include "log.h"
       9             : #include "macro.h"
      10             : #include "tests.h"
      11             : 
      12           1 : int main(int argc, char *argv[]) {
      13           1 :         unsigned n = 0;
      14           2 :         _cleanup_(sd_journal_closep) sd_journal *j = NULL;
      15             : 
      16           1 :         test_setup_logging(LOG_DEBUG);
      17             : 
      18           1 :         assert_se(sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY) >= 0);
      19             : 
      20           1 :         assert_se(sd_journal_add_match(j, "_TRANSPORT=syslog", 0) >= 0);
      21           1 :         assert_se(sd_journal_add_match(j, "_UID=0", 0) >= 0);
      22             : 
      23          10 :         SD_JOURNAL_FOREACH_BACKWARDS(j) {
      24             :                 const void *d;
      25             :                 size_t l;
      26             : 
      27          10 :                 assert_se(sd_journal_get_data(j, "MESSAGE", &d, &l) >= 0);
      28             : 
      29          10 :                 printf("%.*s\n", (int) l, (char*) d);
      30             : 
      31          10 :                 n++;
      32          10 :                 if (n >= 10)
      33           1 :                         break;
      34             :         }
      35             : 
      36           1 :         return 0;
      37             : }

Generated by: LCOV version 1.14