Skip to contentSkip to conversation

selftests: gpio: gpio-sim: remove bashisms

PATCH In review Bartosz Golaszewski 2 participants 3 messages Dec 13, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: gpio: gpio-sim: remove bashisms

'==' is a bashisms and not understood by POSIX shell. Drop it from gpio-sim selftests.

---
I ran the newly applied patches on a different system and noticed the tests now fail. I missed '==' operators for string comparison I used in some places.

 tools/testing/selftests/gpio/gpio-sim.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/gpio/gpio-sim.sh +2 -2
index d335a975890c..c913d5aec768 100755
@@ -23,12 +23,12 @@ remove_chip() {
 
 	for FILE in $CONFIGFS_DIR/$CHIP/*; do
 		BANK=`basename $FILE`
-		if [ "$BANK" == "live" ] || [ "$BANK" == "dev_name" ]; then
+		if [ "$BANK" = "live" ] || [ "$BANK" = "dev_name" ]; then
 			continue
 		fi
 
 		LINES=`ls $CONFIGFS_DIR/$CHIP/$BANK/ | egrep ^line`
-		if [ "$?" == 0 ]; then
+		if [ "$?" = 0 ]; then
 			for LINE in $LINES; do
 				if [ -e $CONFIGFS_DIR/$CHIP/$BANK/$LINE/hog ]; then
 					rmdir $CONFIGFS_DIR/$CHIP/$BANK/$LINE/hog || \
Signature · 1 line
2.30.1
#1 lore raw

tools/testing/selftests/gpio/gpio-sim.sh remove_chip() { · line 26

Quoted 5 lines · Bartosz Golaszewski

'==' is a bashisms and not understood by POSIX shell. Drop it from gpio-sim selftests.

tools/testing/selftests/gpio/gpio-sim.sh +1 -1
-		if [ "$BANK" == "live" ] || [ "$BANK" == "dev_name" ]; then
+		if [ "$BANK" = "live" ] || [ "$BANK" = "dev_name" ]; then

While at it, no need to fork test twice, isn't it?

		if [ "$BANK" = "live" -o "$BANK" = "dev_name" ]; then
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 8 lines · Andy Shevchenko

tools/testing/selftests/gpio/gpio-sim.sh remove_chip() { · line 26

Quoted 5 lines · Bartosz Golaszewski

'==' is a bashisms and not understood by POSIX shell. Drop it from gpio-sim selftests.

tools/testing/selftests/gpio/gpio-sim.sh +1 -1
-             if [ "$BANK" == "live" ] || [ "$BANK" == "dev_name" ]; then
+             if [ "$BANK" = "live" ] || [ "$BANK" = "dev_name" ]; then
Quoted 9 lines

While at it, no need to fork test twice, isn't it?

                if [ "$BANK" = "live" -o "$BANK" = "dev_name" ]; then

--
With Best Regards,
Andy Shevchenko

I'll send a follow-up for that, thanks for spotting it.

Bart