1*f8c94cecSXin LI#!/bin/sh 2*f8c94cecSXin LI# 3*f8c94cecSXin LI# $NetBSD: t_vnd,v 1.1 2006/11/09 15:25:37 jmmv Exp $ 4*f8c94cecSXin LI# 5*f8c94cecSXin LI# Copyright (c) 2006 The NetBSD Foundation, Inc. 6*f8c94cecSXin LI# All rights reserved. 7*f8c94cecSXin LI# 8*f8c94cecSXin LI# This code is derived from software contributed to The NetBSD Foundation 9*f8c94cecSXin LI# by Julio M. Merino Vidal. 10*f8c94cecSXin LI# 11*f8c94cecSXin LI# Redistribution and use in source and binary forms, with or without 12*f8c94cecSXin LI# modification, are permitted provided that the following conditions 13*f8c94cecSXin LI# are met: 14*f8c94cecSXin LI# 1. Redistributions of source code must retain the above copyright 15*f8c94cecSXin LI# notice, this list of conditions and the following disclaimer. 16*f8c94cecSXin LI# 2. Redistributions in binary form must reproduce the above copyright 17*f8c94cecSXin LI# notice, this list of conditions and the following disclaimer in the 18*f8c94cecSXin LI# documentation and/or other materials provided with the distribution. 19*f8c94cecSXin LI# 20*f8c94cecSXin LI# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21*f8c94cecSXin LI# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22*f8c94cecSXin LI# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23*f8c94cecSXin LI# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24*f8c94cecSXin LI# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25*f8c94cecSXin LI# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26*f8c94cecSXin LI# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27*f8c94cecSXin LI# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28*f8c94cecSXin LI# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29*f8c94cecSXin LI# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30*f8c94cecSXin LI# POSSIBILITY OF SUCH DAMAGE. 31*f8c94cecSXin LI# 32*f8c94cecSXin LI# 33*f8c94cecSXin LI 34*f8c94cecSXin LI# 35*f8c94cecSXin LI# Verifies that vnd works with files stored in tmpfs. 36*f8c94cecSXin LI# 37*f8c94cecSXin LI 38*f8c94cecSXin LIdie_mounted() { 39*f8c94cecSXin LI umount mnt 40*f8c94cecSXin LI die_configured 41*f8c94cecSXin LI} 42*f8c94cecSXin LI 43*f8c94cecSXin LIdie_configured() { 44*f8c94cecSXin LI mdconfig -d -u 3 45*f8c94cecSXin LI die 46*f8c94cecSXin LI} 47*f8c94cecSXin LI 48*f8c94cecSXin LItest_run() { 49*f8c94cecSXin LI test_mount 50*f8c94cecSXin LI 51*f8c94cecSXin LI test_name "Creation of disk image" 52*f8c94cecSXin LI dd if=/dev/zero of=disk.img bs=1m count=10 >/dev/null 2>&1 || die 53*f8c94cecSXin LI 54*f8c94cecSXin LI test_name "Configuration of vnd" 55*f8c94cecSXin LI mdconfig -a -f disk.img -u 3 -x 32 -y 2 ||die 56*f8c94cecSXin LI 57*f8c94cecSXin LI test_name "Labelling the md" 58*f8c94cecSXin LI bsdlabel -m i386 -w /dev/md3 || die_configured 59*f8c94cecSXin LI 60*f8c94cecSXin LI test_name "Formatting of disk image" 61*f8c94cecSXin LI newfs -n -U -m 0 -O 1 /dev/md3a >/dev/null 2>&1 || die_configured 62*f8c94cecSXin LI 63*f8c94cecSXin LI test_name "Mounting of disk image" 64*f8c94cecSXin LI mkdir mnt || die 65*f8c94cecSXin LI mount /dev/md3a mnt || die_configured 66*f8c94cecSXin LI 67*f8c94cecSXin LI test_name "Creation of several files" 68*f8c94cecSXin LI for f in $(jot 100); do 69*f8c94cecSXin LI jot 1000 >mnt/$f || die_mounted 70*f8c94cecSXin LI done 71*f8c94cecSXin LI 72*f8c94cecSXin LI test_name "Verification of created files" 73*f8c94cecSXin LI for f in $(jot 100); do 74*f8c94cecSXin LI [ $(md5 mnt/$f | cut -d ' ' -f 4) = \ 75*f8c94cecSXin LI 53d025127ae99ab79e8502aae2d9bea6 ] || die_mounted 76*f8c94cecSXin LI done 77*f8c94cecSXin LI 78*f8c94cecSXin LI test_name "Unmounting of disk image" 79*f8c94cecSXin LI umount mnt || die_configured 80*f8c94cecSXin LI 81*f8c94cecSXin LI test_name "Deconfiguration of vnd" 82*f8c94cecSXin LI mdconfig -d -u 3 || die 83*f8c94cecSXin LI 84*f8c94cecSXin LI test_unmount 85*f8c94cecSXin LI} 86*f8c94cecSXin LI 87*f8c94cecSXin LI. ${SUBRDIR}/h_funcs.subr 88