Tests: Split test_compress.sh into separate test unit for each file.

test_compress.sh now takes one command line argument:
a filename to be tested. If it begins with "compress_generated_"
the file will be created with create_compress_files.

This will allow parallel execution of the slow tests.
This commit is contained in:
Lasse Collin 2022-05-23 21:17:47 +03:00
parent c7758ac9c7
commit 9a6dd6d46f
7 changed files with 77 additions and 40 deletions

View File

@ -11,6 +11,11 @@ EXTRA_DIST = \
tests.h \ tests.h \
test_files.sh \ test_files.sh \
test_compress.sh \ test_compress.sh \
test_compress_prepared_bcj_sparc \
test_compress_prepared_bcj_x86 \
test_compress_generated_abc \
test_compress_generated_random \
test_compress_generated_text \
test_scripts.sh \ test_scripts.sh \
bcj_test.c \ bcj_test.c \
compress_prepared_bcj_sparc \ compress_prepared_bcj_sparc \
@ -47,7 +52,11 @@ TESTS = \
test_index \ test_index \
test_bcj_exact_size \ test_bcj_exact_size \
test_files.sh \ test_files.sh \
test_compress.sh test_compress_prepared_bcj_sparc \
test_compress_prepared_bcj_x86 \
test_compress_generated_abc \
test_compress_generated_random \
test_compress_generated_text
if COND_SCRIPTS if COND_SCRIPTS
TESTS += test_scripts.sh TESTS += test_scripts.sh

View File

@ -26,7 +26,7 @@ if test $? != 42 ; then
fi fi
test_xz() { test_xz() {
if $XZ -c "$@" "$FILE" > tmp_compressed; then if $XZ -c "$@" "$FILE" > "$TMP_COMP"; then
: :
else else
echo "Compressing failed: $* $FILE" echo "Compressing failed: $* $FILE"
@ -34,7 +34,7 @@ test_xz() {
exit 1 exit 1
fi fi
if $XZ -cd tmp_compressed > tmp_uncompressed ; then if $XZ -cd "$TMP_COMP" > "$TMP_UNCOMP" ; then
: :
else else
echo "Decompressing failed: $* $FILE" echo "Decompressing failed: $* $FILE"
@ -42,7 +42,7 @@ test_xz() {
exit 1 exit 1
fi fi
if cmp tmp_uncompressed "$FILE" ; then if cmp "$TMP_UNCOMP" "$FILE" ; then
: :
else else
echo "Decompressed file does not match" \ echo "Decompressed file does not match" \
@ -52,7 +52,7 @@ test_xz() {
fi fi
if test -n "$XZDEC" ; then if test -n "$XZDEC" ; then
if $XZDEC tmp_compressed > tmp_uncompressed ; then if $XZDEC "$TMP_COMP" > "$TMP_UNCOMP" ; then
: :
else else
echo "Decompressing failed: $* $FILE" echo "Decompressing failed: $* $FILE"
@ -60,7 +60,7 @@ test_xz() {
exit 1 exit 1
fi fi
if cmp tmp_uncompressed "$FILE" ; then if cmp "$TMP_UNCOMP" "$FILE" ; then
: :
else else
echo "Decompressed file does not match" \ echo "Decompressed file does not match" \
@ -76,32 +76,46 @@ XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
XZDEC="../src/xzdec/xzdec" # No memory usage limiter available XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
test -x ../src/xzdec/xzdec || XZDEC= test -x ../src/xzdec/xzdec || XZDEC=
# Create the required input files. # Create the required input file if needed.
if ./create_compress_files ; then FILE=$1
case $FILE in
compress_generated_*)
if ./create_compress_files "${FILE#compress_generated_}" ; then
: :
else else
rm -f compress_* rm -f "$FILE"
echo "Failed to create files to test compression." echo "Failed to create the file '$FILE'."
(exit 1) (exit 1)
exit 1 exit 1
fi fi
;;
'')
echo "No test file was specified."
(exit 1)
exit 1
;;
esac
# Derive temporary filenames for compressed and uncompressed outputs
# from the input filename. This is needed when multiple tests are
# run in parallel.
TMP_COMP="tmp_comp_${FILE##*/}"
TMP_UNCOMP="tmp_uncomp_${FILE##*/}"
# Remove temporary now (in case they are something weird), and on exit. # Remove temporary now (in case they are something weird), and on exit.
rm -f tmp_compressed tmp_uncompressed rm -f "$TMP_COMP" "$TMP_UNCOMP"
trap 'rm -f tmp_compressed tmp_uncompressed' 0 trap 'rm -f "$TMP_COMP" "$TMP_UNCOMP"' 0
# Compress and decompress each file with various filter configurations. # Compress and decompress the file with various filter configurations.
# This takes quite a bit of time. #
for FILE in compress_generated_* "$srcdir"/compress_prepared_* # Don't test with empty arguments; it breaks some ancient
do # proprietary /bin/sh versions due to $@ used in test_xz().
# Don't test with empty arguments; it breaks some ancient test_xz -1
# proprietary /bin/sh versions due to $@ used in test_xz(). test_xz -2
test_xz -1 test_xz -3
test_xz -2 test_xz -4
test_xz -3
test_xz -4
for ARGS in \ for ARGS in \
--delta=dist=1 \ --delta=dist=1 \
--delta=dist=4 \ --delta=dist=4 \
--delta=dist=256 \ --delta=dist=256 \
@ -111,9 +125,8 @@ do
--arm \ --arm \
--armthumb \ --armthumb \
--sparc --sparc
do do
test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
done
done done
(exit 0) (exit 0)

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$srcdir/test_compress.sh" compress_generated_abc

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$srcdir/test_compress.sh" compress_generated_random

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$srcdir/test_compress.sh" compress_generated_text

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$srcdir/test_compress.sh" "$srcdir/compress_prepared_bcj_sparc"

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$srcdir/test_compress.sh" "$srcdir/compress_prepared_bcj_x86"