LCOV - code coverage report
Current view: top level - discof/restore/utils - fuzz_snapshot_parser.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 9 0.0 %
Date: 2025-08-05 05:04:49 Functions: 0 3 0.0 %

          Line data    Source code
       1             : #include "fd_snapshot_parser.h"
       2             : #include <assert.h>
       3             : #include <stdlib.h>
       4             : 
       5             : #define ACCV_LG_SLOT_CNT 8 /* 256 hashmap slots */
       6             : 
       7             : static void * parser_mem;
       8             : 
       9             : int
      10             : LLVMFuzzerInitialize( int  *   argc,
      11             :                       char *** argv ) {
      12             :   /* Set up shell without signal handlers */
      13             :   putenv( "FD_LOG_BACKTRACE=0" );
      14             :   fd_boot( argc, argv );
      15             :   atexit( fd_halt );
      16             :   fd_log_level_core_set   ( 4 );
      17             :   fd_log_level_logfile_set( 4 );
      18             : 
      19             :   parser_mem = aligned_alloc( fd_snapshot_parser_align(), fd_snapshot_parser_footprint( 1024UL ) );
      20             :   assert( parser_mem );
      21             : 
      22             :   return 0;
      23             : }
      24             : 
      25             : static void
      26             : manifest_cb( void * _ctx,
      27           0 :              ulong  manifest_sz ) {
      28           0 :   (void)_ctx; (void)manifest_sz;
      29           0 : }
      30             : 
      31             : static void
      32             : acc_hdr_cb( void *                          _ctx,
      33           0 :             fd_solana_account_hdr_t const * hdr ) {
      34           0 :   (void)_ctx; (void)hdr;
      35           0 : }
      36             : 
      37             : static void
      38             : acc_data_cb( void *        _ctx,
      39             :              uchar const * buf,
      40           0 :              ulong         data_sz ) {
      41           0 :   (void)_ctx; (void)buf; (void)data_sz;
      42           0 : }
      43             : 
      44             : int
      45             : LLVMFuzzerTestOneInput( uchar const * const data,
      46             :                         ulong         const size ) {
      47             :   fd_snapshot_parser_t * parser = fd_snapshot_parser_new( parser_mem, NULL, 42UL, 1024UL, manifest_cb, acc_hdr_cb, acc_data_cb );
      48             :   assert( parser );
      49             :   /* FIXME split input in the future */
      50             :   uchar const * p   = data;
      51             :   uchar const * end = data+size;
      52             :   while( p<end ) {
      53             :     p = fd_snapshot_parser_process_chunk( parser, data, size );
      54             :   }
      55             :   assert( p==end );
      56             :   return 0;
      57             : }

Generated by: LCOV version 1.14