1 # $NetBSD: t_mtree.sh,v 1.3 2009/04/08 19:06:30 apb Exp $
3 # Copyright (c) 2009 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 # Postprocess mtreee output, canonicalising portions that
29 # are expected to differ from one run to another.
34 /^# machine: /s/:.*/: x/
42 diff -Nru "$1" "$2" || atf_fail
"files $1 and $2 differ"
48 atf_set
"descr" "Create a specfile describing a directory tree"
52 # create some directories
53 mkdir
-p create
/a
/1 create
/a
/2 create
/b
55 for file in create
/top.
file.1 \
58 create
/a
/1/a1.
file.1 \
64 # hard link to file in same dir
65 ln create
/b
/b.
file.1 create
/b
/b.hardlink
.1
66 # hard link to file in another dir
67 ln create
/b
/b.
file.2 create
/a
/a.hardlink.b2
69 ln -s a.
file.1 create
/a.symlink
.1
71 ln -s b create
/top.symlink.b
73 ln -s nonexistent create
/top.dangling
79 # run mtree and check output
80 ( cd create
&& mtree
-c -k type,nlink
,link
,size
,sha256
) >output.raw \
81 || atf_fail
"mtree exit status $?"
82 h_postprocess
<output.raw
>output
83 h_check
"$(atf_get_srcdir)/d_create.out" output
89 atf_set
"descr" "Check a directory tree against a specfile"
93 # we use the same directory tree and specfile as in the "create" test
96 # run mtree and check output
97 ( cd create
&& mtree
) <"$(atf_get_srcdir)/d_create.out" >output \
98 || atf_fail
"mtree exit status $?"
99 h_check
/dev
/null output
102 atf_test_case convert_C
105 atf_set
"descr" "Convert a specfile to mtree -C format, unsorted"
109 mtree
-C -K all
<"$(atf_get_srcdir)/d_convert.in" >output
110 h_check
"$(atf_get_srcdir)/d_convert_C.out" output
113 atf_test_case convert_C_S
116 atf_set
"descr" "Convert a specfile to mtree -C format, sorted"
120 mtree
-C -S -K all
<"$(atf_get_srcdir)/d_convert.in" >output
121 h_check
"$(atf_get_srcdir)/d_convert_C_S.out" output
124 atf_test_case convert_D
127 atf_set
"descr" "Convert a specfile to mtree -D format, unsorted"
131 mtree
-D -K all
<"$(atf_get_srcdir)/d_convert.in" >output
132 h_check
"$(atf_get_srcdir)/d_convert_D.out" output
135 atf_test_case convert_D_S
138 atf_set
"descr" "Convert a specfile to mtree -D format, sorted"
142 mtree
-D -S -K all
<"$(atf_get_srcdir)/d_convert.in" >output
143 h_check
"$(atf_get_srcdir)/d_convert_D_S.out" output
149 atf_set
"descr" "Merge records of different type"
153 mtree
-C -M -K all
<"$(atf_get_srcdir)/d_merge.in" >output
154 h_check
"$(atf_get_srcdir)/d_merge_C_M.out" output
155 # same again, with sorting
156 mtree
-C -M -S -K all
<"$(atf_get_srcdir)/d_merge.in" >output
157 h_check
"$(atf_get_srcdir)/d_merge_C_M_S.out" output
160 atf_init_test_cases
()
162 atf_add_test_case create
163 atf_add_test_case check
164 atf_add_test_case convert_C
165 atf_add_test_case convert_C_S
166 atf_add_test_case convert_D
167 atf_add_test_case convert_D_S
168 atf_add_test_case merge