selftests: gpio: Reject empty simulator names
Subsystems (3)
PATCH 1/1 selftests: gpio: Reject empty simulator names
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 <[email protected]>
--- tools/testing/selftests/gpio/gpio-sim.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/gpio/gpio-sim.sh +2 -2
@@ -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
Signature · 1 line
2.34.1