157718be8SEnji Cooper# $NetBSD: t_mount.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $ 257718be8SEnji Cooper# 357718be8SEnji Cooper# Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. 457718be8SEnji Cooper# All rights reserved. 557718be8SEnji Cooper# 657718be8SEnji Cooper# Redistribution and use in source and binary forms, with or without 757718be8SEnji Cooper# modification, are permitted provided that the following conditions 857718be8SEnji Cooper# are met: 957718be8SEnji Cooper# 1. Redistributions of source code must retain the above copyright 1057718be8SEnji Cooper# notice, this list of conditions and the following disclaimer. 1157718be8SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright 1257718be8SEnji Cooper# notice, this list of conditions and the following disclaimer in the 1357718be8SEnji Cooper# documentation and/or other materials provided with the distribution. 1457718be8SEnji Cooper# 1557718be8SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1657718be8SEnji Cooper# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1757718be8SEnji Cooper# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1857718be8SEnji Cooper# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 1957718be8SEnji Cooper# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2057718be8SEnji Cooper# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2157718be8SEnji Cooper# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2257718be8SEnji Cooper# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2357718be8SEnji Cooper# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2457718be8SEnji Cooper# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2557718be8SEnji Cooper# POSSIBILITY OF SUCH DAMAGE. 2657718be8SEnji Cooper# 2757718be8SEnji Cooper 2857718be8SEnji Cooper# 2957718be8SEnji Cooper# Verifies that an execution of mount and umount works correctly without 3057718be8SEnji Cooper# causing errors and that the root node gets correct attributes. 3157718be8SEnji Cooper# Also verifies command line parsing from mount_tmpfs. 3257718be8SEnji Cooper# 3357718be8SEnji Cooper 3457718be8SEnji Cooperatf_test_case plain 3557718be8SEnji Cooperplain_head() { 3657718be8SEnji Cooper atf_set "descr" "Tests a mount and unmount without any options" 3757718be8SEnji Cooper atf_set "require.user" "root" 3857718be8SEnji Cooper} 3957718be8SEnji Cooperplain_body() { 4057718be8SEnji Cooper test_mount 4157718be8SEnji Cooper test_unmount 4257718be8SEnji Cooper} 4357718be8SEnji Cooper 4457718be8SEnji Cooperatf_test_case links 4557718be8SEnji Cooperlinks_head() { 4657718be8SEnji Cooper atf_set "descr" "Tests that the mount point has two hard links" 4757718be8SEnji Cooper atf_set "require.user" "root" 4857718be8SEnji Cooper} 4957718be8SEnji Cooperlinks_body() { 5057718be8SEnji Cooper test_mount 5157718be8SEnji Cooper eval $(stat -s ${Mount_Point}) 5257718be8SEnji Cooper [ ${st_nlink} = 2 ] || \ 5357718be8SEnji Cooper atf_fail "Root directory does not have two hard links" 5457718be8SEnji Cooper test_unmount 5557718be8SEnji Cooper} 5657718be8SEnji Cooper 5757718be8SEnji Cooperatf_test_case options 5857718be8SEnji Cooperoptions_head() { 5957718be8SEnji Cooper atf_set "descr" "Tests the read-only mount option" 6057718be8SEnji Cooper atf_set "require.user" "root" 6157718be8SEnji Cooper} 6257718be8SEnji Cooperoptions_body() { 6357718be8SEnji Cooper test_mount -o ro 6457718be8SEnji Cooper mount | grep ${Mount_Point} | grep -q read-only || \ 6557718be8SEnji Cooper atf_fail "read-only option (ro) does not work" 6657718be8SEnji Cooper test_unmount 6757718be8SEnji Cooper} 6857718be8SEnji Cooper 6957718be8SEnji Cooperatf_test_case attrs 7057718be8SEnji Cooperattrs_head() { 7157718be8SEnji Cooper atf_set "descr" "Tests that root directory attributes are set" \ 7257718be8SEnji Cooper "correctly" 7357718be8SEnji Cooper atf_set "require.user" "root" 7457718be8SEnji Cooper} 7557718be8SEnji Cooperattrs_body() { 7657718be8SEnji Cooper test_mount -o -u1000 -o -g100 -o -m755 7757718be8SEnji Cooper eval $(stat -s ${Mount_Point}) 7857718be8SEnji Cooper [ ${st_uid} = 1000 ] || atf_fail "uid is incorrect" 7957718be8SEnji Cooper [ ${st_gid} = 100 ] || atf_fail "gid is incorrect" 8057718be8SEnji Cooper [ ${st_mode} = 040755 ] || atf_fail "mode is incorrect" 8157718be8SEnji Cooper test_unmount 8257718be8SEnji Cooper} 8357718be8SEnji Cooper 8457718be8SEnji Cooperatf_test_case negative 8557718be8SEnji Coopernegative_head() { 8657718be8SEnji Cooper atf_set "descr" "Tests that negative values passed to to -s are" \ 8757718be8SEnji Cooper "handled correctly" 8857718be8SEnji Cooper atf_set "require.user" "root" 8957718be8SEnji Cooper} 9057718be8SEnji Coopernegative_body() { 9157718be8SEnji Cooper mkdir tmp 9257718be8SEnji Cooper test_mount -o -s-10 9357718be8SEnji Cooper test_unmount 9457718be8SEnji Cooper} 9557718be8SEnji Cooper 96ac362860SEnji Cooper# Begin FreeBSD 97ac362860SEnji Cooperif true; then 98ac362860SEnji Cooperatf_test_case large cleanup 99ac362860SEnji Cooperlarge_cleanup() { 100*60fbebc3SEnji Cooper umount -f tmp 2>/dev/null || : 101*60fbebc3SEnji Cooper Mount_Point=$(pwd)/mnt _test_unmount || : 102ac362860SEnji Cooper} 103ac362860SEnji Cooperelse 104ac362860SEnji Cooper# End FreeBSD 10557718be8SEnji Cooperatf_test_case large 106ac362860SEnji Cooper# Begin FreeBSD 107ac362860SEnji Cooperfi 108ac362860SEnji Cooper# End FreeBSD 10957718be8SEnji Cooperlarge_head() { 11057718be8SEnji Cooper atf_set "descr" "Tests that extremely long values passed to -s" \ 11157718be8SEnji Cooper "are handled correctly" 11257718be8SEnji Cooper atf_set "require.user" "root" 11357718be8SEnji Cooper} 11457718be8SEnji Cooperlarge_body() { 11557718be8SEnji Cooper test_mount -o -s9223372036854775807 11657718be8SEnji Cooper test_unmount 11757718be8SEnji Cooper 118ac362860SEnji Cooper # Begin FreeBSD 119ac362860SEnji Cooper atf_expect_fail "-o -s<large-size> succeeds unexpectedly on FreeBSD - bug 212862" 120ac362860SEnji Cooper # End FreeBSD 121ac362860SEnji Cooper 12257718be8SEnji Cooper mkdir tmp 12357718be8SEnji Cooper atf_check -s eq:1 -o empty -e ignore \ 12457718be8SEnji Cooper mount -t tmpfs -o -s9223372036854775808 tmpfs tmp 12557718be8SEnji Cooper atf_check -s eq:1 -o empty -e ignore \ 12657718be8SEnji Cooper mount -t tmpfs -o -s9223372036854775808g tmpfs tmp 12757718be8SEnji Cooper rmdir tmp 12857718be8SEnji Cooper} 12957718be8SEnji Cooper 13057718be8SEnji Cooperatf_test_case mntpt 13157718be8SEnji Coopermntpt_head() { 13257718be8SEnji Cooper atf_set "descr" "Tests that the error messages printed when the" \ 13357718be8SEnji Cooper "mount point is invalid do not show the source" \ 13457718be8SEnji Cooper "unused parameter" 13557718be8SEnji Cooper} 13657718be8SEnji Coopermntpt_body() { 13757718be8SEnji Cooper mount_tmpfs unused $(pwd)/mnt >out 2>&1 13857718be8SEnji Cooper atf_check -s eq:1 -o empty -e empty grep unused out 13957718be8SEnji Cooper atf_check -s eq:0 -o ignore -e empty grep "$(pwd)/mnt" out 14057718be8SEnji Cooper 14157718be8SEnji Cooper mount_tmpfs unused mnt >out 2>&1 14257718be8SEnji Cooper atf_check -s eq:1 -o empty -e empty grep unused out 14357718be8SEnji Cooper atf_check -s eq:0 -o ignore -e empty grep mnt out 14457718be8SEnji Cooper} 14557718be8SEnji Cooper 14657718be8SEnji Cooperatf_init_test_cases() { 14757718be8SEnji Cooper . $(atf_get_srcdir)/../h_funcs.subr 14857718be8SEnji Cooper . $(atf_get_srcdir)/h_funcs.subr 14957718be8SEnji Cooper 15057718be8SEnji Cooper atf_add_test_case plain 15157718be8SEnji Cooper atf_add_test_case options 15257718be8SEnji Cooper atf_add_test_case attrs 15357718be8SEnji Cooper atf_add_test_case negative 15457718be8SEnji Cooper atf_add_test_case large 15557718be8SEnji Cooper atf_add_test_case mntpt 15657718be8SEnji Cooper} 157