Skip to content

Commit

Permalink
Tests: Replace HAVE_MICROLZMA usage in CMake and Autotools builds.
Browse files Browse the repository at this point in the history
This reverts commit adaacaf.
  • Loading branch information
JiaT75 committed Mar 9, 2024
1 parent 82ecc53 commit b93a8d7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -853,10 +853,6 @@ if(MICROLZMA_DECODER)
target_sources(liblzma PRIVATE src/liblzma/common/microlzma_decoder.c)
endif()

if (MICROLZMA_ENCODER OR MICROLZMA_DECODER)
add_compile_definitions(HAVE_MICROLZMA)
endif()


#############################
# lzip (.lz) format support #
Expand Down Expand Up @@ -2044,11 +2040,20 @@ if(BUILD_TESTING)
test_index_hash
test_lzip_decoder
test_memlimit
test_microlzma
test_stream_flags
test_vli
)

# MicroLZMA encoder is needed for both encoder and decoder tests.
# If MicroLZMA decoder is not configured but LZMA1 decoder is, then
# test_microlzma will fail to compile because this configuration is
# not possible in the Autotools build, so the test was not made to
# support it since it would have required additional changes.
if (MICROLZMA_ENCODER AND (MICROLZMA_DECODER
OR NOT "lzma1" IN_LIST DECODERS))
list(APPEND LIBLZMA_TESTS test_microlzma)
endif()

foreach(TEST IN LISTS LIBLZMA_TESTS)
add_executable("${TEST}" "tests/${TEST}.c")

Expand Down
9 changes: 2 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,8 @@ AC_ARG_ENABLE([microlzma], AS_HELP_STRING([--disable-microlzma],
for example, erofs-utils.]),
[], [enable_microlzma=yes])
case $enable_microlzma in
yes)
AC_DEFINE([HAVE_MICROLZMA], [1],
[Define to 1 if MicroLZMA support is enabled.])
AC_MSG_RESULT([yes])
;;
no)
AC_MSG_RESULT([no])
yes | no)
AC_MSG_RESULT([$enable_microlzma])
;;
*)
AC_MSG_RESULT([])
Expand Down
9 changes: 6 additions & 3 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ check_PROGRAMS = \
test_bcj_exact_size \
test_memlimit \
test_lzip_decoder \
test_vli \
test_microlzma
test_vli

TESTS = \
test_check \
Expand All @@ -58,7 +57,6 @@ TESTS = \
test_memlimit \
test_lzip_decoder \
test_vli \
test_microlzma \
test_files.sh \
test_suffix.sh \
test_compress_prepared_bcj_sparc \
Expand All @@ -67,6 +65,11 @@ TESTS = \
test_compress_generated_random \
test_compress_generated_text

if COND_MICROLZMA
check_PROGRAMS += test_microlzma
TESTS += test_microlzma
endif

if COND_SCRIPTS
TESTS += test_scripts.sh
endif
Expand Down
12 changes: 4 additions & 8 deletions tests/test_microlzma.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include "tests.h"

#ifdef HAVE_MICROLZMA

#define BUFFER_SIZE 1024

#ifdef HAVE_ENCODER_LZMA1
Expand Down Expand Up @@ -513,25 +511,23 @@ test_decode_bad_lzma_properties(void)
lzma_end(&strm);
}
#endif
#endif


extern int
main(int argc, char **argv)
{
tuktest_start(argc, argv);

#ifndef HAVE_MICROLZMA
tuktest_early_skip("MicroLZMA disabled");
#ifndef HAVE_ENCODER_LZMA1
tuktest_early_skip("LZMA1 encoder disabled");
#else
# ifdef HAVE_ENCODER_LZMA1
tuktest_run(test_encode_options);
tuktest_run(test_encode_basic);
tuktest_run(test_encode_small_out);
tuktest_run(test_encode_actions);
# endif

# if defined(HAVE_DECODER_LZMA1) && defined(HAVE_ENCODER_LZMA1)
// MicroLZMA decoder tests require the basic encoder functionality.
# ifdef HAVE_DECODER_LZMA1
goodbye_world_encoded_size = basic_microlzma_encode(goodbye_world,
ARRAY_SIZE(goodbye_world), &goodbye_world_encoded);

Expand Down

0 comments on commit b93a8d7

Please sign in to comment.