summaryrefslogtreecommitdiff
path: root/test/test_shared_ng.h
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2022-09-28 00:50:36 +0200
committerHans Kristian Rosbach <hk-github@circlestorm.org>2022-11-01 13:25:19 +0100
commite63f36b1cf615a81e2cfa2d97fc54a5f493c9c19 (patch)
tree7341603ae3a3a1488fed6b5f8406e31a12b8cae5 /test/test_shared_ng.h
parentf127bc96fc57d05f2cda19406cfc506cf5256e26 (diff)
downloadProject-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/test_shared_ng.h')
-rw-r--r--test/test_shared_ng.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test_shared_ng.h b/test/test_shared_ng.h
new file mode 100644
index 0000000000..81e451998f
--- /dev/null
+++ b/test/test_shared_ng.h
@@ -0,0 +1,23 @@
+#ifndef TEST_SHARED_NG_H
+#define TEST_SHARED_NG_H
+
+#include "test_shared.h"
+
+/* Test definitions that can only be used in the zlib-ng build environment. */
+
+static inline int deflate_prime_32(PREFIX3(stream) *stream, uint32_t value) {
+ int err;
+
+#ifdef ZLIBNG_ENABLE_TESTS
+ err = PREFIX(deflatePrime)(stream, 32, value);
+#else
+ /* zlib's deflatePrime() takes at most 16 bits */
+ err = PREFIX(deflatePrime)(stream, 16, value & 0xffff);
+ if (err != Z_OK) return err;
+ err = PREFIX(deflatePrime)(stream, 16, value >> 16);
+#endif
+
+ return err;
+}
+
+#endif