@@ -46,12 +46,6 @@ remove_chip() {
46
46
rmdir $CONFIGFS_DIR /$CHIP || fail " Unable to remove the chip"
47
47
}
48
48
49
- configfs_cleanup () {
50
- for CHIP in ` ls $CONFIGFS_DIR /` ; do
51
- remove_chip $CHIP
52
- done
53
- }
54
-
55
49
create_chip () {
56
50
local CHIP=$1
57
51
@@ -105,6 +99,13 @@ disable_chip() {
105
99
echo 0 > $CONFIGFS_DIR /$CHIP /live || fail " Unable to disable the chip"
106
100
}
107
101
102
+ configfs_cleanup () {
103
+ for CHIP in ` ls $CONFIGFS_DIR /` ; do
104
+ disable_chip $CHIP
105
+ remove_chip $CHIP
106
+ done
107
+ }
108
+
108
109
configfs_chip_name () {
109
110
local CHIP=$1
110
111
local BANK=$2
@@ -181,6 +182,7 @@ create_chip chip
181
182
create_bank chip bank
182
183
enable_chip chip
183
184
test -n ` cat $CONFIGFS_DIR /chip/bank/chip_name` || fail " chip_name doesn't work"
185
+ disable_chip chip
184
186
remove_chip chip
185
187
186
188
echo " 1.2. chip_name returns 'none' if the chip is still pending"
@@ -195,6 +197,7 @@ create_chip chip
195
197
create_bank chip bank
196
198
enable_chip chip
197
199
test -n ` cat $CONFIGFS_DIR /chip/dev_name` || fail " dev_name doesn't work"
200
+ disable_chip chip
198
201
remove_chip chip
199
202
200
203
echo " 2. Creating and configuring simulated chips"
@@ -204,6 +207,7 @@ create_chip chip
204
207
create_bank chip bank
205
208
enable_chip chip
206
209
test " ` get_chip_num_lines chip bank` " = " 1" || fail " default number of lines is not 1"
210
+ disable_chip chip
207
211
remove_chip chip
208
212
209
213
echo " 2.2. Number of lines can be specified"
@@ -212,6 +216,7 @@ create_bank chip bank
212
216
set_num_lines chip bank 16
213
217
enable_chip chip
214
218
test " ` get_chip_num_lines chip bank` " = " 16" || fail " number of lines is not 16"
219
+ disable_chip chip
215
220
remove_chip chip
216
221
217
222
echo " 2.3. Label can be set"
@@ -220,13 +225,15 @@ create_bank chip bank
220
225
set_label chip bank foobar
221
226
enable_chip chip
222
227
test " ` get_chip_label chip bank` " = " foobar" || fail " label is incorrect"
228
+ disable_chip chip
223
229
remove_chip chip
224
230
225
231
echo " 2.4. Label can be left empty"
226
232
create_chip chip
227
233
create_bank chip bank
228
234
enable_chip chip
229
235
test -z " ` cat $CONFIGFS_DIR /chip/bank/label` " || fail " label is not empty"
236
+ disable_chip chip
230
237
remove_chip chip
231
238
232
239
echo " 2.5. Line names can be configured"
@@ -238,6 +245,7 @@ set_line_name chip bank 2 bar
238
245
enable_chip chip
239
246
test " ` get_line_name chip bank 0` " = " foo" || fail " line name is incorrect"
240
247
test " ` get_line_name chip bank 2` " = " bar" || fail " line name is incorrect"
248
+ disable_chip chip
241
249
remove_chip chip
242
250
243
251
echo " 2.6. Line config can remain unused if offset is greater than number of lines"
@@ -248,6 +256,7 @@ set_line_name chip bank 5 foobar
248
256
enable_chip chip
249
257
test " ` get_line_name chip bank 0` " = " " || fail " line name is incorrect"
250
258
test " ` get_line_name chip bank 1` " = " " || fail " line name is incorrect"
259
+ disable_chip chip
251
260
remove_chip chip
252
261
253
262
echo " 2.7. Line configfs directory names are sanitized"
@@ -267,6 +276,7 @@ for CHIP in $CHIPS; do
267
276
enable_chip $CHIP
268
277
done
269
278
for CHIP in $CHIPS ; do
279
+ disable_chip $CHIP
270
280
remove_chip $CHIP
271
281
done
272
282
@@ -278,13 +288,15 @@ echo foobar > $CONFIGFS_DIR/chip/bank/label 2> /dev/null && \
278
288
fail " Setting label of a live chip should fail"
279
289
echo 8 > $CONFIGFS_DIR /chip/bank/num_lines 2> /dev/null && \
280
290
fail " Setting number of lines of a live chip should fail"
291
+ disable_chip chip
281
292
remove_chip chip
282
293
283
294
echo " 2.10. Can't create line items when chip is live"
284
295
create_chip chip
285
296
create_bank chip bank
286
297
enable_chip chip
287
298
mkdir $CONFIGFS_DIR /chip/bank/line0 2> /dev/null && fail " Creating line item should fail"
299
+ disable_chip chip
288
300
remove_chip chip
289
301
290
302
echo " 2.11. Probe errors are propagated to user-space"
@@ -316,6 +328,7 @@ mkdir -p $CONFIGFS_DIR/chip/bank/line4/hog
316
328
enable_chip chip
317
329
$BASE_DIR /gpio-mockup-cdev -s 1 /dev/` configfs_chip_name chip bank` 4 2> /dev/null && \
318
330
fail " Setting the value of a hogged line shouldn't succeed"
331
+ disable_chip chip
319
332
remove_chip chip
320
333
321
334
echo " 3. Controlling simulated chips"
@@ -331,6 +344,7 @@ test "$?" = "1" || fail "pull set incorrectly"
331
344
sysfs_set_pull chip bank 0 pull-down
332
345
$BASE_DIR /gpio-mockup-cdev /dev/` configfs_chip_name chip bank` 1
333
346
test " $? " = " 0" || fail " pull set incorrectly"
347
+ disable_chip chip
334
348
remove_chip chip
335
349
336
350
echo " 3.2. Pull can be read from sysfs"
@@ -344,6 +358,7 @@ SYSFS_PATH=/sys/devices/platform/$DEVNAME/$CHIPNAME/sim_gpio0/pull
344
358
test ` cat $SYSFS_PATH ` = " pull-down" || fail " reading the pull failed"
345
359
sysfs_set_pull chip bank 0 pull-up
346
360
test ` cat $SYSFS_PATH ` = " pull-up" || fail " reading the pull failed"
361
+ disable_chip chip
347
362
remove_chip chip
348
363
349
364
echo " 3.3. Incorrect input in sysfs is rejected"
@@ -355,6 +370,7 @@ DEVNAME=`configfs_dev_name chip`
355
370
CHIPNAME=` configfs_chip_name chip bank`
356
371
SYSFS_PATH=" /sys/devices/platform/$DEVNAME /$CHIPNAME /sim_gpio0/pull"
357
372
echo foobar > $SYSFS_PATH 2> /dev/null && fail " invalid input not detected"
373
+ disable_chip chip
358
374
remove_chip chip
359
375
360
376
echo " 3.4. Can't write to value"
@@ -365,6 +381,7 @@ DEVNAME=`configfs_dev_name chip`
365
381
CHIPNAME=` configfs_chip_name chip bank`
366
382
SYSFS_PATH=" /sys/devices/platform/$DEVNAME /$CHIPNAME /sim_gpio0/value"
367
383
echo 1 > $SYSFS_PATH 2> /dev/null && fail " writing to 'value' succeeded unexpectedly"
384
+ disable_chip chip
368
385
remove_chip chip
369
386
370
387
echo " 4. Simulated GPIO chips are functional"
@@ -382,6 +399,7 @@ $BASE_DIR/gpio-mockup-cdev -s 1 /dev/`configfs_chip_name chip bank` 0 &
382
399
sleep 0.1 # FIXME Any better way?
383
400
test ` cat $SYSFS_PATH ` = " 1" || fail " incorrect value read from sysfs"
384
401
kill $!
402
+ disable_chip chip
385
403
remove_chip chip
386
404
387
405
echo " 4.2. Bias settings work correctly"
@@ -394,6 +412,7 @@ CHIPNAME=`configfs_chip_name chip bank`
394
412
SYSFS_PATH=" /sys/devices/platform/$DEVNAME /$CHIPNAME /sim_gpio0/value"
395
413
$BASE_DIR /gpio-mockup-cdev -b pull-up /dev/` configfs_chip_name chip bank` 0
396
414
test ` cat $SYSFS_PATH ` = " 1" || fail " bias setting does not work"
415
+ disable_chip chip
397
416
remove_chip chip
398
417
399
418
echo " GPIO $MODULE test PASS"
0 commit comments