xref: /netbsd-src/tests/fs/tmpfs/t_vnd.sh (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1# $NetBSD: t_vnd.sh,v 1.1 2007/11/12 15:18:28 jmmv 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# 3. All advertising materials mentioning features or use of this software
14#    must display the following acknowledgement:
15#        This product includes software developed by the NetBSD
16#        Foundation, Inc. and its contributors.
17# 4. Neither the name of The NetBSD Foundation nor the names of its
18#    contributors may be used to endorse or promote products derived
19#    from this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31# POSSIBILITY OF SUCH DAMAGE.
32#
33
34#
35# Verifies that vnd works with files stored in tmpfs.
36#
37
38atf_test_case basic
39basic_head() {
40	atf_set "descr" "Verifies that vnd works with files stored in tmpfs"
41	atf_set "require.user" "root"
42}
43basic_body() {
44	test_mount
45
46	atf_check 'dd if=/dev/zero of=disk.img bs=1m count=10' 0 ignore ignore
47	atf_check 'vnconfig /dev/vnd3 disk.img' 0 null null
48
49	atf_check 'newfs /dev/rvnd3a' 0 ignore ignore
50
51	atf_check 'mkdir mnt' 0 null null
52	atf_check 'mount /dev/vnd3a mnt' 0 null null
53
54	echo "Creating test files"
55	for f in $(jot 100); do
56		jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}"
57	done
58
59	echo "Verifying created files"
60	for f in $(jot 100); do
61		[ $(md5 mnt/${f} | cut -d ' ' -f 4) = \
62		    53d025127ae99ab79e8502aae2d9bea6 ] || \
63		    atf_fail "Invalid checksum for file ${f}"
64	done
65
66	atf_check 'umount mnt' 0 null null
67	atf_check 'vnconfig -u /dev/vnd3' 0 null null
68
69	test_unmount
70}
71basic_cleanup() {
72	umount mnt 2>/dev/null 1>&2
73	vnconfig -u /dev/vnd3 2>/dev/null 1>&2
74}
75
76atf_init_test_cases() {
77	. $(atf_get_srcdir)/../h_funcs.subr
78	. $(atf_get_srcdir)/h_funcs.subr
79
80	atf_add_test_case basic
81}
82