1 # $NetBSD: t_mount.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $
3 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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 an execution of mount and umount works correctly without
30 # causing errors and that the root node gets correct attributes.
31 # Also verifies command line parsing from mount_tmpfs.
36 atf_set
"descr" "Tests a mount and unmount without any options"
37 atf_set
"require.user" "root"
46 atf_set
"descr" "Tests that the mount point has two hard links"
47 atf_set
"require.user" "root"
51 eval $
(stat
-s ${Mount_Point})
52 [ ${st_nlink} = 2 ] || \
53 atf_fail
"Root directory does not have two hard links"
59 atf_set
"descr" "Tests the read-only mount option"
60 atf_set
"require.user" "root"
64 mount |
grep ${Mount_Point} |
grep -q read-only || \
65 atf_fail
"read-only option (ro) does not work"
71 atf_set
"descr" "Tests that root directory attributes are set" \
73 atf_set
"require.user" "root"
76 test_mount
-o -u1000 -o -g100 -o -m755
77 eval $
(stat
-s ${Mount_Point})
78 [ ${st_uid} = 1000 ] || atf_fail
"uid is incorrect"
79 [ ${st_gid} = 100 ] || atf_fail
"gid is incorrect"
80 [ ${st_mode} = 040755 ] || atf_fail
"mode is incorrect"
84 atf_test_case negative
86 atf_set
"descr" "Tests that negative values passed to to -s are" \
88 atf_set
"require.user" "root"
98 atf_set
"descr" "Tests that extremely long values passed to -s" \
99 "are handled correctly"
100 atf_set
"require.user" "root"
103 test_mount
-o -s9223372036854775807
107 atf_check
-s eq
:1 -o empty
-e ignore \
108 mount
-t tmpfs
-o -s9223372036854775808 tmpfs tmp
109 atf_check
-s eq
:1 -o empty
-e ignore \
110 mount
-t tmpfs
-o -s9223372036854775808g tmpfs tmp
116 atf_set
"descr" "Tests that the error messages printed when the" \
117 "mount point is invalid do not show the source" \
121 mount_tmpfs unused $
(pwd)/mnt
>out
2>&1
122 atf_check
-s eq
:1 -o empty
-e empty
grep unused out
123 atf_check
-s eq
:0 -o ignore
-e empty
grep "$(pwd)/mnt" out
125 mount_tmpfs unused mnt
>out
2>&1
126 atf_check
-s eq
:1 -o empty
-e empty
grep unused out
127 atf_check
-s eq
:0 -o ignore
-e empty
grep mnt out
130 atf_init_test_cases
() {
131 . $
(atf_get_srcdir
)/..
/h_funcs.subr
132 . $
(atf_get_srcdir
)/h_funcs.subr
134 atf_add_test_case plain
135 atf_add_test_case options
136 atf_add_test_case attrs
137 atf_add_test_case negative
138 atf_add_test_case large
139 atf_add_test_case mntpt