1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# Copyright 2026 Google LLC 4 5BASE_DIR=`dirname $0` 6MODULE="gpio-cdev-uaf" 7 8fail() { 9 echo "$*" >&2 10 echo "GPIO $MODULE test FAIL" 11 exit 1 12} 13 14skip() { 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. 21modprobe 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. 23for _ in `seq 5`; do 24 mountpoint -q /sys/kernel/config && break 25 mount -t configfs none /sys/kernel/config 26 sleep 0.1 27done 28mountpoint -q /sys/kernel/config || \ 29 skip "configfs not mounted at /sys/kernel/config" 30 31echo "1. GPIO" 32 33echo "1.1. poll" 34$BASE_DIR/gpio-cdev-uaf chip poll || fail "failed to test chip poll" 35echo "1.2. read" 36$BASE_DIR/gpio-cdev-uaf chip read || fail "failed to test chip read" 37echo "1.3. ioctl" 38$BASE_DIR/gpio-cdev-uaf chip ioctl || fail "failed to test chip ioctl" 39 40echo "2. linehandle" 41 42echo "2.1. ioctl" 43$BASE_DIR/gpio-cdev-uaf handle ioctl || fail "failed to test handle ioctl" 44 45echo "3. lineevent" 46 47echo "3.1. read" 48$BASE_DIR/gpio-cdev-uaf event read || fail "failed to test event read" 49echo "3.2. poll" 50$BASE_DIR/gpio-cdev-uaf event poll || fail "failed to test event poll" 51echo "3.3. ioctl" 52$BASE_DIR/gpio-cdev-uaf event ioctl || fail "failed to test event ioctl" 53 54echo "4. linereq" 55 56echo "4.1. read" 57$BASE_DIR/gpio-cdev-uaf req read || fail "failed to test req read" 58echo "4.2. poll" 59$BASE_DIR/gpio-cdev-uaf req poll || fail "failed to test req poll" 60echo "4.3. ioctl" 61$BASE_DIR/gpio-cdev-uaf req ioctl || fail "failed to test req ioctl" 62 63echo "GPIO $MODULE test PASS" 64