aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2022-05-23 21:17:47 +0300
committerLasse Collin <lasse.collin@tukaani.org>2022-05-23 21:31:20 +0300
commit9a6dd6d46f7f256a5573e5d874c1052033ed7b05 (patch)
tree87e5f43d35f693b8930e1da5d359af8d0b96fd73 /tests
parentTest: Make create_compress_files.c a little more flexible. (diff)
downloadxz-9a6dd6d46f7f256a5573e5d874c1052033ed7b05.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--tests/Makefile.am11
-rwxr-xr-xtests/test_compress.sh91
-rwxr-xr-xtests/test_compress_generated_abc3
-rwxr-xr-xtests/test_compress_generated_random3
-rwxr-xr-xtests/test_compress_generated_text3
-rwxr-xr-xtests/test_compress_prepared_bcj_sparc3
-rwxr-xr-xtests/test_compress_prepared_bcj_x863
7 files changed, 77 insertions, 40 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4116b81a..f576ac12 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -11,6 +11,11 @@ EXTRA_DIST = \
tests.h \
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 \
test_scripts.sh \
bcj_test.c \
compress_prepared_bcj_sparc \
@@ -47,7 +52,11 @@ TESTS = \
test_index \
test_bcj_exact_size \
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
TESTS += test_scripts.sh
diff --git a/tests/test_compress.sh b/tests/test_compress.sh
index 6a486d4c..c88799e7 100755
--- a/tests/test_compress.sh
+++ b/tests/test_compress.sh
@@ -26,7 +26,7 @@ if test $? != 42 ; then
fi
test_xz() {
- if $XZ -c "$@" "$FILE" > tmp_compressed; then
+ if $XZ -c "$@" "$FILE" > "$TMP_COMP"; then
:
else
echo "Compressing failed: $* $FILE"
@@ -34,7 +34,7 @@ test_xz() {
exit 1
fi
- if $XZ -cd tmp_compressed > tmp_uncompressed ; then
+ if $XZ -cd "$TMP_COMP" > "$TMP_UNCOMP" ; then
:
else
echo "Decompressing failed: $* $FILE"
@@ -42,7 +42,7 @@ test_xz() {
exit 1
fi
- if cmp tmp_uncompressed "$FILE" ; then
+ if cmp "$TMP_UNCOMP" "$FILE" ; then
:
else
echo "Decompressed file does not match" \
@@ -52,7 +52,7 @@ test_xz() {
fi
if test -n "$XZDEC" ; then
- if $XZDEC tmp_compressed > tmp_uncompressed ; then
+ if $XZDEC "$TMP_COMP" > "$TMP_UNCOMP" ; then
:
else
echo "Decompressing failed: $* $FILE"
@@ -60,7 +60,7 @@ test_xz() {
exit 1
fi
- if cmp tmp_uncompressed "$FILE" ; then
+ if cmp "$TMP_UNCOMP" "$FILE" ; then
:
else
echo "Decompressed file does not match" \
@@ -76,44 +76,57 @@ XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
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
+# Create the required input file if needed.
+FILE=$1
+case $FILE in
+ compress_generated_*)
+ if ./create_compress_files "${FILE#compress_generated_}" ; then
+ :
+ else
+ rm -f "$FILE"
+ echo "Failed to create the file '$FILE'."
+ (exit 1)
+ exit 1
+ 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.
-rm -f tmp_compressed tmp_uncompressed
-trap 'rm -f tmp_compressed tmp_uncompressed' 0
+rm -f "$TMP_COMP" "$TMP_UNCOMP"
+trap 'rm -f "$TMP_COMP" "$TMP_UNCOMP"' 0
-# Compress and decompress each file with various filter configurations.
-# This takes quite a bit of time.
-for FILE in compress_generated_* "$srcdir"/compress_prepared_*
-do
- # 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
+# Compress and decompress the file with various filter configurations.
+#
+# 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
- 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
- done
+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
done
(exit 0)
diff --git a/tests/test_compress_generated_abc b/tests/test_compress_generated_abc
new file mode 100755
index 00000000..43c69516
--- /dev/null
+++ b/tests/test_compress_generated_abc
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec "$srcdir/test_compress.sh" compress_generated_abc
diff --git a/tests/test_compress_generated_random b/tests/test_compress_generated_random
new file mode 100755
index 00000000..e47555d0
--- /dev/null
+++ b/tests/test_compress_generated_random
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec "$srcdir/test_compress.sh" compress_generated_random
diff --git a/tests/test_compress_generated_text b/tests/test_compress_generated_text
new file mode 100755
index 00000000..412ae0e9
--- /dev/null
+++ b/tests/test_compress_generated_text
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec "$srcdir/test_compress.sh" compress_generated_text
diff --git a/tests/test_compress_prepared_bcj_sparc b/tests/test_compress_prepared_bcj_sparc
new file mode 100755
index 00000000..01447e13
--- /dev/null
+++ b/tests/test_compress_prepared_bcj_sparc
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec "$srcdir/test_compress.sh" "$srcdir/compress_prepared_bcj_sparc"
diff --git a/tests/test_compress_prepared_bcj_x86 b/tests/test_compress_prepared_bcj_x86
new file mode 100755
index 00000000..a2771498
--- /dev/null
+++ b/tests/test_compress_prepared_bcj_x86
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec "$srcdir/test_compress.sh" "$srcdir/compress_prepared_bcj_x86"