summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-05-09 14:33:35 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-05-09 14:33:35 +0200
commitcfa417a44111e1801b17aa0ab31fd0368794c034 (patch)
tree33716998e05d422c565eeed4de2a20f597cab34d
parentab0b93778426c376436690ba6e54374bf830d213 (diff)
Add a basic de-compressor stream test
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--tests/libfstream/Makemodule.am47
-rw-r--r--tests/libfstream/uncompress.c275
2 files changed, 322 insertions, 0 deletions
diff --git a/tests/libfstream/Makemodule.am b/tests/libfstream/Makemodule.am
index bba35f5..9303a8a 100644
--- a/tests/libfstream/Makemodule.am
+++ b/tests/libfstream/Makemodule.am
@@ -3,9 +3,56 @@ test_get_line_LDADD = libfstream.a libcompat.a
test_get_line_CPPFLAGS = $(AM_CPPFLAGS)
test_get_line_CPPFLAGS += -DTESTFILE=$(top_srcdir)/tests/libfstream/get_line.txt
+test_xfrm_bzip2_SOURCES = tests/libfstream/uncompress.c tests/test.h
+test_xfrm_bzip2_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)
+test_xfrm_bzip2_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)
+test_xfrm_bzip2_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_BZIP2=1
+
+test_xfrm_xz_SOURCES = tests/libfstream/uncompress.c tests/test.h
+test_xfrm_xz_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)
+test_xfrm_xz_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)
+test_xfrm_xz_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_XZ=1
+
+test_xfrm_gzip_SOURCES = tests/libfstream/uncompress.c tests/test.h
+test_xfrm_gzip_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)
+test_xfrm_gzip_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)
+test_xfrm_gzip_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_GZIP=1
+
+test_xfrm_zstd_SOURCES = tests/libfstream/uncompress.c tests/test.h
+test_xfrm_zstd_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)
+test_xfrm_zstd_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)
+test_xfrm_zstd_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_ZSTD=1
+
+if WITH_OWN_ZLIB
+test_xfrm_bzip2_LDADD += libz.la
+test_xfrm_xz_LDADD += libz.la
+test_xfrm_gzip_LDADD += libz.la
+test_xfrm_zstd_LDADD += libz.la
+endif
+
if BUILD_TOOLS
check_PROGRAMS += test_get_line
TESTS += test_get_line
+
+if WITH_BZIP2
+check_PROGRAMS += test_xfrm_bzip2
+TESTS += test_xfrm_bzip2
+endif
+
+if WITH_XZ
+check_PROGRAMS += test_xfrm_xz
+TESTS += test_xfrm_xz
+endif
+
+if WITH_GZIP
+check_PROGRAMS += test_xfrm_gzip
+TESTS += test_xfrm_gzip
+endif
+
+if WITH_ZSTD
+check_PROGRAMS += test_xfrm_zstd
+TESTS += test_xfrm_zstd
+endif
endif
EXTRA_DIST += $(top_srcdir)/tests/libfstream/get_line.txt
diff --git a/tests/libfstream/uncompress.c b/tests/libfstream/uncompress.c
new file mode 100644
index 0000000..bd7df46
--- /dev/null
+++ b/tests/libfstream/uncompress.c
@@ -0,0 +1,275 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * uncompress.c
+ *
+ * Copyright (C) 2021 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "fstream.h"
+#include "../test.h"
+
+static sqfs_u8 data_in[] = {
+#if defined(TEST_BZIP2)
+ 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26,
+ 0x53, 0x59, 0x05, 0x24, 0x28, 0x04, 0x00, 0x00,
+ 0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xb6, 0x1b, 0xb7, 0x96, 0x35, 0xa8,
+ 0x0d, 0x1e, 0xae, 0xac, 0x4a, 0x70, 0xa5, 0x31,
+ 0xd0, 0x0c, 0x78, 0xbf, 0xdd, 0xc5, 0x24, 0x3e,
+ 0xcb, 0x0a, 0x0a, 0x69, 0x40, 0xba, 0xb0, 0xc4,
+ 0x2a, 0x9b, 0x1e, 0x0a, 0x51, 0xa6, 0x16, 0x98,
+ 0x76
+#endif
+};
+
+static const char orig[] =
+"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n"
+"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\n"
+"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\n"
+"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n"
+"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\n"
+"proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n";
+
+#if defined(TEST_BZIP2)
+#define COMP_NAME "bzip2"
+#define COMP_ID FSTREAM_COMPRESSOR_BZIP2
+#elif defined(TEST_XZ)
+#define COMP_NAME "xz"
+#define COMP_ID FSTREAM_COMPRESSOR_XZ
+#elif defined(TEST_GZIP)
+#define COMP_NAME "gzip"
+#define COMP_ID FSTREAM_COMPRESSOR_GZIP
+#elif defined(TEST_ZSTD)
+#define COMP_NAME "zstd"
+#define COMP_ID FSTREAM_COMPRESSOR_ZSTD
+#endif
+
+static void destroy_noop(sqfs_object_t *obj)
+{
+ (void)obj;
+}
+
+static int precache_noop(istream_t *strm)
+{
+ (void)strm;
+ return 0;
+}
+
+static const char *get_filename(istream_t *strm)
+{
+ (void)strm;
+ return "memstream";
+}
+
+static istream_t memstream = {
+ .base = {
+ .destroy = destroy_noop,
+ },
+
+ .buffer_used = sizeof(data_in) / sizeof(data_in[0]),
+ .buffer_offset = 0,
+ .eof = true,
+ .buffer = data_in,
+
+ .precache = precache_noop,
+ .get_filename = get_filename,
+};
+
+int main(void)
+{
+ char buffer[2 * (sizeof(orig) / sizeof(orig[0]))];
+ const char *name;
+ istream_t *xfrm;
+ size_t orig_sz;
+ int ret;
+
+ /* XXX: null terminator not included in the compressed blob */
+ orig_sz = (sizeof(orig) / sizeof(orig[0])) - 1;
+
+ /* generic API test */
+ TEST_ASSERT(fstream_compressor_exists(COMP_ID));
+
+ name = fstream_compressor_name_from_id(COMP_ID);
+ TEST_STR_EQUAL(name, COMP_NAME);
+
+ ret = fstream_compressor_id_from_name(name);
+ TEST_EQUAL_I(ret, COMP_ID);
+
+ ret = istream_detect_compressor(&memstream, NULL);
+ TEST_EQUAL_I(ret, COMP_ID);
+
+ /* decoder test */
+ xfrm = istream_compressor_create(&memstream, COMP_ID);
+ TEST_NOT_NULL(xfrm);
+
+ name = istream_get_filename(xfrm);
+ TEST_STR_EQUAL(name, "memstream");
+
+ ret = istream_read(xfrm, buffer, sizeof(buffer));
+ TEST_ASSERT(ret > 0);
+ TEST_EQUAL_UI((size_t)ret, orig_sz);
+
+ ret = memcmp(buffer, orig, ret);
+ TEST_EQUAL_I(ret, 0);
+
+ ret = istream_read(xfrm, buffer, sizeof(buffer));
+ TEST_EQUAL_I(ret, 0);
+
+ /* cleanup */
+ sqfs_destroy(xfrm);
+ return EXIT_SUCCESS;
+}