Import xz 5.2.2 (as of svn r86089)
This commit is contained in:
57
tests/Makefile.am
Normal file
57
tests/Makefile.am
Normal file
@@ -0,0 +1,57 @@
|
||||
##
|
||||
## Author: Lasse Collin
|
||||
##
|
||||
## This file has been put into the public domain.
|
||||
## You can do whatever you want with this file.
|
||||
##
|
||||
|
||||
EXTRA_DIST = \
|
||||
files \
|
||||
tests.h \
|
||||
test_files.sh \
|
||||
test_compress.sh \
|
||||
test_scripts.sh \
|
||||
bcj_test.c \
|
||||
compress_prepared_bcj_sparc \
|
||||
compress_prepared_bcj_x86 \
|
||||
xzgrep_expected_output
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/common \
|
||||
-I$(top_srcdir)/src/liblzma/api \
|
||||
-I$(top_builddir)/lib
|
||||
|
||||
LDADD = $(top_builddir)/src/liblzma/liblzma.la
|
||||
|
||||
if COND_GNULIB
|
||||
LDADD += $(top_builddir)/lib/libgnu.a
|
||||
endif
|
||||
|
||||
LDADD += $(LTLIBINTL)
|
||||
|
||||
check_PROGRAMS = \
|
||||
create_compress_files \
|
||||
test_check \
|
||||
test_stream_flags \
|
||||
test_filter_flags \
|
||||
test_block_header \
|
||||
test_index \
|
||||
test_bcj_exact_size
|
||||
|
||||
TESTS = \
|
||||
test_check \
|
||||
test_stream_flags \
|
||||
test_filter_flags \
|
||||
test_block_header \
|
||||
test_index \
|
||||
test_bcj_exact_size \
|
||||
test_files.sh \
|
||||
test_compress.sh
|
||||
|
||||
if COND_SCRIPTS
|
||||
TESTS += test_scripts.sh
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
-rm -f compress_generated_* \
|
||||
xzgrep_test_output xzgrep_test_1.xz xzgrep_test_2.xz
|
||||
845
tests/Makefile.in
Normal file
845
tests/Makefile.in
Normal file
@@ -0,0 +1,845 @@
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@COND_GNULIB_TRUE@am__append_1 = $(top_builddir)/lib/libgnu.a
|
||||
check_PROGRAMS = create_compress_files$(EXEEXT) test_check$(EXEEXT) \
|
||||
test_stream_flags$(EXEEXT) test_filter_flags$(EXEEXT) \
|
||||
test_block_header$(EXEEXT) test_index$(EXEEXT) \
|
||||
test_bcj_exact_size$(EXEEXT)
|
||||
TESTS = test_check$(EXEEXT) test_stream_flags$(EXEEXT) \
|
||||
test_filter_flags$(EXEEXT) test_block_header$(EXEEXT) \
|
||||
test_index$(EXEEXT) test_bcj_exact_size$(EXEEXT) test_files.sh \
|
||||
test_compress.sh $(am__append_2)
|
||||
@COND_SCRIPTS_TRUE@am__append_2 = test_scripts.sh
|
||||
subdir = tests
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_pthread.m4 \
|
||||
$(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettext.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
|
||||
$(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/progtest.m4 \
|
||||
$(top_srcdir)/m4/tuklib_common.m4 \
|
||||
$(top_srcdir)/m4/tuklib_cpucores.m4 \
|
||||
$(top_srcdir)/m4/tuklib_integer.m4 \
|
||||
$(top_srcdir)/m4/tuklib_mbstr.m4 \
|
||||
$(top_srcdir)/m4/tuklib_physmem.m4 \
|
||||
$(top_srcdir)/m4/tuklib_progname.m4 \
|
||||
$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
create_compress_files_SOURCES = create_compress_files.c
|
||||
create_compress_files_OBJECTS = create_compress_files.$(OBJEXT)
|
||||
create_compress_files_LDADD = $(LDADD)
|
||||
am__DEPENDENCIES_1 =
|
||||
create_compress_files_DEPENDENCIES = \
|
||||
$(top_builddir)/src/liblzma/liblzma.la $(am__append_1) \
|
||||
$(am__DEPENDENCIES_1)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
test_bcj_exact_size_SOURCES = test_bcj_exact_size.c
|
||||
test_bcj_exact_size_OBJECTS = test_bcj_exact_size.$(OBJEXT)
|
||||
test_bcj_exact_size_LDADD = $(LDADD)
|
||||
test_bcj_exact_size_DEPENDENCIES = \
|
||||
$(top_builddir)/src/liblzma/liblzma.la $(am__append_1) \
|
||||
$(am__DEPENDENCIES_1)
|
||||
test_block_header_SOURCES = test_block_header.c
|
||||
test_block_header_OBJECTS = test_block_header.$(OBJEXT)
|
||||
test_block_header_LDADD = $(LDADD)
|
||||
test_block_header_DEPENDENCIES = \
|
||||
$(top_builddir)/src/liblzma/liblzma.la $(am__append_1) \
|
||||
$(am__DEPENDENCIES_1)
|
||||
test_check_SOURCES = test_check.c
|
||||
test_check_OBJECTS = test_check.$(OBJEXT)
|
||||
test_check_LDADD = $(LDADD)
|
||||
test_check_DEPENDENCIES = $(top_builddir)/src/liblzma/liblzma.la \
|
||||
$(am__append_1) $(am__DEPENDENCIES_1)
|
||||
test_filter_flags_SOURCES = test_filter_flags.c
|
||||
test_filter_flags_OBJECTS = test_filter_flags.$(OBJEXT)
|
||||
test_filter_flags_LDADD = $(LDADD)
|
||||
test_filter_flags_DEPENDENCIES = \
|
||||
$(top_builddir)/src/liblzma/liblzma.la $(am__append_1) \
|
||||
$(am__DEPENDENCIES_1)
|
||||
test_index_SOURCES = test_index.c
|
||||
test_index_OBJECTS = test_index.$(OBJEXT)
|
||||
test_index_LDADD = $(LDADD)
|
||||
test_index_DEPENDENCIES = $(top_builddir)/src/liblzma/liblzma.la \
|
||||
$(am__append_1) $(am__DEPENDENCIES_1)
|
||||
test_stream_flags_SOURCES = test_stream_flags.c
|
||||
test_stream_flags_OBJECTS = test_stream_flags.$(OBJEXT)
|
||||
test_stream_flags_LDADD = $(LDADD)
|
||||
test_stream_flags_DEPENDENCIES = \
|
||||
$(top_builddir)/src/liblzma/liblzma.la $(am__append_1) \
|
||||
$(am__DEPENDENCIES_1)
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_@AM_V@)
|
||||
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
am__v_CC_1 =
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = create_compress_files.c test_bcj_exact_size.c \
|
||||
test_block_header.c test_check.c test_filter_flags.c \
|
||||
test_index.c test_stream_flags.c
|
||||
DIST_SOURCES = create_compress_files.c test_bcj_exact_size.c \
|
||||
test_block_header.c test_check.c test_filter_flags.c \
|
||||
test_index.c test_stream_flags.c
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__tty_colors_dummy = \
|
||||
mgn= red= grn= lgn= blu= brg= std=; \
|
||||
am__color_tests=no
|
||||
am__tty_colors = { \
|
||||
$(am__tty_colors_dummy); \
|
||||
if test "X$(AM_COLOR_TESTS)" = Xno; then \
|
||||
am__color_tests=no; \
|
||||
elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
|
||||
am__color_tests=yes; \
|
||||
elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
|
||||
am__color_tests=yes; \
|
||||
fi; \
|
||||
if test $$am__color_tests = yes; then \
|
||||
red='[0;31m'; \
|
||||
grn='[0;32m'; \
|
||||
lgn='[1;32m'; \
|
||||
blu='[1;34m'; \
|
||||
mgn='[0;35m'; \
|
||||
brg='[1m'; \
|
||||
std='[m'; \
|
||||
fi; \
|
||||
}
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in \
|
||||
$(top_srcdir)/build-aux/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CCASDEPMODE = @CCASDEPMODE@
|
||||
CCASFLAGS = @CCASFLAGS@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GETOPT_H = @GETOPT_H@
|
||||
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GMSGFMT_015 = @GMSGFMT_015@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBINTL = @LIBINTL@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_EXEEXT = @LN_EXEEXT@
|
||||
LN_S = @LN_S@
|
||||
LTLIBICONV = @LTLIBICONV@
|
||||
LTLIBINTL = @LTLIBINTL@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
MSGFMT = @MSGFMT@
|
||||
MSGFMT_015 = @MSGFMT_015@
|
||||
MSGMERGE = @MSGMERGE@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
POSIX_SHELL = @POSIX_SHELL@
|
||||
POSUB = @POSUB@
|
||||
PREFERABLY_POSIX_SHELL = @PREFERABLY_POSIX_SHELL@
|
||||
PTHREAD_CC = @PTHREAD_CC@
|
||||
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
|
||||
PTHREAD_LIBS = @PTHREAD_LIBS@
|
||||
RANLIB = @RANLIB@
|
||||
RC = @RC@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
USE_NLS = @USE_NLS@
|
||||
VERSION = @VERSION@
|
||||
XGETTEXT = @XGETTEXT@
|
||||
XGETTEXT_015 = @XGETTEXT_015@
|
||||
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
ax_pthread_config = @ax_pthread_config@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
xz = @xz@
|
||||
EXTRA_DIST = \
|
||||
files \
|
||||
tests.h \
|
||||
test_files.sh \
|
||||
test_compress.sh \
|
||||
test_scripts.sh \
|
||||
bcj_test.c \
|
||||
compress_prepared_bcj_sparc \
|
||||
compress_prepared_bcj_x86 \
|
||||
xzgrep_expected_output
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/common \
|
||||
-I$(top_srcdir)/src/liblzma/api \
|
||||
-I$(top_builddir)/lib
|
||||
|
||||
LDADD = $(top_builddir)/src/liblzma/liblzma.la $(am__append_1) \
|
||||
$(LTLIBINTL)
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign tests/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
clean-checkPROGRAMS:
|
||||
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list || exit $$?; \
|
||||
test -n "$(EXEEXT)" || exit 0; \
|
||||
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list
|
||||
|
||||
create_compress_files$(EXEEXT): $(create_compress_files_OBJECTS) $(create_compress_files_DEPENDENCIES) $(EXTRA_create_compress_files_DEPENDENCIES)
|
||||
@rm -f create_compress_files$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(create_compress_files_OBJECTS) $(create_compress_files_LDADD) $(LIBS)
|
||||
|
||||
test_bcj_exact_size$(EXEEXT): $(test_bcj_exact_size_OBJECTS) $(test_bcj_exact_size_DEPENDENCIES) $(EXTRA_test_bcj_exact_size_DEPENDENCIES)
|
||||
@rm -f test_bcj_exact_size$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(test_bcj_exact_size_OBJECTS) $(test_bcj_exact_size_LDADD) $(LIBS)
|
||||
|
||||
test_block_header$(EXEEXT): $(test_block_header_OBJECTS) $(test_block_header_DEPENDENCIES) $(EXTRA_test_block_header_DEPENDENCIES)
|
||||
@rm -f test_block_header$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(test_block_header_OBJECTS) $(test_block_header_LDADD) $(LIBS)
|
||||
|
||||
test_check$(EXEEXT): $(test_check_OBJECTS) $(test_check_DEPENDENCIES) $(EXTRA_test_check_DEPENDENCIES)
|
||||
@rm -f test_check$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(test_check_OBJECTS) $(test_check_LDADD) $(LIBS)
|
||||
|
||||
test_filter_flags$(EXEEXT): $(test_filter_flags_OBJECTS) $(test_filter_flags_DEPENDENCIES) $(EXTRA_test_filter_flags_DEPENDENCIES)
|
||||
@rm -f test_filter_flags$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(test_filter_flags_OBJECTS) $(test_filter_flags_LDADD) $(LIBS)
|
||||
|
||||
test_index$(EXEEXT): $(test_index_OBJECTS) $(test_index_DEPENDENCIES) $(EXTRA_test_index_DEPENDENCIES)
|
||||
@rm -f test_index$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(test_index_OBJECTS) $(test_index_LDADD) $(LIBS)
|
||||
|
||||
test_stream_flags$(EXEEXT): $(test_stream_flags_OBJECTS) $(test_stream_flags_DEPENDENCIES) $(EXTRA_test_stream_flags_DEPENDENCIES)
|
||||
@rm -f test_stream_flags$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(test_stream_flags_OBJECTS) $(test_stream_flags_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/create_compress_files.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_bcj_exact_size.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_block_header.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_check.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_filter_flags.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_index.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_stream_flags.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
check-TESTS: $(TESTS)
|
||||
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
|
||||
srcdir=$(srcdir); export srcdir; \
|
||||
list=' $(TESTS) '; \
|
||||
$(am__tty_colors); \
|
||||
if test -n "$$list"; then \
|
||||
for tst in $$list; do \
|
||||
if test -f ./$$tst; then dir=./; \
|
||||
elif test -f $$tst; then dir=; \
|
||||
else dir="$(srcdir)/"; fi; \
|
||||
if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
|
||||
all=`expr $$all + 1`; \
|
||||
case " $(XFAIL_TESTS) " in \
|
||||
*[\ \ ]$$tst[\ \ ]*) \
|
||||
xpass=`expr $$xpass + 1`; \
|
||||
failed=`expr $$failed + 1`; \
|
||||
col=$$red; res=XPASS; \
|
||||
;; \
|
||||
*) \
|
||||
col=$$grn; res=PASS; \
|
||||
;; \
|
||||
esac; \
|
||||
elif test $$? -ne 77; then \
|
||||
all=`expr $$all + 1`; \
|
||||
case " $(XFAIL_TESTS) " in \
|
||||
*[\ \ ]$$tst[\ \ ]*) \
|
||||
xfail=`expr $$xfail + 1`; \
|
||||
col=$$lgn; res=XFAIL; \
|
||||
;; \
|
||||
*) \
|
||||
failed=`expr $$failed + 1`; \
|
||||
col=$$red; res=FAIL; \
|
||||
;; \
|
||||
esac; \
|
||||
else \
|
||||
skip=`expr $$skip + 1`; \
|
||||
col=$$blu; res=SKIP; \
|
||||
fi; \
|
||||
echo "$${col}$$res$${std}: $$tst"; \
|
||||
done; \
|
||||
if test "$$all" -eq 1; then \
|
||||
tests="test"; \
|
||||
All=""; \
|
||||
else \
|
||||
tests="tests"; \
|
||||
All="All "; \
|
||||
fi; \
|
||||
if test "$$failed" -eq 0; then \
|
||||
if test "$$xfail" -eq 0; then \
|
||||
banner="$$All$$all $$tests passed"; \
|
||||
else \
|
||||
if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
|
||||
banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
|
||||
fi; \
|
||||
else \
|
||||
if test "$$xpass" -eq 0; then \
|
||||
banner="$$failed of $$all $$tests failed"; \
|
||||
else \
|
||||
if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
|
||||
banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dashes="$$banner"; \
|
||||
skipped=""; \
|
||||
if test "$$skip" -ne 0; then \
|
||||
if test "$$skip" -eq 1; then \
|
||||
skipped="($$skip test was not run)"; \
|
||||
else \
|
||||
skipped="($$skip tests were not run)"; \
|
||||
fi; \
|
||||
test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
|
||||
dashes="$$skipped"; \
|
||||
fi; \
|
||||
report=""; \
|
||||
if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
|
||||
report="Please report to $(PACKAGE_BUGREPORT)"; \
|
||||
test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
|
||||
dashes="$$report"; \
|
||||
fi; \
|
||||
dashes=`echo "$$dashes" | sed s/./=/g`; \
|
||||
if test "$$failed" -eq 0; then \
|
||||
col="$$grn"; \
|
||||
else \
|
||||
col="$$red"; \
|
||||
fi; \
|
||||
echo "$${col}$$dashes$${std}"; \
|
||||
echo "$${col}$$banner$${std}"; \
|
||||
test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
|
||||
test -z "$$report" || echo "$${col}$$report$${std}"; \
|
||||
echo "$${col}$$dashes$${std}"; \
|
||||
test "$$failed" -eq 0; \
|
||||
else :; fi
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
|
||||
check: check-am
|
||||
all-am: Makefile
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: check-am install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \
|
||||
clean-checkPROGRAMS clean-generic clean-libtool clean-local \
|
||||
cscopelist-am ctags ctags-am distclean distclean-compile \
|
||||
distclean-generic distclean-libtool distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-am uninstall uninstall-am
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
clean-local:
|
||||
-rm -f compress_generated_* \
|
||||
xzgrep_test_output xzgrep_test_1.xz xzgrep_test_2.xz
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
65
tests/bcj_test.c
Normal file
65
tests/bcj_test.c
Normal file
@@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file bcj_test.c
|
||||
/// \brief Source code of compress_prepared_bcj_*
|
||||
///
|
||||
/// This is a simple program that should make the compiler to generate
|
||||
/// PC-relative branches, jumps, and calls. The compiled files can then
|
||||
/// be used to test the branch conversion filters. Note that this program
|
||||
/// itself does nothing useful.
|
||||
///
|
||||
/// Compiling: gcc -std=c99 -fPIC -c bcj_test.c
|
||||
/// Don't optimize or strip.
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern int jump(int a, int b);
|
||||
|
||||
|
||||
extern int
|
||||
call(int a, int b)
|
||||
{
|
||||
if (a < b)
|
||||
a = jump(a, b);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
extern int
|
||||
jump(int a, int b)
|
||||
{
|
||||
// The loop generates conditional jump backwards.
|
||||
while (1) {
|
||||
if (a < b) {
|
||||
a *= 2;
|
||||
a += 3 * b;
|
||||
break;
|
||||
} else {
|
||||
// Put enough code here to prevent JMP SHORT on x86.
|
||||
a += b;
|
||||
a /= 2;
|
||||
b += b % 5;
|
||||
a -= b / 3;
|
||||
b = 2 * b + a - 1;
|
||||
a *= b + a + 1;
|
||||
b += a - 1;
|
||||
a += b * 2 - a / 5;
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int a = call(argc, argc + 1);
|
||||
return a == 0;
|
||||
}
|
||||
BIN
tests/compress_prepared_bcj_sparc
Normal file
BIN
tests/compress_prepared_bcj_sparc
Normal file
Binary file not shown.
BIN
tests/compress_prepared_bcj_x86
Normal file
BIN
tests/compress_prepared_bcj_x86
Normal file
Binary file not shown.
158
tests/create_compress_files.c
Normal file
158
tests/create_compress_files.c
Normal file
@@ -0,0 +1,158 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file create_compress_files.c
|
||||
/// \brief Creates bunch of test files to be compressed
|
||||
///
|
||||
/// Using a test file generator program saves space in the source code
|
||||
/// package considerably.
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "sysdefs.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Avoid re-creating the test files every time the tests are run.
|
||||
#define create_test(name) \
|
||||
do { \
|
||||
if (!file_exists("compress_generated_" #name)) { \
|
||||
FILE *file = file_create("compress_generated_" #name); \
|
||||
write_ ## name(file); \
|
||||
file_finish(file, "compress_generated_" #name); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
static bool
|
||||
file_exists(const char *filename)
|
||||
{
|
||||
// Trying to be somewhat portable by avoiding stat().
|
||||
FILE *file = fopen(filename, "rb");
|
||||
bool ret;
|
||||
|
||||
if (file != NULL) {
|
||||
fclose(file);
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static FILE *
|
||||
file_create(const char *filename)
|
||||
{
|
||||
FILE *file = fopen(filename, "wb");
|
||||
|
||||
if (file == NULL) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
file_finish(FILE *file, const char *filename)
|
||||
{
|
||||
const bool ferror_fail = ferror(file);
|
||||
const bool fclose_fail = fclose(file);
|
||||
|
||||
if (ferror_fail || fclose_fail) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// File that repeats "abc\n" a few thousand times. This is targeted
|
||||
// especially at Subblock filter's run-length encoder.
|
||||
static void
|
||||
write_abc(FILE *file)
|
||||
{
|
||||
for (size_t i = 0; i < 12345; ++i)
|
||||
if (fwrite("abc\n", 4, 1, file) != 1)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
// File that doesn't compress. We always use the same random seed to
|
||||
// generate identical files on all systems.
|
||||
static void
|
||||
write_random(FILE *file)
|
||||
{
|
||||
uint32_t n = 5;
|
||||
|
||||
for (size_t i = 0; i < 123456; ++i) {
|
||||
n = 101771 * n + 71777;
|
||||
|
||||
putc(n & 0xFF, file);
|
||||
putc((n >> 8) & 0xFF, file);
|
||||
putc((n >> 16) & 0xFF, file);
|
||||
putc(n >> 24, file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Text file
|
||||
static void
|
||||
write_text(FILE *file)
|
||||
{
|
||||
static const char *lorem[] = {
|
||||
"Lorem", "ipsum", "dolor", "sit", "amet,", "consectetur",
|
||||
"adipisicing", "elit,", "sed", "do", "eiusmod", "tempor",
|
||||
"incididunt", "ut", "labore", "et", "dolore", "magna",
|
||||
"aliqua.", "Ut", "enim", "ad", "minim", "veniam,", "quis",
|
||||
"nostrud", "exercitation", "ullamco", "laboris", "nisi",
|
||||
"ut", "aliquip", "ex", "ea", "commodo", "consequat.",
|
||||
"Duis", "aute", "irure", "dolor", "in", "reprehenderit",
|
||||
"in", "voluptate", "velit", "esse", "cillum", "dolore",
|
||||
"eu", "fugiat", "nulla", "pariatur.", "Excepteur", "sint",
|
||||
"occaecat", "cupidatat", "non", "proident,", "sunt", "in",
|
||||
"culpa", "qui", "officia", "deserunt", "mollit", "anim",
|
||||
"id", "est", "laborum."
|
||||
};
|
||||
|
||||
// Let the first paragraph be the original text.
|
||||
for (size_t w = 0; w < ARRAY_SIZE(lorem); ++w) {
|
||||
fprintf(file, "%s ", lorem[w]);
|
||||
|
||||
if (w % 7 == 6)
|
||||
fprintf(file, "\n");
|
||||
}
|
||||
|
||||
// The rest shall be (hopefully) meaningless combinations of
|
||||
// the same words.
|
||||
uint32_t n = 29;
|
||||
|
||||
for (size_t p = 0; p < 500; ++p) {
|
||||
fprintf(file, "\n\n");
|
||||
|
||||
for (size_t w = 0; w < ARRAY_SIZE(lorem); ++w) {
|
||||
n = 101771 * n + 71777;
|
||||
|
||||
fprintf(file, "%s ", lorem[n % ARRAY_SIZE(lorem)]);
|
||||
|
||||
if (w % 7 == 6)
|
||||
fprintf(file, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
create_test(abc);
|
||||
create_test(random);
|
||||
create_test(text);
|
||||
return 0;
|
||||
}
|
||||
240
tests/files/README
Normal file
240
tests/files/README
Normal file
@@ -0,0 +1,240 @@
|
||||
|
||||
.xz Test Files
|
||||
----------------
|
||||
|
||||
0. Introduction
|
||||
|
||||
This directory contains bunch of files to test handling of .xz files
|
||||
in .xz decoder implementations. Many of the files have been created
|
||||
by hand with a hex editor, thus there is no better "source code" than
|
||||
the files themselves. All the test files (*.xz) and this README have
|
||||
been put into the public domain.
|
||||
|
||||
|
||||
1. File Types
|
||||
|
||||
Good files (good-*.xz) must decode successfully without requiring
|
||||
a lot of CPU time or RAM.
|
||||
|
||||
Unsupported files (unsupported-*.xz) are good files, but headers
|
||||
indicate features not supported by the current file format
|
||||
specification.
|
||||
|
||||
Bad files (bad-*.xz) must cause the decoder to give an error. Like
|
||||
with the good files, these files must not require a lot of CPU time
|
||||
or RAM before they get detected to be broken.
|
||||
|
||||
|
||||
2. Descriptions of Individual Files
|
||||
|
||||
2.1. Good Files
|
||||
|
||||
good-0-empty.xz has one Stream with no Blocks.
|
||||
|
||||
good-0pad-empty.xz has one Stream with no Blocks followed by
|
||||
four-byte Stream Padding.
|
||||
|
||||
good-0cat-empty.xz has two zero-Block Streams concatenated without
|
||||
Stream Padding.
|
||||
|
||||
good-0catpad-empty.xz has two zero-Block Streams concatenated with
|
||||
four-byte Stream Padding between the Streams.
|
||||
|
||||
good-1-check-none.xz has one Stream with one Block with two
|
||||
uncompressed LZMA2 chunks and no integrity check.
|
||||
|
||||
good-1-check-crc32.xz has one Stream with one Block with two
|
||||
uncompressed LZMA2 chunks and CRC32 check.
|
||||
|
||||
good-1-check-crc64.xz is like good-1-check-crc32.xz but with CRC64.
|
||||
|
||||
good-1-check-sha256.xz is like good-1-check-crc32.xz but with
|
||||
SHA256.
|
||||
|
||||
good-2-lzma2.xz has one Stream with two Blocks with one uncompressed
|
||||
LZMA2 chunk in each Block.
|
||||
|
||||
good-1-block_header-1.xz has both Compressed Size and Uncompressed
|
||||
Size in the Block Header. This has also four extra bytes of Header
|
||||
Padding.
|
||||
|
||||
good-1-block_header-2.xz has known Compressed Size.
|
||||
|
||||
good-1-block_header-3.xz has known Uncompressed Size.
|
||||
|
||||
good-1-delta-lzma2.tiff.xz is an image file that compresses
|
||||
better with Delta+LZMA2 than with plain LZMA2.
|
||||
|
||||
good-1-x86-lzma2.xz uses the x86 filter (BCJ) and LZMA2. The
|
||||
uncompressed file is compress_prepared_bcj_x86 found from the tests
|
||||
directory.
|
||||
|
||||
good-1-sparc-lzma2.xz uses the SPARC filter and LZMA. The
|
||||
uncompressed file is compress_prepared_bcj_sparc found from the tests
|
||||
directory.
|
||||
|
||||
good-1-lzma2-1.xz has two LZMA2 chunks, of which the second sets
|
||||
new properties.
|
||||
|
||||
good-1-lzma2-2.xz has two LZMA2 chunks, of which the second resets
|
||||
the state without specifying new properties.
|
||||
|
||||
good-1-lzma2-3.xz has two LZMA2 chunks, of which the first is
|
||||
uncompressed and the second is LZMA. The first chunk resets dictionary
|
||||
and the second sets new properties.
|
||||
|
||||
good-1-lzma2-4.xz has three LZMA2 chunks: First is LZMA, second is
|
||||
uncompressed with dictionary reset, and third is LZMA with new
|
||||
properties but without dictionary reset.
|
||||
|
||||
good-1-lzma2-5.xz has an empty LZMA2 stream with only the end of
|
||||
payload marker. XZ Utils 5.0.1 and older incorrectly see this file
|
||||
as corrupt.
|
||||
|
||||
good-1-3delta-lzma2.xz has three Delta filters and LZMA2.
|
||||
|
||||
|
||||
2.2. Unsupported Files
|
||||
|
||||
unsupported-check.xz uses Check ID 0x02 which isn't supported by
|
||||
the current version of the file format. It is implementation-defined
|
||||
how this file handled (it may reject it, or decode it possibly with
|
||||
a warning).
|
||||
|
||||
unsupported-block_header.xz has a non-null byte in Header Padding,
|
||||
which may indicate presence of a new unsupported field.
|
||||
|
||||
unsupported-filter_flags-1.xz has unsupported Filter ID 0x7F.
|
||||
|
||||
unsupported-filter_flags-2.xz specifies only Delta filter in the
|
||||
List of Filter Flags, but Delta isn't allowed as the last filter in
|
||||
the chain. It could be a little more correct to detect this file as
|
||||
corrupt instead of unsupported, but saying it is unsupported is
|
||||
simpler in case of liblzma.
|
||||
|
||||
unsupported-filter_flags-3.xz specifies two LZMA2 filters in the
|
||||
List of Filter Flags. LZMA2 is allowed only as the last filter in the
|
||||
chain. It could be a little more correct to detect this file as
|
||||
corrupt instead of unsupported, but saying it is unsupported is
|
||||
simpler in case of liblzma.
|
||||
|
||||
|
||||
2.3. Bad Files
|
||||
|
||||
bad-0pad-empty.xz has one Stream with no Blocks followed by
|
||||
five-byte Stream Padding. Stream Padding must be a multiple of four
|
||||
bytes, thus this file is corrupt.
|
||||
|
||||
bad-0catpad-empty.xz has two zero-Block Streams concatenated with
|
||||
five-byte Stream Padding between the Streams.
|
||||
|
||||
bad-0cat-alone.xz is good-0-empty.xz concatenated with an empty
|
||||
LZMA_Alone file.
|
||||
|
||||
bad-0cat-header_magic.xz is good-0cat-empty.xz but with one byte
|
||||
wrong in the Header Magic Bytes field of the second Stream. liblzma
|
||||
gives LZMA_DATA_ERROR for this. (LZMA_FORMAT_ERROR is used only if
|
||||
the first Stream of a file has invalid Header Magic Bytes.)
|
||||
|
||||
bad-0-header_magic.xz is good-0-empty.xz but with one byte wrong
|
||||
in the Header Magic Bytes field. liblzma gives LZMA_FORMAT_ERROR for
|
||||
this.
|
||||
|
||||
bad-0-footer_magic.xz is good-0-empty.xz but with one byte wrong
|
||||
in the Footer Magic Bytes field. liblzma gives LZMA_DATA_ERROR for
|
||||
this.
|
||||
|
||||
bad-0-empty-truncated.xz is good-0-empty.xz without the last byte
|
||||
of the file.
|
||||
|
||||
bad-0-nonempty_index.xz has no Blocks but Index claims that there is
|
||||
one Block.
|
||||
|
||||
bad-0-backward_size.xz has wrong Backward Size in Stream Footer.
|
||||
|
||||
bad-1-stream_flags-1.xz has different Stream Flags in Stream Header
|
||||
and Stream Footer.
|
||||
|
||||
bad-1-stream_flags-2.xz has wrong CRC32 in Stream Header.
|
||||
|
||||
bad-1-stream_flags-3.xz has wrong CRC32 in Stream Footer.
|
||||
|
||||
bad-1-vli-1.xz has two-byte variable-length integer in the
|
||||
Uncompressed Size field in Block Header while one-byte would be enough
|
||||
for that value. It's important that the file gets rejected due to too
|
||||
big integer encoding instead of due to Uncompressed Size not matching
|
||||
the value stored in the Block Header. That is, the decoder must not
|
||||
try to decode the Compressed Data field.
|
||||
|
||||
bad-1-vli-2.xz has ten-byte variable-length integer as Uncompressed
|
||||
Size in Block Header. It's important that the file gets rejected due
|
||||
to too big integer encoding instead of due to Uncompressed Size not
|
||||
matching the value stored in the Block Header. That is, the decoder
|
||||
must not try to decode the Compressed Data field.
|
||||
|
||||
bad-1-block_header-1.xz has Block Header that ends in the middle of
|
||||
the Filter Flags field.
|
||||
|
||||
bad-1-block_header-2.xz has Block Header that has Compressed Size and
|
||||
Uncompressed Size but no List of Filter Flags field.
|
||||
|
||||
bad-1-block_header-3.xz has wrong CRC32 in Block Header.
|
||||
|
||||
bad-1-block_header-4.xz has too big Compressed Size in Block Header
|
||||
(2^63 - 1 bytes while maximum is a little less, because the whole
|
||||
Block must stay smaller than 2^63). It's important that the file
|
||||
gets rejected due to invalid Compressed Size value; the decoder
|
||||
must not try decoding the Compressed Data field.
|
||||
|
||||
bad-1-block_header-5.xz has zero as Compressed Size in Block Header.
|
||||
|
||||
bad-1-block_header-6.xz has corrupt Block Header which may crash
|
||||
xz -lvv in XZ Utils 5.0.3 and earlier. It was fixed in the commit
|
||||
c0297445064951807803457dca1611b3c47e7f0f.
|
||||
|
||||
bad-2-index-1.xz has wrong Unpadded Sizes in Index.
|
||||
|
||||
bad-2-index-2.xz has wrong Uncompressed Sizes in Index.
|
||||
|
||||
bad-2-index-3.xz has non-null byte in Index Padding.
|
||||
|
||||
bad-2-index-4.xz wrong CRC32 in Index.
|
||||
|
||||
bad-2-index-5.xz has zero as Unpadded Size. It is important that the
|
||||
file gets rejected specifically due to Unpadded Size having an invalid
|
||||
value.
|
||||
|
||||
bad-2-compressed_data_padding.xz has non-null byte in the padding of
|
||||
the Compressed Data field of the first Block.
|
||||
|
||||
bad-1-check-crc32.xz has wrong Check (CRC32).
|
||||
|
||||
bad-1-check-crc64.xz has wrong Check (CRC64).
|
||||
|
||||
bad-1-check-sha256.xz has wrong Check (SHA-256).
|
||||
|
||||
bad-1-lzma2-1.xz has LZMA2 stream whose first chunk (uncompressed)
|
||||
doesn't reset the dictionary.
|
||||
|
||||
bad-1-lzma2-2.xz has two LZMA2 chunks, of which the second chunk
|
||||
indicates dictionary reset, but the LZMA compressed data tries to
|
||||
repeat data from the previous chunk.
|
||||
|
||||
bad-1-lzma2-3.xz sets new invalid properties (lc=8, lp=0, pb=0) in
|
||||
the middle of Block.
|
||||
|
||||
bad-1-lzma2-4.xz has two LZMA2 chunks, of which the first is
|
||||
uncompressed and the second is LZMA. The first chunk resets dictionary
|
||||
as it should, but the second chunk tries to reset state without
|
||||
specifying properties for LZMA.
|
||||
|
||||
bad-1-lzma2-5.xz is like bad-1-lzma2-4.xz but doesn't try to reset
|
||||
anything in the header of the second chunk.
|
||||
|
||||
bad-1-lzma2-6.xz has reserved LZMA2 control byte value (0x03).
|
||||
|
||||
bad-1-lzma2-7.xz has EOPM at LZMA level.
|
||||
|
||||
bad-1-lzma2-8.xz is like good-1-lzma2-4.xz but doesn't set new
|
||||
properties in the third LZMA2 chunk.
|
||||
|
||||
BIN
tests/files/bad-0-backward_size.xz
Normal file
BIN
tests/files/bad-0-backward_size.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0-empty-truncated.xz
Normal file
BIN
tests/files/bad-0-empty-truncated.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0-footer_magic.xz
Normal file
BIN
tests/files/bad-0-footer_magic.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0-header_magic.xz
Normal file
BIN
tests/files/bad-0-header_magic.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0-nonempty_index.xz
Normal file
BIN
tests/files/bad-0-nonempty_index.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0cat-alone.xz
Normal file
BIN
tests/files/bad-0cat-alone.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0cat-header_magic.xz
Normal file
BIN
tests/files/bad-0cat-header_magic.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0catpad-empty.xz
Normal file
BIN
tests/files/bad-0catpad-empty.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-0pad-empty.xz
Normal file
BIN
tests/files/bad-0pad-empty.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-block_header-1.xz
Normal file
BIN
tests/files/bad-1-block_header-1.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-block_header-2.xz
Normal file
BIN
tests/files/bad-1-block_header-2.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-block_header-3.xz
Normal file
BIN
tests/files/bad-1-block_header-3.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-block_header-4.xz
Normal file
BIN
tests/files/bad-1-block_header-4.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-block_header-5.xz
Normal file
BIN
tests/files/bad-1-block_header-5.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-block_header-6.xz
Normal file
BIN
tests/files/bad-1-block_header-6.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-check-crc32.xz
Normal file
BIN
tests/files/bad-1-check-crc32.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-check-crc64.xz
Normal file
BIN
tests/files/bad-1-check-crc64.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-check-sha256.xz
Normal file
BIN
tests/files/bad-1-check-sha256.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-1.xz
Normal file
BIN
tests/files/bad-1-lzma2-1.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-2.xz
Normal file
BIN
tests/files/bad-1-lzma2-2.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-3.xz
Normal file
BIN
tests/files/bad-1-lzma2-3.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-4.xz
Normal file
BIN
tests/files/bad-1-lzma2-4.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-5.xz
Normal file
BIN
tests/files/bad-1-lzma2-5.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-6.xz
Normal file
BIN
tests/files/bad-1-lzma2-6.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-7.xz
Normal file
BIN
tests/files/bad-1-lzma2-7.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-lzma2-8.xz
Normal file
BIN
tests/files/bad-1-lzma2-8.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-stream_flags-1.xz
Normal file
BIN
tests/files/bad-1-stream_flags-1.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-stream_flags-2.xz
Normal file
BIN
tests/files/bad-1-stream_flags-2.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-stream_flags-3.xz
Normal file
BIN
tests/files/bad-1-stream_flags-3.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-vli-1.xz
Normal file
BIN
tests/files/bad-1-vli-1.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-1-vli-2.xz
Normal file
BIN
tests/files/bad-1-vli-2.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-2-compressed_data_padding.xz
Normal file
BIN
tests/files/bad-2-compressed_data_padding.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-2-index-1.xz
Normal file
BIN
tests/files/bad-2-index-1.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-2-index-2.xz
Normal file
BIN
tests/files/bad-2-index-2.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-2-index-3.xz
Normal file
BIN
tests/files/bad-2-index-3.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-2-index-4.xz
Normal file
BIN
tests/files/bad-2-index-4.xz
Normal file
Binary file not shown.
BIN
tests/files/bad-2-index-5.xz
Normal file
BIN
tests/files/bad-2-index-5.xz
Normal file
Binary file not shown.
BIN
tests/files/good-0-empty.xz
Normal file
BIN
tests/files/good-0-empty.xz
Normal file
Binary file not shown.
BIN
tests/files/good-0cat-empty.xz
Normal file
BIN
tests/files/good-0cat-empty.xz
Normal file
Binary file not shown.
BIN
tests/files/good-0catpad-empty.xz
Normal file
BIN
tests/files/good-0catpad-empty.xz
Normal file
Binary file not shown.
BIN
tests/files/good-0pad-empty.xz
Normal file
BIN
tests/files/good-0pad-empty.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-3delta-lzma2.xz
Normal file
BIN
tests/files/good-1-3delta-lzma2.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-block_header-1.xz
Normal file
BIN
tests/files/good-1-block_header-1.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-block_header-2.xz
Normal file
BIN
tests/files/good-1-block_header-2.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-block_header-3.xz
Normal file
BIN
tests/files/good-1-block_header-3.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-check-crc32.xz
Normal file
BIN
tests/files/good-1-check-crc32.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-check-crc64.xz
Normal file
BIN
tests/files/good-1-check-crc64.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-check-none.xz
Normal file
BIN
tests/files/good-1-check-none.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-check-sha256.xz
Normal file
BIN
tests/files/good-1-check-sha256.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-delta-lzma2.tiff.xz
Normal file
BIN
tests/files/good-1-delta-lzma2.tiff.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-lzma2-1.xz
Normal file
BIN
tests/files/good-1-lzma2-1.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-lzma2-2.xz
Normal file
BIN
tests/files/good-1-lzma2-2.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-lzma2-3.xz
Normal file
BIN
tests/files/good-1-lzma2-3.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-lzma2-4.xz
Normal file
BIN
tests/files/good-1-lzma2-4.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-lzma2-5.xz
Normal file
BIN
tests/files/good-1-lzma2-5.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-sparc-lzma2.xz
Normal file
BIN
tests/files/good-1-sparc-lzma2.xz
Normal file
Binary file not shown.
BIN
tests/files/good-1-x86-lzma2.xz
Normal file
BIN
tests/files/good-1-x86-lzma2.xz
Normal file
Binary file not shown.
BIN
tests/files/good-2-lzma2.xz
Normal file
BIN
tests/files/good-2-lzma2.xz
Normal file
Binary file not shown.
BIN
tests/files/unsupported-block_header.xz
Normal file
BIN
tests/files/unsupported-block_header.xz
Normal file
Binary file not shown.
BIN
tests/files/unsupported-check.xz
Normal file
BIN
tests/files/unsupported-check.xz
Normal file
Binary file not shown.
BIN
tests/files/unsupported-filter_flags-1.xz
Normal file
BIN
tests/files/unsupported-filter_flags-1.xz
Normal file
Binary file not shown.
BIN
tests/files/unsupported-filter_flags-2.xz
Normal file
BIN
tests/files/unsupported-filter_flags-2.xz
Normal file
Binary file not shown.
BIN
tests/files/unsupported-filter_flags-3.xz
Normal file
BIN
tests/files/unsupported-filter_flags-3.xz
Normal file
Binary file not shown.
113
tests/test_bcj_exact_size.c
Normal file
113
tests/test_bcj_exact_size.c
Normal file
@@ -0,0 +1,113 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file test_bcj_exact_size.c
|
||||
/// \brief Tests BCJ decoding when the output size is known
|
||||
///
|
||||
/// These tests fail with XZ Utils 5.0.3 and earlier.
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
/// Something to be compressed
|
||||
static const uint8_t in[16] = "0123456789ABCDEF";
|
||||
|
||||
/// in[] after compression
|
||||
static uint8_t compressed[1024];
|
||||
static size_t compressed_size = 0;
|
||||
|
||||
/// Output buffer for decompressing compressed[]
|
||||
static uint8_t out[sizeof(in)];
|
||||
|
||||
|
||||
static void
|
||||
compress(void)
|
||||
{
|
||||
// Compress with PowerPC BCJ and LZMA2. PowerPC BCJ is used because
|
||||
// it has fixed 4-byte alignment which makes triggering the potential
|
||||
// bug easy.
|
||||
lzma_options_lzma opt_lzma2;
|
||||
succeed(lzma_lzma_preset(&opt_lzma2, 0));
|
||||
|
||||
lzma_filter filters[3] = {
|
||||
{ .id = LZMA_FILTER_POWERPC, .options = NULL },
|
||||
{ .id = LZMA_FILTER_LZMA2, .options = &opt_lzma2 },
|
||||
{ .id = LZMA_VLI_UNKNOWN, .options = NULL },
|
||||
};
|
||||
|
||||
expect(lzma_stream_buffer_encode(filters, LZMA_CHECK_CRC32, NULL,
|
||||
in, sizeof(in),
|
||||
compressed, &compressed_size, sizeof(compressed))
|
||||
== LZMA_OK);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
decompress(void)
|
||||
{
|
||||
lzma_stream strm = LZMA_STREAM_INIT;
|
||||
expect(lzma_stream_decoder(&strm, 10 << 20, 0) == LZMA_OK);
|
||||
|
||||
strm.next_in = compressed;
|
||||
strm.next_out = out;
|
||||
|
||||
while (true) {
|
||||
if (strm.total_in < compressed_size)
|
||||
strm.avail_in = 1;
|
||||
|
||||
const lzma_ret ret = lzma_code(&strm, LZMA_RUN);
|
||||
if (ret == LZMA_STREAM_END) {
|
||||
expect(strm.total_in == compressed_size);
|
||||
expect(strm.total_out == sizeof(in));
|
||||
lzma_end(&strm);
|
||||
return;
|
||||
}
|
||||
|
||||
expect(ret == LZMA_OK);
|
||||
|
||||
if (strm.total_out < sizeof(in))
|
||||
strm.avail_out = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
decompress_empty(void)
|
||||
{
|
||||
// An empty file with one Block using PowerPC BCJ and LZMA2.
|
||||
static const uint8_t empty_bcj_lzma2[] = {
|
||||
0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00, 0x00, 0x01,
|
||||
0x69, 0x22, 0xDE, 0x36, 0x02, 0x01, 0x05, 0x00,
|
||||
0x21, 0x01, 0x00, 0x00, 0x7F, 0xE0, 0xF1, 0xC8,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x11, 0x00, 0x3B, 0x96, 0x5F, 0x73,
|
||||
0x90, 0x42, 0x99, 0x0D, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x59, 0x5A
|
||||
};
|
||||
|
||||
// Decompress without giving any output space.
|
||||
uint64_t memlimit = 1 << 20;
|
||||
size_t in_pos = 0;
|
||||
size_t out_pos = 0;
|
||||
expect(lzma_stream_buffer_decode(&memlimit, 0, NULL,
|
||||
empty_bcj_lzma2, &in_pos, sizeof(empty_bcj_lzma2),
|
||||
out, &out_pos, 0) == LZMA_OK);
|
||||
expect(in_pos == sizeof(empty_bcj_lzma2));
|
||||
expect(out_pos == 0);
|
||||
}
|
||||
|
||||
|
||||
extern int
|
||||
main(void)
|
||||
{
|
||||
compress();
|
||||
decompress();
|
||||
decompress_empty();
|
||||
return 0;
|
||||
}
|
||||
240
tests/test_block_header.c
Normal file
240
tests/test_block_header.c
Normal file
@@ -0,0 +1,240 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file test_block_header.c
|
||||
/// \brief Tests Block Header coders
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
static uint8_t buf[LZMA_BLOCK_HEADER_SIZE_MAX];
|
||||
static lzma_block known_options;
|
||||
static lzma_block decoded_options;
|
||||
|
||||
static lzma_options_lzma opt_lzma;
|
||||
|
||||
static lzma_filter filters_none[1] = {
|
||||
{
|
||||
.id = LZMA_VLI_UNKNOWN,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
static lzma_filter filters_one[2] = {
|
||||
{
|
||||
.id = LZMA_FILTER_LZMA2,
|
||||
.options = &opt_lzma,
|
||||
}, {
|
||||
.id = LZMA_VLI_UNKNOWN,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static lzma_filter filters_four[5] = {
|
||||
{
|
||||
.id = LZMA_FILTER_X86,
|
||||
.options = NULL,
|
||||
}, {
|
||||
.id = LZMA_FILTER_X86,
|
||||
.options = NULL,
|
||||
}, {
|
||||
.id = LZMA_FILTER_X86,
|
||||
.options = NULL,
|
||||
}, {
|
||||
.id = LZMA_FILTER_LZMA2,
|
||||
.options = &opt_lzma,
|
||||
}, {
|
||||
.id = LZMA_VLI_UNKNOWN,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static lzma_filter filters_five[6] = {
|
||||
{
|
||||
.id = LZMA_FILTER_X86,
|
||||
.options = NULL,
|
||||
}, {
|
||||
.id = LZMA_FILTER_X86,
|
||||
.options = NULL,
|
||||
}, {
|
||||
.id = LZMA_FILTER_X86,
|
||||
.options = NULL,
|
||||
}, {
|
||||
.id = LZMA_FILTER_X86,
|
||||
.options = NULL,
|
||||
}, {
|
||||
.id = LZMA_FILTER_LZMA2,
|
||||
.options = &opt_lzma,
|
||||
}, {
|
||||
.id = LZMA_VLI_UNKNOWN,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
code(void)
|
||||
{
|
||||
expect(lzma_block_header_encode(&known_options, buf) == LZMA_OK);
|
||||
|
||||
lzma_filter filters[LZMA_FILTERS_MAX + 1];
|
||||
memcrap(filters, sizeof(filters));
|
||||
memcrap(&decoded_options, sizeof(decoded_options));
|
||||
|
||||
decoded_options.header_size = known_options.header_size;
|
||||
decoded_options.check = known_options.check;
|
||||
decoded_options.filters = filters;
|
||||
expect(lzma_block_header_decode(&decoded_options, NULL, buf)
|
||||
== LZMA_OK);
|
||||
|
||||
expect(known_options.compressed_size
|
||||
== decoded_options.compressed_size);
|
||||
expect(known_options.uncompressed_size
|
||||
== decoded_options.uncompressed_size);
|
||||
|
||||
for (size_t i = 0; known_options.filters[i].id
|
||||
!= LZMA_VLI_UNKNOWN; ++i)
|
||||
expect(known_options.filters[i].id == filters[i].id);
|
||||
|
||||
for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i)
|
||||
free(decoded_options.filters[i].options);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test1(void)
|
||||
{
|
||||
known_options = (lzma_block){
|
||||
.check = LZMA_CHECK_NONE,
|
||||
.compressed_size = LZMA_VLI_UNKNOWN,
|
||||
.uncompressed_size = LZMA_VLI_UNKNOWN,
|
||||
.filters = NULL,
|
||||
};
|
||||
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_PROG_ERROR);
|
||||
|
||||
known_options.filters = filters_none;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_PROG_ERROR);
|
||||
|
||||
known_options.filters = filters_five;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_PROG_ERROR);
|
||||
|
||||
known_options.filters = filters_one;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
|
||||
known_options.check = 999; // Some invalid value, which gets ignored.
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
|
||||
known_options.compressed_size = 5;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
|
||||
known_options.compressed_size = 0; // Cannot be zero.
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_PROG_ERROR);
|
||||
|
||||
// LZMA_VLI_MAX is too big to keep the total size of the Block
|
||||
// a valid VLI, but lzma_block_header_size() is not meant
|
||||
// to validate it. (lzma_block_header_encode() must validate it.)
|
||||
known_options.compressed_size = LZMA_VLI_MAX;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
|
||||
known_options.compressed_size = LZMA_VLI_UNKNOWN;
|
||||
known_options.uncompressed_size = 0;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
|
||||
known_options.uncompressed_size = LZMA_VLI_MAX + 1;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_PROG_ERROR);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test2(void)
|
||||
{
|
||||
known_options = (lzma_block){
|
||||
.check = LZMA_CHECK_CRC32,
|
||||
.compressed_size = LZMA_VLI_UNKNOWN,
|
||||
.uncompressed_size = LZMA_VLI_UNKNOWN,
|
||||
.filters = filters_four,
|
||||
};
|
||||
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
code();
|
||||
|
||||
known_options.compressed_size = 123456;
|
||||
known_options.uncompressed_size = 234567;
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
code();
|
||||
|
||||
// We can make the sizes smaller while keeping the header size
|
||||
// the same.
|
||||
known_options.compressed_size = 12;
|
||||
known_options.uncompressed_size = 23;
|
||||
code();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test3(void)
|
||||
{
|
||||
known_options = (lzma_block){
|
||||
.check = LZMA_CHECK_CRC32,
|
||||
.compressed_size = LZMA_VLI_UNKNOWN,
|
||||
.uncompressed_size = LZMA_VLI_UNKNOWN,
|
||||
.filters = filters_one,
|
||||
};
|
||||
|
||||
expect(lzma_block_header_size(&known_options) == LZMA_OK);
|
||||
known_options.header_size += 4;
|
||||
expect(lzma_block_header_encode(&known_options, buf) == LZMA_OK);
|
||||
|
||||
lzma_filter filters[LZMA_FILTERS_MAX + 1];
|
||||
decoded_options.header_size = known_options.header_size;
|
||||
decoded_options.check = known_options.check;
|
||||
decoded_options.filters = filters;
|
||||
|
||||
// Wrong size
|
||||
++buf[0];
|
||||
expect(lzma_block_header_decode(&decoded_options, NULL, buf)
|
||||
== LZMA_PROG_ERROR);
|
||||
--buf[0];
|
||||
|
||||
// Wrong CRC32
|
||||
buf[known_options.header_size - 1] ^= 1;
|
||||
expect(lzma_block_header_decode(&decoded_options, NULL, buf)
|
||||
== LZMA_DATA_ERROR);
|
||||
buf[known_options.header_size - 1] ^= 1;
|
||||
|
||||
// Unsupported filter
|
||||
// NOTE: This may need updating when new IDs become supported.
|
||||
buf[2] ^= 0x1F;
|
||||
unaligned_write32le(buf + known_options.header_size - 4,
|
||||
lzma_crc32(buf, known_options.header_size - 4, 0));
|
||||
expect(lzma_block_header_decode(&decoded_options, NULL, buf)
|
||||
== LZMA_OPTIONS_ERROR);
|
||||
buf[2] ^= 0x1F;
|
||||
|
||||
// Non-nul Padding
|
||||
buf[known_options.header_size - 4 - 1] ^= 1;
|
||||
unaligned_write32le(buf + known_options.header_size - 4,
|
||||
lzma_crc32(buf, known_options.header_size - 4, 0));
|
||||
expect(lzma_block_header_decode(&decoded_options, NULL, buf)
|
||||
== LZMA_OPTIONS_ERROR);
|
||||
buf[known_options.header_size - 4 - 1] ^= 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
succeed(lzma_lzma_preset(&opt_lzma, 1));
|
||||
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
|
||||
return 0;
|
||||
}
|
||||
83
tests/test_check.c
Normal file
83
tests/test_check.c
Normal file
@@ -0,0 +1,83 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file test_check.c
|
||||
/// \brief Tests integrity checks
|
||||
///
|
||||
/// \todo Add SHA256
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
static const uint8_t test_string[9] = "123456789";
|
||||
static const uint8_t test_unaligned[12] = "xxx123456789";
|
||||
|
||||
|
||||
static bool
|
||||
test_crc32(void)
|
||||
{
|
||||
static const uint32_t test_vector = 0xCBF43926;
|
||||
|
||||
// Test 1
|
||||
uint32_t crc = lzma_crc32(test_string, sizeof(test_string), 0);
|
||||
if (crc != test_vector)
|
||||
return true;
|
||||
|
||||
// Test 2
|
||||
crc = lzma_crc32(test_unaligned + 3, sizeof(test_string), 0);
|
||||
if (crc != test_vector)
|
||||
return true;
|
||||
|
||||
// Test 3
|
||||
crc = 0;
|
||||
for (size_t i = 0; i < sizeof(test_string); ++i)
|
||||
crc = lzma_crc32(test_string + i, 1, crc);
|
||||
if (crc != test_vector)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
test_crc64(void)
|
||||
{
|
||||
static const uint64_t test_vector = 0x995DC9BBDF1939FA;
|
||||
|
||||
// Test 1
|
||||
uint64_t crc = lzma_crc64(test_string, sizeof(test_string), 0);
|
||||
if (crc != test_vector)
|
||||
return true;
|
||||
|
||||
// Test 2
|
||||
crc = lzma_crc64(test_unaligned + 3, sizeof(test_string), 0);
|
||||
if (crc != test_vector)
|
||||
return true;
|
||||
|
||||
// Test 3
|
||||
crc = 0;
|
||||
for (size_t i = 0; i < sizeof(test_string); ++i)
|
||||
crc = lzma_crc64(test_string + i, 1, crc);
|
||||
if (crc != test_vector)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
error |= test_crc32();
|
||||
error |= test_crc64();
|
||||
|
||||
return error ? 1 : 0;
|
||||
}
|
||||
142
tests/test_compress.sh
Normal file
142
tests/test_compress.sh
Normal file
@@ -0,0 +1,142 @@
|
||||
#!/bin/sh
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Author: Lasse Collin
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# If xz wasn't built, this test is skipped.
|
||||
if test -x ../src/xz/xz ; then
|
||||
:
|
||||
else
|
||||
(exit 77)
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Find out if our shell supports functions.
|
||||
eval 'unset foo ; foo() { return 42; } ; foo'
|
||||
if test $? != 42 ; then
|
||||
echo "/bin/sh doesn't support functions, skipping this test."
|
||||
(exit 77)
|
||||
exit 77
|
||||
fi
|
||||
|
||||
test_xz() {
|
||||
if $XZ -c "$@" "$FILE" > tmp_compressed; then
|
||||
:
|
||||
else
|
||||
echo "Compressing failed: $* $FILE"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if $XZ -cd tmp_compressed > tmp_uncompressed ; then
|
||||
:
|
||||
else
|
||||
echo "Decompressing failed: $* $FILE"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if cmp tmp_uncompressed "$FILE" ; then
|
||||
:
|
||||
else
|
||||
echo "Decompressed file does not match" \
|
||||
"the original: $* $FILE"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -n "$XZDEC" ; then
|
||||
if $XZDEC tmp_compressed > tmp_uncompressed ; then
|
||||
:
|
||||
else
|
||||
echo "Decompressing failed: $* $FILE"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if cmp tmp_uncompressed "$FILE" ; then
|
||||
:
|
||||
else
|
||||
echo "Decompressed file does not match" \
|
||||
"the original: $* $FILE"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Show progress:
|
||||
echo . | tr -d '\n\r'
|
||||
}
|
||||
|
||||
XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
|
||||
--no-adjust --threads=1 --check=crc64"
|
||||
XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
|
||||
test -x ../src/xzdec/xzdec || XZDEC=
|
||||
|
||||
# Create the required input files.
|
||||
if ./create_compress_files ; then
|
||||
:
|
||||
else
|
||||
rm -f compress_*
|
||||
echo "Failed to create files to test compression."
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove temporary now (in case they are something weird), and on exit.
|
||||
rm -f tmp_compressed tmp_uncompressed
|
||||
trap 'rm -f tmp_compressed tmp_uncompressed' 0
|
||||
|
||||
# Compress and decompress each file with various filter configurations.
|
||||
# This takes quite a bit of time.
|
||||
echo "test_compress.sh:"
|
||||
for FILE in compress_generated_* "$srcdir"/compress_prepared_*
|
||||
do
|
||||
MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
|
||||
echo " $MSG" | tr -d '\n\r'
|
||||
|
||||
# Don't test with empty arguments; it breaks some ancient
|
||||
# proprietary /bin/sh versions due to $@ used in test_xz().
|
||||
test_xz -1
|
||||
test_xz -2
|
||||
test_xz -3
|
||||
test_xz -4
|
||||
|
||||
# Disabled until Subblock format is stable.
|
||||
# --subblock \
|
||||
# --subblock=size=1 \
|
||||
# --subblock=size=1,rle=1 \
|
||||
# --subblock=size=1,rle=4 \
|
||||
# --subblock=size=4,rle=4 \
|
||||
# --subblock=size=8,rle=4 \
|
||||
# --subblock=size=8,rle=8 \
|
||||
# --subblock=size=4096,rle=12 \
|
||||
#
|
||||
for ARGS in \
|
||||
--delta=dist=1 \
|
||||
--delta=dist=4 \
|
||||
--delta=dist=256 \
|
||||
--x86 \
|
||||
--powerpc \
|
||||
--ia64 \
|
||||
--arm \
|
||||
--armthumb \
|
||||
--sparc
|
||||
do
|
||||
test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
|
||||
|
||||
# Disabled until Subblock format is stable.
|
||||
# test_xz --subblock $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
|
||||
done
|
||||
|
||||
echo
|
||||
done
|
||||
|
||||
(exit 0)
|
||||
exit 0
|
||||
57
tests/test_files.sh
Normal file
57
tests/test_files.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Author: Lasse Collin
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# If both xz and xzdec were not build, skip this test.
|
||||
XZ=../src/xz/xz
|
||||
XZDEC=../src/xzdec/xzdec
|
||||
test -x "$XZ" || XZ=
|
||||
test -x "$XZDEC" || XZDEC=
|
||||
if test -z "$XZ$XZDEC"; then
|
||||
(exit 77)
|
||||
exit 77
|
||||
fi
|
||||
|
||||
for I in "$srcdir"/files/good-*.xz
|
||||
do
|
||||
if test -z "$XZ" || "$XZ" -dc "$I" > /dev/null; then
|
||||
:
|
||||
else
|
||||
echo "Good file failed: $I"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$XZDEC" || "$XZDEC" "$I" > /dev/null; then
|
||||
:
|
||||
else
|
||||
echo "Good file failed: $I"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
for I in "$srcdir"/files/bad-*.xz
|
||||
do
|
||||
if test -n "$XZ" && "$XZ" -dc "$I" > /dev/null 2>&1; then
|
||||
echo "Bad file succeeded: $I"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -n "$XZDEC" && "$XZDEC" "$I" > /dev/null 2>&1; then
|
||||
echo "Bad file succeeded: $I"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
(exit 0)
|
||||
exit 0
|
||||
258
tests/test_filter_flags.c
Normal file
258
tests/test_filter_flags.c
Normal file
@@ -0,0 +1,258 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file test_filter_flags.c
|
||||
/// \brief Tests Filter Flags coders
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
static uint8_t buffer[4096];
|
||||
static lzma_filter known_flags;
|
||||
static lzma_filter decoded_flags;
|
||||
static lzma_stream strm = LZMA_STREAM_INIT;
|
||||
|
||||
|
||||
static bool
|
||||
encode(uint32_t known_size)
|
||||
{
|
||||
memcrap(buffer, sizeof(buffer));
|
||||
|
||||
uint32_t tmp;
|
||||
if (lzma_filter_flags_size(&tmp, &known_flags) != LZMA_OK)
|
||||
return true;
|
||||
|
||||
if (tmp != known_size)
|
||||
return true;
|
||||
|
||||
size_t out_pos = 0;
|
||||
if (lzma_filter_flags_encode(&known_flags,
|
||||
buffer, &out_pos, known_size) != LZMA_OK)
|
||||
return true;
|
||||
|
||||
if (out_pos != known_size)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
decode_ret(uint32_t known_size, lzma_ret expected_ret)
|
||||
{
|
||||
memcrap(&decoded_flags, sizeof(decoded_flags));
|
||||
|
||||
size_t pos = 0;
|
||||
if (lzma_filter_flags_decode(&decoded_flags, NULL,
|
||||
buffer, &pos, known_size) != expected_ret
|
||||
|| pos != known_size)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
decode(uint32_t known_size)
|
||||
{
|
||||
if (decode_ret(known_size, LZMA_OK))
|
||||
return true;
|
||||
|
||||
if (known_flags.id != decoded_flags.id)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_ENCODER_X86) && defined(HAVE_DECODER_X86)
|
||||
static void
|
||||
test_bcj(void)
|
||||
{
|
||||
// Test 1
|
||||
known_flags.id = LZMA_FILTER_X86;
|
||||
known_flags.options = NULL;
|
||||
|
||||
expect(!encode(2));
|
||||
expect(!decode(2));
|
||||
expect(decoded_flags.options == NULL);
|
||||
|
||||
// Test 2
|
||||
lzma_options_bcj options;
|
||||
options.start_offset = 0;
|
||||
known_flags.options = &options;
|
||||
expect(!encode(2));
|
||||
expect(!decode(2));
|
||||
expect(decoded_flags.options == NULL);
|
||||
|
||||
// Test 3
|
||||
options.start_offset = 123456;
|
||||
known_flags.options = &options;
|
||||
expect(!encode(6));
|
||||
expect(!decode(6));
|
||||
expect(decoded_flags.options != NULL);
|
||||
|
||||
lzma_options_bcj *decoded = decoded_flags.options;
|
||||
expect(decoded->start_offset == options.start_offset);
|
||||
|
||||
free(decoded);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_ENCODER_DELTA) && defined(HAVE_DECODER_DELTA)
|
||||
static void
|
||||
test_delta(void)
|
||||
{
|
||||
// Test 1
|
||||
known_flags.id = LZMA_FILTER_DELTA;
|
||||
known_flags.options = NULL;
|
||||
expect(encode(99));
|
||||
|
||||
// Test 2
|
||||
lzma_options_delta options = {
|
||||
.type = LZMA_DELTA_TYPE_BYTE,
|
||||
.dist = 0
|
||||
};
|
||||
known_flags.options = &options;
|
||||
expect(encode(99));
|
||||
|
||||
// Test 3
|
||||
options.dist = LZMA_DELTA_DIST_MIN;
|
||||
expect(!encode(3));
|
||||
expect(!decode(3));
|
||||
expect(((lzma_options_delta *)(decoded_flags.options))->dist
|
||||
== options.dist);
|
||||
|
||||
free(decoded_flags.options);
|
||||
|
||||
// Test 4
|
||||
options.dist = LZMA_DELTA_DIST_MAX;
|
||||
expect(!encode(3));
|
||||
expect(!decode(3));
|
||||
expect(((lzma_options_delta *)(decoded_flags.options))->dist
|
||||
== options.dist);
|
||||
|
||||
free(decoded_flags.options);
|
||||
|
||||
// Test 5
|
||||
options.dist = LZMA_DELTA_DIST_MAX + 1;
|
||||
expect(encode(99));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef HAVE_FILTER_LZMA
|
||||
static void
|
||||
validate_lzma(void)
|
||||
{
|
||||
const lzma_options_lzma *known = known_flags.options;
|
||||
const lzma_options_lzma *decoded = decoded_flags.options;
|
||||
|
||||
expect(known->dictionary_size <= decoded->dictionary_size);
|
||||
|
||||
if (known->dictionary_size == 1)
|
||||
expect(decoded->dictionary_size == 1);
|
||||
else
|
||||
expect(known->dictionary_size + known->dictionary_size / 2
|
||||
> decoded->dictionary_size);
|
||||
|
||||
expect(known->literal_context_bits == decoded->literal_context_bits);
|
||||
expect(known->literal_pos_bits == decoded->literal_pos_bits);
|
||||
expect(known->pos_bits == decoded->pos_bits);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_lzma(void)
|
||||
{
|
||||
// Test 1
|
||||
known_flags.id = LZMA_FILTER_LZMA1;
|
||||
known_flags.options = NULL;
|
||||
expect(encode(99));
|
||||
|
||||
// Test 2
|
||||
lzma_options_lzma options = {
|
||||
.dictionary_size = 0,
|
||||
.literal_context_bits = 0,
|
||||
.literal_pos_bits = 0,
|
||||
.pos_bits = 0,
|
||||
.preset_dictionary = NULL,
|
||||
.preset_dictionary_size = 0,
|
||||
.mode = LZMA_MODE_INVALID,
|
||||
.fast_bytes = 0,
|
||||
.match_finder = LZMA_MF_INVALID,
|
||||
.match_finder_cycles = 0,
|
||||
};
|
||||
|
||||
// Test 3 (empty dictionary not allowed)
|
||||
known_flags.options = &options;
|
||||
expect(encode(99));
|
||||
|
||||
// Test 4 (brute-force test some valid dictionary sizes)
|
||||
options.dictionary_size = LZMA_DICTIONARY_SIZE_MIN;
|
||||
while (options.dictionary_size != LZMA_DICTIONARY_SIZE_MAX) {
|
||||
if (++options.dictionary_size == 5000)
|
||||
options.dictionary_size = LZMA_DICTIONARY_SIZE_MAX - 5;
|
||||
|
||||
expect(!encode(4));
|
||||
expect(!decode(4));
|
||||
validate_lzma();
|
||||
|
||||
free(decoded_flags.options);
|
||||
}
|
||||
|
||||
// Test 5 (too big dictionary size)
|
||||
options.dictionary_size = LZMA_DICTIONARY_SIZE_MAX + 1;
|
||||
expect(encode(99));
|
||||
|
||||
// Test 6 (brute-force test lc/lp/pb)
|
||||
options.dictionary_size = LZMA_DICTIONARY_SIZE_MIN;
|
||||
for (uint32_t lc = LZMA_LITERAL_CONTEXT_BITS_MIN;
|
||||
lc <= LZMA_LITERAL_CONTEXT_BITS_MAX; ++lc) {
|
||||
for (uint32_t lp = LZMA_LITERAL_POS_BITS_MIN;
|
||||
lp <= LZMA_LITERAL_POS_BITS_MAX; ++lp) {
|
||||
for (uint32_t pb = LZMA_POS_BITS_MIN;
|
||||
pb <= LZMA_POS_BITS_MAX; ++pb) {
|
||||
if (lc + lp > LZMA_LITERAL_BITS_MAX)
|
||||
continue;
|
||||
|
||||
options.literal_context_bits = lc;
|
||||
options.literal_pos_bits = lp;
|
||||
options.pos_bits = pb;
|
||||
|
||||
expect(!encode(4));
|
||||
expect(!decode(4));
|
||||
validate_lzma();
|
||||
|
||||
free(decoded_flags.options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if defined(HAVE_ENCODER_X86) && defined(HAVE_DECODER_X86)
|
||||
test_bcj();
|
||||
#endif
|
||||
#if defined(HAVE_ENCODER_DELTA) && defined(HAVE_DECODER_DELTA)
|
||||
test_delta();
|
||||
#endif
|
||||
// #ifdef HAVE_FILTER_LZMA
|
||||
// test_lzma();
|
||||
// #endif
|
||||
|
||||
lzma_end(&strm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
659
tests/test_index.c
Normal file
659
tests/test_index.c
Normal file
@@ -0,0 +1,659 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file test_index.c
|
||||
/// \brief Tests functions handling the lzma_index structure
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
#define MEMLIMIT (LZMA_VLI_C(1) << 20)
|
||||
|
||||
#define SMALL_COUNT 3
|
||||
#define BIG_COUNT 5555
|
||||
|
||||
|
||||
static lzma_index *
|
||||
create_empty(void)
|
||||
{
|
||||
lzma_index *i = lzma_index_init(NULL);
|
||||
expect(i != NULL);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static lzma_index *
|
||||
create_small(void)
|
||||
{
|
||||
lzma_index *i = lzma_index_init(NULL);
|
||||
expect(i != NULL);
|
||||
expect(lzma_index_append(i, NULL, 101, 555) == LZMA_OK);
|
||||
expect(lzma_index_append(i, NULL, 602, 777) == LZMA_OK);
|
||||
expect(lzma_index_append(i, NULL, 804, 999) == LZMA_OK);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static lzma_index *
|
||||
create_big(void)
|
||||
{
|
||||
lzma_index *i = lzma_index_init(NULL);
|
||||
expect(i != NULL);
|
||||
|
||||
lzma_vli total_size = 0;
|
||||
lzma_vli uncompressed_size = 0;
|
||||
|
||||
// Add pseudo-random sizes (but always the same size values).
|
||||
uint32_t n = 11;
|
||||
for (size_t j = 0; j < BIG_COUNT; ++j) {
|
||||
n = 7019 * n + 7607;
|
||||
const uint32_t t = n * 3011;
|
||||
expect(lzma_index_append(i, NULL, t, n) == LZMA_OK);
|
||||
total_size += (t + 3) & ~LZMA_VLI_C(3);
|
||||
uncompressed_size += n;
|
||||
}
|
||||
|
||||
expect(lzma_index_block_count(i) == BIG_COUNT);
|
||||
expect(lzma_index_total_size(i) == total_size);
|
||||
expect(lzma_index_uncompressed_size(i) == uncompressed_size);
|
||||
expect(lzma_index_total_size(i) + lzma_index_size(i)
|
||||
+ 2 * LZMA_STREAM_HEADER_SIZE
|
||||
== lzma_index_stream_size(i));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
is_equal(const lzma_index *a, const lzma_index *b)
|
||||
{
|
||||
// Compare only the Stream and Block sizes and offsets.
|
||||
lzma_index_iter ra, rb;
|
||||
lzma_index_iter_init(&ra, a);
|
||||
lzma_index_iter_init(&rb, b);
|
||||
|
||||
while (true) {
|
||||
bool reta = lzma_index_iter_next(&ra, LZMA_INDEX_ITER_ANY);
|
||||
bool retb = lzma_index_iter_next(&rb, LZMA_INDEX_ITER_ANY);
|
||||
if (reta)
|
||||
return !(reta ^ retb);
|
||||
|
||||
if (ra.stream.number != rb.stream.number
|
||||
|| ra.stream.block_count
|
||||
!= rb.stream.block_count
|
||||
|| ra.stream.compressed_offset
|
||||
!= rb.stream.compressed_offset
|
||||
|| ra.stream.uncompressed_offset
|
||||
!= rb.stream.uncompressed_offset
|
||||
|| ra.stream.compressed_size
|
||||
!= rb.stream.compressed_size
|
||||
|| ra.stream.uncompressed_size
|
||||
!= rb.stream.uncompressed_size
|
||||
|| ra.stream.padding
|
||||
!= rb.stream.padding)
|
||||
return false;
|
||||
|
||||
if (ra.stream.block_count == 0)
|
||||
continue;
|
||||
|
||||
if (ra.block.number_in_file != rb.block.number_in_file
|
||||
|| ra.block.compressed_file_offset
|
||||
!= rb.block.compressed_file_offset
|
||||
|| ra.block.uncompressed_file_offset
|
||||
!= rb.block.uncompressed_file_offset
|
||||
|| ra.block.number_in_stream
|
||||
!= rb.block.number_in_stream
|
||||
|| ra.block.compressed_stream_offset
|
||||
!= rb.block.compressed_stream_offset
|
||||
|| ra.block.uncompressed_stream_offset
|
||||
!= rb.block.uncompressed_stream_offset
|
||||
|| ra.block.uncompressed_size
|
||||
!= rb.block.uncompressed_size
|
||||
|| ra.block.unpadded_size
|
||||
!= rb.block.unpadded_size
|
||||
|| ra.block.total_size
|
||||
!= rb.block.total_size)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_equal(void)
|
||||
{
|
||||
lzma_index *a = create_empty();
|
||||
lzma_index *b = create_small();
|
||||
lzma_index *c = create_big();
|
||||
expect(a && b && c);
|
||||
|
||||
expect(is_equal(a, a));
|
||||
expect(is_equal(b, b));
|
||||
expect(is_equal(c, c));
|
||||
|
||||
expect(!is_equal(a, b));
|
||||
expect(!is_equal(a, c));
|
||||
expect(!is_equal(b, c));
|
||||
|
||||
lzma_index_end(a, NULL);
|
||||
lzma_index_end(b, NULL);
|
||||
lzma_index_end(c, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_overflow(void)
|
||||
{
|
||||
// Integer overflow tests
|
||||
lzma_index *i = create_empty();
|
||||
|
||||
expect(lzma_index_append(i, NULL, LZMA_VLI_MAX - 5, 1234)
|
||||
== LZMA_DATA_ERROR);
|
||||
|
||||
// TODO
|
||||
|
||||
lzma_index_end(i, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_copy(const lzma_index *i)
|
||||
{
|
||||
lzma_index *d = lzma_index_dup(i, NULL);
|
||||
expect(d != NULL);
|
||||
expect(is_equal(i, d));
|
||||
lzma_index_end(d, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_read(lzma_index *i)
|
||||
{
|
||||
lzma_index_iter r;
|
||||
lzma_index_iter_init(&r, i);
|
||||
|
||||
// Try twice so we see that rewinding works.
|
||||
for (size_t j = 0; j < 2; ++j) {
|
||||
lzma_vli total_size = 0;
|
||||
lzma_vli uncompressed_size = 0;
|
||||
lzma_vli stream_offset = LZMA_STREAM_HEADER_SIZE;
|
||||
lzma_vli uncompressed_offset = 0;
|
||||
uint32_t count = 0;
|
||||
|
||||
while (!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)) {
|
||||
++count;
|
||||
|
||||
total_size += r.block.total_size;
|
||||
uncompressed_size += r.block.uncompressed_size;
|
||||
|
||||
expect(r.block.compressed_file_offset
|
||||
== stream_offset);
|
||||
expect(r.block.uncompressed_file_offset
|
||||
== uncompressed_offset);
|
||||
|
||||
stream_offset += r.block.total_size;
|
||||
uncompressed_offset += r.block.uncompressed_size;
|
||||
}
|
||||
|
||||
expect(lzma_index_total_size(i) == total_size);
|
||||
expect(lzma_index_uncompressed_size(i) == uncompressed_size);
|
||||
expect(lzma_index_block_count(i) == count);
|
||||
|
||||
lzma_index_iter_rewind(&r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_code(lzma_index *i)
|
||||
{
|
||||
const size_t alloc_size = 128 * 1024;
|
||||
uint8_t *buf = malloc(alloc_size);
|
||||
expect(buf != NULL);
|
||||
|
||||
// Encode
|
||||
lzma_stream strm = LZMA_STREAM_INIT;
|
||||
expect(lzma_index_encoder(&strm, i) == LZMA_OK);
|
||||
const lzma_vli index_size = lzma_index_size(i);
|
||||
succeed(coder_loop(&strm, NULL, 0, buf, index_size,
|
||||
LZMA_STREAM_END, LZMA_RUN));
|
||||
|
||||
// Decode
|
||||
lzma_index *d;
|
||||
expect(lzma_index_decoder(&strm, &d, MEMLIMIT) == LZMA_OK);
|
||||
expect(d == NULL);
|
||||
succeed(decoder_loop(&strm, buf, index_size));
|
||||
|
||||
expect(is_equal(i, d));
|
||||
|
||||
lzma_index_end(d, NULL);
|
||||
lzma_end(&strm);
|
||||
|
||||
// Decode with hashing
|
||||
lzma_index_hash *h = lzma_index_hash_init(NULL, NULL);
|
||||
expect(h != NULL);
|
||||
lzma_index_iter r;
|
||||
lzma_index_iter_init(&r, i);
|
||||
while (!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK))
|
||||
expect(lzma_index_hash_append(h, r.block.unpadded_size,
|
||||
r.block.uncompressed_size) == LZMA_OK);
|
||||
size_t pos = 0;
|
||||
while (pos < index_size - 1)
|
||||
expect(lzma_index_hash_decode(h, buf, &pos, pos + 1)
|
||||
== LZMA_OK);
|
||||
expect(lzma_index_hash_decode(h, buf, &pos, pos + 1)
|
||||
== LZMA_STREAM_END);
|
||||
|
||||
lzma_index_hash_end(h, NULL);
|
||||
|
||||
// Encode buffer
|
||||
size_t buf_pos = 1;
|
||||
expect(lzma_index_buffer_encode(i, buf, &buf_pos, index_size)
|
||||
== LZMA_BUF_ERROR);
|
||||
expect(buf_pos == 1);
|
||||
|
||||
succeed(lzma_index_buffer_encode(i, buf, &buf_pos, index_size + 1));
|
||||
expect(buf_pos == index_size + 1);
|
||||
|
||||
// Decode buffer
|
||||
buf_pos = 1;
|
||||
uint64_t memlimit = MEMLIMIT;
|
||||
expect(lzma_index_buffer_decode(&d, &memlimit, NULL, buf, &buf_pos,
|
||||
index_size) == LZMA_DATA_ERROR);
|
||||
expect(buf_pos == 1);
|
||||
expect(d == NULL);
|
||||
|
||||
succeed(lzma_index_buffer_decode(&d, &memlimit, NULL, buf, &buf_pos,
|
||||
index_size + 1));
|
||||
expect(buf_pos == index_size + 1);
|
||||
expect(is_equal(i, d));
|
||||
|
||||
lzma_index_end(d, NULL);
|
||||
|
||||
free(buf);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_many(lzma_index *i)
|
||||
{
|
||||
test_copy(i);
|
||||
test_read(i);
|
||||
test_code(i);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_cat(void)
|
||||
{
|
||||
lzma_index *a, *b, *c;
|
||||
lzma_index_iter r;
|
||||
|
||||
// Empty Indexes
|
||||
a = create_empty();
|
||||
b = create_empty();
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
expect(lzma_index_block_count(a) == 0);
|
||||
expect(lzma_index_stream_size(a) == 2 * LZMA_STREAM_HEADER_SIZE + 8);
|
||||
expect(lzma_index_file_size(a)
|
||||
== 2 * (2 * LZMA_STREAM_HEADER_SIZE + 8));
|
||||
lzma_index_iter_init(&r, a);
|
||||
expect(lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK));
|
||||
|
||||
b = create_empty();
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
expect(lzma_index_block_count(a) == 0);
|
||||
expect(lzma_index_stream_size(a) == 2 * LZMA_STREAM_HEADER_SIZE + 8);
|
||||
expect(lzma_index_file_size(a)
|
||||
== 3 * (2 * LZMA_STREAM_HEADER_SIZE + 8));
|
||||
|
||||
b = create_empty();
|
||||
c = create_empty();
|
||||
expect(lzma_index_stream_padding(b, 4) == LZMA_OK);
|
||||
expect(lzma_index_cat(b, c, NULL) == LZMA_OK);
|
||||
expect(lzma_index_block_count(b) == 0);
|
||||
expect(lzma_index_stream_size(b) == 2 * LZMA_STREAM_HEADER_SIZE + 8);
|
||||
expect(lzma_index_file_size(b)
|
||||
== 2 * (2 * LZMA_STREAM_HEADER_SIZE + 8) + 4);
|
||||
|
||||
expect(lzma_index_stream_padding(a, 8) == LZMA_OK);
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
expect(lzma_index_block_count(a) == 0);
|
||||
expect(lzma_index_stream_size(a) == 2 * LZMA_STREAM_HEADER_SIZE + 8);
|
||||
expect(lzma_index_file_size(a)
|
||||
== 5 * (2 * LZMA_STREAM_HEADER_SIZE + 8) + 4 + 8);
|
||||
|
||||
expect(lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK));
|
||||
lzma_index_iter_rewind(&r);
|
||||
expect(lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK));
|
||||
lzma_index_end(a, NULL);
|
||||
|
||||
// Small Indexes
|
||||
a = create_small();
|
||||
lzma_vli stream_size = lzma_index_stream_size(a);
|
||||
lzma_index_iter_init(&r, a);
|
||||
for (int i = SMALL_COUNT; i >= 0; --i)
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)
|
||||
^ (i == 0));
|
||||
|
||||
b = create_small();
|
||||
expect(lzma_index_stream_padding(a, 4) == LZMA_OK);
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
expect(lzma_index_file_size(a) == stream_size * 2 + 4);
|
||||
expect(lzma_index_stream_size(a) > stream_size);
|
||||
expect(lzma_index_stream_size(a) < stream_size * 2);
|
||||
for (int i = SMALL_COUNT; i >= 0; --i)
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)
|
||||
^ (i == 0));
|
||||
|
||||
lzma_index_iter_rewind(&r);
|
||||
for (int i = SMALL_COUNT * 2; i >= 0; --i)
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)
|
||||
^ (i == 0));
|
||||
|
||||
b = create_small();
|
||||
c = create_small();
|
||||
expect(lzma_index_stream_padding(b, 8) == LZMA_OK);
|
||||
expect(lzma_index_cat(b, c, NULL) == LZMA_OK);
|
||||
expect(lzma_index_stream_padding(a, 12) == LZMA_OK);
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
expect(lzma_index_file_size(a) == stream_size * 4 + 4 + 8 + 12);
|
||||
|
||||
expect(lzma_index_block_count(a) == SMALL_COUNT * 4);
|
||||
for (int i = SMALL_COUNT * 2; i >= 0; --i)
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)
|
||||
^ (i == 0));
|
||||
|
||||
lzma_index_iter_rewind(&r);
|
||||
for (int i = SMALL_COUNT * 4; i >= 0; --i)
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)
|
||||
^ (i == 0));
|
||||
|
||||
lzma_index_end(a, NULL);
|
||||
|
||||
// Mix of empty and small
|
||||
a = create_empty();
|
||||
b = create_small();
|
||||
expect(lzma_index_stream_padding(a, 4) == LZMA_OK);
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
lzma_index_iter_init(&r, a);
|
||||
for (int i = SMALL_COUNT; i >= 0; --i)
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)
|
||||
^ (i == 0));
|
||||
|
||||
lzma_index_end(a, NULL);
|
||||
|
||||
// Big Indexes
|
||||
a = create_big();
|
||||
stream_size = lzma_index_stream_size(a);
|
||||
b = create_big();
|
||||
expect(lzma_index_stream_padding(a, 4) == LZMA_OK);
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
expect(lzma_index_file_size(a) == stream_size * 2 + 4);
|
||||
expect(lzma_index_stream_size(a) > stream_size);
|
||||
expect(lzma_index_stream_size(a) < stream_size * 2);
|
||||
|
||||
b = create_big();
|
||||
c = create_big();
|
||||
expect(lzma_index_stream_padding(b, 8) == LZMA_OK);
|
||||
expect(lzma_index_cat(b, c, NULL) == LZMA_OK);
|
||||
expect(lzma_index_stream_padding(a, 12) == LZMA_OK);
|
||||
expect(lzma_index_cat(a, b, NULL) == LZMA_OK);
|
||||
expect(lzma_index_file_size(a) == stream_size * 4 + 4 + 8 + 12);
|
||||
|
||||
lzma_index_iter_init(&r, a);
|
||||
for (int i = BIG_COUNT * 4; i >= 0; --i)
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK)
|
||||
^ (i == 0));
|
||||
|
||||
lzma_index_end(a, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_locate(void)
|
||||
{
|
||||
lzma_index *i = lzma_index_init(NULL);
|
||||
expect(i != NULL);
|
||||
lzma_index_iter r;
|
||||
lzma_index_iter_init(&r, i);
|
||||
|
||||
// Cannot locate anything from an empty Index.
|
||||
expect(lzma_index_iter_locate(&r, 0));
|
||||
expect(lzma_index_iter_locate(&r, 555));
|
||||
|
||||
// One empty Record: nothing is found since there's no uncompressed
|
||||
// data.
|
||||
expect(lzma_index_append(i, NULL, 16, 0) == LZMA_OK);
|
||||
expect(lzma_index_iter_locate(&r, 0));
|
||||
|
||||
// Non-empty Record and we can find something.
|
||||
expect(lzma_index_append(i, NULL, 32, 5) == LZMA_OK);
|
||||
expect(!lzma_index_iter_locate(&r, 0));
|
||||
expect(r.block.total_size == 32);
|
||||
expect(r.block.uncompressed_size == 5);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + 16);
|
||||
expect(r.block.uncompressed_file_offset == 0);
|
||||
|
||||
// Still cannot find anything past the end.
|
||||
expect(lzma_index_iter_locate(&r, 5));
|
||||
|
||||
// Add the third Record.
|
||||
expect(lzma_index_append(i, NULL, 40, 11) == LZMA_OK);
|
||||
|
||||
expect(!lzma_index_iter_locate(&r, 0));
|
||||
expect(r.block.total_size == 32);
|
||||
expect(r.block.uncompressed_size == 5);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + 16);
|
||||
expect(r.block.uncompressed_file_offset == 0);
|
||||
|
||||
expect(!lzma_index_iter_next(&r, LZMA_INDEX_ITER_BLOCK));
|
||||
expect(r.block.total_size == 40);
|
||||
expect(r.block.uncompressed_size == 11);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + 16 + 32);
|
||||
expect(r.block.uncompressed_file_offset == 5);
|
||||
|
||||
expect(!lzma_index_iter_locate(&r, 2));
|
||||
expect(r.block.total_size == 32);
|
||||
expect(r.block.uncompressed_size == 5);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + 16);
|
||||
expect(r.block.uncompressed_file_offset == 0);
|
||||
|
||||
expect(!lzma_index_iter_locate(&r, 5));
|
||||
expect(r.block.total_size == 40);
|
||||
expect(r.block.uncompressed_size == 11);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + 16 + 32);
|
||||
expect(r.block.uncompressed_file_offset == 5);
|
||||
|
||||
expect(!lzma_index_iter_locate(&r, 5 + 11 - 1));
|
||||
expect(r.block.total_size == 40);
|
||||
expect(r.block.uncompressed_size == 11);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + 16 + 32);
|
||||
expect(r.block.uncompressed_file_offset == 5);
|
||||
|
||||
expect(lzma_index_iter_locate(&r, 5 + 11));
|
||||
expect(lzma_index_iter_locate(&r, 5 + 15));
|
||||
|
||||
// Large Index
|
||||
lzma_index_end(i, NULL);
|
||||
i = lzma_index_init(NULL);
|
||||
expect(i != NULL);
|
||||
lzma_index_iter_init(&r, i);
|
||||
|
||||
for (size_t n = 4; n <= 4 * 5555; n += 4)
|
||||
expect(lzma_index_append(i, NULL, n + 8, n) == LZMA_OK);
|
||||
|
||||
expect(lzma_index_block_count(i) == 5555);
|
||||
|
||||
// First Record
|
||||
expect(!lzma_index_iter_locate(&r, 0));
|
||||
expect(r.block.total_size == 4 + 8);
|
||||
expect(r.block.uncompressed_size == 4);
|
||||
expect(r.block.compressed_file_offset == LZMA_STREAM_HEADER_SIZE);
|
||||
expect(r.block.uncompressed_file_offset == 0);
|
||||
|
||||
expect(!lzma_index_iter_locate(&r, 3));
|
||||
expect(r.block.total_size == 4 + 8);
|
||||
expect(r.block.uncompressed_size == 4);
|
||||
expect(r.block.compressed_file_offset == LZMA_STREAM_HEADER_SIZE);
|
||||
expect(r.block.uncompressed_file_offset == 0);
|
||||
|
||||
// Second Record
|
||||
expect(!lzma_index_iter_locate(&r, 4));
|
||||
expect(r.block.total_size == 2 * 4 + 8);
|
||||
expect(r.block.uncompressed_size == 2 * 4);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + 4 + 8);
|
||||
expect(r.block.uncompressed_file_offset == 4);
|
||||
|
||||
// Last Record
|
||||
expect(!lzma_index_iter_locate(
|
||||
&r, lzma_index_uncompressed_size(i) - 1));
|
||||
expect(r.block.total_size == 4 * 5555 + 8);
|
||||
expect(r.block.uncompressed_size == 4 * 5555);
|
||||
expect(r.block.compressed_file_offset == lzma_index_total_size(i)
|
||||
+ LZMA_STREAM_HEADER_SIZE - 4 * 5555 - 8);
|
||||
expect(r.block.uncompressed_file_offset
|
||||
== lzma_index_uncompressed_size(i) - 4 * 5555);
|
||||
|
||||
// Allocation chunk boundaries. See INDEX_GROUP_SIZE in
|
||||
// liblzma/common/index.c.
|
||||
const size_t group_multiple = 256 * 4;
|
||||
const size_t radius = 8;
|
||||
const size_t start = group_multiple - radius;
|
||||
lzma_vli ubase = 0;
|
||||
lzma_vli tbase = 0;
|
||||
size_t n;
|
||||
for (n = 1; n < start; ++n) {
|
||||
ubase += n * 4;
|
||||
tbase += n * 4 + 8;
|
||||
}
|
||||
|
||||
while (n < start + 2 * radius) {
|
||||
expect(!lzma_index_iter_locate(&r, ubase + n * 4));
|
||||
|
||||
expect(r.block.compressed_file_offset == tbase + n * 4 + 8
|
||||
+ LZMA_STREAM_HEADER_SIZE);
|
||||
expect(r.block.uncompressed_file_offset == ubase + n * 4);
|
||||
|
||||
tbase += n * 4 + 8;
|
||||
ubase += n * 4;
|
||||
++n;
|
||||
|
||||
expect(r.block.total_size == n * 4 + 8);
|
||||
expect(r.block.uncompressed_size == n * 4);
|
||||
}
|
||||
|
||||
// Do it also backwards.
|
||||
while (n > start) {
|
||||
expect(!lzma_index_iter_locate(&r, ubase + (n - 1) * 4));
|
||||
|
||||
expect(r.block.total_size == n * 4 + 8);
|
||||
expect(r.block.uncompressed_size == n * 4);
|
||||
|
||||
--n;
|
||||
tbase -= n * 4 + 8;
|
||||
ubase -= n * 4;
|
||||
|
||||
expect(r.block.compressed_file_offset == tbase + n * 4 + 8
|
||||
+ LZMA_STREAM_HEADER_SIZE);
|
||||
expect(r.block.uncompressed_file_offset == ubase + n * 4);
|
||||
}
|
||||
|
||||
// Test locating in concatenated Index.
|
||||
lzma_index_end(i, NULL);
|
||||
i = lzma_index_init(NULL);
|
||||
expect(i != NULL);
|
||||
lzma_index_iter_init(&r, i);
|
||||
for (n = 0; n < group_multiple; ++n)
|
||||
expect(lzma_index_append(i, NULL, 8, 0) == LZMA_OK);
|
||||
expect(lzma_index_append(i, NULL, 16, 1) == LZMA_OK);
|
||||
expect(!lzma_index_iter_locate(&r, 0));
|
||||
expect(r.block.total_size == 16);
|
||||
expect(r.block.uncompressed_size == 1);
|
||||
expect(r.block.compressed_file_offset
|
||||
== LZMA_STREAM_HEADER_SIZE + group_multiple * 8);
|
||||
expect(r.block.uncompressed_file_offset == 0);
|
||||
|
||||
lzma_index_end(i, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_corrupt(void)
|
||||
{
|
||||
const size_t alloc_size = 128 * 1024;
|
||||
uint8_t *buf = malloc(alloc_size);
|
||||
expect(buf != NULL);
|
||||
lzma_stream strm = LZMA_STREAM_INIT;
|
||||
|
||||
lzma_index *i = create_empty();
|
||||
expect(lzma_index_append(i, NULL, 0, 1) == LZMA_PROG_ERROR);
|
||||
lzma_index_end(i, NULL);
|
||||
|
||||
// Create a valid Index and corrupt it in different ways.
|
||||
i = create_small();
|
||||
expect(lzma_index_encoder(&strm, i) == LZMA_OK);
|
||||
succeed(coder_loop(&strm, NULL, 0, buf, 20,
|
||||
LZMA_STREAM_END, LZMA_RUN));
|
||||
lzma_index_end(i, NULL);
|
||||
|
||||
// Wrong Index Indicator
|
||||
buf[0] ^= 1;
|
||||
expect(lzma_index_decoder(&strm, &i, MEMLIMIT) == LZMA_OK);
|
||||
succeed(decoder_loop_ret(&strm, buf, 1, LZMA_DATA_ERROR));
|
||||
buf[0] ^= 1;
|
||||
|
||||
// Wrong Number of Records and thus CRC32 fails.
|
||||
--buf[1];
|
||||
expect(lzma_index_decoder(&strm, &i, MEMLIMIT) == LZMA_OK);
|
||||
succeed(decoder_loop_ret(&strm, buf, 10, LZMA_DATA_ERROR));
|
||||
++buf[1];
|
||||
|
||||
// Padding not NULs
|
||||
buf[15] ^= 1;
|
||||
expect(lzma_index_decoder(&strm, &i, MEMLIMIT) == LZMA_OK);
|
||||
succeed(decoder_loop_ret(&strm, buf, 16, LZMA_DATA_ERROR));
|
||||
|
||||
lzma_end(&strm);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
test_equal();
|
||||
|
||||
test_overflow();
|
||||
|
||||
lzma_index *i = create_empty();
|
||||
test_many(i);
|
||||
lzma_index_end(i, NULL);
|
||||
|
||||
i = create_small();
|
||||
test_many(i);
|
||||
lzma_index_end(i, NULL);
|
||||
|
||||
i = create_big();
|
||||
test_many(i);
|
||||
lzma_index_end(i, NULL);
|
||||
|
||||
test_cat();
|
||||
|
||||
test_locate();
|
||||
|
||||
test_corrupt();
|
||||
|
||||
return 0;
|
||||
}
|
||||
76
tests/test_scripts.sh
Normal file
76
tests/test_scripts.sh
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Author: Jonathan Nieder
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# If scripts weren't built, this test is skipped.
|
||||
XZ=../src/xz/xz
|
||||
XZDIFF=../src/scripts/xzdiff
|
||||
XZGREP=../src/scripts/xzgrep
|
||||
|
||||
for i in XZ XZDIFF XZGREP; do
|
||||
eval test -x "\$$i" && continue
|
||||
(exit 77)
|
||||
exit 77
|
||||
done
|
||||
|
||||
PATH=`pwd`/../src/xz:$PATH
|
||||
export PATH
|
||||
|
||||
test -z "$srcdir" && srcdir=.
|
||||
preimage=$srcdir/files/good-1-check-crc32.xz
|
||||
samepostimage=$srcdir/files/good-1-check-crc64.xz
|
||||
otherpostimage=$srcdir/files/good-1-lzma2-1.xz
|
||||
|
||||
"$XZDIFF" "$preimage" "$samepostimage" >/dev/null
|
||||
status=$?
|
||||
if test "$status" != 0 ; then
|
||||
echo "xzdiff with no changes exited with status $status != 0"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$XZDIFF" "$preimage" "$otherpostimage" >/dev/null
|
||||
status=$?
|
||||
if test "$status" != 1 ; then
|
||||
echo "xzdiff with changes exited with status $status != 1"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$XZDIFF" "$preimage" "$srcdir/files/missing.xz" >/dev/null 2>&1
|
||||
status=$?
|
||||
if test "$status" != 2 ; then
|
||||
echo "xzdiff with missing operand exited with status $status != 2"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The exit status must be 0 when a match was found at least from one file,
|
||||
# and 1 when no match was found in any file.
|
||||
cp "$srcdir/files/good-1-lzma2-1.xz" xzgrep_test_1.xz
|
||||
cp "$srcdir/files/good-2-lzma2.xz" xzgrep_test_2.xz
|
||||
for pattern in el Hello NOMATCH; do
|
||||
for opts in "" "-l" "-h" "-H"; do
|
||||
echo "=> xzgrep $opts $pattern <="
|
||||
"$XZGREP" $opts $pattern xzgrep_test_1.xz xzgrep_test_2.xz
|
||||
echo retval $?
|
||||
done
|
||||
done > xzgrep_test_output 2>&1
|
||||
|
||||
if cmp -s "$srcdir/xzgrep_expected_output" xzgrep_test_output ; then
|
||||
:
|
||||
else
|
||||
echo "unexpected output from xzgrep"
|
||||
(exit 1)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(exit 0)
|
||||
exit 0
|
||||
180
tests/test_stream_flags.c
Normal file
180
tests/test_stream_flags.c
Normal file
@@ -0,0 +1,180 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file test_stream_flags.c
|
||||
/// \brief Tests Stream Header and Stream Footer coders
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
|
||||
static lzma_stream_flags known_flags;
|
||||
static lzma_stream_flags decoded_flags;
|
||||
static uint8_t buffer[LZMA_STREAM_HEADER_SIZE];
|
||||
|
||||
|
||||
static bool
|
||||
validate(void)
|
||||
{
|
||||
// TODO: This could require the specific error type as an argument.
|
||||
// We could also test that lzma_stream_flags_compare() gives
|
||||
// the correct return values in different situations.
|
||||
return lzma_stream_flags_compare(&known_flags, &decoded_flags)
|
||||
!= LZMA_OK;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
test_header_decoder(lzma_ret expected_ret)
|
||||
{
|
||||
memcrap(&decoded_flags, sizeof(decoded_flags));
|
||||
|
||||
if (lzma_stream_header_decode(&decoded_flags, buffer) != expected_ret)
|
||||
return true;
|
||||
|
||||
if (expected_ret != LZMA_OK)
|
||||
return false;
|
||||
|
||||
// Header doesn't have Backward Size, so make
|
||||
// lzma_stream_flags_compare() ignore it.
|
||||
decoded_flags.backward_size = LZMA_VLI_UNKNOWN;
|
||||
return validate();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_header(void)
|
||||
{
|
||||
memcrap(buffer, sizeof(buffer));
|
||||
expect(lzma_stream_header_encode(&known_flags, buffer) == LZMA_OK);
|
||||
succeed(test_header_decoder(LZMA_OK));
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
test_footer_decoder(lzma_ret expected_ret)
|
||||
{
|
||||
memcrap(&decoded_flags, sizeof(decoded_flags));
|
||||
|
||||
if (lzma_stream_footer_decode(&decoded_flags, buffer) != expected_ret)
|
||||
return true;
|
||||
|
||||
if (expected_ret != LZMA_OK)
|
||||
return false;
|
||||
|
||||
return validate();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_footer(void)
|
||||
{
|
||||
memcrap(buffer, sizeof(buffer));
|
||||
expect(lzma_stream_footer_encode(&known_flags, buffer) == LZMA_OK);
|
||||
succeed(test_footer_decoder(LZMA_OK));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_encode_invalid(void)
|
||||
{
|
||||
known_flags.check = LZMA_CHECK_ID_MAX + 1;
|
||||
known_flags.backward_size = 1024;
|
||||
|
||||
expect(lzma_stream_header_encode(&known_flags, buffer)
|
||||
== LZMA_PROG_ERROR);
|
||||
|
||||
expect(lzma_stream_footer_encode(&known_flags, buffer)
|
||||
== LZMA_PROG_ERROR);
|
||||
|
||||
known_flags.check = (lzma_check)(-1);
|
||||
|
||||
expect(lzma_stream_header_encode(&known_flags, buffer)
|
||||
== LZMA_PROG_ERROR);
|
||||
|
||||
expect(lzma_stream_footer_encode(&known_flags, buffer)
|
||||
== LZMA_PROG_ERROR);
|
||||
|
||||
known_flags.check = LZMA_CHECK_NONE;
|
||||
known_flags.backward_size = 0;
|
||||
|
||||
// Header encoder ignores backward_size.
|
||||
expect(lzma_stream_header_encode(&known_flags, buffer) == LZMA_OK);
|
||||
|
||||
expect(lzma_stream_footer_encode(&known_flags, buffer)
|
||||
== LZMA_PROG_ERROR);
|
||||
|
||||
known_flags.backward_size = LZMA_VLI_MAX;
|
||||
|
||||
expect(lzma_stream_header_encode(&known_flags, buffer) == LZMA_OK);
|
||||
|
||||
expect(lzma_stream_footer_encode(&known_flags, buffer)
|
||||
== LZMA_PROG_ERROR);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_decode_invalid(void)
|
||||
{
|
||||
known_flags.check = LZMA_CHECK_NONE;
|
||||
known_flags.backward_size = 1024;
|
||||
|
||||
expect(lzma_stream_header_encode(&known_flags, buffer) == LZMA_OK);
|
||||
|
||||
// Test 1 (invalid Magic Bytes)
|
||||
buffer[5] ^= 1;
|
||||
succeed(test_header_decoder(LZMA_FORMAT_ERROR));
|
||||
buffer[5] ^= 1;
|
||||
|
||||
// Test 2a (valid CRC32)
|
||||
uint32_t crc = lzma_crc32(buffer + 6, 2, 0);
|
||||
unaligned_write32le(buffer + 8, crc);
|
||||
succeed(test_header_decoder(LZMA_OK));
|
||||
|
||||
// Test 2b (invalid Stream Flags with valid CRC32)
|
||||
buffer[6] ^= 0x20;
|
||||
crc = lzma_crc32(buffer + 6, 2, 0);
|
||||
unaligned_write32le(buffer + 8, crc);
|
||||
succeed(test_header_decoder(LZMA_OPTIONS_ERROR));
|
||||
|
||||
// Test 3 (invalid CRC32)
|
||||
expect(lzma_stream_header_encode(&known_flags, buffer) == LZMA_OK);
|
||||
buffer[9] ^= 1;
|
||||
succeed(test_header_decoder(LZMA_DATA_ERROR));
|
||||
|
||||
// Test 4 (invalid Stream Flags with valid CRC32)
|
||||
expect(lzma_stream_footer_encode(&known_flags, buffer) == LZMA_OK);
|
||||
buffer[9] ^= 0x40;
|
||||
crc = lzma_crc32(buffer + 4, 6, 0);
|
||||
unaligned_write32le(buffer, crc);
|
||||
succeed(test_footer_decoder(LZMA_OPTIONS_ERROR));
|
||||
|
||||
// Test 5 (invalid Magic Bytes)
|
||||
expect(lzma_stream_footer_encode(&known_flags, buffer) == LZMA_OK);
|
||||
buffer[11] ^= 1;
|
||||
succeed(test_footer_decoder(LZMA_FORMAT_ERROR));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
// Valid headers
|
||||
known_flags.backward_size = 1024;
|
||||
for (lzma_check check = LZMA_CHECK_NONE;
|
||||
check <= LZMA_CHECK_ID_MAX; ++check) {
|
||||
test_header();
|
||||
test_footer();
|
||||
}
|
||||
|
||||
// Invalid headers
|
||||
test_encode_invalid();
|
||||
test_decode_invalid();
|
||||
|
||||
return 0;
|
||||
}
|
||||
124
tests/tests.h
Normal file
124
tests/tests.h
Normal file
@@ -0,0 +1,124 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tests.h
|
||||
/// \brief Common definitions for test applications
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LZMA_TESTS_H
|
||||
#define LZMA_TESTS_H
|
||||
|
||||
#include "sysdefs.h"
|
||||
#include "tuklib_integer.h"
|
||||
#include "lzma.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define memcrap(buf, size) memset(buf, 0xFD, size)
|
||||
|
||||
#define expect(test) ((test) ? 0 : (fprintf(stderr, "%s:%d: %s\n", \
|
||||
__FILE__, __LINE__, #test), abort(), 0))
|
||||
|
||||
#define succeed(test) expect(!(test))
|
||||
|
||||
#define fail(test) expect(test)
|
||||
|
||||
|
||||
static inline const char *
|
||||
lzma_ret_sym(lzma_ret ret)
|
||||
{
|
||||
if ((unsigned int)(ret) > LZMA_PROG_ERROR)
|
||||
return "UNKNOWN_ERROR";
|
||||
|
||||
static const char *msgs[] = {
|
||||
"LZMA_OK",
|
||||
"LZMA_STREAM_END",
|
||||
"LZMA_NO_CHECK",
|
||||
"LZMA_UNSUPPORTED_CHECK",
|
||||
"LZMA_GET_CHECK",
|
||||
"LZMA_MEM_ERROR",
|
||||
"LZMA_MEMLIMIT_ERROR",
|
||||
"LZMA_FORMAT_ERROR",
|
||||
"LZMA_OPTIONS_ERROR",
|
||||
"LZMA_DATA_ERROR",
|
||||
"LZMA_BUF_ERROR",
|
||||
"LZMA_PROG_ERROR"
|
||||
};
|
||||
|
||||
return msgs[ret];
|
||||
}
|
||||
|
||||
|
||||
static inline bool
|
||||
coder_loop(lzma_stream *strm, uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t out_size,
|
||||
lzma_ret expected_ret, lzma_action finishing_action)
|
||||
{
|
||||
size_t in_left = in_size;
|
||||
size_t out_left = out_size > 0 ? out_size + 1 : 0;
|
||||
lzma_action action = LZMA_RUN;
|
||||
lzma_ret ret;
|
||||
|
||||
strm->next_in = NULL;
|
||||
strm->avail_in = 0;
|
||||
strm->next_out = NULL;
|
||||
strm->avail_out = 0;
|
||||
|
||||
while (true) {
|
||||
if (in_left > 0) {
|
||||
if (--in_left == 0)
|
||||
action = finishing_action;
|
||||
|
||||
strm->next_in = in++;
|
||||
strm->avail_in = 1;
|
||||
}
|
||||
|
||||
if (out_left > 0) {
|
||||
--out_left;
|
||||
strm->next_out = out++;
|
||||
strm->avail_out = 1;
|
||||
}
|
||||
|
||||
ret = lzma_code(strm, action);
|
||||
if (ret != LZMA_OK)
|
||||
break;
|
||||
}
|
||||
|
||||
bool error = false;
|
||||
|
||||
if (ret != expected_ret)
|
||||
error = true;
|
||||
|
||||
if (expected_ret == LZMA_STREAM_END) {
|
||||
if (strm->total_in != in_size || strm->total_out != out_size)
|
||||
error = true;
|
||||
} else {
|
||||
if (strm->total_in != in_size || strm->total_out != out_size)
|
||||
error = true;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static inline bool
|
||||
decoder_loop_ret(lzma_stream *strm, uint8_t *in, size_t in_size,
|
||||
lzma_ret expected_ret)
|
||||
{
|
||||
return coder_loop(strm, in, in_size, NULL, 0, expected_ret, LZMA_RUN);
|
||||
}
|
||||
|
||||
|
||||
static inline bool
|
||||
decoder_loop(lzma_stream *strm, uint8_t *in, size_t in_size)
|
||||
{
|
||||
return coder_loop(strm, in, in_size, NULL, 0,
|
||||
LZMA_STREAM_END, LZMA_RUN);
|
||||
}
|
||||
|
||||
#endif
|
||||
39
tests/xzgrep_expected_output
Normal file
39
tests/xzgrep_expected_output
Normal file
@@ -0,0 +1,39 @@
|
||||
=> xzgrep el <=
|
||||
xzgrep_test_1.xz:elit, sed do eiusmod tempor incididunt ut
|
||||
xzgrep_test_1.xz:in voluptate velit esse cillum dolore eu
|
||||
xzgrep_test_2.xz:Hello
|
||||
retval 0
|
||||
=> xzgrep -l el <=
|
||||
xzgrep_test_1.xz
|
||||
xzgrep_test_2.xz
|
||||
retval 0
|
||||
=> xzgrep -h el <=
|
||||
elit, sed do eiusmod tempor incididunt ut
|
||||
in voluptate velit esse cillum dolore eu
|
||||
Hello
|
||||
retval 0
|
||||
=> xzgrep -H el <=
|
||||
xzgrep_test_1.xz:elit, sed do eiusmod tempor incididunt ut
|
||||
xzgrep_test_1.xz:in voluptate velit esse cillum dolore eu
|
||||
xzgrep_test_2.xz:Hello
|
||||
retval 0
|
||||
=> xzgrep Hello <=
|
||||
xzgrep_test_2.xz:Hello
|
||||
retval 0
|
||||
=> xzgrep -l Hello <=
|
||||
xzgrep_test_2.xz
|
||||
retval 0
|
||||
=> xzgrep -h Hello <=
|
||||
Hello
|
||||
retval 0
|
||||
=> xzgrep -H Hello <=
|
||||
xzgrep_test_2.xz:Hello
|
||||
retval 0
|
||||
=> xzgrep NOMATCH <=
|
||||
retval 1
|
||||
=> xzgrep -l NOMATCH <=
|
||||
retval 1
|
||||
=> xzgrep -h NOMATCH <=
|
||||
retval 1
|
||||
=> xzgrep -H NOMATCH <=
|
||||
retval 1
|
||||
Reference in New Issue
Block a user