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