From baba440ffaaf849e14e31862649767227e8c6432 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Tue, 6 Dec 2022 11:28:58 +1300 Subject: compression tests: avoid div by zero in failure (CID 1517297) Signed-off-by: Douglas Bagnall Reviewed-by: Jeremy Allison --- lib/compression/tests/test_lzx_huffman.c | 1 + lib/compression/tests/test_lzxpress_plain.c | 1 + 2 files changed, 2 insertions(+) (limited to 'lib/compression') diff --git a/lib/compression/tests/test_lzx_huffman.c b/lib/compression/tests/test_lzx_huffman.c index 647a01fa3c0..b7f22b9072b 100644 --- a/lib/compression/tests/test_lzx_huffman.c +++ b/lib/compression/tests/test_lzx_huffman.c @@ -694,6 +694,7 @@ static void test_lzxpress_huffman_round_trip(void **state) print_message("total reference size: %zd \n", reference_total); print_message("diff: %7zd \n", reference_total - compressed_total); + assert_true(reference_total != 0); print_message("ratio: \033[1;3%dm%.2f\033[0m \n", 2 + (compressed_total >= reference_total), ((double)compressed_total) / reference_total); diff --git a/lib/compression/tests/test_lzxpress_plain.c b/lib/compression/tests/test_lzxpress_plain.c index 1264f48530b..b1a4bee6e92 100644 --- a/lib/compression/tests/test_lzxpress_plain.c +++ b/lib/compression/tests/test_lzxpress_plain.c @@ -475,6 +475,7 @@ static void test_lzxpress_plain_round_trip_files(void **state) print_message("total reference size: %zd \n", reference_total); print_message("diff: %7zd \n", reference_total - compressed_total); + assert_true(reference_total != 0); print_message("ratio: \033[1;3%dm%.2f\033[0m \n", 2 + (compressed_total >= reference_total), ((double)compressed_total) / reference_total); -- cgit v1.2.1