From 6b1020ef3e034cbb6e0fa4cd984b181c0dd414ff Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 21 Feb 2023 13:23:56 +0100 Subject: libio: Add an xfrm stream wrapper test This basically re-uses the libxfrm pack/unpack tests, but runs the data through a stream wrapper. When de-compressing, we have a ridiculously tiny input buffer, to force the wrapper to snort up the data in several attempts until the it can decompress something. We read the data byte-by-byte to force the wraper to internally cache the uncompressed data and spoon feed it to us. It has to be completely transparent to us that it internaly decompresses and also reads transparently across concatenated streams. When compressing, we only require that the output is smaller than the input and not equal to it. We also require the wrapper to flush the wrapped stream when it is flushed. We then test if the compressed data can be unpacked again. Signed-off-by: David Oberhollenzer --- lib/io/Makemodule.am | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'lib/io/Makemodule.am') diff --git a/lib/io/Makemodule.am b/lib/io/Makemodule.am index 71f01e8..e8e1697 100644 --- a/lib/io/Makemodule.am +++ b/lib/io/Makemodule.am @@ -15,6 +15,9 @@ endif noinst_LIBRARIES += libio.a +LIBIO_TESTS = test_get_line test_sparse_fb test_istream_read \ + test_istream_skip test_stream_splice + test_get_line_SOURCES = lib/io/test/get_line.c test_get_line_LDADD = libio.a libcompat.a test_get_line_CPPFLAGS = $(AM_CPPFLAGS) @@ -32,9 +35,41 @@ test_istream_skip_LDADD = libio.a libutil.a libcompat.a test_stream_splice_SOURCES = lib/io/test/stream_splice.c test_stream_splice_LDADD = libio.a libutil.a libcompat.a -check_PROGRAMS += test_get_line test_sparse_fb test_istream_read -check_PROGRAMS += test_istream_skip test_stream_splice -TESTS += test_get_line test_sparse_fb test_istream_read -TESTS += test_istream_skip test_stream_splice +if WITH_XZ +test_io_xfrm_xz_SOURCES = lib/io/test/xfrm.c +test_io_xfrm_xz_LDADD = libio.a libxfrm.a $(XZ_LIBS) +test_io_xfrm_xz_CPPFLAGS = $(AM_CPPFLAGS) -DDO_XZ=1 + +LIBIO_TESTS += test_io_xfrm_xz +endif + +if WITH_BZIP2 +test_io_xfrm_bzip2_SOURCES = lib/io/test/xfrm.c +test_io_xfrm_bzip2_LDADD = libio.a libxfrm.a $(BZIP2_LIBS) +test_io_xfrm_bzip2_CPPFLAGS = $(AM_CPPFLAGS) -DDO_BZIP2=1 + +LIBIO_TESTS += test_io_xfrm_bzip2 +endif + +if WITH_GZIP +test_io_xfrm_gzip_SOURCES = lib/io/test/xfrm.c +test_io_xfrm_gzip_LDADD = libio.a libxfrm.a $(ZLIB_LIBS) +test_io_xfrm_gzip_CPPFLAGS = $(AM_CPPFLAGS) -DDO_GZIP=1 + +LIBIO_TESTS += test_io_xfrm_gzip +endif + +if WITH_ZSTD +if HAVE_ZSTD_STREAM +test_io_xfrm_zstd_SOURCES = lib/io/test/xfrm.c +test_io_xfrm_zstd_LDADD = libio.a libxfrm.a $(ZSTD_LIBS) +test_io_xfrm_zstd_CPPFLAGS = $(AM_CPPFLAGS) -DDO_ZSTD=1 + +LIBIO_TESTS += test_io_xfrm_zstd +endif +endif + +check_PROGRAMS += $(LIBIO_TESTS) +TESTS += $(LIBIO_TESTS) EXTRA_DIST += $(top_srcdir)/lib/io/test/get_line.txt -- cgit v1.2.3