t_fss.sh revision 1.7 1 1.7 rin # $NetBSD: t_fss.sh,v 1.7 2025/04/19 02:07:43 rin Exp $
2 1.1 pgoyette #
3 1.1 pgoyette # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
4 1.1 pgoyette # All rights reserved.
5 1.1 pgoyette # Redistribution and use in source and binary forms, with or without
6 1.1 pgoyette # modification, are permitted provided that the following conditions
7 1.1 pgoyette # are met:
8 1.1 pgoyette # 1. Redistributions of source code must retain the above copyright
9 1.1 pgoyette # notice, this list of conditions and the following disclaimer.
10 1.1 pgoyette # 2. Redistributions in binary form must reproduce the above copyright
11 1.1 pgoyette # notice, this list of conditions and the following disclaimer in the
12 1.1 pgoyette # documentation and/or other materials provided with the distribution.
13 1.1 pgoyette #
14 1.1 pgoyette # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
15 1.1 pgoyette # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16 1.1 pgoyette # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 1.1 pgoyette # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
18 1.1 pgoyette # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 1.1 pgoyette # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 1.1 pgoyette # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 1.1 pgoyette # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 1.1 pgoyette # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 1.1 pgoyette # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 1.1 pgoyette # POSSIBILITY OF SUCH DAMAGE.
25 1.1 pgoyette #
26 1.1 pgoyette
27 1.1 pgoyette #
28 1.1 pgoyette # Verify basic operation of fss(4) file system snapshot device
29 1.1 pgoyette #
30 1.1 pgoyette
31 1.3 martin vnddev=vnd0
32 1.5 martin vnd=/dev/${vnddev}
33 1.3 martin
34 1.1 pgoyette orig_data="Original data"
35 1.1 pgoyette repl_data="Replacement data"
36 1.1 pgoyette
37 1.1 pgoyette atf_test_case basic cleanup
38 1.6 gutterid basic_head() {
39 1.6 gutterid atf_set "descr" "Verify basic operation of fss(4) file system " \
40 1.6 gutterid "snapshot device"
41 1.6 gutterid }
42 1.6 gutterid
43 1.1 pgoyette basic_body() {
44 1.7 rin if [ $(uname -p) = vax ]; then
45 1.7 rin atf_skip "port-vax/59287 vnd(4) can cause kernel crash"
46 1.7 rin fi
47 1.1 pgoyette
48 1.3 martin # verify fss is available (or loadable as a module)
49 1.3 martin
50 1.3 martin fssconfig -l /dev/fss0 > /dev/null || atf_skip "FSS not available"
51 1.3 martin
52 1.1 pgoyette # create of mount-points for the file system and snapshot
53 1.1 pgoyette
54 1.1 pgoyette mkdir ./m1
55 1.1 pgoyette mkdir ./m2
56 1.1 pgoyette
57 1.1 pgoyette # create a small 4MB file, treat it as a disk, init a file-system on it,
58 1.1 pgoyette # and mount it
59 1.1 pgoyette
60 1.1 pgoyette dd if=/dev/zero of=./image bs=32k count=64
61 1.3 martin vndconfig -c ${vnddev} ./image
62 1.3 martin newfs -I ${vnd}
63 1.3 martin mount ${vnd} ./m1
64 1.1 pgoyette
65 1.1 pgoyette echo "${orig_data}" > ./m1/text
66 1.1 pgoyette
67 1.1 pgoyette # configure and mount a snapshot of the file system
68 1.1 pgoyette
69 1.1 pgoyette fssconfig -c fss0 ./m1 ./backup
70 1.2 pgoyette mount -o rdonly /dev/fss0 ./m2
71 1.1 pgoyette
72 1.1 pgoyette # Modify the data on the underlying file system
73 1.1 pgoyette
74 1.1 pgoyette echo "${repl_data}" > ./m1/text || abort
75 1.1 pgoyette
76 1.1 pgoyette # Verify that original data is still visible in the snapshot
77 1.1 pgoyette
78 1.1 pgoyette read test_data < ./m2/text
79 1.1 pgoyette atf_check_equal "${orig_data}" "${test_data}"
80 1.1 pgoyette }
81 1.1 pgoyette
82 1.1 pgoyette basic_cleanup() {
83 1.3 martin # Unmount our temporary stuff
84 1.4 simonb umount /dev/fss0 || true
85 1.4 simonb fssconfig -u fss0 || true
86 1.3 martin umount ${vnd} || true
87 1.3 martin vndconfig -u ${vnddev} || true
88 1.1 pgoyette }
89 1.1 pgoyette
90 1.1 pgoyette atf_init_test_cases()
91 1.1 pgoyette {
92 1.6 gutterid atf_add_test_case basic
93 1.1 pgoyette }
94