Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/tools/testing/selftests/gpio/gpio-cdev-uaf.sh
170953 views
1
#!/bin/sh
2
# SPDX-License-Identifier: GPL-2.0
3
# Copyright 2026 Google LLC
4
5
BASE_DIR=`dirname $0`
6
MODULE="gpio-cdev-uaf"
7
8
fail() {
9
echo "$*" >&2
10
echo "GPIO $MODULE test FAIL"
11
exit 1
12
}
13
14
skip() {
15
echo "$*" >&2
16
echo "GPIO $MODULE test SKIP"
17
exit 4
18
}
19
20
# Load the gpio-sim module. This will pull in configfs if needed too.
21
modprobe gpio-sim || skip "unable to load the gpio-sim module"
22
# Make sure configfs is mounted at /sys/kernel/config. Wait a bit if needed.
23
for _ in `seq 5`; do
24
mountpoint -q /sys/kernel/config && break
25
mount -t configfs none /sys/kernel/config
26
sleep 0.1
27
done
28
mountpoint -q /sys/kernel/config || \
29
skip "configfs not mounted at /sys/kernel/config"
30
31
echo "1. GPIO"
32
33
echo "1.1. poll"
34
$BASE_DIR/gpio-cdev-uaf chip poll || fail "failed to test chip poll"
35
echo "1.2. read"
36
$BASE_DIR/gpio-cdev-uaf chip read || fail "failed to test chip read"
37
echo "1.3. ioctl"
38
$BASE_DIR/gpio-cdev-uaf chip ioctl || fail "failed to test chip ioctl"
39
40
echo "2. linehandle"
41
42
echo "2.1. ioctl"
43
$BASE_DIR/gpio-cdev-uaf handle ioctl || fail "failed to test handle ioctl"
44
45
echo "3. lineevent"
46
47
echo "3.1. read"
48
$BASE_DIR/gpio-cdev-uaf event read || fail "failed to test event read"
49
echo "3.2. poll"
50
$BASE_DIR/gpio-cdev-uaf event poll || fail "failed to test event poll"
51
echo "3.3. ioctl"
52
$BASE_DIR/gpio-cdev-uaf event ioctl || fail "failed to test event ioctl"
53
54
echo "4. linereq"
55
56
echo "4.1. read"
57
$BASE_DIR/gpio-cdev-uaf req read || fail "failed to test req read"
58
echo "4.2. poll"
59
$BASE_DIR/gpio-cdev-uaf req poll || fail "failed to test req poll"
60
echo "4.3. ioctl"
61
$BASE_DIR/gpio-cdev-uaf req ioctl || fail "failed to test req ioctl"
62
63
echo "GPIO $MODULE test PASS"
64
65