]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/netbsd-tests/fs/tmpfs/t_vnd.sh
MFC r309774,r309778,r309779,r309780:
[FreeBSD/stable/10.git] / contrib / netbsd-tests / fs / tmpfs / t_vnd.sh
1 # $NetBSD: t_vnd.sh,v 1.9 2016/07/29 05:23:24 pgoyette Exp $
2 #
3 # Copyright (c) 2006, 2007, 2008 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
31 atf_test_case basic cleanup
32 basic_head() {
33         atf_set "descr" "Verifies that vnd works with files stored in tmpfs"
34         atf_set "require.user" "root"
35 }
36 basic_body() {
37         test_mount
38
39         atf_check -s eq:0 -o ignore -e ignore \
40             dd if=/dev/zero of=disk.img bs=1m count=10
41         # Begin FreeBSD
42         if true; then
43                 atf_check -s eq:0 -o empty -e empty mkdir mnt
44                 atf_check -s eq:0 -o empty -e empty mdmfs -F disk.img md3 mnt
45         else
46         # End FreeBSD
47         atf_check -s eq:0 -o empty -e empty vndconfig /dev/vnd3 disk.img
48
49         atf_check -s eq:0 -o ignore -e ignore newfs /dev/rvnd3a
50
51         atf_check -s eq:0 -o empty -e empty mkdir mnt
52         atf_check -s eq:0 -o empty -e empty mount /dev/vnd3a mnt
53         # Begin FreeBSD
54         fi
55         # End FreeBSD
56
57         echo "Creating test files"
58         for f in $(jot -w %u 100 | uniq); do
59                 jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}"
60         done
61
62         echo "Verifying created files"
63         for f in $(jot -w %u 100 | uniq); do
64                 [ $(md5 mnt/${f} | cut -d ' ' -f 4) = \
65                     53d025127ae99ab79e8502aae2d9bea6 ] || \
66                     atf_fail "Invalid checksum for file ${f}"
67         done
68
69         atf_check -s eq:0 -o empty -e empty umount mnt
70         # Begin FreeBSD
71         if true; then
72                 atf_check -s eq:0 -o empty -e empty mdconfig -d -u 3
73         else
74         # End FreeBSD
75         atf_check -s eq:0 -o empty -e empty vndconfig -u /dev/vnd3
76         # Begin FreeBSD
77         fi
78         # End FreeBSD
79
80         test_unmount
81         touch done
82 }
83 basic_cleanup() {
84         if [ ! -f done ]; then
85                 umount mnt 2>/dev/null 1>&2
86                 # Begin FreeBSD
87                 if true; then
88                         [ ! -c /dev/md3 ] || mdconfig -d -u 3
89                 else
90                 # End FreeBSD
91                 vndconfig -u /dev/vnd3 2>/dev/null 1>&2
92                 # Begin FreeBSD
93                 fi
94                 # End FreeBSD
95         fi
96 }
97
98 atf_init_test_cases() {
99         . $(atf_get_srcdir)/../h_funcs.subr
100         . $(atf_get_srcdir)/h_funcs.subr
101
102         atf_add_test_case basic
103 }