1170809Sdelphij#!/bin/sh
2170809Sdelphij#
3171801Sdelphij# $NetBSD: t_mount,v 1.8 2007/07/24 11:29:16 jmmv Exp $
4170809Sdelphij#
5171801Sdelphij# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
6170809Sdelphij# All rights reserved.
7170809Sdelphij#
8170809Sdelphij# This code is derived from software contributed to The NetBSD Foundation
9170809Sdelphij# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
10170809Sdelphij# 2005 program.
11170809Sdelphij#
12170809Sdelphij# Redistribution and use in source and binary forms, with or without
13170809Sdelphij# modification, are permitted provided that the following conditions
14170809Sdelphij# are met:
15170809Sdelphij# 1. Redistributions of source code must retain the above copyright
16170809Sdelphij#    notice, this list of conditions and the following disclaimer.
17170809Sdelphij# 2. Redistributions in binary form must reproduce the above copyright
18170809Sdelphij#    notice, this list of conditions and the following disclaimer in the
19170809Sdelphij#    documentation and/or other materials provided with the distribution.
20170809Sdelphij#
21170809Sdelphij# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22170809Sdelphij# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23170809Sdelphij# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24170809Sdelphij# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25170809Sdelphij# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26170809Sdelphij# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27170809Sdelphij# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28170809Sdelphij# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29170809Sdelphij# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30170809Sdelphij# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31170809Sdelphij# POSSIBILITY OF SUCH DAMAGE.
32170809Sdelphij#
33170809Sdelphij# $FreeBSD$
34170809Sdelphij#
35170809Sdelphij
36170809Sdelphij#
37170809Sdelphij# Verifies that an execution of mount and umount works correctly without
38170809Sdelphij# causing errors and that the root node gets correct attributes.
39170809Sdelphij# Also verifies command line parsing from mount_tmpfs.
40170809Sdelphij#
41170809Sdelphij
42170809Sdelphijtest_run() {
43170809Sdelphij	test_name "File-system can be mounted"
44170809Sdelphij	test_mount
45170809Sdelphij	test_name "Root directory has two links"
46170809Sdelphij	eval $(stat -s ${Work_Dir})
47170809Sdelphij	[ ${st_nlink} = 2 ] || die
48170809Sdelphij	test_name "File-system can be unmounted"
49170809Sdelphij	test_unmount
50170809Sdelphij
51170809Sdelphij	test_name "File-system mount options work"
52170809Sdelphij	test_mount -o ro
53170809Sdelphij	mount | grep ${Work_Dir} | grep -q read-only || die
54170809Sdelphij	test_unmount
55170809Sdelphij
56170809Sdelphij	test_name "Root directory attributes are set correctly"
57170809Sdelphij	test_mount -o "uid=1000,gid=100,mode=755"
58170809Sdelphij	eval $(stat -s ${Work_Dir})
59170809Sdelphij	[ ${st_uid} = 1000 ] || die
60170809Sdelphij	[ ${st_gid} = 100 ] || die
61170809Sdelphij	[ ${st_mode} = 040755 ] || die
62170809Sdelphij	test_unmount
63170809Sdelphij
64170809Sdelphij	test_name "Negative values are correctly handled"
65170809Sdelphij	test_mount -o "size=-10"
66170809Sdelphij	test_unmount
67170809Sdelphij
68170809Sdelphij	test_name "Extremely large values are correctly handled"
69170809Sdelphij	test_mount -o size=9223372036854775807
70170809Sdelphij	test_unmount
71170809Sdelphij	mount -t tmpfs -o size=9223372036854775808 tmpfs ${Work_Dir} \
72170809Sdelphij	    2>/dev/null && die
73170809Sdelphij	mount -t tmpfs -o size=9223372036854775808g tmpfs ${Work_Dir} \
74170809Sdelphij	    2>/dev/null && die
75170809Sdelphij	rmdir ${Work_Dir}
76170809Sdelphij}
77170809Sdelphij
78170809Sdelphij. ${SUBRDIR}/h_funcs.subr
79