cmake-args: -DWITH_OPTIM=OFF -DHAVE_BUILTIN_CTZLL=OFF -DHAVE_BUILTIN_CTZ=OFF
codecov: ubuntu_gcc_no_ctz
- - name: Ubuntu GCC Link Zlib
- os: ubuntu-latest
- compiler: gcc
- cxx-compiler: g++
- cmake-args: -DZLIB_DUAL_LINK=ON
-
- name: Ubuntu GCC No AVX2 UBSAN
os: ubuntu-latest
compiler: gcc
target_compile_definitions(${target} PUBLIC -DWITH_GZFILEOP)
target_sources(${target} PRIVATE ${ZLIB_GZFILE_PRIVATE_HDRS} ${ZLIB_GZFILE_SRCS})
endif()
- if(ZLIB_DUAL_LINK)
- find_package(ZLIB)
- if(ZLIB_FOUND)
- target_link_libraries(${target} ${ZLIB_LIBRARIES})
- endif()
- endif()
endmacro()
macro(add_simple_test_executable target)
-fsanitize-memory-track-origins)
endif()
+if(ZLIB_DUAL_LINK AND NOT ZLIB_COMPAT)
+ find_package(ZLIB)
+ if(ZLIB_FOUND)
+ message(STATUS "Added dual linking tests against zlib")
+ message(STATUS " Zlib include dir: ${ZLIB_INCLUDE_DIR}")
+ message(STATUS " Zlib libraries: ${ZLIB_LIBRARIES}")
+
+ target_sources(gtest_zlib PRIVATE test_compress_dual.cc)
+ target_include_directories(gtest_zlib PRIVATE ${ZLIB_INCLUDE_DIR})
+ target_link_libraries(gtest_zlib ${ZLIB_LIBRARIES})
+ else()
+ message(WARNING "Zlib not found, skipping dual linking tests")
+ endif()
+endif()
+
target_link_libraries(gtest_zlib zlibstatic GTest::GTest)
find_package(Threads)
--- /dev/null
+/* test_compress_dual.cc - Test linking against both zlib and zlib-ng */
+
+#include "zlib.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "test_shared.h"
+
+#include <gtest/gtest.h>
+
+TEST(compress, basic_zlib) {
+ Byte compr[128], uncompr[128];
+ uLong compr_len = sizeof(compr), uncompr_len = sizeof(uncompr);
+ int err;
+
+ err = compress(compr, &compr_len, (const unsigned char *)hello, hello_len);
+ EXPECT_EQ(err, Z_OK);
+
+ strcpy((char*)uncompr, "garbage");
+
+ err = uncompress(uncompr, &uncompr_len, compr, compr_len);
+ EXPECT_EQ(err, Z_OK);
+
+ EXPECT_STREQ((char *)uncompr, (char *)hello);
+}