t_mount.sh revision 302408
1# $NetBSD: t_mount.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $ 2# 3# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. 4# All rights reserved. 5# 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. 14# 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. 26# 27 28# 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. 32# 33 34atf_test_case plain 35plain_head() { 36 atf_set "descr" "Tests a mount and unmount without any options" 37 atf_set "require.user" "root" 38} 39plain_body() { 40 test_mount 41 test_unmount 42} 43 44atf_test_case links 45links_head() { 46 atf_set "descr" "Tests that the mount point has two hard links" 47 atf_set "require.user" "root" 48} 49links_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 55} 56 57atf_test_case options 58options_head() { 59 atf_set "descr" "Tests the read-only mount option" 60 atf_set "require.user" "root" 61} 62options_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 67} 68 69atf_test_case attrs 70attrs_head() { 71 atf_set "descr" "Tests that root directory attributes are set" \ 72 "correctly" 73 atf_set "require.user" "root" 74} 75attrs_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 82} 83 84atf_test_case negative 85negative_head() { 86 atf_set "descr" "Tests that negative values passed to to -s are" \ 87 "handled correctly" 88 atf_set "require.user" "root" 89} 90negative_body() { 91 mkdir tmp 92 test_mount -o -s-10 93 test_unmount 94} 95 96atf_test_case large 97large_head() { 98 atf_set "descr" "Tests that extremely long values passed to -s" \ 99 "are handled correctly" 100 atf_set "require.user" "root" 101} 102large_body() { 103 test_mount -o -s9223372036854775807 104 test_unmount 105 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 112} 113 114atf_test_case mntpt 115mntpt_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" 119} 120mntpt_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 124 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 128} 129 130atf_init_test_cases() { 131 . $(atf_get_srcdir)/../h_funcs.subr 132 . $(atf_get_srcdir)/h_funcs.subr 133 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 140} 141