LCOV - code coverage report
Current view: top level - fuzz - fuzz-main.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 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "alloc-util.h"
       4                 :            : #include "log.h"
       5                 :            : #include "fileio.h"
       6                 :            : #include "fuzz.h"
       7                 :            : #include "tests.h"
       8                 :            : 
       9                 :            : /* This is a test driver for the systemd fuzzers that provides main function
      10                 :            :  * for regression testing outside of oss-fuzz (https://github.com/google/oss-fuzz)
      11                 :            :  *
      12                 :            :  * It reads files named on the command line and passes them one by one into the
      13                 :            :  * fuzzer that it is compiled into. */
      14                 :            : 
      15                 :            : /* This one was borrowed from
      16                 :            :  * https://github.com/google/oss-fuzz/blob/646fca1b506b056db3a60d32c4a1a7398f171c94/infra/base-images/base-runner/bad_build_check#L19
      17                 :            :  */
      18                 :            : #define MIN_NUMBER_OF_RUNS 4
      19                 :            : 
      20                 :          0 : int main(int argc, char **argv) {
      21                 :            :         int i, r;
      22                 :            :         size_t size;
      23                 :            :         char *name;
      24                 :            : 
      25                 :          0 :         test_setup_logging(LOG_DEBUG);
      26                 :            : 
      27         [ #  # ]:          0 :         for (i = 1; i < argc; i++) {
      28         [ #  # ]:          0 :                 _cleanup_free_ char *buf = NULL;
      29                 :            : 
      30                 :          0 :                 name = argv[i];
      31                 :          0 :                 r = read_full_file(name, &buf, &size);
      32         [ #  # ]:          0 :                 if (r < 0) {
      33         [ #  # ]:          0 :                         log_error_errno(r, "Failed to open '%s': %m", name);
      34                 :          0 :                         return EXIT_FAILURE;
      35                 :            :                 }
      36                 :          0 :                 printf("%s... ", name);
      37                 :          0 :                 fflush(stdout);
      38         [ #  # ]:          0 :                 for (int j = 0; j < MIN_NUMBER_OF_RUNS; j++)
      39         [ #  # ]:          0 :                         if (LLVMFuzzerTestOneInput((uint8_t*)buf, size) == EXIT_TEST_SKIP)
      40                 :          0 :                                 return EXIT_TEST_SKIP;
      41                 :          0 :                 printf("ok\n");
      42                 :            :         }
      43                 :            : 
      44                 :          0 :         return EXIT_SUCCESS;
      45                 :            : }

Generated by: LCOV version 1.14