@ -12,9 +12,33 @@
# include "rocksdb/file_system.h"
# include "rocksdb/sst_file_writer.h"
# include "src/libfuzzer/libfuzzer_macro.h"
# include "table/table_builder.h"
# include "table/table_reader.h"
# include "util.h"
using ROCKSDB_NAMESPACE : : BytewiseComparator ;
using ROCKSDB_NAMESPACE : : Comparator ;
using ROCKSDB_NAMESPACE : : EnvOptions ;
using ROCKSDB_NAMESPACE : : ExternalSstFileInfo ;
using ROCKSDB_NAMESPACE : : FileOptions ;
using ROCKSDB_NAMESPACE : : FileSystem ;
using ROCKSDB_NAMESPACE : : ImmutableCFOptions ;
using ROCKSDB_NAMESPACE : : ImmutableOptions ;
using ROCKSDB_NAMESPACE : : InternalIterator ;
using ROCKSDB_NAMESPACE : : IOOptions ;
using ROCKSDB_NAMESPACE : : kMaxSequenceNumber ;
using ROCKSDB_NAMESPACE : : Options ;
using ROCKSDB_NAMESPACE : : ParsedInternalKey ;
using ROCKSDB_NAMESPACE : : ParseInternalKey ;
using ROCKSDB_NAMESPACE : : RandomAccessFileReader ;
using ROCKSDB_NAMESPACE : : ReadOptions ;
using ROCKSDB_NAMESPACE : : SstFileWriter ;
using ROCKSDB_NAMESPACE : : Status ;
using ROCKSDB_NAMESPACE : : TableReader ;
using ROCKSDB_NAMESPACE : : TableReaderCaller ;
using ROCKSDB_NAMESPACE : : TableReaderOptions ;
using ROCKSDB_NAMESPACE : : ValueType ;
// Keys in SST file writer operations must be unique and in ascending order.
// For each DBOperation generated by the fuzzer, this function is called on
// it to deduplicate and sort the keys in the DBOperations.
@ -60,15 +84,15 @@ TableReader* NewTableReader(const std::string& sst_file_path,
std : : unique_ptr < TableReader > table_reader ;
const auto & fs = options . env - > GetFileSystem ( ) ;
FileOptions fopts ( env_options ) ;
Status s = options . env - > GetFileSize ( sst_file_path , fopts . io_options ,
& file_size , nullptr ) ;
Status s = options . env - > GetFileSize ( sst_file_path , & file_size ) ;
if ( s . ok ( ) ) {
s = RandomAccessFileReader : : Create ( fs , sst_file_path , fopts , & file_reader ,
nullptr ) ;
}
if ( s . ok ( ) ) {
TableReaderOptions t_opt ( cf_ioptions , /*prefix_extractor=*/ nullptr ,
env_options , cf_ioptions . internal_comparator ) ;
ImmutableOptions iopts ( options , cf_ioptions ) ;
TableReaderOptions t_opt ( iopts , /*prefix_extractor=*/ nullptr , env_options ,
cf_ioptions . internal_comparator ) ;
t_opt . largest_seqno = kMaxSequenceNumber ;
s = options . table_factory - > NewTableReader ( t_opt , std : : move ( file_reader ) ,
file_size , & table_reader ,
@ -153,7 +177,7 @@ DEFINE_PROTO_FUZZER(DBOperations& input) {
// Iterate and verify key-value pairs.
std : : unique_ptr < TableReader > table_reader (
NewTableReader ( sstfile , options , env_options , cf_ioptions ) ) ;
: : NewTableReader ( sstfile , options , env_options , cf_ioptions ) ) ;
ReadOptions roptions ;
CHECK_OK ( table_reader - > VerifyChecksum ( roptions ,
TableReaderCaller : : kUncategorized ) ) ;