tools: tests: remove dependency on grep
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 28 May 2024 08:25:51 +0000 (10:25 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 29 May 2024 13:32:00 +0000 (15:32 +0200)
We only use grep in one place where we don't really need it as we can use
find directly.

Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Suggested-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240528-fix-bash-tests-v3-4-e9b5be2ba8bf@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
tools/gpio-tools-test.bash

index b6809f3790bfad96739427ba80e38e262cf72032..521556c24be4f1dbd22953b84fcbec0e28b33768 100755 (executable)
@@ -158,19 +158,10 @@ gpiosim_cleanup() {
                local BANKPATH=$DEVPATH/bank0
 
                echo 0 > $DEVPATH/live
-
-               ls $BANKPATH/line* > /dev/null 2>&1
-               if [ "$?" = "0" ]
-               then
-                       for LINE in $(find $BANKPATH/ | grep -E "line[0-9]+$")
-                       do
-                               test -e $LINE/hog && rmdir $LINE/hog
-                               rmdir $LINE
-                       done
-               fi
-
-               rmdir $BANKPATH
-               rmdir $DEVPATH
+               find "$DEVPATH" -type d -name hog -exec rmdir '{}' '+'
+               find "$DEVPATH" -type d -name "line*" -exec rmdir '{}' '+'
+               find "$DEVPATH" -type d -name "bank*" -exec rmdir '{}' '+'
+               rmdir "$DEVPATH"
        done
 
        gpiosim_chip_symlink_cleanup
@@ -3078,7 +3069,6 @@ check_prog() {
 check_prog shunit2
 check_prog modprobe
 check_prog timeout
-check_prog grep
 
 # Check if we're running a kernel at the required version or later
 check_kernel $MIN_KERNEL_VERSION