travisCI: added ASAN fuzzer tests
and fixed minor formatting warnings
This commit is contained in:
parent
567b4e098b
commit
3b917ef6e6
@ -27,6 +27,12 @@ matrix:
|
||||
script:
|
||||
- make -C tests test-frametest test-fuzzer
|
||||
|
||||
- name: ASAN tests with fuzzer and frametest
|
||||
install:
|
||||
- sudo sysctl -w vm.mmap_min_addr=4096
|
||||
script:
|
||||
- CC=clang MOREFLAGS=-fsanitize=address make -C tests test-frametest test-fuzzer
|
||||
|
||||
- name: (Precise) g++ and clang CMake test
|
||||
dist: precise
|
||||
script:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
enum {
|
||||
MESSAGE_MAX_BYTES = 1024,
|
||||
@ -39,7 +40,8 @@ size_t write_int32(FILE* fp, int32_t i) {
|
||||
}
|
||||
|
||||
size_t write_bin(FILE* fp, const void* array, int arrayBytes) {
|
||||
return fwrite(array, 1, arrayBytes, fp);
|
||||
assert(arrayBytes >= 0);
|
||||
return fwrite(array, 1, (size_t)arrayBytes, fp);
|
||||
}
|
||||
|
||||
size_t read_int32(FILE* fp, int32_t* i) {
|
||||
@ -47,7 +49,8 @@ size_t read_int32(FILE* fp, int32_t* i) {
|
||||
}
|
||||
|
||||
size_t read_bin(FILE* fp, void* array, int arrayBytes) {
|
||||
return fread(array, 1, arrayBytes, fp);
|
||||
assert(arrayBytes >= 0);
|
||||
return fread(array, 1, (size_t)arrayBytes, fp);
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +177,7 @@ int main(int argc, const char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "-p")) pause = 1, fileID = 2;
|
||||
if (!strcmp(argv[1], "-p")) { pause = 1; fileID = 2; }
|
||||
|
||||
snprintf(inpFilename, 256, "%s", argv[fileID]);
|
||||
snprintf(lz4Filename, 256, "%s.lz4s-%d", argv[fileID], 9);
|
||||
|
@ -541,9 +541,10 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
|
||||
if (initFunction!=NULL) initFunction();
|
||||
for (chunkNb=0; chunkNb<nbChunks; chunkNb++) {
|
||||
chunkP[chunkNb].compressedSize = compressionFunction(chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize);
|
||||
if (chunkP[chunkNb].compressedSize==0)
|
||||
DISPLAY("ERROR ! %s() = 0 !! \n", compressorName), exit(1);
|
||||
}
|
||||
if (chunkP[chunkNb].compressedSize==0) {
|
||||
DISPLAY("ERROR ! %s() = 0 !! \n", compressorName);
|
||||
exit(1);
|
||||
} }
|
||||
nb_loops++;
|
||||
}
|
||||
clockTime = BMK_GetClockSpan(clockTime);
|
||||
@ -551,7 +552,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
|
||||
nb_loops += !nb_loops; /* avoid division by zero */
|
||||
averageTime = ((double)clockTime) / nb_loops / CLOCKS_PER_SEC;
|
||||
if (averageTime < bestTime) bestTime = averageTime;
|
||||
cSize=0; for (chunkNb=0; chunkNb<nbChunks; chunkNb++) cSize += chunkP[chunkNb].compressedSize;
|
||||
cSize=0; for (chunkNb=0; chunkNb<nbChunks; chunkNb++) cSize += (size_t)chunkP[chunkNb].compressedSize;
|
||||
ratio = (double)cSize/(double)benchedSize*100.;
|
||||
PROGRESS("%2i-%-34.34s :%10i ->%9i (%5.2f%%),%7.1f MB/s\r", loopNb, compressorName, (int)benchedSize, (int)cSize, ratio, (double)benchedSize / bestTime / 1000000);
|
||||
}
|
||||
@ -586,9 +587,10 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
|
||||
}
|
||||
for (chunkNb=0; chunkNb<nbChunks; chunkNb++) {
|
||||
chunkP[chunkNb].compressedSize = LZ4_compress_default(chunkP[chunkNb].origBuffer, chunkP[chunkNb].compressedBuffer, chunkP[chunkNb].origSize, maxCompressedChunkSize);
|
||||
if (chunkP[chunkNb].compressedSize==0)
|
||||
DISPLAY("ERROR ! %s() = 0 !! \n", "LZ4_compress"), exit(1);
|
||||
}
|
||||
if (chunkP[chunkNb].compressedSize==0) {
|
||||
DISPLAY("ERROR ! %s() = 0 !! \n", "LZ4_compress");
|
||||
exit(1);
|
||||
} }
|
||||
|
||||
/* Decompression Algorithms */
|
||||
for (dAlgNb=0; (dAlgNb <= NB_DECOMPRESSION_ALGORITHMS) && g_decompressionTest; dAlgNb++) {
|
||||
|
@ -126,7 +126,7 @@ static U32 FUZ_highbit32(U32 v32)
|
||||
{
|
||||
unsigned nbBits = 0;
|
||||
if (v32==0) return 0;
|
||||
while (v32) v32 >>= 1, nbBits++;
|
||||
while (v32) { v32 >>= 1; nbBits++; }
|
||||
return nbBits;
|
||||
}
|
||||
|
||||
@ -766,8 +766,8 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
|
||||
if (blockSize > missingBytes) {
|
||||
decodedBuffer[blockSize-missingBytes] = 0;
|
||||
ret = LZ4_decompress_safe_usingDict(compressedBuffer, decodedBuffer, blockContinueCompressedSize, blockSize-missingBytes, dict, dictSize);
|
||||
FUZ_CHECKTEST(ret>=0, "LZ4_decompress_safe_usingDict should have failed : output buffer too small (-%u byte)", missingBytes);
|
||||
FUZ_CHECKTEST(decodedBuffer[blockSize-missingBytes], "LZ4_decompress_safe_usingDict overrun specified output buffer size (-%u byte) (blockSize=%i)", missingBytes, blockSize);
|
||||
FUZ_CHECKTEST(ret>=0, "LZ4_decompress_safe_usingDict should have failed : output buffer too small (-%i byte)", missingBytes);
|
||||
FUZ_CHECKTEST(decodedBuffer[blockSize-missingBytes], "LZ4_decompress_safe_usingDict overrun specified output buffer size (-%i byte) (blockSize=%i)", missingBytes, blockSize);
|
||||
} }
|
||||
|
||||
/* Compress using external dictionary stream */
|
||||
|
Loading…
Reference in New Issue
Block a user