summaryrefslogtreecommitdiff
path: root/lib/compression
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-11-23 13:06:41 +1300
committerJoseph Sutton <jsutton@samba.org>2022-12-01 22:56:39 +0000
commit9589f5282b9e2adfacd7e1cfdc2651551c4c6702 (patch)
treec0253aaf3f6457e679acd4fa43b6b9b5e8a54fc1 /lib/compression
parentc2db7fda4e3af571b3b63b753b98517ac948b006 (diff)
downloadsamba-9589f5282b9e2adfacd7e1cfdc2651551c4c6702.tar.gz
lib/compression/lzx-plain: relax size requirements on long file
We are going to change from a slow exact match algorithm to a fast heuristic search that will not always get the same results as the exhaustive search. To be precise, a million zeros will compress to 112 rather than 93 bytes. We don't insist on an exact size, because that is not an issue here. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Diffstat (limited to 'lib/compression')
-rw-r--r--lib/compression/tests/test_lzxpress_plain.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/compression/tests/test_lzxpress_plain.c b/lib/compression/tests/test_lzxpress_plain.c
index 8ce3a7715d0..5d2a51eb466 100644
--- a/lib/compression/tests/test_lzxpress_plain.c
+++ b/lib/compression/tests/test_lzxpress_plain.c
@@ -309,7 +309,8 @@ static void test_lzxpress_many_zeros(void **state)
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
const size_t N_ZEROS = 1000000;
const uint8_t *zeros = talloc_zero_size(tmp_ctx, N_ZEROS);
- const ssize_t expected_c_size = 93;
+ const ssize_t expected_c_size_max = 120;
+ const ssize_t expected_c_size_min = 93;
ssize_t c_size;
uint8_t *comp, *decomp;
static struct timespec t_start, t_end;
@@ -327,8 +328,13 @@ static void test_lzxpress_many_zeros(void **state)
N_ZEROS,
comp,
talloc_get_size(comp));
+ /*
+ * Because our compression depends on heuristics, we don't insist on
+ * an exact size in this case.
+ */
- assert_int_equal(c_size, expected_c_size);
+ assert_true(c_size <= expected_c_size_max);
+ assert_true(c_size >= expected_c_size_min);
decomp = talloc_size(tmp_ctx, N_ZEROS * 2);
c_size = lzxpress_decompress(comp,