LCOV - code coverage report
Current view: top level - fuzz - fuzz-journald-stream.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 16 0.0 %
Date: 2019-08-23 13:36:53 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 18 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include <linux/sockios.h>
       4                 :            : #include <sys/ioctl.h>
       5                 :            : #include <unistd.h>
       6                 :            : 
       7                 :            : #include "fd-util.h"
       8                 :            : #include "fuzz.h"
       9                 :            : #include "fuzz-journald.h"
      10                 :            : #include "journald-stream.h"
      11                 :            : 
      12                 :            : static int stream_fds[2] = { -1, -1 };
      13                 :            : 
      14                 :          0 : int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
      15                 :            :         Server s;
      16                 :            :         StdoutStream *stream;
      17                 :            :         int v;
      18                 :            : 
      19   [ #  #  #  # ]:          0 :         if (size == 0 || size > 65536)
      20                 :          0 :                 return 0;
      21                 :            : 
      22         [ #  # ]:          0 :         if (!getenv("SYSTEMD_LOG_LEVEL"))
      23                 :          0 :                 log_set_max_level(LOG_CRIT);
      24                 :            : 
      25         [ #  # ]:          0 :         assert_se(socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0, stream_fds) >= 0);
      26                 :          0 :         dummy_server_init(&s, NULL, 0);
      27         [ #  # ]:          0 :         assert_se(stdout_stream_install(&s, stream_fds[0], &stream) >= 0);
      28         [ #  # ]:          0 :         assert_se(write(stream_fds[1], data, size) == (ssize_t) size);
      29   [ #  #  #  # ]:          0 :         while (ioctl(stream_fds[0], SIOCINQ, &v) == 0 && v)
      30                 :          0 :                 sd_event_run(s.event, (uint64_t) -1);
      31         [ #  # ]:          0 :         if (s.n_stdout_streams)
      32                 :          0 :                 stdout_stream_destroy(stream);
      33                 :          0 :         server_done(&s);
      34                 :          0 :         stream_fds[1] = safe_close(stream_fds[1]);
      35                 :            : 
      36                 :          0 :         return 0;
      37                 :            : }

Generated by: LCOV version 1.14