Remove building with NOCRYPTO option
[minix3.git] / tests / usr.sbin / mtree / t_mtree.sh
blobea1cd513254a5306d1a3d75e4b1cfed886bf5fd5
1 # $NetBSD: t_mtree.sh,v 1.6 2013/02/05 16:49:42 christos Exp $
3 # Copyright (c) 2009, 2012 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
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 mtree output, canonicalising portions that
29 # are expected to differ from one run to another.
32 # mtree is not in the default user PATH on MINIX
33 export PATH=$PATH:/usr/sbin
35 h_postprocess()
37 sed -e '
38 /^# user: /s/:.*/: x/
39 /^# machine: /s/:.*/: x/
40 /^# tree: /s/:.*/: x/
41 /^# date: /s/:.*/: x/
42 ' \
43 -e '/type=dir/s/ size=[0-9]*//'
46 h_check()
48 diff -Nru "$1" "$2" || atf_fail "files $1 and $2 differ"
52 atf_test_case mtree_create
53 atf_test_case netbsd6_create
54 create_head()
56 atf_set "descr" "Create a specfile describing a directory tree"
59 create_setup()
61 # create some directories
62 rm -fr create
63 mkdir -p create/a/1 create/a/2 create/b
64 # create some files
65 for file in create/top.file.1 \
66 create/a/a.file.1 \
67 create/a/a.file.2 \
68 create/a/1/a1.file.1 \
69 create/b/b.file.1 \
70 create/b/b.file.2
72 echo "$file" >$file
73 done
74 # hard link to file in same dir
75 ln create/b/b.file.1 create/b/b.hardlink.1
76 # hard link to file in another dir
77 ln create/b/b.file.2 create/a/a.hardlink.b2
78 # symlink to file
79 ln -s a.file.1 create/a.symlink.1
80 # symlink to dir
81 ln -s b create/top.symlink.b
82 # dangling symlink
83 ln -s nonexistent create/top.dangling
86 create_body()
88 create_setup
90 # run mtree and check output
91 ( cd create && mtree -F ${FLAVOR} -c -k type,nlink,link,size,sha256 ) >output.raw \
92 || atf_fail "mtree exit status $?"
93 h_postprocess <output.raw >output
94 h_check "$(atf_get_srcdir)/${FLAVOR}_d_create.out" output
97 mtree_create_head()
99 FLAVOR=mtree create_head
101 netbsd6_create_head()
103 FLAVOR=netbsd6 create_head
106 mtree_create_body()
108 FLAVOR=mtree create_body
110 netbsd6_create_body()
112 FLAVOR=netbsd6 create_body
116 atf_test_case mtree_check
117 atf_test_case netbsd6_check
118 check_head()
120 atf_set "descr" "Check a directory tree against a specfile"
123 check_body()
125 # we use the same directory tree and specfile as in the "create" test
126 create_setup
128 # run mtree and check output
129 ( cd create && mtree -F ${FLAVOR} ) <"$(atf_get_srcdir)/${FLAVOR}_d_create.out" >output \
130 || atf_fail "mtree exit status $?"
131 h_check /dev/null output
134 mtree_check_head()
136 FLAVOR=mtree check_head
138 netbsd6_check_head()
140 FLAVOR=netbsd6 check_head
143 mtree_check_body()
145 FLAVOR=mtree check_body
147 netbsd6_check_body()
149 FLAVOR=netbsd6 check_body
153 atf_test_case mtree_convert_C
154 atf_test_case netbsd6_convert_C
155 convert_C_head()
157 atf_set "descr" "Convert a specfile to mtree -C format, unsorted"
160 convert_C_body()
162 mtree -F ${FLAVOR} -C -K all <"$(atf_get_srcdir)/d_convert.in" >output
163 h_check "$(atf_get_srcdir)/d_convert_C.out" output
166 mtree_convert_C_head()
168 FLAVOR=mtree convert_C_head
170 netbsd6_convert_C_head()
172 FLAVOR=netbsd6 convert_C_head
175 mtree_convert_C_body()
177 FLAVOR=mtree convert_C_body
179 netbsd6_convert_C_body()
181 FLAVOR=netbsd6 convert_C_body
185 atf_test_case mtree_convert_C_S
186 atf_test_case netbsd6_convert_C_S
187 convert_C_S_head()
189 atf_set "descr" "Convert a specfile to mtree -C format, sorted"
192 convert_C_S_body()
194 mtree -F ${FLAVOR} -C -S -K all <"$(atf_get_srcdir)/d_convert.in" >output
195 h_check "$(atf_get_srcdir)/d_convert_C_S.out" output
198 mtree_convert_C_S_head()
200 FLAVOR=mtree convert_C_S_head
202 netbsd6_convert_C_S_head()
204 FLAVOR=netbsd6 convert_C_S_head
207 mtree_convert_C_S_body()
209 FLAVOR=mtree convert_C_S_body
211 netbsd6_convert_C_S_body()
213 FLAVOR=netbsd6 convert_C_S_body
217 atf_test_case mtree_convert_D
218 atf_test_case netbsd6_convert_D
219 convert_D_head()
221 atf_set "descr" "Convert a specfile to mtree -D format, unsorted"
224 convert_D_body()
226 mtree -F ${FLAVOR} -D -K all <"$(atf_get_srcdir)/d_convert.in" >output
227 h_check "$(atf_get_srcdir)/d_convert_D.out" output
230 mtree_convert_D_head()
232 FLAVOR=mtree convert_D_head
234 netbsd6_convert_D_head()
236 FLAVOR=netbsd6 convert_D_head
239 mtree_convert_D_body()
241 FLAVOR=mtree convert_D_body
243 netbsd6_convert_D_body()
245 FLAVOR=netbsd6 convert_D_body
249 atf_test_case mtree_convert_D_S
250 atf_test_case netbsd6_convert_D_S
251 convert_D_S_head()
253 atf_set "descr" "Convert a specfile to mtree -D format, sorted"
256 convert_D_S_body()
258 mtree -F ${FLAVOR} -D -S -K all <"$(atf_get_srcdir)/d_convert.in" >output
259 h_check "$(atf_get_srcdir)/d_convert_D_S.out" output
262 mtree_convert_D_S_head()
264 FLAVOR=mtree convert_D_S_head
266 netbsd6_convert_D_S_head()
268 FLAVOR=netbsd6 convert_D_S_head
271 mtree_convert_D_S_body()
273 FLAVOR=mtree convert_D_S_body
275 netbsd6_convert_D_S_body()
277 FLAVOR=netbsd6 convert_D_S_body
281 atf_test_case mtree_ignore
282 atf_test_case netbs6_ignore
283 ignore_head()
285 atf_set "descr" "Test that -d ignores symlinks (PR bin/41061)"
288 ignore_body()
290 mkdir newdir
291 mtree -F ${FLAVOR} -c | mtree -F ${FLAVOR} -Ck uid,gid,mode > mtree.spec
292 ln -s newdir otherdir
294 # This yields "extra: otherdir" even with -d.
295 # (PR bin/41061)
296 atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec"
298 # Delete the symlink and re-verify.
300 rm otherdir
301 atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec"
304 mtree_ignore_head()
306 FLAVOR=mtree ignore_head
308 netbsd6_ignore_head()
310 FLAVOR=netbsd6 ignore_head
313 mtree_ignore_body()
315 FLAVOR=mtree ignore_body
317 netbsd6_ignore_body()
319 FLAVOR=netbsd6 ignore_body
323 atf_test_case mtree_merge
324 atf_test_case netbsd6_merge
325 merge_head()
327 atf_set "descr" "Merge records of different type"
330 merge_body()
332 mtree -F ${FLAVOR} -C -M -K all <"$(atf_get_srcdir)/d_merge.in" >output
333 h_check "$(atf_get_srcdir)/d_merge_C_M.out" output
334 # same again, with sorting
335 mtree -F ${FLAVOR} -C -M -S -K all <"$(atf_get_srcdir)/d_merge.in" >output
336 h_check "$(atf_get_srcdir)/d_merge_C_M_S.out" output
339 mtree_merge_head()
341 FLAVOR=mtree merge_head
343 netbsd6_merge_head()
345 FLAVOR=netbsd6 merge_head
348 mtree_merge_body()
350 FLAVOR=mtree merge_body
352 netbsd6_merge_body()
354 FLAVOR=netbsd6 merge_body
358 atf_test_case mtree_nonemptydir
359 atf_test_case netbsd6_nonemptydir
360 nonemptydir_head()
362 atf_set "descr" "Test that new non-empty " \
363 "directories are recorded (PR bin/25693)"
366 nonemptydir_body()
368 mkdir testdir
369 cd testdir
371 mtree -F ${FLAVOR} -c > mtree.spec
373 if [ ! -f mtree.spec ]; then
374 atf_fail "mtree failed"
377 touch bar
378 atf_check -s ignore -o save:output -x "mtree -F ${FLAVOR} -f mtree.spec"
380 if [ ! -n "$(egrep "extra: bar" output)" ]; then
381 atf_fail "mtree did not record changes (PR bin/25693)"
385 mtree_nonemptydir_head()
387 FLAVOR=mtree nonemptydir_head
389 netbsd6_nonemptydir_head()
391 FLAVOR=netbsd6 nonemptydir_head
394 mtree_nonemptydir_body()
396 FLAVOR=mtree nonemptydir_body
398 netbsd6_nonemptydir_body()
400 FLAVOR=netbsd6 nonemptydir_body
404 atf_init_test_cases()
406 atf_add_test_case mtree_create
407 atf_add_test_case mtree_check
408 atf_add_test_case mtree_convert_C
409 atf_add_test_case mtree_convert_C_S
410 atf_add_test_case mtree_convert_D
411 atf_add_test_case mtree_convert_D_S
412 atf_add_test_case mtree_ignore
413 atf_add_test_case mtree_merge
414 atf_add_test_case mtree_nonemptydir
416 atf_add_test_case netbsd6_create
417 atf_add_test_case netbsd6_check
418 atf_add_test_case netbsd6_convert_C
419 atf_add_test_case netbsd6_convert_C_S
420 atf_add_test_case netbsd6_convert_D
421 atf_add_test_case netbsd6_convert_D_S
422 atf_add_test_case netbsd6_ignore
423 atf_add_test_case netbsd6_merge
424 atf_add_test_case netbsd6_nonemptydir