Home | History | Annotate | Line # | Download | only in tests
      1  1.1  joerg #!/bin/sh
      2  1.1  joerg 
      3  1.1  joerg ###############################################################################
      4  1.1  joerg #
      5  1.1  joerg # Author: Lasse Collin
      6  1.1  joerg #
      7  1.1  joerg # This file has been put into the public domain.
      8  1.1  joerg # You can do whatever you want with this file.
      9  1.1  joerg #
     10  1.1  joerg ###############################################################################
     11  1.1  joerg 
     12  1.1  joerg # If xz wasn't built, this test is skipped.
     13  1.1  joerg if test -x ../src/xz/xz ; then
     14  1.1  joerg 	:
     15  1.1  joerg else
     16  1.1  joerg 	(exit 77)
     17  1.1  joerg 	exit 77
     18  1.1  joerg fi
     19  1.1  joerg 
     20  1.1  joerg # Find out if our shell supports functions.
     21  1.1  joerg eval 'unset foo ; foo() { return 42; } ; foo'
     22  1.1  joerg if test $? != 42 ; then
     23  1.1  joerg 	echo "/bin/sh doesn't support functions, skipping this test."
     24  1.1  joerg 	(exit 77)
     25  1.1  joerg 	exit 77
     26  1.1  joerg fi
     27  1.1  joerg 
     28  1.1  joerg test_xz() {
     29  1.1  joerg 	if $XZ -c "$@" "$FILE" > tmp_compressed; then
     30  1.1  joerg 		:
     31  1.1  joerg 	else
     32  1.1  joerg 		echo "Compressing failed: $* $FILE"
     33  1.1  joerg 		(exit 1)
     34  1.1  joerg 		exit 1
     35  1.1  joerg 	fi
     36  1.1  joerg 
     37  1.1  joerg 	if $XZ -cd tmp_compressed > tmp_uncompressed ; then
     38  1.1  joerg 		:
     39  1.1  joerg 	else
     40  1.1  joerg 		echo "Decompressing failed: $* $FILE"
     41  1.1  joerg 		(exit 1)
     42  1.1  joerg 		exit 1
     43  1.1  joerg 	fi
     44  1.1  joerg 
     45  1.1  joerg 	if cmp tmp_uncompressed "$FILE" ; then
     46  1.1  joerg 		:
     47  1.1  joerg 	else
     48  1.1  joerg 		echo "Decompressed file does not match" \
     49  1.1  joerg 				"the original: $* $FILE"
     50  1.1  joerg 		(exit 1)
     51  1.1  joerg 		exit 1
     52  1.1  joerg 	fi
     53  1.1  joerg 
     54  1.1  joerg 	if test -n "$XZDEC" ; then
     55  1.1  joerg 		if $XZDEC tmp_compressed > tmp_uncompressed ; then
     56  1.1  joerg 			:
     57  1.1  joerg 		else
     58  1.1  joerg 			echo "Decompressing failed: $* $FILE"
     59  1.1  joerg 			(exit 1)
     60  1.1  joerg 			exit 1
     61  1.1  joerg 		fi
     62  1.1  joerg 
     63  1.1  joerg 		if cmp tmp_uncompressed "$FILE" ; then
     64  1.1  joerg 			:
     65  1.1  joerg 		else
     66  1.1  joerg 			echo "Decompressed file does not match" \
     67  1.1  joerg 					"the original: $* $FILE"
     68  1.1  joerg 			(exit 1)
     69  1.1  joerg 			exit 1
     70  1.1  joerg 		fi
     71  1.1  joerg 	fi
     72  1.1  joerg 
     73  1.1  joerg 	# Show progress:
     74  1.1  joerg 	echo . | tr -d '\n\r'
     75  1.1  joerg }
     76  1.1  joerg 
     77  1.1  joerg XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
     78  1.1  joerg 		--no-adjust --threads=1 --check=crc64"
     79  1.1  joerg XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
     80  1.1  joerg test -x ../src/xzdec/xzdec || XZDEC=
     81  1.1  joerg 
     82  1.1  joerg # Create the required input files.
     83  1.1  joerg if ./create_compress_files ; then
     84  1.1  joerg 	:
     85  1.1  joerg else
     86  1.1  joerg 	rm -f compress_*
     87  1.1  joerg 	echo "Failed to create files to test compression."
     88  1.1  joerg 	(exit 1)
     89  1.1  joerg 	exit 1
     90  1.1  joerg fi
     91  1.1  joerg 
     92  1.1  joerg # Remove temporary now (in case they are something weird), and on exit.
     93  1.1  joerg rm -f tmp_compressed tmp_uncompressed
     94  1.1  joerg trap 'rm -f tmp_compressed tmp_uncompressed' 0
     95  1.1  joerg 
     96  1.1  joerg # Compress and decompress each file with various filter configurations.
     97  1.1  joerg # This takes quite a bit of time.
     98  1.1  joerg echo "test_compress.sh:"
     99  1.1  joerg for FILE in compress_generated_* "$srcdir"/compress_prepared_*
    100  1.1  joerg do
    101  1.1  joerg 	MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
    102  1.1  joerg 	echo "  $MSG" | tr -d '\n\r'
    103  1.1  joerg 
    104  1.1  joerg 	# Don't test with empty arguments; it breaks some ancient
    105  1.1  joerg 	# proprietary /bin/sh versions due to $@ used in test_xz().
    106  1.1  joerg 	test_xz -1
    107  1.1  joerg 	test_xz -2
    108  1.1  joerg 	test_xz -3
    109  1.1  joerg 	test_xz -4
    110  1.1  joerg 
    111  1.1  joerg 	# Disabled until Subblock format is stable.
    112  1.1  joerg #		--subblock \
    113  1.1  joerg #		--subblock=size=1 \
    114  1.1  joerg #		--subblock=size=1,rle=1 \
    115  1.1  joerg #		--subblock=size=1,rle=4 \
    116  1.1  joerg #		--subblock=size=4,rle=4 \
    117  1.1  joerg #		--subblock=size=8,rle=4 \
    118  1.1  joerg #		--subblock=size=8,rle=8 \
    119  1.1  joerg #		--subblock=size=4096,rle=12 \
    120  1.1  joerg #
    121  1.1  joerg 	for ARGS in \
    122  1.1  joerg 		--delta=dist=1 \
    123  1.1  joerg 		--delta=dist=4 \
    124  1.1  joerg 		--delta=dist=256 \
    125  1.1  joerg 		--x86 \
    126  1.1  joerg 		--powerpc \
    127  1.1  joerg 		--ia64 \
    128  1.1  joerg 		--arm \
    129  1.1  joerg 		--armthumb \
    130  1.1  joerg 		--sparc
    131  1.1  joerg 	do
    132  1.1  joerg 		test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
    133  1.1  joerg 
    134  1.1  joerg 		# Disabled until Subblock format is stable.
    135  1.1  joerg 		# test_xz --subblock $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
    136  1.1  joerg 	done
    137  1.1  joerg 
    138  1.1  joerg 	echo
    139  1.1  joerg done
    140  1.1  joerg 
    141  1.1  joerg (exit 0)
    142  1.1  joerg exit 0
    143