Home | History | Annotate | Line # | Download | only in fss
t_fss.sh revision 1.2
      1  1.2  pgoyette # $NetBSD: t_fss.sh,v 1.2 2016/07/29 20:27:37 pgoyette 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.1  pgoyette orig_data="Original data"
     32  1.1  pgoyette repl_data="Replacement data"
     33  1.1  pgoyette 
     34  1.1  pgoyette atf_test_case basic cleanup
     35  1.1  pgoyette basic_body() {
     36  1.1  pgoyette 
     37  1.1  pgoyette # create of mount-points for the file system and snapshot
     38  1.1  pgoyette 
     39  1.1  pgoyette 	mkdir ./m1
     40  1.1  pgoyette 	mkdir ./m2
     41  1.1  pgoyette 
     42  1.1  pgoyette # create a small 4MB file, treat it as a disk, init a file-system on it,
     43  1.1  pgoyette # and mount it
     44  1.1  pgoyette 
     45  1.1  pgoyette 	dd if=/dev/zero of=./image bs=32k count=64
     46  1.1  pgoyette 	vndconfig -c vnd0 ./image
     47  1.1  pgoyette 	newfs /dev/vnd0a
     48  1.1  pgoyette 	mount /dev/vnd0a ./m1
     49  1.1  pgoyette 
     50  1.1  pgoyette 	echo "${orig_data}" > ./m1/text
     51  1.1  pgoyette 
     52  1.1  pgoyette # configure and mount a snapshot of the file system
     53  1.1  pgoyette 
     54  1.1  pgoyette 	fssconfig -c fss0 ./m1 ./backup
     55  1.2  pgoyette 	mount -o rdonly /dev/fss0 ./m2
     56  1.1  pgoyette 
     57  1.1  pgoyette # Modify the data on the underlying file system
     58  1.1  pgoyette 
     59  1.1  pgoyette 	echo "${repl_data}" > ./m1/text || abort
     60  1.1  pgoyette 
     61  1.1  pgoyette # Verify that original data is still visible in the snapshot
     62  1.1  pgoyette 
     63  1.1  pgoyette 	read test_data < ./m2/text
     64  1.1  pgoyette 	atf_check_equal "${orig_data}" "${test_data}"
     65  1.1  pgoyette 
     66  1.1  pgoyette # Unmount our temporary stuff
     67  1.1  pgoyette 
     68  1.2  pgoyette 	umount /dev/fss0	|| true
     69  1.2  pgoyette 	fssconfig -u fss0	|| true
     70  1.1  pgoyette 	umount /dev/vnd0a	|| true
     71  1.2  pgoyette 	vndconfig -u vnd0	|| true
     72  1.1  pgoyette }
     73  1.1  pgoyette 
     74  1.1  pgoyette basic_cleanup() {
     75  1.1  pgoyette 	umount /dev/vnd0a	|| true
     76  1.2  pgoyette 	fssconfig -u fss0	|| true
     77  1.1  pgoyette 	umount /dev/fss0	|| true
     78  1.1  pgoyette 	vndconfig -u vnd0	|| true
     79  1.1  pgoyette }
     80  1.1  pgoyette 
     81  1.1  pgoyette atf_init_test_cases()
     82  1.1  pgoyette {
     83  1.1  pgoyette         atf_add_test_case basic
     84  1.1  pgoyette }
     85