Home | History | Annotate | Line # | Download | only in tmpfs
t_mount.sh revision 1.1
      1 # $NetBSD: t_mount.sh,v 1.1 2007/11/12 15:18:24 jmmv Exp $
      2 #
      3 # Copyright (c) 2005, 2006, 2007 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 # 3. All advertising materials mentioning features or use of this software
     15 #    must display the following acknowledgement:
     16 #        This product includes software developed by the NetBSD
     17 #        Foundation, Inc. and its contributors.
     18 # 4. Neither the name of The NetBSD Foundation nor the names of its
     19 #    contributors may be used to endorse or promote products derived
     20 #    from this software without specific prior written permission.
     21 #
     22 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     23 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     24 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     25 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     26 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32 # POSSIBILITY OF SUCH DAMAGE.
     33 #
     34 
     35 #
     36 # Verifies that an execution of mount and umount works correctly without
     37 # causing errors and that the root node gets correct attributes.
     38 # Also verifies command line parsing from mount_tmpfs.
     39 #
     40 
     41 atf_test_case plain
     42 plain_head() {
     43 	atf_set "descr" "Tests a mount and unmount without any options"
     44 	atf_set "require.user" "root"
     45 }
     46 plain_body() {
     47 	test_mount
     48 	test_unmount
     49 }
     50 
     51 atf_test_case links
     52 links_head() {
     53 	atf_set "descr" "Tests that the mount point has two hard links"
     54 	atf_set "require.user" "root"
     55 }
     56 links_body() {
     57 	test_mount
     58 	eval $(stat -s ${Mount_Point})
     59 	[ ${st_nlink} = 2 ] || \
     60 	    atf_fail "Root directory does not have two hard links"
     61 	test_unmount
     62 }
     63 
     64 atf_test_case options
     65 options_head() {
     66 	atf_set "descr" "Tests the read-only mount option"
     67 	atf_set "require.user" "root"
     68 }
     69 options_body() {
     70 	test_mount -o ro
     71 	mount | grep ${Mount_Point} | grep -q read-only || \
     72 	    atf_fail "read-only option (ro) does not work"
     73 	test_unmount
     74 }
     75 
     76 atf_test_case attrs
     77 attrs_head() {
     78 	atf_set "descr" "Tests that root directory attributes are set" \
     79 	                "correctly"
     80 	atf_set "require.user" "root"
     81 }
     82 attrs_body() {
     83 	test_mount -o -u1000 -o -g100 -o -m755
     84 	eval $(stat -s ${Mount_Point})
     85 	[ ${st_uid} = 1000 ] || atf_fail "uid is incorrect"
     86 	[ ${st_gid} = 100 ] || atf_fail "gid is incorrect"
     87 	[ ${st_mode} = 040755 ] || atf_fail "mode is incorrect"
     88 	test_unmount
     89 }
     90 
     91 atf_test_case negative
     92 negative_head() {
     93 	atf_set "descr" "Tests that negative values passed to to -s are" \
     94 	                "handled correctly"
     95 	atf_set "require.user" "root"
     96 }
     97 negative_body() {
     98 	mkdir tmp
     99 	test_mount -o -s-10
    100 	test_unmount
    101 }
    102 
    103 atf_test_case large
    104 large_head() {
    105 	atf_set "descr" "Tests that extremely long values passed to -s" \
    106 	                "are handled correctly"
    107 	atf_set "require.user" "root"
    108 }
    109 large_body() {
    110 	test_mount -o -s9223372036854775807
    111 	test_unmount
    112 
    113 	mkdir tmp
    114 	atf_check "mount -t tmpfs -o -s9223372036854775808 tmpfs \
    115 	    tmp" 1 null ignore
    116 	atf_check "mount -t tmpfs -o -s9223372036854775808g tmpfs \
    117 	    tmp" 1 null ignore
    118 	rmdir tmp
    119 }
    120 
    121 atf_init_test_cases() {
    122 	. $(atf_get_srcdir)/../h_funcs.subr
    123 	. $(atf_get_srcdir)/h_funcs.subr
    124 
    125 	atf_add_test_case plain
    126 	atf_add_test_case options
    127 	atf_add_test_case attrs
    128 	atf_add_test_case negative
    129 	atf_add_test_case large
    130 }
    131