Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] selftests: gpio: Reject empty simulator names
@ 2026-11-20 21:13 Mohammed Rayan
  0 siblings, 0 replies; only message in thread
From: Mohammed Rayan @ 2026-11-20 21:13 UTC (permalink / raw)
  To: linux-gpio
  Cc: linux-kselftest, Bamvor Jian Zhang, Shuah Khan,
	Bartosz Golaszewski, Mohammed Rayan

The gpio-sim selftest checks that chip_name and dev_name are nonempty,
but the command substitutions in both checks are unquoted. If a read
produces no output, the shell removes the empty argument and leaves
"test -n", which succeeds instead of reporting the missing name.

Quote the substitutions so that an empty result fails the checks.

In a disposable QEMU guest, the original and modified scripts both
passed normally. With empty output or a failed read injected for each
attribute using a userspace wrapper, the original script passed and the
modified script failed as expected.

The issue was investigated with Codex assistance.

Fixes: 1d96b8f635d9 ("selftests: gpio: add test cases for gpio-sim")
Signed-off-by: Mohammed Rayan <mohammedrah1289@gmail.com>
---
 tools/testing/selftests/gpio/gpio-sim.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/gpio/gpio-sim.sh b/tools/testing/selftests/gpio/gpio-sim.sh
index bbc29ed9c60a..2c9e354fe9ed 100755
--- a/tools/testing/selftests/gpio/gpio-sim.sh
+++ b/tools/testing/selftests/gpio/gpio-sim.sh
@@ -181,7 +181,7 @@ echo "1.1. Chip name is communicated to user"
 create_chip chip
 create_bank chip bank
 enable_chip chip
-test -n `cat $CONFIGFS_DIR/chip/bank/chip_name` || fail "chip_name doesn't work"
+test -n "`cat $CONFIGFS_DIR/chip/bank/chip_name`" || fail "chip_name doesn't work"
 disable_chip chip
 remove_chip chip
 
@@ -196,7 +196,7 @@ echo "1.3. Device name is communicated to user"
 create_chip chip
 create_bank chip bank
 enable_chip chip
-test -n `cat $CONFIGFS_DIR/chip/dev_name` || fail "dev_name doesn't work"
+test -n "`cat $CONFIGFS_DIR/chip/dev_name`" || fail "dev_name doesn't work"
 disable_chip chip
 remove_chip chip
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-20 21:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 21:13 [PATCH] selftests: gpio: Reject empty simulator names Mohammed Rayan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox