linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Bamvor Jian Zhang <bamv2005@gmail.com>, Shuah Khan <shuah@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH] selftests: gpio: correctly check the type of /dev/gpiochipX
Date: Thu, 27 Nov 2025 16:55:40 +0800	[thread overview]
Message-ID: <20251127085540.21142-1-kanie@linux.alibaba.com> (raw)

/dev/gpiochipX is a character device, not a directory, so we should
use "test -c" instead of "test -d" to check for its existence;
otherwise, the current check will not work correctly when
/dev/gpiochipX is left over (e.g., as a stale device node).

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 tools/testing/selftests/gpio/gpio-aggregator.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/gpio/gpio-aggregator.sh b/tools/testing/selftests/gpio/gpio-aggregator.sh
index 9b6f80ad9f8a..13d8e1607571 100755
--- a/tools/testing/selftests/gpio/gpio-aggregator.sh
+++ b/tools/testing/selftests/gpio/gpio-aggregator.sh
@@ -351,7 +351,7 @@ test "$(agg_get_chip_num_lines _sysfs.0)" = "1" || fail "number of lines is not
 test "$(agg_get_line_name _sysfs.0 0)" = "" || fail "line name is unset"
 echo "$(agg_configfs_dev_name _sysfs.0)" > "$SYSFS_AGG_DIR/delete_device"
 test -d $CONFIGFS_AGG_DIR/_sysfs.0 && fail "_sysfs.0 unexpectedly remains"
-test -d /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
+test -c /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
 
 echo "1.2.2. Complex creation/deletion"
 echo "chip0bank0_0 chip1_bank1 10-11" > "$SYSFS_AGG_DIR/new_device"
@@ -365,7 +365,7 @@ test "$(agg_get_line_name _sysfs.0 1)" = "" || fail "line name is unset"
 test "$(agg_get_line_name _sysfs.0 2)" = "" || fail "line name is unset"
 echo "$(agg_configfs_dev_name _sysfs.0)" > "$SYSFS_AGG_DIR/delete_device"
 test -d $CONFIGFS_AGG_DIR/_sysfs.0 && fail "_sysfs.0 unexpectedly remains"
-test -d /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
+test -c /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
 
 echo "1.2.3. Asynchronous creation with deferred probe"
 sim_disable_chip  chip0
@@ -382,7 +382,7 @@ test "$(agg_get_chip_num_lines _sysfs.0)" = "1" || fail "number of lines is not
 test "$(agg_get_line_name _sysfs.0 0)" = "" || fail "line name unexpectedly set"
 echo "$(agg_configfs_dev_name _sysfs.0)" > "$SYSFS_AGG_DIR/delete_device"
 test -d $CONFIGFS_AGG_DIR/_sysfs.0 && fail "_sysfs.0 unexpectedly remains"
-test -d /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
+test -c /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
 
 echo "1.2.4. Can't instantiate a chip with invalid configuration"
 echo "xyz 0" > "$SYSFS_AGG_DIR/new_device"
-- 
2.43.0


             reply	other threads:[~2025-11-27  8:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27  8:55 Guixin Liu [this message]
2025-12-04  1:45 ` [PATCH] selftests: gpio: correctly check the type of /dev/gpiochipX Guixin Liu

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=20251127085540.21142-1-kanie@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=bamv2005@gmail.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).