1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3set -e 4 5ret=0 6 7do_splice() 8{ 9 filename="$1" 10 bytes="$2" 11 expected="$3" 12 13 out=$(./splice_read "$filename" "$bytes" | cat) 14 if [ "$out" = "$expected" ] ; then 15 echo "ok: $filename $bytes" 16 else 17 echo "FAIL: $filename $bytes" 18 ret=1 19 fi 20} 21 22test_splice() 23{ 24 filename="$1" 25 26 full=$(cat "$filename") 27 two=$(echo "$full" | grep -m1 . | cut -c-2) 28 29 # Make sure full splice has the same contents as a standard read. 30 do_splice "$filename" 4096 "$full" 31 32 # Make sure a partial splice see the first two characters. 33 do_splice "$filename" 2 "$two" 34} 35 36# proc_single_open(), seq_read() 37test_splice /proc/$$/limits 38# special open, seq_read() 39test_splice /proc/$$/comm 40 41# proc_handler, proc_dointvec_minmax 42test_splice /proc/sys/fs/nr_open 43# proc_handler, proc_dostring 44test_splice /proc/sys/kernel/modprobe 45# proc_handler, special read 46test_splice /proc/sys/kernel/version 47 48if ! [ -d /sys/module/test_module/sections ] ; then 49 modprobe test_module 50fi 51# kernfs, attr 52test_splice /sys/module/test_module/coresize 53# kernfs, binattr 54test_splice /sys/module/test_module/sections/.init.text 55 56exit $ret 57