~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/gpio/gpio-mockup-sysfs.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/gpio/gpio-mockup-sysfs.sh (Version linux-6.11.5) and /tools/testing/selftests/gpio/gpio-mockup-sysfs.sh (Version linux-5.1.21)


  1                                                     1 
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
                                                   >>   3 is_consistent()
                                                   >>   4 {
                                                   >>   5         val=
                                                   >>   6 
                                                   >>   7         active_low_sysfs=`cat $GPIO_SYSFS/gpio$nr/active_low`
                                                   >>   8         val_sysfs=`cat $GPIO_SYSFS/gpio$nr/value`
                                                   >>   9         dir_sysfs=`cat $GPIO_SYSFS/gpio$nr/direction`
                                                   >>  10 
                                                   >>  11         gpio_this_debugfs=`cat $GPIO_DEBUGFS |grep "gpio-$nr" | sed "s/(.*)//g"`
                                                   >>  12         dir_debugfs=`echo $gpio_this_debugfs | awk '{print $2}'`
                                                   >>  13         val_debugfs=`echo $gpio_this_debugfs | awk '{print $3}'`
                                                   >>  14         if [ $val_debugfs = "lo" ]; then
                                                   >>  15                 val=0
                                                   >>  16         elif [ $val_debugfs = "hi" ]; then
                                                   >>  17                 val=1
                                                   >>  18         fi
                                                   >>  19 
                                                   >>  20         if [ $active_low_sysfs = "1" ]; then
                                                   >>  21                 if [ $val = "0" ]; then
                                                   >>  22                         val="1"
                                                   >>  23                 else
                                                   >>  24                         val="0"
                                                   >>  25                 fi
                                                   >>  26         fi
                                                   >>  27 
                                                   >>  28         if [ $val_sysfs = $val ] && [ $dir_sysfs = $dir_debugfs ]; then
                                                   >>  29                 echo -n "."
                                                   >>  30         else
                                                   >>  31                 echo "test fail, exit"
                                                   >>  32                 die
                                                   >>  33         fi
                                                   >>  34 }
                                                   >>  35 
                                                   >>  36 test_pin_logic()
                                                   >>  37 {
                                                   >>  38         nr=$1
                                                   >>  39         direction=$2
                                                   >>  40         active_low=$3
                                                   >>  41         value=$4
                                                   >>  42 
                                                   >>  43         echo $direction > $GPIO_SYSFS/gpio$nr/direction
                                                   >>  44         echo $active_low > $GPIO_SYSFS/gpio$nr/active_low
                                                   >>  45         if [ $direction = "out" ]; then
                                                   >>  46                 echo $value > $GPIO_SYSFS/gpio$nr/value
                                                   >>  47         fi
                                                   >>  48         is_consistent $nr
                                                   >>  49 }
  3                                                    50 
  4 # Overrides functions in gpio-mockup.sh to tes !!  51 test_one_pin()
                                                   >>  52 {
                                                   >>  53         nr=$1
  5                                                    54 
  6 SYSFS=`grep -w sysfs /proc/mounts | cut -f2 -d !!  55         echo -n "test pin<$nr>"
  7 [ -d "$SYSFS" ] || skip "sysfs is not mounted" << 
  8                                                    56 
  9 GPIO_SYSFS="${SYSFS}/class/gpio"               !!  57         echo $nr > $GPIO_SYSFS/export 2>/dev/null
 10 [ -d "$GPIO_SYSFS" ] || skip "CONFIG_GPIO_SYSF << 
 11                                                    58 
 12 PLATFORM_SYSFS=$SYSFS/devices/platform         !!  59         if [ X$? != X0 ]; then
                                                   >>  60                 echo "test GPIO pin $nr failed"
                                                   >>  61                 die
                                                   >>  62         fi
 13                                                    63 
 14 sysfs_nr=                                      !!  64         #"Checking if the sysfs is consistent with debugfs: "
 15 sysfs_ldir=                                    !!  65         is_consistent $nr
 16                                                    66 
 17 # determine the sysfs GPIO number given the $c !!  67         #"Checking the logic of active_low: "
 18 # e.g. gpiochip1:32                            !!  68         test_pin_logic $nr out 1 1
 19 find_sysfs_nr()                                !!  69         test_pin_logic $nr out 1 0
 20 {                                              !!  70         test_pin_logic $nr out 0 1
 21         # e.g. /sys/devices/platform/gpio-mock !!  71         test_pin_logic $nr out 0 0
 22         local platform=$(find $PLATFORM_SYSFS  !!  72 
 23         [ "$platform" ] || fail "can't find pl !!  73         #"Checking the logic of direction: "
 24         # e.g. /sys/devices/platform/gpio-mock !!  74         test_pin_logic $nr in 1 1
 25         local base=$(find ${platform%/*}/gpio/ !!  75         test_pin_logic $nr out 1 0
 26         [ "$base" ] || fail "can't find base o !!  76         test_pin_logic $nr low 0 1
 27         sysfs_nr=$(($(< "$base") + $offset))   !!  77         test_pin_logic $nr high 0 0
 28         sysfs_ldir="$GPIO_SYSFS/gpio$sysfs_nr" !!  78 
                                                   >>  79         echo $nr > $GPIO_SYSFS/unexport
                                                   >>  80 
                                                   >>  81         echo "successful"
 29 }                                                  82 }
 30                                                    83 
 31 acquire_line()                                 !!  84 test_one_pin_fail()
 32 {                                                  85 {
 33         [ "$sysfs_nr" ] && return              !!  86         nr=$1
 34         find_sysfs_nr                          !!  87 
 35         echo "$sysfs_nr" > "$GPIO_SYSFS/export !!  88         echo $nr > $GPIO_SYSFS/export 2>/dev/null
                                                   >>  89 
                                                   >>  90         if [ X$? != X0 ]; then
                                                   >>  91                 echo "test invalid pin $nr successful"
                                                   >>  92         else
                                                   >>  93                 echo "test invalid pin $nr failed"
                                                   >>  94                 echo $nr > $GPIO_SYSFS/unexport 2>/dev/null
                                                   >>  95                 die
                                                   >>  96         fi
 36 }                                                  97 }
 37                                                    98 
 38 # The helpers being overridden...              !!  99 list_chip()
 39 get_line()                                     << 
 40 {                                                 100 {
 41         [ -e "$sysfs_ldir/value" ] && echo $(< !! 101         echo `ls -d $GPIO_DRV_SYSFS/gpiochip* 2>/dev/null`
 42 }                                                 102 }
 43                                                   103 
 44 set_line()                                     !! 104 test_chip()
 45 {                                                 105 {
 46         acquire_line                           !! 106         chip=$1
 47                                                !! 107         name=`basename $chip`
 48         for option in $*; do                   !! 108         base=`cat $chip/base`
 49                 case $option in                !! 109         ngpio=`cat $chip/ngpio`
 50                 active-high)                   !! 110         printf "%-10s %-5s %-5s\n" $name $base $ngpio
 51                         echo 0 > "$sysfs_ldir/ !! 111         if [ $ngpio = "0" ]; then
 52                         ;;                     !! 112                 echo "number of gpio is zero is not allowed".
 53                 active-low)                    !! 113         fi
 54                         echo 1 > "$sysfs_ldir/ !! 114         test_one_pin $base
 55                         ;;                     !! 115         test_one_pin $(($base + $ngpio - 1))
 56                 input)                         !! 116         test_one_pin $((( RANDOM % $ngpio )  + $base ))
 57                         echo "in" > "$sysfs_ld << 
 58                         ;;                     << 
 59                 0)                             << 
 60                         echo "out" > "$sysfs_l << 
 61                         echo 0 > "$sysfs_ldir/ << 
 62                         ;;                     << 
 63                 1)                             << 
 64                         echo "out" > "$sysfs_l << 
 65                         echo 1 > "$sysfs_ldir/ << 
 66                         ;;                     << 
 67                 esac                           << 
 68         done                                   << 
 69 }                                                 117 }
 70                                                   118 
 71 release_line()                                 !! 119 test_chips_sysfs()
 72 {                                                 120 {
 73         [ "$sysfs_nr" ] || return 0            !! 121        gpiochip=`list_chip $module`
 74         echo "$sysfs_nr" > "$GPIO_SYSFS/unexpo !! 122        if [ X"$gpiochip" = X ]; then
 75         sysfs_nr=                              !! 123                if [ X"$valid" = Xfalse ]; then
 76         sysfs_ldir=                            !! 124                        echo "successful"
                                                   >> 125                else
                                                   >> 126                        echo "fail"
                                                   >> 127                        die
                                                   >> 128                fi
                                                   >> 129        else
                                                   >> 130                for chip in $gpiochip; do
                                                   >> 131                        test_chip $chip
                                                   >> 132                done
                                                   >> 133        fi
 77 }                                                 134 }
                                                   >> 135 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php