summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-11-05 09:01:28 +1100
committerAndrew Tridgell <tridge@samba.org>2010-11-04 22:09:52 +0000
commita9714246a30107597210077d3c6d7188018fde32 (patch)
treec1486450ffffb95ed40beb52335a05ed64054d0f
parent199399ef7451482ce6efbb15cbbc165e5d29a800 (diff)
downloadsamba-a9714246a30107597210077d3c6d7188018fde32.tar.gz
samba-a9714246a30107597210077d3c6d7188018fde32.tar.bz2
samba-a9714246a30107597210077d3c6d7188018fde32.zip
compression: added a simple lzxpress test
-rw-r--r--lib/compression/testsuite.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/lib/compression/testsuite.c b/lib/compression/testsuite.c
index b9cebb2e8d..8c3c66a046 100644
--- a/lib/compression/testsuite.c
+++ b/lib/compression/testsuite.c
@@ -20,11 +20,58 @@
#include "includes.h"
#include "torture/torture.h"
-#include "../compression/mszip.h"
+#include "talloc.h"
+#include "mszip.h"
+#include "lzxpress.h"
+
+/*
+ test lzxpress
+ */
+static bool test_lzxpress(struct torture_context *test)
+{
+ TALLOC_CTX *tmp_ctx = talloc_new(test);
+ uint8_t *data;
+ const char *fixed_data = "this is a test. and this is a test too";
+ const uint8_t fixed_out[] = { 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;
+
+ data = talloc_size(tmp_ctx, 1023);
+ out = talloc_size(tmp_ctx, 2048);
+ memset(out, 0x42, talloc_get_size(out));
+
+ torture_comment(test, "lzxpress fixed compression\n");
+ c_size = lzxpress_compress((const uint8_t *)fixed_data,
+ strlen(fixed_data),
+ out,
+ talloc_get_size(out));
+
+ torture_assert_int_equal(test, c_size, sizeof(fixed_out), "fixed lzxpress_compress size");
+ torture_assert_mem_equal(test, out, fixed_out, c_size, "fixed lzxpress_compress data");
+
+ torture_comment(test, "lzxpress fixed decompression\n");
+ out2 = talloc_size(tmp_ctx, strlen(fixed_data));
+ c_size = lzxpress_decompress(out,
+ sizeof(fixed_out),
+ out2,
+ talloc_get_size(out2));
+
+ torture_assert_int_equal(test, c_size, strlen(fixed_data), "fixed lzxpress_decompress size");
+ torture_assert_mem_equal(test, out2, fixed_data, c_size, "fixed lzxpress_decompress data");
+
+ return true;
+}
+
struct torture_suite *torture_local_compression(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "COMPRESSION");
+ torture_suite_add_simple_test(suite, "lzxpress", test_lzxpress);
+
return suite;
}