diff options
author | Yann Collet <cyan@fb.com> | 2020-10-02 13:06:51 -0700 |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-10-02 13:23:11 -0700 |
commit | de52a52518ad0a76a0a078d3db4ee440fad2ff7a (patch) | |
tree | 52b214a21db53d6c32760c1e8aef5db8d8a39979 | |
parent | d1414fd5524a70d47656e0fceb58ee10dc573b75 (diff) | |
download | lz4-de52a52518ad0a76a0a078d3db4ee440fad2ff7a.tar.gz lz4-de52a52518ad0a76a0a078d3db4ee440fad2ff7a.tar.bz2 lz4-de52a52518ad0a76a0a078d3db4ee440fad2ff7a.zip |
added LZ4_streamHC_t init test
which includes an alignment test
-rw-r--r-- | tests/fuzzer.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 6c2ccb7..820ac8e 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -1200,6 +1200,25 @@ static void FUZ_unitTests(int compressionLevel) } } + DISPLAYLEVEL(3, "LZ4_initStreamHC with multiple valid alignments : "); + { struct { + LZ4_streamHC_t hc1; + char c1; + LZ4_streamHC_t hc2; + char c2; + LZ4_streamHC_t hc3; + } shc; + DISPLAYLEVEL(3, "hc1(%p) hc2(%p) hc3(%p) size(0x%x): ", + &(shc.hc1), &(shc.hc2), &(shc.hc3), (unsigned)sizeof(LZ4_streamHC_t)); + FUZ_CHECKTEST( LZ4_initStreamHC(&(shc.hc1), sizeof(shc.hc1)) == NULL, "hc1 (%p) failed init", &(shc.hc1) ); + FUZ_CHECKTEST( LZ4_initStreamHC(&(shc.hc2), sizeof(shc.hc2)) == NULL, "hc2 (%p) failed init", &(shc.hc2) ); + FUZ_CHECKTEST( LZ4_initStreamHC(&(shc.hc3), sizeof(shc.hc3)) == NULL, "hc3 (%p) failed init", &(shc.hc3) ); + FUZ_CHECKTEST( LZ4_initStreamHC((char*)&(shc.hc1) + 1, sizeof(shc.hc1)) != NULL, + "hc1+1 (%p) init must fail, due to bad alignment", (char*)&(shc.hc1) + 1 ); + /* no need to release anything : LZ4_streamHC_t is a simple POD type */ + } + DISPLAYLEVEL(3, "OK \n"); + /* LZ4 HC streaming tests */ { LZ4_streamHC_t sHC; /* statically allocated */ int result; @@ -1211,7 +1230,7 @@ static void FUZ_unitTests(int compressionLevel) FUZ_CHECKTEST(sp==NULL, "LZ4_createStreamHC() allocation failed"); LZ4_freeStreamHC(sp); } - DISPLAYLEVEL(3, " OK \n"); + DISPLAYLEVEL(3, "OK \n"); /* simple HC compression test */ DISPLAYLEVEL(3, "Simple HC round-trip : "); @@ -1226,7 +1245,7 @@ static void FUZ_unitTests(int compressionLevel) { U64 const crcNew = XXH64(testVerify, testCompressedSize, 0); FUZ_CHECKTEST(crc64!=crcNew, "LZ4_decompress_safe() decompression corruption"); } } - DISPLAYLEVEL(3, " OK \n"); + DISPLAYLEVEL(3, "OK \n"); /* long sequence test */ DISPLAYLEVEL(3, "Long sequence HC_destSize test : "); |