Path: blob/master/tools/testing/selftests/gpio/gpio-cdev-uaf.sh
170953 views
#!/bin/sh1# SPDX-License-Identifier: GPL-2.02# Copyright 2026 Google LLC34BASE_DIR=`dirname $0`5MODULE="gpio-cdev-uaf"67fail() {8echo "$*" >&29echo "GPIO $MODULE test FAIL"10exit 111}1213skip() {14echo "$*" >&215echo "GPIO $MODULE test SKIP"16exit 417}1819# Load the gpio-sim module. This will pull in configfs if needed too.20modprobe gpio-sim || skip "unable to load the gpio-sim module"21# Make sure configfs is mounted at /sys/kernel/config. Wait a bit if needed.22for _ in `seq 5`; do23mountpoint -q /sys/kernel/config && break24mount -t configfs none /sys/kernel/config25sleep 0.126done27mountpoint -q /sys/kernel/config || \28skip "configfs not mounted at /sys/kernel/config"2930echo "1. GPIO"3132echo "1.1. poll"33$BASE_DIR/gpio-cdev-uaf chip poll || fail "failed to test chip poll"34echo "1.2. read"35$BASE_DIR/gpio-cdev-uaf chip read || fail "failed to test chip read"36echo "1.3. ioctl"37$BASE_DIR/gpio-cdev-uaf chip ioctl || fail "failed to test chip ioctl"3839echo "2. linehandle"4041echo "2.1. ioctl"42$BASE_DIR/gpio-cdev-uaf handle ioctl || fail "failed to test handle ioctl"4344echo "3. lineevent"4546echo "3.1. read"47$BASE_DIR/gpio-cdev-uaf event read || fail "failed to test event read"48echo "3.2. poll"49$BASE_DIR/gpio-cdev-uaf event poll || fail "failed to test event poll"50echo "3.3. ioctl"51$BASE_DIR/gpio-cdev-uaf event ioctl || fail "failed to test event ioctl"5253echo "4. linereq"5455echo "4.1. read"56$BASE_DIR/gpio-cdev-uaf req read || fail "failed to test req read"57echo "4.2. poll"58$BASE_DIR/gpio-cdev-uaf req poll || fail "failed to test req poll"59echo "4.3. ioctl"60$BASE_DIR/gpio-cdev-uaf req ioctl || fail "failed to test req ioctl"6162echo "GPIO $MODULE test PASS"636465