xref: /freebsd/tests/sys/vfs/trailing_slash.sh (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1#!/bin/sh
2#
3#
4# Tests vfs_lookup()'s handling of trailing slashes for symlinks that
5# point to files.  See kern/21768 for details.  Fixed in r193028.
6#
7
8: ${TMPDIR=/tmp}
9testfile="$TMPDIR/testfile-$$"
10testlink="$TMPDIR/testlink-$$"
11
12tests="
13$testfile:$testlink:$testfile:0
14$testfile:$testlink:$testfile/:1
15$testfile:$testlink:$testlink:0
16$testfile:$testlink:$testlink/:1
17$testfile/:$testlink:$testlink:1
18$testfile/:$testlink:$testlink/:1
19"
20
21touch $testfile || exit 1
22trap "rm $testfile $testlink" EXIT
23
24set $tests
25echo "1..$#"
26n=1
27for testspec ; do
28	(
29		IFS=:
30		set $testspec
31		unset IFS
32		ln -fs "$1" "$2" || exit 1
33		cat "$3" >/dev/null 2>&1
34		ret=$?
35		if [ "$ret" -eq "$4" ] ; then
36			echo "ok $n"
37		else
38			echo "fail $n - expected $4, got $ret"
39		fi
40	)
41	n=$((n+1))
42done
43