~ [ 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-4.13.16)


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

~ [ 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