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