Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Pitt <martin@amutable.com>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <xiang@kernel.org>, Yifan Zhao <zhaoyifan28@huawei.com>,
	Martin Pitt <martin@amutable.com>
Subject: [PATCH 2/3] erofs-utils: tests: look up programs with command -v
Date: Tue,  4 Aug 2026 05:32:13 +0200	[thread overview]
Message-ID: <20260804033214.211267-3-martin@amutable.com> (raw)
In-Reply-To: <20260804033214.211267-1-martin@amutable.com>

`which` stopped being installed by default in recent distros, and it is
not needed at all. Use the POSIX `command -v` instead.

Drop a doubled "unless" from the POSIX compliant note.

Signed-off-by: Martin Pitt <martin@amutable.com>
---
 tests/Makefile.am | 2 +-
 tests/common/rc   | 8 ++++----
 tests/erofs/028   | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2f109b8..c0291ac 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -137,7 +137,7 @@ TESTS += erofs/031
 
 # NOTE: When adding a new test case or updating an existing one, please write
 # POSIX-compliant shell scripts and avoid using Linux-specific features unless
-# unless the test case is expected to run only on Linux platforms.
+# the test case is expected to run only on Linux platforms.
 
 EXTRA_DIST = common/rc erofs
 
diff --git a/tests/common/rc b/tests/common/rc
index 78e704d..aa7ef99 100644
--- a/tests/common/rc
+++ b/tests/common/rc
@@ -48,10 +48,10 @@ _fatal()
     exit 1
 }
 
-export MOUNT_PROG="$(which mount)"
+export MOUNT_PROG="$(command -v mount)"
 [ "$MOUNT_PROG" = "" ] && _fatal "mount not found"
 
-export UMOUNT_PROG="$(which umount)"
+export UMOUNT_PROG="$(command -v umount)"
 [ "$UMOUNT_PROG" = "" ] && _fatal "umount not found"
 [ "$MKFS_EROFS_PROG" = "" ] && _fatal "mkfs.erofs not found"
 
@@ -94,7 +94,7 @@ _require_root()
 
 _require_xattr()
 {
-	which setfattr >/dev/null 2>&1 ||
+	command -v setfattr >/dev/null 2>&1 ||
 		_notrun "attr isn't installed, skipped."
 }
 
@@ -309,7 +309,7 @@ _do_unmount()
 {
 	local mnt_path=$1
 
-	if [ "$FSTYP" = "erofsfuse" -a "$(which fusermount > /dev/null && echo ok)" = "ok" ]; then
+	if [ "$FSTYP" = "erofsfuse" ] && command -v fusermount > /dev/null 2>&1; then
 		fusermount -u $mnt_path
 	else
 		$UMOUNT_PROG $mnt_path
diff --git a/tests/erofs/028 b/tests/erofs/028
index bf31c3f..05d9a5e 100755
--- a/tests/erofs/028
+++ b/tests/erofs/028
@@ -42,9 +42,9 @@ check_ishare()
 _require_erofs
 _require_erofs_inode_sharing
 _require_erofs_compression "-zlz4"
-which strace > /dev/null 2>&1 || _notrun "strace is not found"
-which fincore > /dev/null 2>&1 || _notrun "fincore is not found"
-which fadvise > /dev/null 2>&1 || _notrun "fadvise is not found"
+command -v strace > /dev/null 2>&1 || _notrun "strace is not found"
+command -v fincore > /dev/null 2>&1 || _notrun "fincore is not found"
+command -v fadvise > /dev/null 2>&1 || _notrun "fadvise is not found"
 
 # remove previous $seqres.full before test
 rm -f $seqres.full
-- 
2.55.0



  parent reply	other threads:[~2026-08-04  3:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  3:32 [PATCH 0/3] erofs-utils: tests: cover the canonical xattr order Martin Pitt
2026-08-04  3:32 ` [PATCH 1/3] erofs-utils: tests: fix broken loop in POSIX shells Martin Pitt
2026-08-04  3:32 ` Martin Pitt [this message]
2026-08-04  3:32 ` [PATCH 3/3] erofs-utils: tests: check that the xattr layout is order-independent Martin Pitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260804033214.211267-3-martin@amutable.com \
    --to=martin@amutable.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@kernel.org \
    --cc=zhaoyifan28@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox