1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Tests: Replace non portable shell parameter expansion

The shell parameter expansion using # and ## is not supported in
Solaris 10 Bourne shell (/bin/sh). Even though this is POSIX, it is not fully
portable, so we should avoid it.
This commit is contained in:
Jia Tan 2023-01-04 23:58:58 +08:00 committed by GitHub
parent d0eb345bb7
commit 52380678f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View file

@ -24,7 +24,7 @@
// Avoid re-creating the test files every time the tests are run. // Avoid re-creating the test files every time the tests are run.
#define maybe_create_test(argc, argv, name) \ #define maybe_create_test(argc, argv, name) \
do { \ do { \
if ((argc < 2 || strcmp(argv[1], #name) == 0) \ if ((argc < 2 || strcmp(argv[1], "compress_generated_" #name) == 0) \
&& !file_exists("compress_generated_" #name)) { \ && !file_exists("compress_generated_" #name)) { \
FILE *file = file_create("compress_generated_" #name); \ FILE *file = file_create("compress_generated_" #name); \
write_ ## name(file); \ write_ ## name(file); \

View file

@ -85,9 +85,16 @@ test -x ../src/xzdec/xzdec || XZDEC=
# Create the required input file if needed. # Create the required input file if needed.
FILE=$1 FILE=$1
# 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"
case $FILE in case $FILE in
# compress_generated files will be created in the build directory
# in the /tests/ sub-directory.
compress_generated_*) compress_generated_*)
if ./create_compress_files "${FILE#compress_generated_}" ; then if ./create_compress_files "$FILE" ; then
: :
else else
rm -f "$FILE" rm -f "$FILE"
@ -95,18 +102,17 @@ case $FILE in
exit 1 exit 1
fi fi
;; ;;
# compress_prepared files exist in the source directory since they
# do not need to be copied or regenerated.
compress_prepared_*)
FILE="$srcdir/$FILE"
;;
'') '')
echo "No test file was specified." echo "No test file was specified."
exit 1 exit 1
;; ;;
esac 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_COMP" "$TMP_UNCOMP" rm -f "$TMP_COMP" "$TMP_UNCOMP"
trap 'rm -f "$TMP_COMP" "$TMP_UNCOMP"' 0 trap 'rm -f "$TMP_COMP" "$TMP_UNCOMP"' 0

View file

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

View file

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