t_fss.sh revision 1.4 1 1.4 simonb # $NetBSD: t_fss.sh,v 1.4 2021/01/14 04:30:40 simonb 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.3 martin rawpart=$( sysctl -n kern.rawpartition | tr '01234' 'abcde' )
33 1.3 martin vnd=/dev/${vnddev}${rawpart}
34 1.3 martin
35 1.1 pgoyette orig_data="Original data"
36 1.1 pgoyette repl_data="Replacement data"
37 1.1 pgoyette
38 1.1 pgoyette atf_test_case basic cleanup
39 1.1 pgoyette basic_body() {
40 1.1 pgoyette
41 1.3 martin # verify fss is available (or loadable as a module)
42 1.3 martin
43 1.3 martin fssconfig -l /dev/fss0 > /dev/null || atf_skip "FSS not available"
44 1.3 martin
45 1.1 pgoyette # create of mount-points for the file system and snapshot
46 1.1 pgoyette
47 1.1 pgoyette mkdir ./m1
48 1.1 pgoyette mkdir ./m2
49 1.1 pgoyette
50 1.1 pgoyette # create a small 4MB file, treat it as a disk, init a file-system on it,
51 1.1 pgoyette # and mount it
52 1.1 pgoyette
53 1.1 pgoyette dd if=/dev/zero of=./image bs=32k count=64
54 1.3 martin vndconfig -c ${vnddev} ./image
55 1.3 martin newfs -I ${vnd}
56 1.3 martin mount ${vnd} ./m1
57 1.1 pgoyette
58 1.1 pgoyette echo "${orig_data}" > ./m1/text
59 1.1 pgoyette
60 1.1 pgoyette # configure and mount a snapshot of the file system
61 1.1 pgoyette
62 1.1 pgoyette fssconfig -c fss0 ./m1 ./backup
63 1.2 pgoyette mount -o rdonly /dev/fss0 ./m2
64 1.1 pgoyette
65 1.1 pgoyette # Modify the data on the underlying file system
66 1.1 pgoyette
67 1.1 pgoyette echo "${repl_data}" > ./m1/text || abort
68 1.1 pgoyette
69 1.1 pgoyette # Verify that original data is still visible in the snapshot
70 1.1 pgoyette
71 1.1 pgoyette read test_data < ./m2/text
72 1.1 pgoyette atf_check_equal "${orig_data}" "${test_data}"
73 1.1 pgoyette }
74 1.1 pgoyette
75 1.1 pgoyette basic_cleanup() {
76 1.3 martin # Unmount our temporary stuff
77 1.4 simonb umount /dev/fss0 || true
78 1.4 simonb fssconfig -u fss0 || true
79 1.3 martin umount ${vnd} || true
80 1.3 martin vndconfig -u ${vnddev} || true
81 1.1 pgoyette }
82 1.1 pgoyette
83 1.1 pgoyette atf_init_test_cases()
84 1.1 pgoyette {
85 1.1 pgoyette atf_add_test_case basic
86 1.1 pgoyette }
87