Rizin
unix-like reverse engineering framework and cli tools
|
#include "util.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include "lz4frame.h"
#include "lz4.h"
#include "xxhash.h"
Go to the source code of this file.
Macros | |
#define | LZ4F_STATIC_LINKING_ONLY |
#define | LZ4_STATIC_LINKING_ONLY /* LZ4_DISTANCE_MAX */ |
#define | XXH_STATIC_LINKING_ONLY |
#define | LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U |
#define | KB *(1U<<10) |
#define | MB *(1U<<20) |
#define | GB *(1U<<30) |
#define | FUZ_COMPRESSIBILITY_DEFAULT 50 |
#define | DISPLAY(...) fprintf(stderr, __VA_ARGS__) |
#define | DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); } |
#define | DISPLAYUPDATE(l, ...) |
#define | MIN(a, b) ( (a) < (b) ? (a) : (b) ) |
#define | MAX(a, b) ( (a) > (b) ? (a) : (b) ) |
#define | FUZ_rotl32(x, r) ((x << r) | (x >> (32 - r))) |
#define | FUZ_RAND15BITS (FUZ_rand(seed) & 0x7FFF) |
#define | FUZ_RANDLENGTH ( (FUZ_rand(seed) & 3) ? (FUZ_rand(seed) % 15) : (FUZ_rand(seed) % 510) + 15) |
#define | CHECK_V(v, f) v = f; if (LZ4F_isError(v)) { fprintf(stderr, "%s \n", LZ4F_getErrorName(v)); goto _output_error; } |
#define | CHECK(f) { LZ4F_errorCode_t const CHECK_V(err_ , f); } |
#define | COMPRESSIBLE_NOISE_LENGTH (2 MB) |
#define | EXIT_MSG(...) |
#define | CHECK(cond, ...) { if (cond) { EXIT_MSG(__VA_ARGS__); } } |
Enumerations | |
enum | o_scenario_e { o_contiguous , o_noncontiguous , o_overwrite } |
Functions | |
static void | FUZ_writeLE32 (void *dstVoidPtr, U32 value32) |
static clock_t | FUZ_GetClockSpan (clock_t clockStart) |
unsigned int | FUZ_rand (unsigned int *src) |
static void | FUZ_fillCompressibleNoiseBuffer (void *buffer, size_t bufferSize, double proba, U32 *seed) |
static unsigned | FUZ_highbit (U32 v32) |
int | basicTests (U32 seed, double compressibility) |
static void | locateBuffDiff (const void *buff1, const void *buff2, size_t size, o_scenario_e o_scenario) |
size_t | test_lz4f_decompression_wBuffers (const void *cSrc, size_t cSize, void *dst, size_t dstCapacity, o_scenario_e o_scenario, const void *srcRef, size_t decompressedSize, U64 crcOrig, U32 *const randState, LZ4F_dctx *const dCtx, U32 seed, U32 testNb, int findErrorPos) |
size_t | test_lz4f_decompression (const void *cSrc, size_t cSize, const void *srcRef, size_t decompressedSize, U64 crcOrig, U32 *const randState, LZ4F_dctx *const dCtx, U32 seed, U32 testNb, int findErrorPos) |
int | fuzzerTests (U32 seed, unsigned nbTests, unsigned startTest, double compressibility, U32 duration_s) |
int | FUZ_usage (const char *programName) |
int | main (int argc, const char **argv) |
Variables | |
static const U32 | nbTestsDefault = 256 KB |
static const U32 | prime1 = 2654435761U |
static const U32 | prime2 = 2246822519U |
static const clock_t | refreshRate = CLOCKS_PER_SEC / 6 |
static clock_t | g_clockTime = 0 |
static U32 | no_prompt = 0 |
static U32 | displayLevel = 2 |
static U32 | use_pause = 0 |
Definition at line 807 of file frametest.c.
#define CHECK | ( | f | ) | { LZ4F_errorCode_t const CHECK_V(err_ , f); } |
Definition at line 807 of file frametest.c.
#define CHECK_V | ( | v, | |
f | |||
) | v = f; if (LZ4F_isError(v)) { fprintf(stderr, "%s \n", LZ4F_getErrorName(v)); goto _output_error; } |
Definition at line 169 of file frametest.c.
#define COMPRESSIBLE_NOISE_LENGTH (2 MB) |
#define DISPLAY | ( | ... | ) | fprintf(stderr, __VA_ARGS__) |
Definition at line 83 of file frametest.c.
#define DISPLAYLEVEL | ( | l, | |
... | |||
) | if (displayLevel>=l) { DISPLAY(__VA_ARGS__); } |
Definition at line 84 of file frametest.c.
#define DISPLAYUPDATE | ( | l, | |
... | |||
) |
Definition at line 85 of file frametest.c.
#define EXIT_MSG | ( | ... | ) |
Definition at line 804 of file frametest.c.
#define FUZ_COMPRESSIBILITY_DEFAULT 50 |
Definition at line 75 of file frametest.c.
#define FUZ_RAND15BITS (FUZ_rand(seed) & 0x7FFF) |
Definition at line 125 of file frametest.c.
#define FUZ_RANDLENGTH ( (FUZ_rand(seed) & 3) ? (FUZ_rand(seed) % 15) : (FUZ_rand(seed) % 510) + 15) |
Definition at line 126 of file frametest.c.
Definition at line 113 of file frametest.c.
#define GB *(1U<<30) |
Definition at line 72 of file frametest.c.
#define KB *(1U<<10) |
Definition at line 70 of file frametest.c.
#define LZ4_STATIC_LINKING_ONLY /* LZ4_DISTANCE_MAX */ |
Definition at line 48 of file frametest.c.
#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U |
Definition at line 68 of file frametest.c.
#define LZ4F_STATIC_LINKING_ONLY |
Definition at line 45 of file frametest.c.
#define MB *(1U<<20) |
Definition at line 71 of file frametest.c.
#define XXH_STATIC_LINKING_ONLY |
Definition at line 50 of file frametest.c.
enum o_scenario_e |
Definition at line 172 of file frametest.c.
References assert(), LZ4F_preferences_t::autoFlush, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockMode, LZ4F_frameInfo_t::blockSizeID, CHECK, CHECK_V, compressedSize, COMPRESSIBLE_NOISE_LENGTH, LZ4F_preferences_t::compressionLevel, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_frameInfo_t::contentSize, LZ4F_frameInfo_t::dictID, DISPLAY, DISPLAYLEVEL, LZ4F_preferences_t::frameInfo, free(), FUZ_fillCompressibleNoiseBuffer(), FUZ_highbit(), FUZ_rand(), FUZ_writeLE32(), inputSize, ip, KB, LZ4F_blockChecksumEnabled, LZ4F_blockIndependent, LZ4F_blockLinked, LZ4F_compressBegin(), LZ4F_compressBound(), LZ4F_compressEnd(), LZ4F_compressFrame(), LZ4F_compressFrame_usingCDict(), LZ4F_compressFrameBound(), LZ4F_compressionLevel_max(), LZ4F_compressUpdate(), LZ4F_contentChecksumEnabled, LZ4F_createCDict(), LZ4F_createCompressionContext(), LZ4F_createDecompressionContext(), LZ4F_decompress(), LZ4F_decompress_usingDict(), LZ4F_freeCDict(), LZ4F_freeCompressionContext(), LZ4F_freeDecompressionContext(), LZ4F_getBlockSize(), LZ4F_getErrorCode(), LZ4F_getErrorName(), LZ4F_getFrameInfo(), LZ4F_headerSize(), LZ4F_isError(), LZ4F_MAGIC_SKIPPABLE_START, LZ4F_max1MB, LZ4F_max256KB, LZ4F_max4MB, LZ4F_max64KB, LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH, LZ4F_noContentChecksum, LZ4F_resetDecompressionContext(), LZ4F_VERSION, malloc(), memcpy(), memset(), NULL, and XXH64().
Referenced by main().
|
static |
Definition at line 127 of file frametest.c.
References test_evm::end, FUZ_rand(), FUZ_RAND15BITS, FUZ_RANDLENGTH, length, MIN, pos, and U32.
Referenced by basicTests(), and fuzzerTests().
Definition at line 107 of file frametest.c.
Referenced by fuzzerTests().
Definition at line 157 of file frametest.c.
Referenced by basicTests(), fuzzerTests(), and test_lz4f_decompression_wBuffers().
Definition at line 114 of file frametest.c.
References FUZ_rotl32, prime1, prime2, and src.
Referenced by basicTests(), FUZ_fillCompressibleNoiseBuffer(), fuzzerTests(), test_lz4f_decompression(), and test_lz4f_decompression_wBuffers().
Definition at line 1130 of file frametest.c.
References DISPLAY, FUZ_COMPRESSIBILITY_DEFAULT, and nbTestsDefault.
Referenced by main().
|
static |
int fuzzerTests | ( | U32 | seed, |
unsigned | nbTests, | ||
unsigned | startTest, | ||
double | compressibility, | ||
U32 | duration_s | ||
) |
Definition at line 928 of file frametest.c.
References assert(), LZ4F_preferences_t::autoFlush, LZ4F_frameInfo_t::blockChecksumFlag, LZ4F_frameInfo_t::blockMode, LZ4F_frameInfo_t::blockSizeID, calloc(), CHECK, LZ4F_preferences_t::compressionLevel, LZ4F_frameInfo_t::contentChecksumFlag, LZ4F_frameInfo_t::contentSize, DISPLAY, DISPLAYLEVEL, DISPLAYUPDATE, LZ4F_preferences_t::frameInfo, free(), FUZ_fillCompressibleNoiseBuffer(), FUZ_GetClockSpan(), FUZ_highbit(), FUZ_rand(), FUZ_writeLE32(), int, ip, LZ4F_compressBegin(), LZ4F_compressBound(), LZ4F_compressEnd(), LZ4F_compressFrame(), LZ4F_compressFrameBound(), LZ4F_compressUpdate(), LZ4F_createCompressionContext(), LZ4F_createDecompressionContext(), LZ4F_flush(), LZ4F_freeCompressionContext(), LZ4F_freeDecompressionContext(), LZ4F_getErrorName(), LZ4F_isError(), LZ4F_MAGIC_SKIPPABLE_START, LZ4F_resetDecompressionContext(), LZ4F_VERSION, malloc(), mask, MB, memcpy(), memset(), MIN, NULL, pos, prime1, srcSize, LZ4F_compressOptions_t::stableSrc, test_lz4f_decompression(), use_pause, XXH32(), and XXH64().
Referenced by main().
|
static |
Definition at line 785 of file frametest.c.
References b1, b2, DISPLAY, displayLevel, o_contiguous, and p.
Referenced by test_lz4f_decompression_wBuffers().
Definition at line 1147 of file frametest.c.
References argv, basicTests(), DISPLAY, displayLevel, FUZ_COMPRESSIBILITY_DEFAULT, FUZ_usage(), fuzzerTests(), h, LZ4_VERSION_STRING, nbTestsDefault, no_prompt, NULL, time, U32, unsigned, use_pause, and XXH32().
size_t test_lz4f_decompression | ( | const void * | cSrc, |
size_t | cSize, | ||
const void * | srcRef, | ||
size_t | decompressedSize, | ||
U64 | crcOrig, | ||
U32 *const | randState, | ||
LZ4F_dctx *const | dCtx, | ||
U32 | seed, | ||
U32 | testNb, | ||
int | findErrorPos | ||
) |
Definition at line 898 of file frametest.c.
References assert(), free(), FUZ_rand(), malloc(), NULL, o_noncontiguous, and test_lz4f_decompression_wBuffers().
Referenced by fuzzerTests().
size_t test_lz4f_decompression_wBuffers | ( | const void * | cSrc, |
size_t | cSize, | ||
void * | dst, | ||
size_t | dstCapacity, | ||
o_scenario_e | o_scenario, | ||
const void * | srcRef, | ||
size_t | decompressedSize, | ||
U64 | crcOrig, | ||
U32 *const | randState, | ||
LZ4F_dctx *const | dCtx, | ||
U32 | seed, | ||
U32 | testNb, | ||
int | findErrorPos | ||
) |
Definition at line 810 of file frametest.c.
References assert(), CHECK, DISPLAYLEVEL, dst, free(), FUZ_highbit(), FUZ_rand(), ip, locateBuffDiff(), LZ4F_decompress(), LZ4F_getErrorCode(), LZ4F_isError(), malloc(), MAX, memcpy(), memset(), MIN, NULL, o_noncontiguous, o_overwrite, op, LZ4F_decompressOptions_t::stableDst, XXH64_digest(), XXH64_reset(), and XXH64_update().
Referenced by test_lz4f_decompression().
|
static |
Definition at line 97 of file frametest.c.
Referenced by locateBuffDiff(), and main().
|
static |
Definition at line 90 of file frametest.c.
Definition at line 74 of file frametest.c.
Referenced by FUZ_usage(), and main().
|
static |
Definition at line 96 of file frametest.c.
Referenced by main().
Definition at line 76 of file frametest.c.
Referenced by FUZ_rand(), FUZZ_rand(), and fuzzerTests().
Definition at line 77 of file frametest.c.
Referenced by FUZ_rand(), and FUZZ_rand().
Definition at line 89 of file frametest.c.
|
static |
Definition at line 98 of file frametest.c.
Referenced by fuzzerTests(), and main().