t_fss.sh revision 1.6 1 1.6 gutterid # $NetBSD: t_fss.sh,v 1.6 2023/05/11 01:56:31 gutteridge 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.1 pgoyette
45 1.3 martin # verify fss is available (or loadable as a module)
46 1.3 martin
47 1.3 martin fssconfig -l /dev/fss0 > /dev/null || atf_skip "FSS not available"
48 1.3 martin
49 1.1 pgoyette # create of mount-points for the file system and snapshot
50 1.1 pgoyette
51 1.1 pgoyette mkdir ./m1
52 1.1 pgoyette mkdir ./m2
53 1.1 pgoyette
54 1.1 pgoyette # create a small 4MB file, treat it as a disk, init a file-system on it,
55 1.1 pgoyette # and mount it
56 1.1 pgoyette
57 1.1 pgoyette dd if=/dev/zero of=./image bs=32k count=64
58 1.3 martin vndconfig -c ${vnddev} ./image
59 1.3 martin newfs -I ${vnd}
60 1.3 martin mount ${vnd} ./m1
61 1.1 pgoyette
62 1.1 pgoyette echo "${orig_data}" > ./m1/text
63 1.1 pgoyette
64 1.1 pgoyette # configure and mount a snapshot of the file system
65 1.1 pgoyette
66 1.1 pgoyette fssconfig -c fss0 ./m1 ./backup
67 1.2 pgoyette mount -o rdonly /dev/fss0 ./m2
68 1.1 pgoyette
69 1.1 pgoyette # Modify the data on the underlying file system
70 1.1 pgoyette
71 1.1 pgoyette echo "${repl_data}" > ./m1/text || abort
72 1.1 pgoyette
73 1.1 pgoyette # Verify that original data is still visible in the snapshot
74 1.1 pgoyette
75 1.1 pgoyette read test_data < ./m2/text
76 1.1 pgoyette atf_check_equal "${orig_data}" "${test_data}"
77 1.1 pgoyette }
78 1.1 pgoyette
79 1.1 pgoyette basic_cleanup() {
80 1.3 martin # Unmount our temporary stuff
81 1.4 simonb umount /dev/fss0 || true
82 1.4 simonb fssconfig -u fss0 || true
83 1.3 martin umount ${vnd} || true
84 1.3 martin vndconfig -u ${vnddev} || true
85 1.1 pgoyette }
86 1.1 pgoyette
87 1.1 pgoyette atf_init_test_cases()
88 1.1 pgoyette {
89 1.6 gutterid atf_add_test_case basic
90 1.1 pgoyette }
91