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