KVM: PPC: Book3S HV: Avoid preemptibility warning in module initialization
[linux/fpc-iii.git] / tools / testing / selftests / gpio / gpio-mockup-sysfs.sh
blob085d7a39899c7678a4245178cfa166da88c2cdf7
2 is_consistent()
4 val=
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`
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
19 if [ $active_low_sysfs = "1" ]; then
20 if [ $val = "0" ]; then
21 val="1"
22 else
23 val="0"
27 if [ $val_sysfs = $val ] && [ $dir_sysfs = $dir_debugfs ]; then
28 echo -n "."
29 else
30 echo "test fail, exit"
31 die
35 test_pin_logic()
37 nr=$1
38 direction=$2
39 active_low=$3
40 value=$4
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
47 is_consistent $nr
50 test_one_pin()
52 nr=$1
54 echo -n "test pin<$nr>"
56 echo $nr > $GPIO_SYSFS/export 2>/dev/null
58 if [ X$? != X0 ]; then
59 echo "test GPIO pin $nr failed"
60 die
63 #"Checking if the sysfs is consistent with debugfs: "
64 is_consistent $nr
66 #"Checking the logic of active_low: "
67 test_pin_logic $nr out 1 1
68 test_pin_logic $nr out 1 0
69 test_pin_logic $nr out 0 1
70 test_pin_logic $nr out 0 0
72 #"Checking the logic of direction: "
73 test_pin_logic $nr in 1 1
74 test_pin_logic $nr out 1 0
75 test_pin_logic $nr low 0 1
76 test_pin_logic $nr high 0 0
78 echo $nr > $GPIO_SYSFS/unexport
80 echo "successful"
83 test_one_pin_fail()
85 nr=$1
87 echo $nr > $GPIO_SYSFS/export 2>/dev/null
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
98 list_chip()
100 echo `ls -d $GPIO_DRV_SYSFS/gpiochip* 2>/dev/null`
103 test_chip()
105 chip=$1
106 name=`basename $chip`
107 base=`cat $chip/base`
108 ngpio=`cat $chip/ngpio`
109 printf "%-10s %-5s %-5s\n" $name $base $ngpio
110 if [ $ngpio = "0" ]; then
111 echo "number of gpio is zero is not allowed".
113 test_one_pin $base
114 test_one_pin $(($base + $ngpio - 1))
115 test_one_pin $((( RANDOM % $ngpio ) + $base ))
118 test_chips_sysfs()
120 gpiochip=`list_chip $module`
121 if [ X"$gpiochip" = X ]; then
122 if [ X"$valid" = Xfalse ]; then
123 echo "successful"
124 else
125 echo "fail"
128 else
129 for chip in $gpiochip; do
130 test_chip $chip
131 done