aboutsummaryrefslogtreecommitdiff
path: root/tests/test_vli.c
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2022-10-05 23:54:12 +0800
committerLasse Collin <lasse.collin@tukaani.org>2022-10-06 17:34:27 +0300
commit84963318952064a93bfc52edd6b0ef70593384ee (patch)
treec89b493e4f8c3cde1644c4e2e2810cdf35a358db /tests/test_vli.c
parentTests: Include mythread.h in the tests that use MYTHREAD_ENABLED. (diff)
downloadxz-84963318952064a93bfc52edd6b0ef70593384ee.tar.xz
Tests: Fix compilation issues.
test_bcj_exact_size, test_check, test_hardware, and test_index will all now compile and skip properly if encoders or decoders are disabled. Also fixed a small typo (disabed -> disabled). Thanks to Sebastian Andrzej Siewior.
Diffstat (limited to '')
-rw-r--r--tests/test_vli.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_vli.c b/tests/test_vli.c
index 3cf027a8..793dcf2e 100644
--- a/tests/test_vli.c
+++ b/tests/test_vli.c
@@ -70,6 +70,7 @@ test_lzma_vli_size(void)
}
+#ifdef HAVE_ENCODERS
// Helper function for test_lzma_vli_encode
// Encodes an input VLI and compares against a pre-computed value
static void
@@ -108,11 +109,15 @@ encode_multi_call_mode(lzma_vli input, const uint8_t *expected,
assert_uint_eq(vli_pos, expected_len);
assert_array_eq(out, expected, expected_len);
}
+#endif
static void
test_lzma_vli_encode(void)
{
+#ifndef HAVE_ENCODERS
+ assert_skip("Encoder support disabled");
+#else
size_t vli_pos = 0;
uint8_t out[LZMA_VLI_BYTES_MAX];
uint8_t zeros[LZMA_VLI_BYTES_MAX];
@@ -189,9 +194,11 @@ test_lzma_vli_encode(void)
sizeof(eight_bytes));
encode_multi_call_mode(nine_byte_value, nine_bytes,
sizeof(nine_bytes));
+#endif
}
+#ifdef HAVE_DECODERS
static void
decode_single_call_mode(const uint8_t *input, uint32_t input_len,
lzma_vli expected)
@@ -227,10 +234,15 @@ decode_multi_call_mode(const uint8_t *input, uint32_t input_len,
assert_uint_eq(vli_pos, input_len);
assert_uint_eq(out, expected);
}
+#endif
+
static void
test_lzma_vli_decode(void)
{
+#ifndef HAVE_DECODERS
+ assert_skip("Decoder support disabled");
+#else
lzma_vli out = 0;
size_t in_pos = 0;
@@ -295,6 +307,7 @@ test_lzma_vli_decode(void)
eight_byte_value);
decode_multi_call_mode(nine_bytes, sizeof(nine_bytes),
nine_byte_value);
+#endif
}