diff options
| author | Ilya Leoshkevich <iii@linux.ibm.com> | 2022-09-28 00:50:36 +0200 |
|---|---|---|
| committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2022-11-01 13:25:19 +0100 |
| commit | e63f36b1cf615a81e2cfa2d97fc54a5f493c9c19 (patch) | |
| tree | 7341603ae3a3a1488fed6b5f8406e31a12b8cae5 /test/example.c | |
| parent | f127bc96fc57d05f2cda19406cfc506cf5256e26 (diff) | |
| download | Project-Tick-e63f36b1cf615a81e2cfa2d97fc54a5f493c9c19.tar.gz Project-Tick-e63f36b1cf615a81e2cfa2d97fc54a5f493c9c19.zip | |
Introduce ZLIBNG_ENABLE_TESTS
This patch adds the ability to run zlib-ng test suite against the
original zlib as follows:
cmake -DZLIB_COMPAT=ON -DZLIBNG_ENABLE_TESTS=OFF .
make
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu make test
The benefit of this is that modifications to the original zlib can be
tested with a more extensive zlib-ng's testsuite, and the assumptions
that the zlib-ng tests make can be validated against the original zlib.
In addition to a number of tests that exercise purely zlib-ng specific
API, there are a few that expect zlib-ng specific behavior from the
original zlib API:
- deflate() (obviously) emits different streams
- zlib-ng's deflatePrime() can take more than 16 bits
- zVersion() returns a different string
Adjust or disable the respective tests for ZLIBNG_ENABLE_TESTS=OFF.
Diffstat (limited to 'test/example.c')
| -rw-r--r-- | test/example.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/test/example.c b/test/example.c index 33232dedda..c6556ed197 100644 --- a/test/example.c +++ b/test/example.c @@ -15,12 +15,9 @@ #include <stdarg.h> #include <inttypes.h> -#define TESTFILE "foo.gz" +#include "test_shared_ng.h" -static const char hello[] = "hello, hello!"; -/* "hello world" would be more standard, but the repeated "hello" - * stresses the compression code better, sorry... - */ +#define TESTFILE "foo.gz" static const char dictionary[] = "hello"; static unsigned long dictId = 0; /* Adler32 value of the dictionary */ @@ -437,8 +434,10 @@ void test_flush(unsigned char *compr, z_size_t *comprLen) { *comprLen = (z_size_t)c_stream.total_out; } +#ifdef ZLIBNG_ENABLE_TESTS /* =========================================================================== * Test inflateSync() + * We expect a certain compressed block layout, so skip this with the original zlib. */ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { int err; @@ -474,6 +473,7 @@ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, si printf("after inflateSync(): hel%s\n", (char *)uncompr); } +#endif /* =========================================================================== * Test deflate() with preset dictionary @@ -785,7 +785,7 @@ void test_deflate_prime(unsigned char *compr, size_t comprLen, unsigned char *un err = PREFIX(deflatePrime)(&c_stream, 5, 0x0); CHECK_ERR(err, "deflatePrime"); /* Gzip modified time */ - err = PREFIX(deflatePrime)(&c_stream, 32, 0x0); + err = deflate_prime_32(&c_stream, 0); CHECK_ERR(err, "deflatePrime"); /* Gzip extra flags */ err = PREFIX(deflatePrime)(&c_stream, 8, 0x0); @@ -805,10 +805,10 @@ void test_deflate_prime(unsigned char *compr, size_t comprLen, unsigned char *un /* Gzip uncompressed data crc32 */ crc = PREFIX(crc32)(0, (const uint8_t *)hello, (uint32_t)len); - err = PREFIX(deflatePrime)(&c_stream, 32, crc); + err = deflate_prime_32(&c_stream, crc); CHECK_ERR(err, "deflatePrime"); /* Gzip uncompressed data length */ - err = PREFIX(deflatePrime)(&c_stream, 32, (uint32_t)len); + err = deflate_prime_32(&c_stream, (uint32_t)len); CHECK_ERR(err, "deflatePrime"); err = PREFIX(deflateEnd)(&c_stream); @@ -993,7 +993,9 @@ int main(int argc, char *argv[]) { #endif test_flush(compr, &comprLen); +#ifdef ZLIBNG_ENABLE_TESTS test_sync(compr, comprLen, uncompr, uncomprLen); +#endif comprLen = uncomprLen; test_dict_deflate(compr, comprLen); |
