MCPcopy Create free account
hub / github.com/buggins/coolreader / runBlockWriteCacheTest

Function runBlockWriteCacheTest

crengine/src/lvtinydom.cpp:11388–11477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11386}
11387
11388void runBlockWriteCacheTest()
11389{
11390
11391
11392
11393 int sz = 2000000;
11394 const char * fn1 = "/tmp/tf1.dat";
11395 const char * fn2 = "/tmp/tf2.dat";
11396 //makeTestFile( fn1, sz );
11397 //makeTestFile( fn2, sz );
11398
11399 CRLog::debug("BlockCache test started");
11400
11401 LVStreamRef s1 = LVOpenFileStream( fn1, LVOM_APPEND );
11402 LVStreamRef s2 = LVCreateBlockWriteStream( LVOpenFileStream( fn2, LVOM_APPEND ), 0x8000, 16);
11403 MYASSERT(! s1.isNull(), "s1");
11404 MYASSERT(! s2.isNull(), "s2");
11405 LVStreamRef ss = LVCreateCompareTestStream(s1, s2);
11406 lUInt8 buf[0x100000];
11407 for ( int i=0; i<sizeof(buf); i++ ) {
11408 buf[i] = (lUInt8)(rand() & 0xFF);
11409 }
11410 //memset( buf, 0xAD, 1000000 );
11411 ss->SetPos( 0 );
11412 ss->Write( buf, 150, NULL );
11413 ss->SetPos( 0 );
11414 ss->Write( buf, 150, NULL );
11415 ss->SetPos( 0 );
11416 ss->Write( buf, 150, NULL );
11417
11418
11419 ss->SetPos( 1000 );
11420 ss->Read( buf, 5000, NULL );
11421 ss->SetPos( 100000 );
11422 ss->Read( buf+10000, 150000, NULL );
11423
11424 ss->SetPos( 1000 );
11425 ss->Write( buf, 15000, NULL );
11426 ss->SetPos( 1000 );
11427 ss->Read( buf+100000, 15000, NULL );
11428 ss->Read( buf, 1000000, NULL );
11429
11430
11431 ss->SetPos( 1000 );
11432 ss->Write( buf, 15000, NULL );
11433 ss->Write( buf, 15000, NULL );
11434 ss->Write( buf, 15000, NULL );
11435 ss->Write( buf, 15000, NULL );
11436
11437
11438 ss->SetPos( 100000 );
11439 ss->Write( buf+15000, 150000, NULL );
11440 ss->SetPos( 100000 );
11441 ss->Read( buf+25000, 200000, NULL );
11442
11443 ss->SetPos( 100000 );
11444 ss->Read( buf+55000, 200000, NULL );
11445

Callers 1

runTinyDomUnitTestsFunction · 0.85

Calls 7

LVOpenFileStreamFunction · 0.85
LVCreateBlockWriteStreamFunction · 0.85
isNullMethod · 0.45
SetPosMethod · 0.45
WriteMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected