1# $NetBSD: t_vnd.sh,v 1.2 2008/04/30 13:11:00 martin Exp $ 2# 3# Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. 4# All rights reserved. 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 15# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 18# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24# POSSIBILITY OF SUCH DAMAGE. 25# 26 27# 28# Verifies that vnd works with files stored in tmpfs. 29# 30 31atf_test_case basic 32basic_head() { 33 atf_set "descr" "Verifies that vnd works with files stored in tmpfs" 34 atf_set "require.user" "root" 35} 36basic_body() { 37 test_mount 38 39 atf_check 'dd if=/dev/zero of=disk.img bs=1m count=10' 0 ignore ignore 40 atf_check 'vnconfig /dev/vnd3 disk.img' 0 null null 41 42 atf_check 'newfs /dev/rvnd3a' 0 ignore ignore 43 44 atf_check 'mkdir mnt' 0 null null 45 atf_check 'mount /dev/vnd3a mnt' 0 null null 46 47 echo "Creating test files" 48 for f in $(jot 100); do 49 jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}" 50 done 51 52 echo "Verifying created files" 53 for f in $(jot 100); do 54 [ $(md5 mnt/${f} | cut -d ' ' -f 4) = \ 55 53d025127ae99ab79e8502aae2d9bea6 ] || \ 56 atf_fail "Invalid checksum for file ${f}" 57 done 58 59 atf_check 'umount mnt' 0 null null 60 atf_check 'vnconfig -u /dev/vnd3' 0 null null 61 62 test_unmount 63} 64basic_cleanup() { 65 umount mnt 2>/dev/null 1>&2 66 vnconfig -u /dev/vnd3 2>/dev/null 1>&2 67} 68 69atf_init_test_cases() { 70 . $(atf_get_srcdir)/../h_funcs.subr 71 . $(atf_get_srcdir)/h_funcs.subr 72 73 atf_add_test_case basic 74} 75