t_vnd.sh revision 1.1
11.1Sjmmv# $NetBSD: t_vnd.sh,v 1.1 2007/11/12 15:18:28 jmmv Exp $
21.1Sjmmv#
31.1Sjmmv# Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
41.1Sjmmv# All rights reserved.
51.1Sjmmv# Redistribution and use in source and binary forms, with or without
61.1Sjmmv# modification, are permitted provided that the following conditions
71.1Sjmmv# are met:
81.1Sjmmv# 1. Redistributions of source code must retain the above copyright
91.1Sjmmv#    notice, this list of conditions and the following disclaimer.
101.1Sjmmv# 2. Redistributions in binary form must reproduce the above copyright
111.1Sjmmv#    notice, this list of conditions and the following disclaimer in the
121.1Sjmmv#    documentation and/or other materials provided with the distribution.
131.1Sjmmv# 3. All advertising materials mentioning features or use of this software
141.1Sjmmv#    must display the following acknowledgement:
151.1Sjmmv#        This product includes software developed by the NetBSD
161.1Sjmmv#        Foundation, Inc. and its contributors.
171.1Sjmmv# 4. Neither the name of The NetBSD Foundation nor the names of its
181.1Sjmmv#    contributors may be used to endorse or promote products derived
191.1Sjmmv#    from this software without specific prior written permission.
201.1Sjmmv#
211.1Sjmmv# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
221.1Sjmmv# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
231.1Sjmmv# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
241.1Sjmmv# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
251.1Sjmmv# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
261.1Sjmmv# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
271.1Sjmmv# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
281.1Sjmmv# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
291.1Sjmmv# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
301.1Sjmmv# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
311.1Sjmmv# POSSIBILITY OF SUCH DAMAGE.
321.1Sjmmv#
331.1Sjmmv
341.1Sjmmv#
351.1Sjmmv# Verifies that vnd works with files stored in tmpfs.
361.1Sjmmv#
371.1Sjmmv
381.1Sjmmvatf_test_case basic
391.1Sjmmvbasic_head() {
401.1Sjmmv	atf_set "descr" "Verifies that vnd works with files stored in tmpfs"
411.1Sjmmv	atf_set "require.user" "root"
421.1Sjmmv}
431.1Sjmmvbasic_body() {
441.1Sjmmv	test_mount
451.1Sjmmv
461.1Sjmmv	atf_check 'dd if=/dev/zero of=disk.img bs=1m count=10' 0 ignore ignore
471.1Sjmmv	atf_check 'vnconfig /dev/vnd3 disk.img' 0 null null
481.1Sjmmv
491.1Sjmmv	atf_check 'newfs /dev/rvnd3a' 0 ignore ignore
501.1Sjmmv
511.1Sjmmv	atf_check 'mkdir mnt' 0 null null
521.1Sjmmv	atf_check 'mount /dev/vnd3a mnt' 0 null null
531.1Sjmmv
541.1Sjmmv	echo "Creating test files"
551.1Sjmmv	for f in $(jot 100); do
561.1Sjmmv		jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}"
571.1Sjmmv	done
581.1Sjmmv
591.1Sjmmv	echo "Verifying created files"
601.1Sjmmv	for f in $(jot 100); do
611.1Sjmmv		[ $(md5 mnt/${f} | cut -d ' ' -f 4) = \
621.1Sjmmv		    53d025127ae99ab79e8502aae2d9bea6 ] || \
631.1Sjmmv		    atf_fail "Invalid checksum for file ${f}"
641.1Sjmmv	done
651.1Sjmmv
661.1Sjmmv	atf_check 'umount mnt' 0 null null
671.1Sjmmv	atf_check 'vnconfig -u /dev/vnd3' 0 null null
681.1Sjmmv
691.1Sjmmv	test_unmount
701.1Sjmmv}
711.1Sjmmvbasic_cleanup() {
721.1Sjmmv	umount mnt 2>/dev/null 1>&2
731.1Sjmmv	vnconfig -u /dev/vnd3 2>/dev/null 1>&2
741.1Sjmmv}
751.1Sjmmv
761.1Sjmmvatf_init_test_cases() {
771.1Sjmmv	. $(atf_get_srcdir)/../h_funcs.subr
781.1Sjmmv	. $(atf_get_srcdir)/h_funcs.subr
791.1Sjmmv
801.1Sjmmv	atf_add_test_case basic
811.1Sjmmv}
82