]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
compression tests: add test for legacy compressed data
authorMatt Suiche <msuiche@comae.com>
Thu, 25 Mar 2021 12:50:42 +0000 (16:50 +0400)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 May 2022 02:22:35 +0000 (02:22 +0000)
Signed-off-by: Matt Suiche <msuiche@comae.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/compression/testsuite.c

index 6d432dd686149f81a812276eeb8cd2dcf725b4ed..2370f2e79fe1c5efa52de1b6c335be0bf32bbc35 100644 (file)
@@ -135,8 +135,16 @@ static bool test_lzxpress(struct torture_context *test)
                0x20, 0x10, 0x00, 0x61, 0x20, 0x74, 0x65, 0x73,
                0x74, 0x2E, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x9F,
                0x00, 0x04, 0x20, 0x74, 0x6F, 0x6F };
+
+       const uint8_t fixed_out_old_version[] = {
+               0x00, 0x20, 0x00, 0x04, 0x74, 0x68, 0x69, 0x73,
+               0x20, 0x10, 0x00, 0x61, 0x20, 0x74, 0x65, 0x73,
+               0x74, 0x2E, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x9F,
+               0x00, 0x04, 0x20, 0x74, 0x6F, 0x6F, 0x00, 0x00,
+               0x00, 0x00 };
+
        ssize_t c_size;
-       uint8_t *out, *out2;
+       uint8_t *out, *out2, *out3;
 
        out  = talloc_size(tmp_ctx, 2048);
        memset(out, 0x42, talloc_get_size(out));
@@ -163,6 +171,20 @@ static bool test_lzxpress(struct torture_context *test)
                                 "fixed lzxpress_decompress size");
        torture_assert_mem_equal(test, out2, fixed_data, c_size,
                                 "fixed lzxpress_decompress data");
+
+
+       torture_comment(test, "lzxpress fixed decompression (old data)\n");
+       out3  = talloc_size(tmp_ctx, strlen(fixed_data));
+       c_size = lzxpress_decompress(fixed_out_old_version,
+                                    sizeof(fixed_out_old_version),
+                                    out3,
+                                    talloc_get_size(out3));
+
+       torture_assert_int_equal(test, c_size, strlen(fixed_data),
+                                "fixed lzxpress_decompress size");
+       torture_assert_mem_equal(test, out3, fixed_data, c_size,
+                                "fixed lzxpress_decompress data");
+
        talloc_free(tmp_ctx);
        return true;
 }