| @@ -1,82 +1,82 @@ | | | @@ -1,82 +1,82 @@ |
1 | # $NetBSD: t_vnd.sh,v 1.10 2017/03/23 08:18:17 martin Exp $ | | 1 | # $NetBSD: t_vnd.sh,v 1.11 2021/06/05 06:40:59 gson Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. | | 3 | # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # Redistribution and use in source and binary forms, with or without | | 5 | # Redistribution and use in source and binary forms, with or without |
6 | # modification, are permitted provided that the following conditions | | 6 | # modification, are permitted provided that the following conditions |
7 | # are met: | | 7 | # are met: |
8 | # 1. Redistributions of source code must retain the above copyright | | 8 | # 1. Redistributions of source code must retain the above copyright |
9 | # notice, this list of conditions and the following disclaimer. | | 9 | # notice, this list of conditions and the following disclaimer. |
10 | # 2. Redistributions in binary form must reproduce the above copyright | | 10 | # 2. Redistributions in binary form must reproduce the above copyright |
11 | # notice, this list of conditions and the following disclaimer in the | | 11 | # notice, this list of conditions and the following disclaimer in the |
12 | # documentation and/or other materials provided with the distribution. | | 12 | # documentation and/or other materials provided with the distribution. |
13 | # | | 13 | # |
14 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 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 | | 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 | | 16 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 17 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
18 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 18 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 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 | | 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 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 | | 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
24 | # POSSIBILITY OF SUCH DAMAGE. | | 24 | # POSSIBILITY OF SUCH DAMAGE. |
25 | # | | 25 | # |
26 | | | 26 | |
27 | # | | 27 | # |
28 | # Verifies that vnd works with files stored in tmpfs. | | 28 | # Verifies that vnd works with files stored in tmpfs. |
29 | # | | 29 | # |
30 | | | 30 | |
31 | vnddev=vnd3 | | 31 | vnddev=vnd3 |
32 | rawpart=$( sysctl -n kern.rawpartition | tr '01234' 'abcde' ) | | 32 | rawpart=$( sysctl -n kern.rawpartition | tr '01234' 'abcde' ) |
33 | vnd=/dev/${vnddev}${rawpart} | | 33 | vnd=/dev/${vnddev}${rawpart} |
34 | | | 34 | |
35 | atf_test_case basic cleanup | | 35 | atf_test_case basic cleanup |
36 | basic_head() { | | 36 | basic_head() { |
37 | atf_set "descr" "Verifies that vnd works with files stored in tmpfs" | | 37 | atf_set "descr" "Verifies that vnd works with files stored in tmpfs" |
38 | atf_set "require.user" "root" | | 38 | atf_set "require.user" "root" |
39 | } | | 39 | } |
40 | basic_body() { | | 40 | basic_body() { |
41 | test_mount | | 41 | test_mount |
42 | | | 42 | |
43 | atf_check -s eq:0 -o ignore -e ignore \ | | 43 | atf_check -s eq:0 -o ignore -e ignore \ |
44 | dd if=/dev/zero of=disk.img bs=1m count=10 | | 44 | dd if=/dev/zero of=disk.img bs=1m count=10 |
45 | atf_check -s eq:0 -o empty -e empty vndconfig -c ${vnddev} disk.img | | 45 | atf_check -s eq:0 -o empty -e empty vndconfig -c ${vnddev} disk.img |
46 | | | 46 | |
47 | atf_check -s eq:0 -o ignore -e ignore newfs -I ${vnd} | | 47 | atf_check -s eq:0 -o ignore -e ignore newfs -I ${vnd} |
48 | | | 48 | |
49 | atf_check -s eq:0 -o empty -e empty mkdir mnt | | 49 | atf_check -s eq:0 -o empty -e empty mkdir mnt |
50 | atf_check -s eq:0 -o empty -e empty mount ${vnd} mnt | | 50 | atf_check -s eq:0 -o empty -e empty mount ${vnd} mnt |
51 | | | 51 | |
52 | echo "Creating test files" | | 52 | echo "Creating test files" |
53 | for f in $(jot -w %u 100 | uniq); do | | 53 | for f in $(jot -w %u 100 | uniq); do |
54 | jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}" | | 54 | jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}" |
55 | done | | 55 | done |
56 | | | 56 | |
57 | echo "Verifying created files" | | 57 | echo "Verifying created files" |
58 | for f in $(jot -w %u 100 | uniq); do | | 58 | for f in $(jot -w %u 100 | uniq); do |
59 | [ $(md5 mnt/${f} | cut -d ' ' -f 4) = \ | | 59 | [ $(md5 mnt/${f} | cut -d ' ' -f 4) = \ |
60 | 53d025127ae99ab79e8502aae2d9bea6 ] || \ | | 60 | 53d025127ae99ab79e8502aae2d9bea6 ] || \ |
61 | atf_fail "Invalid checksum for file ${f}" | | 61 | atf_fail "Invalid checksum for file ${f}" |
62 | done | | 62 | done |
63 | | | 63 | |
64 | atf_check -s eq:0 -o empty -e empty umount mnt | | 64 | atf_check -s eq:0 -o empty -e empty umount mnt |
65 | atf_check -s eq:0 -o empty -e empty vndconfig -u ${vnddev} | | 65 | atf_check -s eq:0 -o empty -e empty vndconfig -u ${vnddev} |
66 | | | 66 | |
67 | test_unmount | | 67 | test_unmount |
68 | touch done | | 68 | touch done |
69 | } | | 69 | } |
70 | basic_cleanup() { | | 70 | basic_cleanup() { |
71 | if [ ! -f done ]; then | | 71 | if [ ! -f done ]; then |
72 | umount mnt 2>/dev/null 1>&2 | | 72 | umount mntpt/mnt 2>/dev/null 1>&2 |
73 | vndconfig -u ${vnddev} 2>/dev/null 1>&2 | | 73 | vndconfig -u ${vnddev} 2>/dev/null 1>&2 |
74 | fi | | 74 | fi |
75 | } | | 75 | } |
76 | | | 76 | |
77 | atf_init_test_cases() { | | 77 | atf_init_test_cases() { |
78 | . $(atf_get_srcdir)/../h_funcs.subr | | 78 | . $(atf_get_srcdir)/../h_funcs.subr |
79 | . $(atf_get_srcdir)/h_funcs.subr | | 79 | . $(atf_get_srcdir)/h_funcs.subr |
80 | | | 80 | |
81 | atf_add_test_case basic | | 81 | atf_add_test_case basic |
82 | } | | 82 | } |