Home | History | Annotate | Line # | Download | only in fss
t_fss.sh revision 1.6
      1 # $NetBSD: t_fss.sh,v 1.6 2023/05/11 01:56:31 gutteridge Exp $
      2 #
      3 # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
      4 # All rights reserved.
      5 # Redistribution and use in source and binary forms, with or without
      6 # modification, are permitted provided that the following conditions
      7 # are met:
      8 # 1. Redistributions of source code must retain the above copyright
      9 #    notice, this list of conditions and the following disclaimer.
     10 # 2. Redistributions in binary form must reproduce the above copyright
     11 #    notice, this list of conditions and the following disclaimer in the
     12 #    documentation and/or other materials provided with the distribution.
     13 #
     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
     16 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     17 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     18 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     19 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     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
     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
     24 # POSSIBILITY OF SUCH DAMAGE.
     25 #
     26 
     27 #
     28 # Verify basic operation of fss(4) file system snapshot device
     29 #
     30 
     31 vnddev=vnd0
     32 vnd=/dev/${vnddev}
     33 
     34 orig_data="Original data"
     35 repl_data="Replacement data"
     36 
     37 atf_test_case basic cleanup
     38 basic_head() {
     39 	atf_set "descr" "Verify basic operation of fss(4) file system " \
     40 		"snapshot device"
     41 }
     42 
     43 basic_body() {
     44 
     45 # verify fss is available (or loadable as a module)
     46 
     47 	fssconfig -l /dev/fss0 > /dev/null || atf_skip "FSS not available"
     48 
     49 # create of mount-points for the file system and snapshot
     50 
     51 	mkdir ./m1
     52 	mkdir ./m2
     53 
     54 # create a small 4MB file, treat it as a disk, init a file-system on it,
     55 # and mount it
     56 
     57 	dd if=/dev/zero of=./image bs=32k count=64
     58 	vndconfig -c ${vnddev} ./image
     59 	newfs -I ${vnd}
     60 	mount ${vnd} ./m1
     61 
     62 	echo "${orig_data}" > ./m1/text
     63 
     64 # configure and mount a snapshot of the file system
     65 
     66 	fssconfig -c fss0 ./m1 ./backup
     67 	mount -o rdonly /dev/fss0 ./m2
     68 
     69 # Modify the data on the underlying file system
     70 
     71 	echo "${repl_data}" > ./m1/text || abort
     72 
     73 # Verify that original data is still visible in the snapshot
     74 
     75 	read test_data < ./m2/text
     76 	atf_check_equal "${orig_data}" "${test_data}"
     77 }
     78 
     79 basic_cleanup() {
     80 # Unmount our temporary stuff
     81 	umount /dev/fss0	|| true
     82 	fssconfig -u fss0	|| true
     83 	umount ${vnd}		|| true
     84 	vndconfig -u ${vnddev}	|| true
     85 }
     86 
     87 atf_init_test_cases()
     88 {
     89 	atf_add_test_case basic
     90 }
     91