From: Christian Goeschel Ndjomouo Date: Fri, 10 Apr 2026 18:23:27 +0000 (-0400) Subject: tests: use find instead of ls for more robust processing X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=8304cd321c60c4c6d6d77f8bf623aff80e0a9e53;p=thirdparty%2Futil-linux.git tests: use find instead of ls for more robust processing Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/tests/ts/blkid/low-probe b/tests/ts/blkid/low-probe index c3f396439..56a7949e3 100755 --- a/tests/ts/blkid/low-probe +++ b/tests/ts/blkid/low-probe @@ -28,7 +28,7 @@ ts_check_prog "xz" mkdir -p $TS_OUTDIR/images-fs -for img in $(ls $TS_SELF/images-fs/*.img.xz | sort); do +for img in $(find "$TS_SELF"/images-fs/ -maxdepth 1 -name "*.img.xz" | sort); do name=$(basename $img .img.xz) outimg=$TS_OUTDIR/images-fs/${name}.img diff --git a/tests/ts/blkid/lowprobe-pt b/tests/ts/blkid/lowprobe-pt index 955de076d..429557b9a 100755 --- a/tests/ts/blkid/lowprobe-pt +++ b/tests/ts/blkid/lowprobe-pt @@ -28,7 +28,7 @@ ts_check_prog "xz" mkdir -p $TS_OUTDIR/images-pt -for img in $(ls $TS_SELF/images-pt/*.img.xz | sort); do +for img in $(find "$TS_SELF"/images-pt/ -maxdepth 1 -name "*.img.xz" 2>/dev/null | sort); do name=$(basename $img .img.xz) outimg=$TS_OUTDIR/images-pt/${name}.img diff --git a/tests/ts/lsblk/lsblk b/tests/ts/lsblk/lsblk index 509b8d0cd..2c83ffc7b 100755 --- a/tests/ts/lsblk/lsblk +++ b/tests/ts/lsblk/lsblk @@ -26,7 +26,7 @@ ts_check_test_command "$TS_CMD_LSBLK" ts_check_prog xz ts_check_prog tar -for dump in $(ls $TS_SELF/dumps/*.tar.xz | sort); do +for dump in $(find "$TS_SELF"/dumps/ -maxdepth 1 -name "*.tar.xz" | sort); do name=$(basename $dump .tar.xz) dumpdir="$TS_OUTDIR/dumps" @@ -38,12 +38,12 @@ for dump in $(ls $TS_SELF/dumps/*.tar.xz | sort); do # from the tarball due to changes in lsblk formatting etc. We keep up to # date version in tests/expected/lsblk. # - for cols_file in $(ls $dumpdir/$name/*.cols | sort); do + for cols_file in $(find "$dumpdir"/"$name"/ -iname "*.cols" | sort); do subname=$(basename $cols_file .cols) subtestname="${name}-${subname}" ts_init_subtest $subtestname - cols=$(cat $cols_file) + cols=$(<"$cols_file") ${TS_CMD_LSBLK} --sysroot "${dumpdir}/${name}" \ --output $cols \ >> ${TS_OUTPUT} 2>> "$TS_ERRLOG" diff --git a/tests/ts/lscpu/lscpu b/tests/ts/lscpu/lscpu index 3b7eb3592..7c073835b 100755 --- a/tests/ts/lscpu/lscpu +++ b/tests/ts/lscpu/lscpu @@ -26,7 +26,7 @@ ts_check_prog "tar" ts_check_prog "gzip" ts_check_test_command "$TS_CMD_LSCPU" -for dump in $(ls $TS_SELF/dumps/*.tar.gz | sort); do +for dump in $(find "$TS_SELF"/dumps/ -maxdepth 1 -name "*.tar.gz" | sort); do name=$(basename $dump .tar.gz) dumpdir="$TS_OUTDIR/dumps" diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem index 5a40e549e..c3011dcb3 100755 --- a/tests/ts/lsmem/lsmem +++ b/tests/ts/lsmem/lsmem @@ -36,7 +36,7 @@ function do_lsmem { } -for dump in $(ls $TS_SELF/dumps/*.tar.bz2 | sort); do +for dump in $(find "$TS_SELF"/dumps/ -maxdepth 1 -name "*.tar.bz2" | sort); do name=$(basename $dump .tar.bz2) dumpdir="$TS_OUTDIR/dumps" diff --git a/tests/ts/wipefs/wipefs b/tests/ts/wipefs/wipefs index bc2d7812d..fef60d6f0 100755 --- a/tests/ts/wipefs/wipefs +++ b/tests/ts/wipefs/wipefs @@ -22,7 +22,7 @@ mkdir -p "$backups" $TS_CMD_WIPEFS --all --backup="${backups}" ${img} &>/dev/null || ts_die "wipefs failed" #there should be just one magic string/backup file in this case -INFILE=$(ls $backups/wipefs-$(basename ${img})-*.bak) +INFILE=$(find "$backups/" -iname "wipefs-$(basename "${img}")-*.bak") OFFT=$(echo $INFILE | sed 's/^.*-\(.*\).bak$/\1/') dd if=$INFILE of=$img bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null