Expand PMF_FN_* macros.
[netbsd-mini2440.git] / tests / fs / tmpfs / t_symlink.sh
blobc3a99331b614be9e2bb726a48b055050c684a8c5
1 # $NetBSD: t_symlink.sh,v 1.2 2008/04/30 13:11:00 martin Exp $
3 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
29 # Verifies that the symlink and readlink operations work.
32 atf_test_case file
33 file_head() {
34 atf_set "descr" "Tests that symlinks to files work"
35 atf_set "require.user" "root"
37 file_body() {
38 test_mount
40 atf_check -s eq:0 -o empty -e empty touch a
41 atf_check -s eq:0 -o empty -e empty ln -s a b
42 [ $(md5 b | cut -d ' ' -f 4) = d41d8cd98f00b204e9800998ecf8427e ] || \
43 atf_fail "Symlink points to an incorrect file"
45 atf_check -s eq:0 -o empty -e empty -x 'echo foo >a'
46 [ $(md5 b | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \
47 atf_fail "Symlink points to an incorrect file"
49 test_unmount
52 atf_test_case exec
53 exec_head() {
54 atf_set "descr" "Tests symlinking to a known system binary and" \
55 "executing it through the symlink"
56 atf_set "require.user" "root"
58 exec_body() {
59 test_mount
61 atf_check -s eq:0 -o empty -e empty touch b
62 atf_check -s eq:0 -o empty -e empty ln -s /bin/cp cp
63 atf_check -s eq:0 -o empty -e empty ./cp b c
64 atf_check -s eq:0 -o empty -e empty test -f c
66 test_unmount
69 atf_test_case dir
70 dir_head() {
71 atf_set "descr" "Tests that symlinks to directories work"
72 atf_set "require.user" "root"
74 dir_body() {
75 test_mount
77 atf_check -s eq:0 -o empty -e empty mkdir d
78 atf_check -s eq:1 -o empty -e empty test -f d/foo
79 atf_check -s eq:1 -o empty -e empty test -f e/foo
80 atf_check -s eq:0 -o empty -e empty ln -s d e
81 atf_check -s eq:0 -o empty -e empty touch d/foo
82 atf_check -s eq:0 -o empty -e empty test -f d/foo
83 atf_check -s eq:0 -o empty -e empty test -f e/foo
85 test_unmount
88 atf_test_case kqueue
89 kqueue_head() {
90 atf_set "descr" "Tests that creating a symlink raises the" \
91 "appropriate kqueue events"
92 atf_set "require.user" "root"
94 kqueue_body() {
95 test_mount
97 atf_check -s eq:0 -o empty -e empty mkdir dir
98 echo 'ln -s non-existent dir/a' | kqueue_monitor 1 dir
99 kqueue_check dir NOTE_WRITE
100 atf_check -s eq:0 -o empty -e empty rm dir/a
101 atf_check -s eq:0 -o empty -e empty rmdir dir
103 test_unmount
106 atf_init_test_cases() {
107 . $(atf_get_srcdir)/../h_funcs.subr
108 . $(atf_get_srcdir)/h_funcs.subr
110 atf_add_test_case file
111 atf_add_test_case exec
112 atf_add_test_case dir
113 atf_add_test_case kqueue