xref: /freebsd/tools/regression/tmpfs/t_vnd (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
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#
20f8c94cecSXin LI# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21f8c94cecSXin LI# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22f8c94cecSXin LI# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23f8c94cecSXin LI# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24f8c94cecSXin LI# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25f8c94cecSXin LI# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26f8c94cecSXin LI# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27f8c94cecSXin LI# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28f8c94cecSXin LI# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29f8c94cecSXin LI# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30f8c94cecSXin LI# POSSIBILITY OF SUCH DAMAGE.
31f8c94cecSXin LI#
32f8c94cecSXin LI#
33f8c94cecSXin LI
34f8c94cecSXin LI#
35f8c94cecSXin LI# Verifies that vnd works with files stored in tmpfs.
36f8c94cecSXin LI#
37f8c94cecSXin LI
38f8c94cecSXin LIdie_mounted() {
39f8c94cecSXin LI	umount mnt
40f8c94cecSXin LI	die_configured
41f8c94cecSXin LI}
42f8c94cecSXin LI
43f8c94cecSXin LIdie_configured() {
44f8c94cecSXin LI	mdconfig -d -u 3
45f8c94cecSXin LI	die
46f8c94cecSXin LI}
47f8c94cecSXin LI
48f8c94cecSXin LItest_run() {
49f8c94cecSXin LI	test_mount
50f8c94cecSXin LI
51f8c94cecSXin LI	test_name "Creation of disk image"
52f8c94cecSXin LI	dd if=/dev/zero of=disk.img bs=1m count=10 >/dev/null 2>&1 || die
53f8c94cecSXin LI
54f8c94cecSXin LI	test_name "Configuration of vnd"
55f8c94cecSXin LI	mdconfig -a -f disk.img -u 3 -x 32 -y 2 ||die
56f8c94cecSXin LI
57f8c94cecSXin LI	test_name "Labelling the md"
58f8c94cecSXin LI	bsdlabel -m i386 -w /dev/md3 || die_configured
59f8c94cecSXin LI
60f8c94cecSXin LI	test_name "Formatting of disk image"
61f8c94cecSXin LI	newfs -n -U -m 0 -O 1 /dev/md3a >/dev/null 2>&1 || die_configured
62f8c94cecSXin LI
63f8c94cecSXin LI	test_name "Mounting of disk image"
64f8c94cecSXin LI	mkdir mnt || die
65f8c94cecSXin LI	mount /dev/md3a mnt || die_configured
66f8c94cecSXin LI
67f8c94cecSXin LI	test_name "Creation of several files"
68f8c94cecSXin LI	for f in $(jot 100); do
69f8c94cecSXin LI		jot 1000 >mnt/$f || die_mounted
70f8c94cecSXin LI	done
71f8c94cecSXin LI
72f8c94cecSXin LI	test_name "Verification of created files"
73f8c94cecSXin LI	for f in $(jot 100); do
74f8c94cecSXin LI		[ $(md5 mnt/$f | cut -d ' ' -f 4) = \
75f8c94cecSXin LI		    53d025127ae99ab79e8502aae2d9bea6 ] || die_mounted
76f8c94cecSXin LI	done
77f8c94cecSXin LI
78f8c94cecSXin LI	test_name "Unmounting of disk image"
79f8c94cecSXin LI	umount mnt || die_configured
80f8c94cecSXin LI
81f8c94cecSXin LI	test_name "Deconfiguration of vnd"
82f8c94cecSXin LI	mdconfig -d -u 3 || die
83f8c94cecSXin LI
84f8c94cecSXin LI	test_unmount
85f8c94cecSXin LI}
86f8c94cecSXin LI
87f8c94cecSXin LI. ${SUBRDIR}/h_funcs.subr
88