fixed g++ warning

This commit is contained in:
Yann Collet 2015-11-26 10:52:30 +01:00
parent 5f2ec63852
commit 7447ee96f6
2 changed files with 28 additions and 9 deletions

View File

@ -53,6 +53,8 @@ EXT =
VOID = /dev/null VOID = /dev/null
endif endif
ZBUFFTEST = -T2mn
.PHONY: default all clean install uninstall test test32 test-all .PHONY: default all clean install uninstall test test32 test-all
default: zstd default: zstd
@ -240,10 +242,10 @@ test-fuzzer32: fuzzer32
./fuzzer32 ./fuzzer32
test-zbuff: zbufftest test-zbuff: zbufftest
./zbufftest ./zbufftest $(ZBUFFTEST)
test-zbuff32: zbufftest32 test-zbuff32: zbufftest32
./zbufftest32 ./zbufftest32 $(ZBUFFTEST)
valgrindTest: zstd datagen fuzzer fullbench valgrindTest: zstd datagen fuzzer fullbench
@echo "\n ---- valgrind tests : memory analyzer ----" @echo "\n ---- valgrind tests : memory analyzer ----"

View File

@ -80,11 +80,13 @@ static const U32 prime2 = 2246822519U;
static U32 g_displayLevel = 2; static U32 g_displayLevel = 2;
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \ #define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
if ((FUZ_GetMilliSpan(g_time) > g_refreshRate) || (g_displayLevel>=4)) \ if ((FUZ_GetMilliSpan(g_displayTime) > g_refreshRate) || (g_displayLevel>=4)) \
{ g_time = FUZ_GetMilliStart(); DISPLAY(__VA_ARGS__); \ { g_displayTime = FUZ_GetMilliStart(); DISPLAY(__VA_ARGS__); \
if (g_displayLevel>=4) fflush(stdout); } } if (g_displayLevel>=4) fflush(stdout); } }
static const U32 g_refreshRate = 150; static const U32 g_refreshRate = 150;
static U32 g_time = 0; static U32 g_displayTime = 0;
static U32 g_testTime = 0;
/********************************************************* /*********************************************************
@ -170,7 +172,7 @@ static int basicUnitTests(U32 seed, double compressibility)
if (readSize != CNBufferSize) goto _output_error; /* entire input should be consumed */ if (readSize != CNBufferSize) goto _output_error; /* entire input should be consumed */
cSize = genSize; cSize = genSize;
genSize = compressedBufferSize - cSize; genSize = compressedBufferSize - cSize;
result = ZBUFF_compressEnd(zc, compressedBuffer+cSize, &genSize); result = ZBUFF_compressEnd(zc, ((char*)compressedBuffer)+cSize, &genSize);
if (result != 0) goto _output_error; /* error, or some data not flushed */ if (result != 0) goto _output_error; /* error, or some data not flushed */
cSize += genSize; cSize += genSize;
DISPLAYLEVEL(4, "OK (%u bytes : %.2f%%)\n", (U32)cSize, (double)cSize/COMPRESSIBLE_NOISE_LENGTH*100); DISPLAYLEVEL(4, "OK (%u bytes : %.2f%%)\n", (U32)cSize, (double)cSize/COMPRESSIBLE_NOISE_LENGTH*100);
@ -247,6 +249,7 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
ZBUFF_CCtx* zc; ZBUFF_CCtx* zc;
ZBUFF_DCtx* zd; ZBUFF_DCtx* zd;
XXH64_state_t crc64; XXH64_state_t crc64;
U32 startTime = FUZ_GetMilliStart();
/* allocation */ /* allocation */
zc = ZBUFF_createCCtx(); zc = ZBUFF_createCCtx();
@ -276,7 +279,7 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
FUZ_rand(&coreSeed); FUZ_rand(&coreSeed);
/* test loop */ /* test loop */
for ( ; testNb <= nbTests; testNb++ ) for ( ; (testNb <= nbTests) || (FUZ_GetMilliSpan(startTime) < g_testTime); testNb++ )
{ {
size_t sampleSize, sampleStart; size_t sampleSize, sampleStart;
size_t cSize; size_t cSize;
@ -369,7 +372,7 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
/* noisy/erroneous src decompression test */ /* noisy/erroneous src decompression test */
/* TBD later */ /* TBD later */
} }
DISPLAY("\rAll fuzzer tests completed \n"); DISPLAY("\r%u fuzzer tests completed \n", testNb);
_cleanup: _cleanup:
ZBUFF_freeCCtx(zc); ZBUFF_freeCCtx(zc);
@ -456,7 +459,7 @@ int main(int argc, char** argv)
case 'i': case 'i':
argument++; argument++;
nbTests=0; nbTests=0; g_testTime=0;
while ((*argument>='0') && (*argument<='9')) while ((*argument>='0') && (*argument<='9'))
{ {
nbTests *= 10; nbTests *= 10;
@ -465,6 +468,20 @@ int main(int argc, char** argv)
} }
break; break;
case 'T':
argument++;
nbTests=0; g_testTime=0;
while ((*argument>='0') && (*argument<='9'))
{
g_testTime *= 10;
g_testTime += *argument - '0';
argument++;
}
if (*argument=='m') g_testTime *=60, argument++;
if (*argument=='n') argument++;
g_testTime *= 1000;
break;
case 's': case 's':
argument++; argument++;
seed=0; seed=0;