t_statvfs revision 204608
1230557Sjimharris#!/bin/sh
2230557Sjimharris#
3230557Sjimharris# $NetBSD: t_statvfs,v 1.4 2006/11/09 16:20:06 jmmv Exp $
4230557Sjimharris#
5230557Sjimharris# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
6230557Sjimharris# All rights reserved.
7230557Sjimharris#
8230557Sjimharris# This code is derived from software contributed to The NetBSD Foundation
9230557Sjimharris# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
10230557Sjimharris# 2005 program.
11230557Sjimharris#
12230557Sjimharris# Redistribution and use in source and binary forms, with or without
13230557Sjimharris# modification, are permitted provided that the following conditions
14230557Sjimharris# are met:
15230557Sjimharris# 1. Redistributions of source code must retain the above copyright
16230557Sjimharris#    notice, this list of conditions and the following disclaimer.
17230557Sjimharris# 2. Redistributions in binary form must reproduce the above copyright
18230557Sjimharris#    notice, this list of conditions and the following disclaimer in the
19230557Sjimharris#    documentation and/or other materials provided with the distribution.
20230557Sjimharris#
21230557Sjimharris# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22230557Sjimharris# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23230557Sjimharris# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24230557Sjimharris# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25230557Sjimharris# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26230557Sjimharris# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27230557Sjimharris# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28230557Sjimharris# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29230557Sjimharris# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30230557Sjimharris# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31230557Sjimharris# POSSIBILITY OF SUCH DAMAGE.
32230557Sjimharris#
33230557Sjimharris# $FreeBSD: head/tools/regression/tmpfs/t_statvfs 204608 2010-03-02 22:25:50Z joel $
34230557Sjimharris#
35230557Sjimharris
36230557Sjimharris#
37230557Sjimharris# Verifies that the statvfs system call works properly (returning the
38230557Sjimharris# correct values) over a tmpfs mount point.
39230557Sjimharris#
40230557Sjimharris
41230557Sjimharristest_run() {
42230557Sjimharris	test_mount -o size=10485760
43230557Sjimharris
44230557Sjimharris	test_name "statvfs(2) returns correct values"
45230557Sjimharris	pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 2)
46230557Sjimharris	eval $(${Src_Dir}/h_tools statvfs .)
47230557Sjimharris	[ ${pagesize} -eq ${f_bsize} ] || die
48230557Sjimharris	[ $((${f_bsize} * ${f_blocks})) -ge $((10 * 1024 * 1024)) ] || die
49230557Sjimharris	[ $((${f_bsize} * ${f_blocks})) -le \
50230557Sjimharris	    $((10 * 1024 * 1024 + ${pagesize})) ] || die
51230557Sjimharris
52230557Sjimharris	test_unmount
53230557Sjimharris}
54230557Sjimharris
55230557Sjimharris. ${SUBRDIR}/h_funcs.subr
56230557Sjimharris