LCOV - code coverage report
Current view: top level - ballet/keccak256 - fuzz_keccak256.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 6 6 100.0 %
Date: 2024-11-13 11:58:15 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #if !FD_HAS_HOSTED
       2             : #error "This target requires FD_HAS_HOSTED"
       3             : #endif
       4             : 
       5             : #include <assert.h>
       6             : #include <stdio.h>
       7             : #include <stdlib.h>
       8             : 
       9             : #include "../../util/fd_util.h"
      10             : #include "../../util/sanitize/fd_fuzz.h"
      11             : #include "fd_keccak256.h"
      12             : 
      13             : int
      14             : LLVMFuzzerInitialize( int  *   argc,
      15          18 :                       char *** argv ) {
      16             :   /* Set up shell without signal handlers */
      17          18 :   putenv( "FD_LOG_BACKTRACE=0" );
      18          18 :   fd_boot( argc, argv );
      19          18 :   atexit( fd_halt );
      20          18 :   return 0;
      21          18 : }
      22             : 
      23             : int
      24             : LLVMFuzzerTestOneInput( uchar const * data,
      25             :                         ulong         size ) {
      26             :   /* hash single message */
      27             :   char const * msg = ( char const * ) data;
      28             : 
      29             :   uchar hash1[ 32 ] __attribute__((aligned(32)));
      30             :   uchar hash2[ 32 ] __attribute__((aligned(32)));
      31             : 
      32             :   fd_keccak256_t sha[1];
      33             :   assert( fd_keccak256_init( sha ) == sha );
      34             :   assert( fd_keccak256_append( sha, msg, size ) == sha );
      35             :   assert( fd_keccak256_fini( sha, hash1 ) == hash1 );
      36             : 
      37             :   assert( fd_keccak256_hash( data, size, hash2 ) == hash2 );
      38             :   assert( !memcmp( hash1, hash2, 32UL ) );
      39             : 
      40             :   FD_FUZZ_MUST_BE_COVERED;
      41             :   return 0;
      42             : }

Generated by: LCOV version 1.14