tests_test.sh revision 258063
1238423Sjhb#!/bin/sh
2238423Sjhb#
3238423Sjhb# Copyright (c) 2010 Advanced Computing Technologies LLC
4238423Sjhb# Written by: John H. Baldwin <jhb@FreeBSD.org>
5238423Sjhb# All rights reserved.
6238423Sjhb#
7238423Sjhb# Redistribution and use in source and binary forms, with or without
8238423Sjhb# modification, are permitted provided that the following conditions
9238423Sjhb# are met:
10238423Sjhb# 1. Redistributions of source code must retain the above copyright
11238423Sjhb#    notice, this list of conditions and the following disclaimer.
12238423Sjhb# 2. Redistributions in binary form must reproduce the above copyright
13238423Sjhb#    notice, this list of conditions and the following disclaimer in the
14238423Sjhb#    documentation and/or other materials provided with the distribution.
15238423Sjhb#
16238423Sjhb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17238423Sjhb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18238423Sjhb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19238423Sjhb# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20238423Sjhb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21238423Sjhb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22238423Sjhb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23238423Sjhb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24238423Sjhb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25238423Sjhb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26238423Sjhb# SUCH DAMAGE.
27238423Sjhb#
28238423Sjhb# $FreeBSD: head/tools/regression/usr.sbin/etcupdate/tests.sh 258063 2013-11-12 19:15:06Z jhb $
29238423Sjhb
30238423Sjhb# Various regression tests to run for the 'update' command.
31238423Sjhb
32238423SjhbWORKDIR=work
33238423Sjhb
34238423Sjhbusage()
35238423Sjhb{
36258063Sjhb	echo "Usage: tests.sh [-s script] [-w workdir]"
37238423Sjhb	exit 1
38238423Sjhb}
39238423Sjhb
40258063Sjhb# Allow the user to specify an alternate work directory or script.
41258063SjhbCOMMAND=etcupdate
42258063Sjhbwhile getopts "s:w:" option; do
43238423Sjhb	case $option in
44258063Sjhb		s)
45258063Sjhb			COMMAND="sh $OPTARG"
46258063Sjhb			;;
47238423Sjhb		w)
48238423Sjhb			WORKDIR=$OPTARG
49238423Sjhb			;;
50238423Sjhb		*)
51238423Sjhb			echo
52238423Sjhb			usage
53238423Sjhb			;;
54238423Sjhb	esac
55238423Sjhbdone
56238423Sjhbshift $((OPTIND - 1))
57238423Sjhbif [ $# -ne 0 ]; then
58238423Sjhb	usage
59238423Sjhbfi
60238423Sjhb
61238423SjhbCONFLICTS=$WORKDIR/conflicts
62238423SjhbOLD=$WORKDIR/old
63238423SjhbNEW=$WORKDIR/current
64238423SjhbTEST=$WORKDIR/test
65238423Sjhb
66238423Sjhb# The various states of the comparison of a file between two trees.
67238423Sjhbstates="equal first second difftype difflinks difffiles"
68238423Sjhb
69238423Sjhbbuild_trees()
70238423Sjhb{
71238423Sjhb	local i j k
72238423Sjhb
73238423Sjhb	rm -rf $OLD $NEW $TEST $CONFLICTS
74238423Sjhb	mkdir -p $OLD/etc $NEW/etc $TEST/etc
75238423Sjhb
76238423Sjhb	# For an given file, there are three different pair-wise
77238423Sjhb	# relations between the three threes (old, new, and test): old
78238423Sjhb	# vs new, old vs test, and new vs test.  Each of these
79238423Sjhb	# relations takes on one of six different states from the
80238423Sjhb	# 'compare()' function in etcupdate: equal, onlyfirst,
81238423Sjhb	# onlysecond, difftype, difflinks, difffiles.  In addition,
82238423Sjhb	# there are special considerations for considering cases such
83238423Sjhb	# as a file merge that results in conflicts versus one that
84238423Sjhb	# does not, special treatment of directories, etc.  The tests
85238423Sjhb	# below attempt to enumerate the three dimensional test matrix
86238423Sjhb	# by having the path name use the three different tree states
87238423Sjhb	# for the parent directories.
88238423Sjhb	#
89238423Sjhb	# Note that if the old and new files are identical (so first
90238423Sjhb	# compare is "equal"), then the second and third comparisons
91238423Sjhb	# will be the same.
92238423Sjhb	#
93238423Sjhb	# Note also that etcupdate only cares about files that are
94238423Sjhb	# present in at least one of the old or new trees.  Thus, none
95238423Sjhb	# of the '*/second/second' cases are relevant.
96238423Sjhb
97238423Sjhb	for i in $states; do
98238423Sjhb		for j in $states; do
99238423Sjhb			for k in $states; do
100238423Sjhb				mkdir -p $OLD/$i/$j/$k $NEW/$i/$j/$k \
101238423Sjhb				    $TEST/$i/$j/$k
102238423Sjhb			done
103238423Sjhb		done
104238423Sjhb	done
105238423Sjhb
106238423Sjhb	# /equal/equal/equal: Everything is equal.  Nothing should happen.
107238423Sjhb	for i in $OLD $NEW $TEST; do
108238423Sjhb		mkfifo $i/equal/equal/equal/fifo
109238423Sjhb		echo "foo" > $i/equal/equal/equal/file
110238423Sjhb		mkdir $i/equal/equal/equal/dir
111238423Sjhb		ln -s "bar" $i/equal/equal/equal/link
112238423Sjhb	done
113238423Sjhb
114238423Sjhb	# /equal/first/first: The file is missing from the test
115238423Sjhb	# directory.  Nothing should happen.
116238423Sjhb	for i in $OLD $NEW; do
117238423Sjhb		mkfifo $i/equal/first/first/fifo
118238423Sjhb		echo "foo" > $i/equal/first/first/file
119238423Sjhb		mkdir $i/equal/first/first/dir
120238423Sjhb		ln -s "bar" $i/equal/first/first/link
121238423Sjhb	done
122238423Sjhb
123238423Sjhb	# /equal/difftype/difftype: The local file is a different
124238423Sjhb	# type.  Nothing should happen.
125238423Sjhb	for i in $OLD $NEW; do
126238423Sjhb		mkfifo $i/equal/difftype/difftype/fifo
127238423Sjhb		mkdir $i/equal/difftype/difftype/fromdir
128238423Sjhb	done
129238423Sjhb	echo "bar" > $TEST/equal/difftype/difftype/fifo
130238423Sjhb	ln -s "test" $TEST/equal/difftype/difftype/fromdir
131238423Sjhb
132238423Sjhb	# /equal/difflinks/difflinks: The local file is a modified
133238423Sjhb	# link. Nothing should happen.
134238423Sjhb	for i in $OLD $NEW; do
135238423Sjhb		ln -s "foo" $i/equal/difflinks/difflinks/link
136238423Sjhb	done
137238423Sjhb	ln -s "bar" $TEST/equal/difflinks/difflinks/link
138238423Sjhb
139238423Sjhb	# /equal/difffiles/difffiles: The local file is a modified
140238423Sjhb	# file.  Nothing should happen.
141238423Sjhb	for i in $OLD $NEW; do
142238423Sjhb		echo "foo" > $i/equal/difffiles/difffiles/file
143238423Sjhb	done
144238423Sjhb	echo "bar" > $TEST/equal/difffiles/difffiles/file
145238423Sjhb
146238423Sjhb	# /first/equal/second: Remove unmodified files.  The files
147238423Sjhb	# should all be removed.
148238423Sjhb	for i in $OLD $TEST; do
149238423Sjhb		mkfifo $i/first/equal/second/fifo
150238423Sjhb		echo "foo" > $i/first/equal/second/file
151238423Sjhb		mkdir $i/first/equal/second/emptydir
152238423Sjhb		ln -s "bar" $i/first/equal/second/link
153238423Sjhb		mkdir $i/first/equal/second/fulldir
154238423Sjhb		echo "foo" > $i/first/equal/second/fulldir/file
155238423Sjhb	done
156238423Sjhb
157238423Sjhb	# /first/equal/*: Cannot occur.  If the file is missing from
158238423Sjhb	# new, then new vs test will always be 'second'.
159238423Sjhb
160238423Sjhb	# /first/first/equal: Removed files are already removed.
161238423Sjhb	# Nothing should happen.
162238423Sjhb	mkfifo $OLD/first/first/equal/fifo
163238423Sjhb	echo "foo" > $OLD/first/first/equal/file
164238423Sjhb	mkdir $OLD/first/first/equal/dir
165238423Sjhb	ln -s "bar" $OLD/first/first/equal/link
166238423Sjhb
167238423Sjhb	# /first/first/*: Cannot occur.  The files are missing from
168238423Sjhb	# both new and test.
169238423Sjhb
170238423Sjhb	# /first/second/*: Cannot happen, if the file is in old for
171238423Sjhb	# old vs new, it cannot be missing for old vs test.
172238423Sjhb
173238423Sjhb	# /first/difftype/second: File with different local type
174238423Sjhb	# removed.  Should generate a warning.
175238423Sjhb	mkfifo $OLD/first/difftype/second/fifo
176238423Sjhb	mkdir $TEST/first/difftype/second/fifo
177238423Sjhb
178238423Sjhb	# /first/difftype/*: Cannot happen since the file is missing
179238423Sjhb	# from new but present in test.
180238423Sjhb
181238423Sjhb	# /first/difflinks/second: Modified link removed.  Should
182238423Sjhb	# generate a warning.
183238423Sjhb	ln -s "old link" $OLD/first/difflinks/second/link
184238423Sjhb	ln -s "test link" $TEST/first/difflinks/second/link
185238423Sjhb
186238423Sjhb	# /first/difflinks/*: Cannot happen since the file is missing
187238423Sjhb	# from new but present in test.
188238423Sjhb
189238423Sjhb	# /first/difffiles/second: Modified file removed.  Should
190238423Sjhb	# generate a warning.
191238423Sjhb	echo "foo" > $OLD/first/difffiles/second/file
192238423Sjhb	echo "bar" > $TEST/first/difffiles/second/file
193238423Sjhb
194238423Sjhb	# /first/difffiles/*: Cannot happen since the file is missing
195238423Sjhb	# from new but present in test.
196238423Sjhb
197238423Sjhb	# /second/equal/first: Added a new file that isn't present in
198238423Sjhb	# test.  The empty directory should be ignored.
199238423Sjhb	echo "bar" > $NEW/second/equal/first/file
200238423Sjhb	mkfifo $NEW/second/equal/first/fifo
201238423Sjhb	ln -s "new" $NEW/second/equal/first/link
202238423Sjhb	mkdir $NEW/second/equal/first/emptydir
203238423Sjhb	mkdir $NEW/second/equal/first/fulldir
204238423Sjhb	echo "foo" > $NEW/second/equal/first/fulldir/file
205238423Sjhb
206238423Sjhb	# /second/equal/*: Cannot happen since the file is missing
207238423Sjhb	# from test but present in new.
208238423Sjhb
209238423Sjhb	# /second/first/*: Cannot happen since the file is missing
210238423Sjhb	# from old.
211238423Sjhb
212238423Sjhb	# /second/second/equal: Newly added file is already present in
213238423Sjhb	# the test directory and identical to the new file.  Nothing
214238423Sjhb	# should happen.
215238423Sjhb	for i in $NEW $TEST; do
216238423Sjhb		mkfifo $i/second/second/equal/fifo
217238423Sjhb		echo "foo" > $i/second/second/equal/file
218238423Sjhb		mkdir $i/second/second/equal/dir
219238423Sjhb		ln -s "bar" $i/second/second/equal/link
220238423Sjhb	done
221238423Sjhb
222238423Sjhb	# /second/second/first: Cannot happen.  The file is in dest in
223238423Sjhb	# the second test, so it can't be missing from the third test.
224238423Sjhb
225238423Sjhb	# /second/second/second: Cannot happen.  The file is in new in
226238423Sjhb	# the first test, so it can't be missing from the third test.
227238423Sjhb
228238423Sjhb	# /second/second/difftype: Newly added file conflicts with
229238423Sjhb	# existing file in test tree of a different type.  Should
230238423Sjhb	# generate a warning.
231238423Sjhb	mkdir $NEW/second/second/difftype/dir
232238423Sjhb	mkfifo $TEST/second/second/difftype/dir
233238423Sjhb
234238423Sjhb	# /second/second/difflinks: Newly added link conflicts with
235238423Sjhb	# existing link in test tree.  Should generate a warning.
236238423Sjhb	ln -s "new link" $NEW/second/second/difflinks/link
237238423Sjhb	ln -s "test link" $TEST/second/second/difflinks/link
238238423Sjhb
239238423Sjhb	# /second/second/difffiles: Newly added file conflicts with
240238423Sjhb	# existing file in test tree.  Should generate a warning.
241238423Sjhb	echo "new" > $NEW/second/second/difffiles/file
242238423Sjhb	echo "test" > $TEST/second/second/difffiles/file
243238423Sjhb
244238423Sjhb	# /second/difftype/*: Cannot happen since the file is missing
245238423Sjhb	# from old.
246238423Sjhb
247238423Sjhb	# /second/difflinks/*: Cannot happen since the file is missing
248238423Sjhb	# from old.
249238423Sjhb
250238423Sjhb	# /second/difffiles/*: Cannot happen since the file is missing
251238423Sjhb	# from old.
252238423Sjhb
253238423Sjhb	# /difftype/equal/difftype: Unmodified file has changed type.
254238423Sjhb	# File should be updated to the new file.  In the 'todir' case
255238423Sjhb	# the directory won't actually be created because it is empty.
256238423Sjhb	for i in $OLD $TEST; do
257238423Sjhb		echo "foo" > $i/difftype/equal/difftype/file
258238423Sjhb		mkdir $i/difftype/equal/difftype/fromdir
259238423Sjhb		ln -s "old" $i/difftype/equal/difftype/todir
260238423Sjhb	done
261238423Sjhb	ln -s "test" $NEW/difftype/equal/difftype/file
262238423Sjhb	mkfifo $NEW/difftype/equal/difftype/fromdir
263238423Sjhb	mkdir $NEW/difftype/equal/difftype/todir
264238423Sjhb
265238423Sjhb	# /difftype/equal/*: Cannot happen.  Since the old file is a
266238423Sjhb	# difftype from the new file and the test file is identical to
267238423Sjhb	# the old file, the test file must be a difftype from the new
268238423Sjhb	# file.
269238423Sjhb
270238423Sjhb	# /difftype/first/first: A removed file has changed type.
271238423Sjhb	# This should generate a warning.
272238423Sjhb	mkfifo $OLD/difftype/first/first/fifo
273238423Sjhb	mkdir $NEW/difftype/first/first/fifo
274238423Sjhb
275238423Sjhb	# /difftype/first/*: Cannot happen.  Since the new file exists
276238423Sjhb	# and the dest file is missing, the last test must be 'first'.
277238423Sjhb
278238423Sjhb	# /difftype/second/*: Cannot happen.  The old file exists in
279238423Sjhb	# the first test, so it cannot be missing in the second test.
280238423Sjhb
281238423Sjhb	# /difftype/difftype/equal: A file has changed type, but the
282238423Sjhb	# file in the test directory already matches the new file.  Do
283238423Sjhb	# nothing.
284238423Sjhb	echo "foo" > $OLD/difftype/difftype/equal/fifo
285238423Sjhb	mkfifo $OLD/difftype/difftype/equal/file
286238423Sjhb	for i in $NEW $TEST; do
287238423Sjhb		mkfifo $i/difftype/difftype/equal/fifo
288238423Sjhb		echo "bar" > $i/difftype/difftype/equal/file
289238423Sjhb	done
290238423Sjhb
291238423Sjhb	# /difftype/difftype/first: Cannot happen.  The dest file
292238423Sjhb	# exists in the second test.
293238423Sjhb
294238423Sjhb	# /difftype/difftype/second: Cannot happen.  The new file
295238423Sjhb	# exists in the first test.
296238423Sjhb
297238423Sjhb	# /difftype/difftype/difftype: All three files (old, new, and
298238423Sjhb	# test) are different types from each other.  This should
299238423Sjhb	# generate a warning.
300238423Sjhb	mkfifo $OLD/difftype/difftype/difftype/one
301238423Sjhb	mkdir $NEW/difftype/difftype/difftype/one
302238423Sjhb	echo "foo" > $TEST/difftype/difftype/difftype/one
303238423Sjhb	mkdir $OLD/difftype/difftype/difftype/two
304238423Sjhb	echo "baz" > $NEW/difftype/difftype/difftype/two
305238423Sjhb	ln -s "bar" $TEST/difftype/difftype/difftype/two
306238423Sjhb
307238423Sjhb	# /difftype/difftype/difflinks: A file has changed from a
308238423Sjhb	# non-link to a link in both the new and test trees, but the
309238423Sjhb	# target of the new and test links differ.  This should
310238423Sjhb	# generate a new link conflict.
311238423Sjhb	mkfifo $OLD/difftype/difftype/difflinks/link
312238423Sjhb	ln -s "new" $NEW/difftype/difftype/difflinks/link
313238423Sjhb	ln -s "test" $TEST/difftype/difftype/difflinks/link
314238423Sjhb
315238423Sjhb	# /difftype/difftype/difffile: A file has changed from a
316238423Sjhb	# non-regular file to a regular file in both the new and test
317238423Sjhb	# trees, but the contents in the new and test files differ.
318238423Sjhb	# This should generate a new file conflict.
319238423Sjhb	ln -s "old" $OLD/difftype/difftype/difffiles/file
320238423Sjhb	echo "foo" > $NEW/difftype/difftype/difffiles/file
321238423Sjhb	echo "bar" > $TEST/difftype/difftype/difffiles/file
322238423Sjhb
323238423Sjhb	# /difflinks/equal/difflinks: An unmodified symlink has
324238423Sjhb	# changed.  The link should be updated.
325238423Sjhb	for i in $OLD $TEST; do
326238423Sjhb		ln -s "old" $i/difflinks/equal/difflinks/link
327238423Sjhb	done
328238423Sjhb	ln -s "new" $NEW/difflinks/equal/difflinks/link
329238423Sjhb
330238423Sjhb	# /difflinks/equal/*: Cannot happen.  Since old is identical
331238423Sjhb	# to test, the third test must be 'difflinks'.
332238423Sjhb
333238423Sjhb	# /difflinks/first/first: A modified link is missing in the
334238423Sjhb	# test tree.  This should generate a warning.
335238423Sjhb	ln -s "old" $OLD/difflinks/first/first/link
336238423Sjhb	ln -s "new" $NEW/difflinks/first/first/link
337238423Sjhb
338238423Sjhb	# /difflinks/first/*: Cannot happen.  Since the test file is
339238423Sjhb	# missing in the second test, it must be missing in the third
340238423Sjhb	# test.
341238423Sjhb
342238423Sjhb	# /difflinks/second/*: Cannot happen.  The old link is present
343238423Sjhb	# in the first test, so it cannot be missing in the second
344238423Sjhb	# test.
345238423Sjhb
346238423Sjhb	# /difflinks/difftype/difftype: An updated link has been
347238423Sjhb	# changed to a different file type in the test tree.  This
348238423Sjhb	# should generate a warning.
349238423Sjhb	ln -s "old" $OLD/difflinks/difftype/difftype/link
350238423Sjhb	ln -s "new" $NEW/difflinks/difftype/difftype/link
351238423Sjhb	echo "test" > $TEST/difflinks/difftype/difftype/link
352238423Sjhb
353238423Sjhb	# /difflinks/difftype/*: Cannot happen.  The old and new files
354238423Sjhb	# are both links and the test file is not a link, so the third
355238423Sjhb	# test must be 'difftype'.
356238423Sjhb
357238423Sjhb	# /difflinks/difflinks/equal: An updated link has already been
358238423Sjhb	# updated to the new target in the test tree.  Nothing should
359238423Sjhb	# happen.
360238423Sjhb	ln -s "old" $OLD/difflinks/difflinks/equal/link
361238423Sjhb	for i in $NEW $TEST; do
362238423Sjhb		ln -s "new" $i/difflinks/difflinks/equal/link
363238423Sjhb	done
364238423Sjhb
365238423Sjhb	# /difflinks/difflinks/difflinks: An updated link has been
366238423Sjhb	# modified in the test tree and doesn't match either the old
367238423Sjhb	# or new links.  This should generate a warning.
368238423Sjhb	ln -s "old" $OLD/difflinks/difflinks/difflinks/link
369238423Sjhb	ln -s "new" $NEW/difflinks/difflinks/difflinks/link
370238423Sjhb	ln -s "test" $TEST/difflinks/difflinks/difflinks/link
371238423Sjhb
372238423Sjhb	# /difflinks/difflinks/*: Cannot happen.  All three files are
373238423Sjhb	# links from the first two tests, so the third test can only
374238423Sjhb	# be 'equal' or 'difflink'.
375238423Sjhb
376238423Sjhb	# /difflinks/difffiles/*: Cannot happen.  The old file is a
377238423Sjhb	# link in the first test, so it cannot be a regular file in
378238423Sjhb	# the second.
379238423Sjhb
380238423Sjhb	# /difffiles/equal/difffiles: An unmodified file has been
381238423Sjhb	# changed in new tree.  The file should be updated to the new
382238423Sjhb	# version.
383238423Sjhb	for i in $OLD $TEST; do
384238423Sjhb		echo "foo" > $i/difffiles/equal/difffiles/file
385238423Sjhb	done
386238423Sjhb	echo "bar" > $NEW/difffiles/equal/difffiles/file
387238423Sjhb
388238423Sjhb	# /difffiles/equal/*: Cannot happen.  Since the old file is
389238423Sjhb	# identical to the test file, the third test must be
390238423Sjhb	# 'difffiles'.
391238423Sjhb
392238423Sjhb	# /difffiles/first/first: A removed file has been changed in
393238423Sjhb	# the new tree.  This should generate a warning.
394238423Sjhb	echo "foo" > $OLD/difffiles/first/first/file
395238423Sjhb	echo "bar" > $NEW/difffiles/first/first/file
396238423Sjhb
397238423Sjhb	# /difffiles/first/*: Cannot happen.  The new file is a
398238423Sjhb	# regular file from the first test and the test file is
399238423Sjhb	# missing in the second test, so the third test must be
400238423Sjhb	# 'first'.
401238423Sjhb
402238423Sjhb	# /difffiles/second/*: Cannot happen.  The old file is present
403238423Sjhb	# in the first test, so it must be present in the second test.
404238423Sjhb
405238423Sjhb	# /difffiles/difftype/difftype: An updated regular file has
406238423Sjhb	# been changed to a different file type in the test tree.
407238423Sjhb	# This should generate a warning.
408238423Sjhb	echo "old" > $OLD/difffiles/difftype/difftype/file
409238423Sjhb	echo "new" > $NEW/difffiles/difftype/difftype/file
410238423Sjhb	mkfifo $TEST/difffiles/difftype/difftype/file
411238423Sjhb
412238423Sjhb	# /difffiles/difftype/*: Cannot happen.  The new file is known
413238423Sjhb	# to be a regular file from the first test, and the test file
414238423Sjhb	# is known to exist as a different file type from the second
415238423Sjhb	# test.  The third test must be 'difftype'.
416238423Sjhb
417238423Sjhb	# /difffiles/difflink/*: Cannot happen.  The old file is known
418238423Sjhb	# to be a regular file from the first test, so it cannot be a
419238423Sjhb	# link in the second test.
420238423Sjhb
421238423Sjhb	# /difffiles/difffiles/equal: An updated regular file has
422238423Sjhb	# already been updated to match the new file in the test tree.
423238423Sjhb	# Nothing should happen.
424238423Sjhb	echo "foo" > $OLD/difffiles/difffiles/equal/file
425238423Sjhb	for i in $NEW $TEST; do
426238423Sjhb		echo "bar" > $i/difffiles/difffiles/equal/file
427238423Sjhb	done
428238423Sjhb
429238423Sjhb	# /difffiles/difffiles/difffiles: A modified regular file was
430238423Sjhb	# updated in the new tree.  The changes should be merged into
431238423Sjhb	# to the new file if possible.  If the merge fails, a conflict
432238423Sjhb	# should be generated.
433238423Sjhb	cat > $OLD/difffiles/difffiles/difffiles/simple <<EOF
434238423Sjhbthis is an old line
435238423Sjhb
436238423SjhbEOF
437238423Sjhb	cat > $NEW/difffiles/difffiles/difffiles/simple <<EOF
438238423Sjhbthis is a new line
439238423Sjhb
440238423SjhbEOF
441238423Sjhb	cat > $TEST/difffiles/difffiles/difffiles/simple <<EOF
442238423Sjhbthis is an old line
443238423Sjhb
444238423Sjhbthis is a local line
445238423SjhbEOF
446238423Sjhb	cat > $OLD/difffiles/difffiles/difffiles/conflict <<EOF
447238423Sjhbthis is an old file
448238423SjhbEOF
449238423Sjhb	cat > $NEW/difffiles/difffiles/difffiles/conflict <<EOF
450238423Sjhbthis is a new file
451238423SjhbEOF
452238423Sjhb	cat > $TEST/difffiles/difffiles/difffiles/conflict <<EOF
453238423Sjhbthis is a test file
454238423SjhbEOF
455238423Sjhb
456238423Sjhb	# /difffiles/difffiles/*: Cannot happen.  From the first three
457238423Sjhb	# tests, all three files are regular files.  The test file can
458238423Sjhb	# either be identical to the new file ('equal') or not
459238423Sjhb	# ('difffiles').
460238423Sjhb
461238423Sjhb	## Tests for adding directories
462238423Sjhb	mkdir -p $OLD/adddir $NEW/adddir $TEST/adddir
463238423Sjhb
464238423Sjhb	# /adddir/conflict: Add a new file in a directory that already
465238423Sjhb	# exists as a file.  This should generate two warnings.
466238423Sjhb	mkdir $NEW/adddir/conflict
467238423Sjhb	touch $NEW/adddir/conflict/newfile
468238423Sjhb	touch $TEST/adddir/conflict
469238423Sjhb
470238423Sjhb	# /adddir/partial: Add a new file in a directory.  The
471238423Sjhb	# directory already exists in the test tree and contains a
472238423Sjhb	# different local file.  The new file from the new tree should
473238423Sjhb	# be added.
474238423Sjhb	for i in $NEW $TEST; do
475238423Sjhb		mkdir $i/adddir/partial
476238423Sjhb	done
477238423Sjhb	echo "foo" > $NEW/adddir/partial/file
478238423Sjhb	mkfifo $TEST/adddir/partial/fifo
479238423Sjhb
480238423Sjhb	## Tests for removing directories
481238423Sjhb	mkdir -p $OLD/rmdir $NEW/rmdir $TEST/rmdir
482238423Sjhb
483238423Sjhb	# /rmdir/extra: Do not remove a directory with an extra local file.
484238423Sjhb	# This should generate a warning.
485238423Sjhb	for i in $OLD $TEST; do
486238423Sjhb		mkdir $i/rmdir/extra
487238423Sjhb	done
488238423Sjhb	echo "foo" > $TEST/rmdir/extra/localfile.txt
489238423Sjhb
490238423Sjhb	# /rmdir/conflict: Do not remove a directory with a conflicted
491238423Sjhb	# remove file.  This should generate a warning.
492238423Sjhb	for i in $OLD $TEST; do
493238423Sjhb		mkdir $i/rmdir/conflict
494238423Sjhb	done
495238423Sjhb	mkfifo $OLD/rmdir/conflict/difftype
496238423Sjhb	mkdir $TEST/rmdir/conflict/difftype
497238423Sjhb
498238423Sjhb	# /rmdir/partial: Remove a complete hierarchy when part of the
499238423Sjhb	# tree has already been removed locally.
500238423Sjhb	for i in $OLD $TEST; do
501238423Sjhb		mkdir -p $i/rmdir/partial/subdir
502238423Sjhb		mkfifo $i/rmdir/partial/subdir/fifo
503238423Sjhb	done
504238423Sjhb	echo "foo" > $OLD/rmdir/partial/subdir/file
505238423Sjhb
506238423Sjhb	## Tests for converting files to directories and vice versa
507238423Sjhb	for i in $OLD $NEW $TEST; do
508238423Sjhb		for j in already old fromdir todir; do
509238423Sjhb			mkdir -p $i/dirchange/$j
510238423Sjhb		done
511238423Sjhb	done
512238423Sjhb
513238423Sjhb	# /dirchange/already/fromdir: Convert a directory tree to a
514238423Sjhb	# file without conflicts where the test tree already has the
515238423Sjhb	# new file.  Nothing should happen.
516238423Sjhb	mkdir $OLD/dirchange/already/fromdir
517238423Sjhb	echo "blah" > $OLD/dirchange/already/fromdir/somefile
518238423Sjhb	for i in $NEW $TEST; do
519238423Sjhb		echo "bar" > $i/dirchange/already/fromdir
520238423Sjhb	done
521238423Sjhb
522238423Sjhb	# /dirchange/already/todir: Convert an unmodified file to a
523238423Sjhb	# directory tree where the test tree already has the new
524238423Sjhb	# tree.  Nothing should happen.
525238423Sjhb	echo "baz" > $OLD/dirchange/already/todir
526238423Sjhb	for i in $NEW $TEST; do
527238423Sjhb		mkdir $i/dirchange/already/todir
528238423Sjhb		echo "blah" > $i/dirchange/already/todir/somefile
529238423Sjhb	done
530238423Sjhb
531238423Sjhb	# /dirchange/old/fromdir: Convert a directory tree to a file.
532238423Sjhb	# The old files are unmodified and should be changed to the new tree.
533238423Sjhb	for i in $OLD $TEST; do
534238423Sjhb		mkdir $i/dirchange/old/fromdir
535238423Sjhb		echo "blah" > $i/dirchange/old/fromdir/somefile
536238423Sjhb	done
537238423Sjhb	echo "bar" > $NEW/dirchange/old/fromdir
538238423Sjhb
539238423Sjhb	# /dirchange/old/todir: Convert a file to a directory tree.
540238423Sjhb	# The old file is unmodified and should be changed to the new
541238423Sjhb	# tree.
542238423Sjhb	for i in $OLD $TEST; do
543238423Sjhb		echo "foo" > $i/dirchange/old/todir
544238423Sjhb	done
545238423Sjhb	mkdir $NEW/dirchange/old/todir
546238423Sjhb	echo "bar" > $NEW/dirchange/old/todir/file
547238423Sjhb
548238423Sjhb	# /dirchange/fromdir/extradir: Convert a directory tree to a
549238423Sjhb	# file.  The test tree includes an extra file in the directory
550238423Sjhb	# that is not present in the old tree.  This should generate a
551238423Sjhb	# warning.
552238423Sjhb	for i in $OLD $TEST; do
553238423Sjhb		mkdir $i/dirchange/fromdir/extradir
554238423Sjhb		echo "foo" > $i/dirchange/fromdir/extradir/file
555238423Sjhb	done
556238423Sjhb	mkfifo $TEST/dirchange/fromdir/extradir/fifo
557238423Sjhb	ln -s "bar" $NEW/dirchange/fromdir/extradir
558238423Sjhb
559238423Sjhb	# /dirchange/fromdir/conflict: Convert a directory tree to a
560238423Sjhb	# file.  The test tree includes a local change that generates
561238423Sjhb	# a warning and prevents the removal of the directory.
562238423Sjhb	for i in $OLD $TEST; do
563238423Sjhb		mkdir $i/dirchange/fromdir/conflict
564238423Sjhb	done
565238423Sjhb	echo "foo" > $OLD/dirchange/fromdir/conflict/somefile
566238423Sjhb	echo "bar" > $TEST/dirchange/fromdir/conflict/somefile
567238423Sjhb	mkfifo $NEW/dirchange/fromdir/conflict
568238423Sjhb
569238423Sjhb	# /dirchange/todir/difffile: Convert a file to a directory
570238423Sjhb	# tree.  The test tree has a locally modified version of the
571238423Sjhb	# file so that the conversion fails with a warning.
572238423Sjhb	echo "foo" > $OLD/dirchange/todir/difffile
573238423Sjhb	mkdir $NEW/dirchange/todir/difffile
574238423Sjhb	echo "baz" > $NEW/dirchange/todir/difffile/file
575238423Sjhb	echo "bar" > $TEST/dirchange/todir/difffile
576238423Sjhb
577238423Sjhb	# /dirchange/todir/difftype: Similar to the previous test, but
578238423Sjhb	# the conflict is due to a change in the file type.
579238423Sjhb	echo "foo" > $OLD/dirchange/todir/difftype
580238423Sjhb	mkdir $NEW/dirchange/todir/difftype
581238423Sjhb	echo "baz" > $NEW/dirchange/todir/difftype/file
582238423Sjhb	mkfifo $TEST/dirchange/todir/difftype
583238423Sjhb
584238423Sjhb	## Tests for post-install actions
585238423Sjhb
586238423Sjhb	# - Adding /etc/master.passwd should cause pwd_mkdb to be run
587238423Sjhb	echo "foo:*:16000:100::0:0:& user:/home/foo:/bin/tcsh" > \
588238423Sjhb	    $NEW/etc/master.passwd
589238423Sjhb
590238423Sjhb	# - Verify that updating an unmodified /etc/login.conf builds
591238423Sjhb	# /etc/login.conf.db.
592238423Sjhb	cat > $OLD/etc/login.conf <<EOF
593238423Sjhbdefault:\\
594238423Sjhb	:passwd_format=md5:
595238423SjhbEOF
596238423Sjhb	cat > $NEW/etc/login.conf <<EOF
597238423Sjhbdefault:\\
598238423Sjhb	:passwd_format=md5:\\
599238423Sjhb	:copyright=/etc/COPYRIGHT
600238423SjhbEOF
601238423Sjhb	cp $OLD/etc/login.conf $TEST/etc/login.conf
602238423Sjhb
603238423Sjhb	# - Verify that a merge without conflicts to /etc/mail/aliases
604238423Sjhb	# will trigger a newaliases run request.
605238423Sjhb	mkdir -p $OLD/etc/mail $NEW/etc/mail $TEST/etc/mail
606238423Sjhb	cat > $OLD/etc/mail/aliases <<EOF
607238423Sjhb# root: me@my.domain
608238423Sjhb
609238423Sjhb# Basic system aliases -- these MUST be present
610238423SjhbMAILER-DAEMON: postmaster
611238423Sjhbpostmaster: root
612238423SjhbEOF
613238423Sjhb	cat > $NEW/etc/mail/aliases <<EOF
614238423Sjhb# root: me@my.domain
615238423Sjhb
616238423Sjhb# Basic system aliases -- these MUST be present
617238423SjhbMAILER-DAEMON: postmaster
618238423Sjhbpostmaster: root
619238423Sjhb
620238423Sjhb# General redirections for pseudo accounts
621238423Sjhb_dhcp:  root
622238423Sjhb_pflogd: root
623238423SjhbEOF
624238423Sjhb	cat > $TEST/etc/mail/aliases <<EOF
625238423Sjhbroot: someone@example.com
626238423Sjhb
627238423Sjhb# Basic system aliases -- these MUST be present
628238423SjhbMAILER-DAEMON: postmaster
629238423Sjhbpostmaster: root
630238423SjhbEOF
631238423Sjhb}
632238423Sjhb
633238423Sjhb# $1 - relative path to file that should be missing from TEST
634238423Sjhbmissing()
635238423Sjhb{
636238423Sjhb	if [ -e $TEST/$1 -o -L $TEST/$1 ]; then
637238423Sjhb		echo "File $1 should be missing"
638238423Sjhb	fi
639238423Sjhb}
640238423Sjhb
641238423Sjhb# $1 - relative path to file that should be present in TEST
642238423Sjhbpresent()
643238423Sjhb{
644238423Sjhb	if ! [ -e $TEST/$1 -o -L $TEST/$1 ]; then
645238423Sjhb		echo "File $1 should be present"
646238423Sjhb	fi
647238423Sjhb}
648238423Sjhb
649238423Sjhb# $1 - relative path to file that should be a fifo in TEST
650238423Sjhbfifo()
651238423Sjhb{
652238423Sjhb	if ! [ -p $TEST/$1 ]; then
653238423Sjhb		echo "File $1 should be a FIFO"
654238423Sjhb	fi
655238423Sjhb}
656238423Sjhb
657238423Sjhb# $1 - relative path to file that should be a directory in TEST
658238423Sjhbdir()
659238423Sjhb{
660238423Sjhb	if ! [ -d $TEST/$1 ]; then
661238423Sjhb		echo "File $1 should be a directory"
662238423Sjhb	fi
663238423Sjhb}
664238423Sjhb
665238423Sjhb# $1 - relative path to file that should be a symlink in TEST
666238423Sjhb# $2 - optional value of the link
667238423Sjhblink()
668238423Sjhb{
669238423Sjhb	local val
670238423Sjhb
671238423Sjhb	if ! [ -L $TEST/$1 ]; then
672238423Sjhb		echo "File $1 should be a link"
673238423Sjhb	elif [ $# -gt 1 ]; then
674238423Sjhb		val=`readlink $TEST/$1`
675238423Sjhb		if [ "$val" != "$2" ]; then
676238423Sjhb			echo "Link $1 should link to \"$2\""
677238423Sjhb		fi
678238423Sjhb	fi
679238423Sjhb}
680238423Sjhb
681238423Sjhb# $1 - relative path to regular file that should be present in TEST
682238423Sjhb# $2 - optional string that should match file contents
683238423Sjhb# $3 - optional MD5 of the flie contents, overrides $2 if present
684238423Sjhbfile()
685238423Sjhb{
686238423Sjhb	local contents sum
687238423Sjhb
688238423Sjhb	if ! [ -f $TEST/$1 ]; then
689238423Sjhb		echo "File $1 should be a regular file"
690238423Sjhb	elif [ $# -eq 2 ]; then
691238423Sjhb		contents=`cat $TEST/$1`
692238423Sjhb		if [ "$contents" != "$2" ]; then
693238423Sjhb			echo "File $1 has wrong contents"
694238423Sjhb		fi
695238423Sjhb	elif [ $# -eq 3 ]; then
696238423Sjhb		sum=`md5 -q $TEST/$1`
697238423Sjhb		if [ "$sum" != "$3" ]; then
698238423Sjhb			echo "File $1 has wrong contents"
699238423Sjhb		fi
700238423Sjhb	fi
701238423Sjhb}
702238423Sjhb
703238423Sjhb# $1 - relative path to a regular file that should have a conflict
704238423Sjhb# $2 - optional MD5 of the conflict file contents
705238423Sjhbconflict()
706238423Sjhb{
707238423Sjhb	local sum
708238423Sjhb
709238423Sjhb	if ! [ -f $CONFLICTS/$1 ]; then
710238423Sjhb		echo "File $1 missing conflict"
711238423Sjhb	elif [ $# -gt 1 ]; then
712238423Sjhb		sum=`md5 -q $CONFLICTS/$1`
713238423Sjhb		if [ "$sum" != "$2" ]; then
714238423Sjhb			echo "Conflict $1 has wrong contents"
715238423Sjhb		fi
716238423Sjhb	fi
717238423Sjhb}
718238423Sjhb
719238423Sjhbcheck_trees()
720238423Sjhb{
721238423Sjhb
722238423Sjhb	echo "Checking tree for correct results:"
723238423Sjhb
724238423Sjhb	## /equal/equal/equal:
725238423Sjhb	fifo /equal/equal/equal/fifo
726238423Sjhb	file /equal/equal/equal/file "foo"
727238423Sjhb	dir /equal/equal/equal/dir
728238423Sjhb	link /equal/equal/equal/link "bar"
729238423Sjhb
730238423Sjhb	## /equal/first/first:
731238423Sjhb	missing /equal/first/first/fifo
732238423Sjhb	missing /equal/first/first/file
733238423Sjhb	missing /equal/first/first/dir
734238423Sjhb	missing /equal/first/first/link
735238423Sjhb
736238423Sjhb	## /equal/difftype/difftype:
737238423Sjhb	file /equal/difftype/difftype/fifo "bar"
738238423Sjhb	link /equal/difftype/difftype/fromdir "test"
739238423Sjhb
740238423Sjhb	## /equal/difflinks/difflinks:
741238423Sjhb	link /equal/difflinks/difflinks/link "bar"
742238423Sjhb
743238423Sjhb	## /equal/difffiles/difffiles:
744238423Sjhb	file /equal/difffiles/difffiles/file "bar"
745238423Sjhb
746238423Sjhb	## /first/equal/second:
747238423Sjhb	missing /first/equal/second/fifo
748238423Sjhb	missing /first/equal/second/file
749238423Sjhb	missing /first/equal/second/emptydir
750238423Sjhb	missing /first/equal/second/link
751238423Sjhb	missing /first/equal/second/fulldir
752238423Sjhb
753238423Sjhb	## /first/first/equal:
754238423Sjhb	missing /first/first/equal/fifo
755238423Sjhb	missing /first/first/equal/file
756238423Sjhb	missing /first/first/equal/dir
757238423Sjhb	missing /first/first/equal/link
758238423Sjhb
759238423Sjhb	## /first/difftype/second:
760238423Sjhb	present /first/difftype/second/fifo
761238423Sjhb
762238423Sjhb	## /first/difflinks/second:
763238423Sjhb	link /first/difflinks/second/link "test link"
764238423Sjhb
765238423Sjhb	## /first/difffiles/second:
766238423Sjhb	file /first/difffiles/second/file "bar"
767238423Sjhb
768238423Sjhb	## /second/equal/first:
769238423Sjhb	file /second/equal/first/file "bar"
770238423Sjhb	fifo /second/equal/first/fifo
771238423Sjhb	link /second/equal/first/link "new"
772238423Sjhb	missing /second/equal/first/emptydir
773238423Sjhb	file /second/equal/first/fulldir/file "foo"
774238423Sjhb
775238423Sjhb	## /second/second/equal:
776238423Sjhb	fifo /second/second/equal/fifo
777238423Sjhb	file /second/second/equal/file "foo"
778238423Sjhb	dir /second/second/equal/dir
779238423Sjhb	link /second/second/equal/link "bar"
780238423Sjhb
781238423Sjhb	## /second/second/difftype:
782238423Sjhb	fifo /second/second/difftype/dir
783238423Sjhb
784238423Sjhb	## /second/second/difflinks:
785238423Sjhb	link /second/second/difflinks/link "test link"
786238423Sjhb
787238423Sjhb	## /second/second/difffiles:
788238423Sjhb	file /second/second/difffiles/file "test"
789238423Sjhb	conflict /second/second/difffiles/file 4f2ee8620a251fd53f06bb6112eb6ffa
790238423Sjhb
791238423Sjhb	## /difftype/equal/difftype:
792238423Sjhb	link /difftype/equal/difftype/file "test"
793238423Sjhb	fifo /difftype/equal/difftype/fromdir
794238423Sjhb	missing /difftype/equal/difftype/todir
795238423Sjhb
796238423Sjhb	## /difftype/first/first:
797238423Sjhb	missing /difftype/first/first/fifo
798238423Sjhb
799238423Sjhb	## /difftype/difftype/equal:
800238423Sjhb	fifo /difftype/difftype/equal/fifo
801238423Sjhb	file /difftype/difftype/equal/file "bar"
802238423Sjhb
803238423Sjhb	## /difftype/difftype/difftype:
804238423Sjhb	file /difftype/difftype/difftype/one "foo"
805238423Sjhb	link /difftype/difftype/difftype/two "bar"
806238423Sjhb
807238423Sjhb	## /difftype/difftype/difflinks:
808238423Sjhb	link /difftype/difftype/difflinks/link "test"
809238423Sjhb
810238423Sjhb	## /difftype/difftype/difffile:
811238423Sjhb	conflict /difftype/difftype/difffiles/file \
812238423Sjhb	    117f2bcd1f6491f6044e79e5a57a9229
813238423Sjhb
814238423Sjhb	## /difflinks/equal/difflinks:
815238423Sjhb	link /difflinks/equal/difflinks/link "new"
816238423Sjhb
817238423Sjhb	## /difflinks/first/first:
818238423Sjhb	missing /difflinks/first/first/link
819238423Sjhb
820238423Sjhb	## /difflinks/difftype/difftype:
821238423Sjhb	file /difflinks/difftype/difftype/link "test"
822238423Sjhb
823238423Sjhb	## /difflinks/difflinks/equal:
824238423Sjhb	link /difflinks/difflinks/equal/link "new"
825238423Sjhb
826238423Sjhb	## /difflinks/difflinks/difflinks:
827238423Sjhb	link /difflinks/difflinks/difflinks/link "test"
828238423Sjhb
829238423Sjhb	## /difffiles/equal/difffiles:
830238423Sjhb	file /difffiles/equal/difffiles/file "bar"
831238423Sjhb
832238423Sjhb	## /difffiles/first/first:
833238423Sjhb	missing /difffiles/first/first/file
834238423Sjhb
835238423Sjhb	## /difffiles/difftype/difftype:
836238423Sjhb	fifo /difffiles/difftype/difftype/file
837238423Sjhb
838238423Sjhb	## /difffiles/difffiles/equal:
839238423Sjhb	file /difffiles/difffiles/equal/file "bar"
840238423Sjhb
841238423Sjhb	## /difffiles/difffiles/difffiles:
842238423Sjhb	file /difffiles/difffiles/difffiles/simple "" \
843238423Sjhb	    cabc7e5e80b0946d79edd555e9648486
844238423Sjhb	file /difffiles/difffiles/difffiles/conflict "this is a test file"
845238423Sjhb	conflict /difffiles/difffiles/difffiles/conflict \
846238423Sjhb	    8261cfdd89280c4a6c26e4ac86541fe9
847238423Sjhb
848238423Sjhb	## /adddir/conflict:
849238423Sjhb	file /adddir/conflict
850238423Sjhb
851238423Sjhb	## /adddir/partial:
852238423Sjhb	file /adddir/partial/file "foo"
853238423Sjhb	fifo /adddir/partial/fifo
854238423Sjhb
855238423Sjhb	## /rmdir/extra:
856238423Sjhb	dir /rmdir/extra
857238423Sjhb	file /rmdir/extra/localfile.txt "foo"
858238423Sjhb
859238423Sjhb	## /rmdir/conflict:
860238423Sjhb	dir /rmdir/conflict/difftype
861238423Sjhb	present /rmdir/conflict
862238423Sjhb
863238423Sjhb	## /rmdir/partial:
864238423Sjhb	missing /rmdir/partial
865238423Sjhb
866238423Sjhb	## /dirchange/already/fromdir:
867238423Sjhb	file /dirchange/already/fromdir "bar"
868238423Sjhb
869238423Sjhb	## /dirchange/already/todir:
870238423Sjhb	file /dirchange/already/todir/somefile "blah"
871238423Sjhb
872238423Sjhb	## /dirchange/old/fromdir:
873238423Sjhb	file /dirchange/old/fromdir "bar"
874238423Sjhb
875238423Sjhb	## /dirchange/old/todir
876238423Sjhb	file /dirchange/old/todir/file "bar"
877238423Sjhb
878238423Sjhb	## /dirchange/fromdir/extradir:
879238423Sjhb	missing /dirchange/fromdir/extradir/file
880238423Sjhb	fifo /dirchange/fromdir/extradir/fifo
881238423Sjhb
882238423Sjhb	## /dirchange/fromdir/conflict:
883238423Sjhb	file /dirchange/fromdir/conflict/somefile "bar"
884238423Sjhb
885238423Sjhb	## /dirchange/todir/difffile:
886238423Sjhb	file /dirchange/todir/difffile "bar"
887238423Sjhb
888238423Sjhb	## /dirchange/todir/difftype:
889238423Sjhb	fifo /dirchange/todir/difftype
890238423Sjhb
891238423Sjhb	## Tests for post-install actions
892238423Sjhb	file /etc/master.passwd
893238423Sjhb	file /etc/passwd
894238423Sjhb	file /etc/pwd.db
895238423Sjhb	file /etc/spwd.db
896238423Sjhb	file /etc/login.conf "" 7774a0f9a3a372c7c109c32fd31c4b6b
897238423Sjhb	file /etc/login.conf.db
898238423Sjhb	file /etc/mail/aliases "" 7d598f89ec040ab56af54011bdb83337
899238423Sjhb}
900238423Sjhb
901238423Sjhbif [ `id -u` -ne 0 ]; then
902238423Sjhb	echo "must be root"
903238423Sjhbfi
904238423Sjhb
905238423Sjhbif [ -r /etc/etcupdate.conf ]; then
906238423Sjhb	echo "WARNING: /etc/etcupdate.conf settings may break some tests."
907238423Sjhbfi
908238423Sjhb
909238423Sjhbbuild_trees
910238423Sjhb
911258063Sjhb$COMMAND -nr -d $WORKDIR -D $TEST > $WORKDIR/testn.out
912238423Sjhb
913238423Sjhbcat > $WORKDIR/correct.out <<EOF
914238423Sjhb  D /dirchange/fromdir/extradir/file
915238423Sjhb  D /dirchange/old/fromdir/somefile
916238423Sjhb  D /first/equal/second/fifo
917238423Sjhb  D /first/equal/second/file
918238423Sjhb  D /first/equal/second/fulldir/file
919238423Sjhb  D /first/equal/second/link
920238423Sjhb  D /rmdir/partial/subdir/fifo
921238423Sjhb  D /rmdir/partial/subdir
922238423Sjhb  D /rmdir/partial
923238423Sjhb  D /first/equal/second/fulldir
924238423Sjhb  D /first/equal/second/emptydir
925238423Sjhb  C /difffiles/difffiles/difffiles/conflict
926238423Sjhb  M /difffiles/difffiles/difffiles/simple
927238423Sjhb  U /difffiles/equal/difffiles/file
928238423Sjhb  U /difflinks/equal/difflinks/link
929238423Sjhb  C /difftype/difftype/difffiles/file
930238423Sjhb  U /difftype/equal/difftype/file
931238423Sjhb  U /difftype/equal/difftype/fromdir
932238423Sjhb  D /difftype/equal/difftype/todir
933238423Sjhb  U /dirchange/old/fromdir
934238423Sjhb  U /dirchange/old/todir
935238423Sjhb  U /etc/login.conf
936238423Sjhb  M /etc/mail/aliases
937238423Sjhb  A /adddir/partial/file
938238423Sjhb  A /dirchange/old/todir/file
939238423Sjhb  A /etc/master.passwd
940238423Sjhb  A /second/equal/first/fifo
941238423Sjhb  A /second/equal/first/file
942238423Sjhb  A /second/equal/first/fulldir/file
943238423Sjhb  A /second/equal/first/link
944238423Sjhb  C /second/second/difffiles/file
945238423SjhbWarnings:
946238423Sjhb  Modified regular file remains: /dirchange/fromdir/conflict/somefile
947238423Sjhb  Modified regular file remains: /first/difffiles/second/file
948238423Sjhb  Modified symbolic link remains: /first/difflinks/second/link
949238423Sjhb  Modified directory remains: /first/difftype/second/fifo
950238423Sjhb  Modified directory remains: /rmdir/conflict/difftype
951238423Sjhb  Non-empty directory remains: /rmdir/extra
952238423Sjhb  Non-empty directory remains: /rmdir/conflict
953238423Sjhb  Modified mismatch: /difffiles/difftype/difftype/file (regular file vs fifo file)
954238423Sjhb  Removed file changed: /difffiles/first/first/file
955238423Sjhb  Modified link changed: /difflinks/difflinks/difflinks/link ("old" became "new")
956238423Sjhb  Modified mismatch: /difflinks/difftype/difftype/link (symbolic link vs regular file)
957238423Sjhb  Removed link changed: /difflinks/first/first/link ("old" became "new")
958238423Sjhb  New link conflict: /difftype/difftype/difflinks/link ("new" vs "test")
959238423Sjhb  Modified regular file changed: /difftype/difftype/difftype/one (fifo file became directory)
960238423Sjhb  Modified symbolic link changed: /difftype/difftype/difftype/two (directory became regular file)
961238423Sjhb  Remove mismatch: /difftype/first/first/fifo (fifo file became directory)
962238423Sjhb  Modified directory changed: /dirchange/fromdir/conflict (directory became fifo file)
963238423Sjhb  Modified directory changed: /dirchange/fromdir/extradir (directory became symbolic link)
964238423Sjhb  Modified regular file changed: /dirchange/todir/difffile (regular file became directory)
965238423Sjhb  Modified fifo file changed: /dirchange/todir/difftype (regular file became directory)
966238423Sjhb  New file mismatch: /adddir/conflict (directory vs regular file)
967238423Sjhb  Directory mismatch: $TEST/adddir/conflict (regular file)
968238423Sjhb  Directory mismatch: $TEST/dirchange/todir/difffile (regular file)
969238423Sjhb  Directory mismatch: $TEST/dirchange/todir/difftype (fifo file)
970238423Sjhb  New link conflict: /second/second/difflinks/link ("new link" vs "test link")
971238423Sjhb  New file mismatch: /second/second/difftype/dir (directory vs fifo file)
972238423Sjhb  Needs update: /etc/mail/aliases.db (requires manual update via newaliases(1))
973238423SjhbEOF
974238423Sjhb
975238423Sjhbecho "Differences for -n:"
976238423Sjhbdiff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/testn.out
977238423Sjhb
978258063Sjhb$COMMAND -r -d $WORKDIR -D $TEST > $WORKDIR/test.out
979238423Sjhb
980238423Sjhbecho "Differences for real:"
981238423Sjhbdiff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out
982238423Sjhb
983238423Sjhbcheck_trees
984