From 9e3a31f2fe7263d8c5397774af11b15bfbf7d2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Ahmet=20Memi=C5=9F?= Date: Sat, 24 Oct 2026 21:57:35 +0300 Subject: [PATCH] Tests: test_scripts.sh: Test xzdiff with one operand The _z test is skipped if gzip isn't available. Closes: https://github.com/tukaani-project/xz/pull/258 --- .gitignore | 3 +++ tests/Makefile.am | 3 ++- tests/test_scripts.sh | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cd84fc42..ffbd9544 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,9 @@ coverage /tests/test_memlimit /tests/test_stream_flags /tests/test_vli +/tests/xzdiff_test +/tests/xzdiff_test.xz +/tests/xzdiff_test_z /tests/xzgrep_test_1.xz /tests/xzgrep_test_2.xz /tests/xzgrep_test_output diff --git a/tests/Makefile.am b/tests/Makefile.am index 53fe347e..b29967e7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -86,4 +86,5 @@ endif clean-local: -rm -f compress_generated_* \ - xzgrep_test_output xzgrep_test_1.xz xzgrep_test_2.xz + xzgrep_test_output xzgrep_test_1.xz xzgrep_test_2.xz \ + xzdiff_test xzdiff_test.xz xzdiff_test_z diff --git a/tests/test_scripts.sh b/tests/test_scripts.sh index ca9600ec..c5ca52b3 100755 --- a/tests/test_scripts.sh +++ b/tests/test_scripts.sh @@ -60,6 +60,25 @@ if test "$status" != 2 ; then exit 1 fi +# With one operand, the file is compared to the same name without the suffix. +"$XZ" -dc "$preimage" > xzdiff_test +cp "$preimage" xzdiff_test.xz +"$XZDIFF" xzdiff_test.xz >/dev/null +status=$? +if test "$status" != 0 ; then + echo "xzdiff with one .xz operand exited with status $status != 0" + exit 1 +fi + +if gzip -c xzdiff_test > xzdiff_test_z 2>/dev/null ; then + "$XZDIFF" xzdiff_test_z >/dev/null + status=$? + if test "$status" != 0 ; then + echo "xzdiff with one _z operand exited with status $status != 0" + exit 1 + fi +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