xref: /freebsd/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh (revision 8c4282b370bd66908b45b6a223226a9fc2b69d57)
157718be8SEnji Cooper# $NetBSD: t_statvfs.sh,v 1.4 2010/11/07 17:51:18 jmmv Exp $
257718be8SEnji Cooper#
357718be8SEnji Cooper# Copyright (c) 2005, 2006, 2007 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 the statvfs system call works properly (returning the
3057718be8SEnji Cooper# correct values) over a tmpfs mount point.
3157718be8SEnji Cooper#
3257718be8SEnji Cooper
3357718be8SEnji Cooperatf_test_case values
3457718be8SEnji Coopervalues_head() {
3557718be8SEnji Cooper	atf_set "descr" "Tests that statvfs(2) returns correct values"
3657718be8SEnji Cooper	atf_set "require.user" "root"
3757718be8SEnji Cooper}
3857718be8SEnji Coopervalues_body() {
3957718be8SEnji Cooper	test_mount -o -s10M
4057718be8SEnji Cooper
41*548f948aSEnji Cooper	# Begin FreeBSD
42*548f948aSEnji Cooper	if true; then
43*548f948aSEnji Cooper		pagesize=$(sysctl -n hw.pagesize)
44*548f948aSEnji Cooper	else
45*548f948aSEnji Cooper	# End FreeBSD
4657718be8SEnji Cooper	pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
47*548f948aSEnji Cooper	# Begin FreeBSD
48*548f948aSEnji Cooper	fi
49*548f948aSEnji Cooper	# End FreeBSD
5057718be8SEnji Cooper	eval $($(atf_get_srcdir)/h_tools statvfs .)
5157718be8SEnji Cooper	[ ${pagesize} -eq ${f_bsize} ] || \
5257718be8SEnji Cooper	    atf_fail "Invalid bsize"
5357718be8SEnji Cooper	[ $((${f_bsize} * ${f_blocks})) -ge $((10 * 1024 * 1024)) ] || \
5457718be8SEnji Cooper	    atf_file "bsize * blocks too small"
5557718be8SEnji Cooper	[ $((${f_bsize} * ${f_blocks})) -le \
5657718be8SEnji Cooper	    $((10 * 1024 * 1024 + ${pagesize})) ] || \
5757718be8SEnji Cooper	    atf_fail "bsize * blocks too big"
5857718be8SEnji Cooper
5957718be8SEnji Cooper	test_unmount
6057718be8SEnji Cooper}
6157718be8SEnji Cooper
6257718be8SEnji Cooperatf_init_test_cases() {
6357718be8SEnji Cooper	. $(atf_get_srcdir)/../h_funcs.subr
6457718be8SEnji Cooper	. $(atf_get_srcdir)/h_funcs.subr
6557718be8SEnji Cooper
6657718be8SEnji Cooper	atf_add_test_case values
6757718be8SEnji Cooper}
68