etc/services - sync with NetBSD-8
[minix.git] / tests / fs / tmpfs / t_mount.sh
blob11a77d49c24a9537458f58da97d4767b1a2d02e4
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.
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 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.
34 atf_test_case plain
35 plain_head() {
36 atf_set "descr" "Tests a mount and unmount without any options"
37 atf_set "require.user" "root"
39 plain_body() {
40 test_mount
41 test_unmount
44 atf_test_case links
45 links_head() {
46 atf_set "descr" "Tests that the mount point has two hard links"
47 atf_set "require.user" "root"
49 links_body() {
50 test_mount
51 eval $(stat -s ${Mount_Point})
52 [ ${st_nlink} = 2 ] || \
53 atf_fail "Root directory does not have two hard links"
54 test_unmount
57 atf_test_case options
58 options_head() {
59 atf_set "descr" "Tests the read-only mount option"
60 atf_set "require.user" "root"
62 options_body() {
63 test_mount -o ro
64 mount | grep ${Mount_Point} | grep -q read-only || \
65 atf_fail "read-only option (ro) does not work"
66 test_unmount
69 atf_test_case attrs
70 attrs_head() {
71 atf_set "descr" "Tests that root directory attributes are set" \
72 "correctly"
73 atf_set "require.user" "root"
75 attrs_body() {
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"
81 test_unmount
84 atf_test_case negative
85 negative_head() {
86 atf_set "descr" "Tests that negative values passed to to -s are" \
87 "handled correctly"
88 atf_set "require.user" "root"
90 negative_body() {
91 mkdir tmp
92 test_mount -o -s-10
93 test_unmount
96 atf_test_case large
97 large_head() {
98 atf_set "descr" "Tests that extremely long values passed to -s" \
99 "are handled correctly"
100 atf_set "require.user" "root"
102 large_body() {
103 test_mount -o -s9223372036854775807
104 test_unmount
106 mkdir tmp
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
111 rmdir tmp
114 atf_test_case mntpt
115 mntpt_head() {
116 atf_set "descr" "Tests that the error messages printed when the" \
117 "mount point is invalid do not show the source" \
118 "unused parameter"
120 mntpt_body() {
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