WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / splice / short_splice_read.sh
blob7810d3589d9ab0ef5a491cca24d0f09c4177b369
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 set -e
5 ret=0
7 do_splice()
9 filename="$1"
10 bytes="$2"
11 expected="$3"
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
22 test_splice()
24 filename="$1"
26 full=$(cat "$filename")
27 two=$(echo "$full" | grep -m1 . | cut -c-2)
29 # Make sure full splice has the same contents as a standard read.
30 do_splice "$filename" 4096 "$full"
32 # Make sure a partial splice see the first two characters.
33 do_splice "$filename" 2 "$two"
36 # proc_single_open(), seq_read()
37 test_splice /proc/$$/limits
38 # special open, seq_read()
39 test_splice /proc/$$/comm
41 # proc_handler, proc_dointvec_minmax
42 test_splice /proc/sys/fs/nr_open
43 # proc_handler, proc_dostring
44 test_splice /proc/sys/kernel/modprobe
45 # proc_handler, special read
46 test_splice /proc/sys/kernel/version
48 if ! [ -d /sys/module/test_module/sections ] ; then
49 modprobe test_module
51 # kernfs, attr
52 test_splice /sys/module/test_module/coresize
53 # kernfs, binattr
54 test_splice /sys/module/test_module/sections/.init.text
56 exit $ret