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$
29238423Sjhb
30238423Sjhb# Various regression tests to test the -A flag to the 'update' command.
31238423Sjhb
32263221SjmmvFAILED=no
33238423SjhbWORKDIR=work
34238423Sjhb
35238423Sjhbusage()
36238423Sjhb{
37258063Sjhb	echo "Usage: always.sh [-s script] [-w workdir]"
38238423Sjhb	exit 1
39238423Sjhb}
40238423Sjhb
41258063Sjhb# Allow the user to specify an alternate work directory or script.
42258063SjhbCOMMAND=etcupdate
43258063Sjhbwhile getopts "s:w:" option; do
44238423Sjhb	case $option in
45258063Sjhb		s)
46258063Sjhb			COMMAND="sh $OPTARG"
47258063Sjhb			;;
48238423Sjhb		w)
49238423Sjhb			WORKDIR=$OPTARG
50238423Sjhb			;;
51238423Sjhb		*)
52238423Sjhb			echo
53238423Sjhb			usage
54238423Sjhb			;;
55238423Sjhb	esac
56238423Sjhbdone
57238423Sjhbshift $((OPTIND - 1))
58238423Sjhbif [ $# -ne 0 ]; then
59238423Sjhb	usage
60238423Sjhbfi
61238423Sjhb
62238423SjhbCONFLICTS=$WORKDIR/conflicts
63238423SjhbOLD=$WORKDIR/old
64238423SjhbNEW=$WORKDIR/current
65238423SjhbTEST=$WORKDIR/test
66238423Sjhb
67238423Sjhb# The various states of the comparison of a file between two trees.
68238423Sjhbstates="equal first second difftype difflinks difffiles"
69238423Sjhb
70238423Sjhb# These tests deal with ignoring certain patterns of files.  We run
71238423Sjhb# the test multiple times forcing the install of different patterns.
72238423Sjhbbuild_trees()
73238423Sjhb{
74238423Sjhb	local i
75238423Sjhb
76238423Sjhb	rm -rf $OLD $NEW $TEST $CONFLICTS
77238423Sjhb
78238423Sjhb	for i in $states; do
79238423Sjhb		for j in $states; do
80238423Sjhb			for k in $states; do
81238423Sjhb				mkdir -p $OLD/$i/$j/$k $NEW/$i/$j/$k \
82238423Sjhb				    $TEST/$i/$j/$k
83238423Sjhb			done
84238423Sjhb		done
85238423Sjhb	done
86238423Sjhb
87238423Sjhb	# What follows are the various warning/conflict cases from the
88238423Sjhb	# larger regression tests.  These results of many of these
89238423Sjhb	# tests should be changed when installation is forced.  The
90238423Sjhb	# cases when these updates should still fail even when forced
91238423Sjhb	# are: 1) it should not force the removal of a modified file
92238423Sjhb	# and 2) it should not remove a subdirectory that contains a
93238423Sjhb	# modified or added file.
94238423Sjhb
95238423Sjhb	# /first/difftype/second: File with different local type
96238423Sjhb	# removed.  Should generate a warning.
97238423Sjhb	mkfifo $OLD/first/difftype/second/fifo
98238423Sjhb	mkdir $TEST/first/difftype/second/fifo
99238423Sjhb
100238423Sjhb	# /first/difflinks/second: Modified link removed.  Should
101238423Sjhb	# generate a warning.
102238423Sjhb	ln -s "old link" $OLD/first/difflinks/second/link
103238423Sjhb	ln -s "test link" $TEST/first/difflinks/second/link
104238423Sjhb
105238423Sjhb	# /first/difffiles/second: Modified file removed.  Should
106238423Sjhb	# generate a warning.
107238423Sjhb	echo "foo" > $OLD/first/difffiles/second/file
108238423Sjhb	echo "bar" > $TEST/first/difffiles/second/file
109238423Sjhb
110238423Sjhb	# /second/second/difftype: Newly added file conflicts with
111238423Sjhb	# existing file in test tree of a different type.  Should
112238423Sjhb	# generate a warning.
113238423Sjhb	mkdir $NEW/second/second/difftype/dir
114238423Sjhb	mkfifo $TEST/second/second/difftype/dir
115238423Sjhb
116238423Sjhb	# /second/second/difflinks: Newly added link conflicts with
117238423Sjhb	# existing link in test tree.  Should generate a warning.
118238423Sjhb	ln -s "new link" $NEW/second/second/difflinks/link
119238423Sjhb	ln -s "test link" $TEST/second/second/difflinks/link
120238423Sjhb
121238423Sjhb	# /second/second/difffiles: Newly added file conflicts with
122238423Sjhb	# existing file in test tree.  Should generate a warning.
123238423Sjhb	echo "new" > $NEW/second/second/difffiles/file
124238423Sjhb	echo "test" > $TEST/second/second/difffiles/file
125238423Sjhb
126238423Sjhb	# /difftype/first/first: A removed file has changed type.
127238423Sjhb	# This should generate a warning.
128238423Sjhb	mkfifo $OLD/difftype/first/first/fifo
129238423Sjhb	mkdir $NEW/difftype/first/first/fifo
130238423Sjhb
131238423Sjhb	# /difftype/difftype/difftype: All three files (old, new, and
132238423Sjhb	# test) are different types from each other.  This should
133238423Sjhb	# generate a warning.
134238423Sjhb	mkfifo $OLD/difftype/difftype/difftype/one
135238423Sjhb	mkdir $NEW/difftype/difftype/difftype/one
136238423Sjhb	echo "foo" > $TEST/difftype/difftype/difftype/one
137238423Sjhb	mkdir $OLD/difftype/difftype/difftype/two
138238423Sjhb	echo "baz" > $NEW/difftype/difftype/difftype/two
139238423Sjhb	ln -s "bar" $TEST/difftype/difftype/difftype/two
140238423Sjhb
141238423Sjhb	# /difftype/difftype/difflinks: A file has changed from a
142238423Sjhb	# non-link to a link in both the new and test trees, but the
143238423Sjhb	# target of the new and test links differ.  This should
144238423Sjhb	# generate a new link conflict.
145238423Sjhb	mkfifo $OLD/difftype/difftype/difflinks/link
146238423Sjhb	ln -s "new" $NEW/difftype/difftype/difflinks/link
147238423Sjhb	ln -s "test" $TEST/difftype/difftype/difflinks/link
148238423Sjhb
149238423Sjhb	# /difftype/difftype/difffile: A file has changed from a
150238423Sjhb	# non-regular file to a regular file in both the new and test
151238423Sjhb	# trees, but the contents in the new and test files differ.
152238423Sjhb	# This should generate a new file conflict.
153238423Sjhb	ln -s "old" $OLD/difftype/difftype/difffiles/file
154238423Sjhb	echo "foo" > $NEW/difftype/difftype/difffiles/file
155238423Sjhb	echo "bar" > $TEST/difftype/difftype/difffiles/file
156238423Sjhb
157238423Sjhb	# /difflinks/first/first: A modified link is missing in the
158238423Sjhb	# test tree.  This should generate a warning.
159238423Sjhb	ln -s "old" $OLD/difflinks/first/first/link
160238423Sjhb	ln -s "new" $NEW/difflinks/first/first/link
161238423Sjhb
162238423Sjhb	# /difflinks/difftype/difftype: An updated link has been
163238423Sjhb	# changed to a different file type in the test tree.  This
164238423Sjhb	# should generate a warning.
165238423Sjhb	ln -s "old" $OLD/difflinks/difftype/difftype/link
166238423Sjhb	ln -s "new" $NEW/difflinks/difftype/difftype/link
167238423Sjhb	echo "test" > $TEST/difflinks/difftype/difftype/link
168238423Sjhb
169238423Sjhb	# /difflinks/difflinks/difflinks: An updated link has been
170238423Sjhb	# modified in the test tree and doesn't match either the old
171238423Sjhb	# or new links.  This should generate a warning.
172238423Sjhb	ln -s "old" $OLD/difflinks/difflinks/difflinks/link
173238423Sjhb	ln -s "new" $NEW/difflinks/difflinks/difflinks/link
174238423Sjhb	ln -s "test" $TEST/difflinks/difflinks/difflinks/link
175238423Sjhb
176238423Sjhb	# /difffiles/first/first: A removed file has been changed in
177238423Sjhb	# the new tree.  This should generate a warning.
178238423Sjhb	echo "foo" > $OLD/difffiles/first/first/file
179238423Sjhb	echo "bar" > $NEW/difffiles/first/first/file
180238423Sjhb
181238423Sjhb	# /difffiles/difftype/difftype: An updated regular file has
182238423Sjhb	# been changed to a different file type in the test tree.
183238423Sjhb	# This should generate a warning.
184238423Sjhb	echo "old" > $OLD/difffiles/difftype/difftype/file
185238423Sjhb	echo "new" > $NEW/difffiles/difftype/difftype/file
186238423Sjhb	mkfifo $TEST/difffiles/difftype/difftype/file
187238423Sjhb
188238423Sjhb	# /difffiles/difffiles/difffiles: A modified regular file was
189238423Sjhb	# updated in the new tree.  The changes should be merged into
190238423Sjhb	# to the new file if possible.  If the merge fails, a conflict
191238423Sjhb	# should be generated.  For this test we just include the
192238423Sjhb	# conflict case.
193238423Sjhb	cat > $OLD/difffiles/difffiles/difffiles/conflict <<EOF
194238423Sjhbthis is an old file
195238423SjhbEOF
196238423Sjhb	cat > $NEW/difffiles/difffiles/difffiles/conflict <<EOF
197238423Sjhbthis is a new file
198238423SjhbEOF
199238423Sjhb	cat > $TEST/difffiles/difffiles/difffiles/conflict <<EOF
200238423Sjhbthis is a test file
201238423SjhbEOF
202238423Sjhb
203238423Sjhb	## Tests for adding directories
204238423Sjhb	mkdir -p $OLD/adddir $NEW/adddir $TEST/adddir
205238423Sjhb
206238423Sjhb	# /adddir/conflict: Add a new file in a directory that already
207238423Sjhb	# exists as a file.  This should generate two warnings.
208238423Sjhb	mkdir $NEW/adddir/conflict
209238423Sjhb	touch $NEW/adddir/conflict/newfile
210238423Sjhb	touch $TEST/adddir/conflict
211238423Sjhb
212238423Sjhb	## Tests for removing directories
213238423Sjhb	mkdir -p $OLD/rmdir $NEW/rmdir $TEST/rmdir
214238423Sjhb
215238423Sjhb	# /rmdir/extra: Do not remove a directory with an extra local file.
216238423Sjhb	# This should generate a warning.
217238423Sjhb	for i in $OLD $TEST; do
218238423Sjhb		mkdir $i/rmdir/extra
219238423Sjhb	done
220238423Sjhb	echo "foo" > $TEST/rmdir/extra/localfile.txt
221238423Sjhb
222238423Sjhb	# /rmdir/conflict: Do not remove a directory with a conflicted
223238423Sjhb	# remove file.  This should generate a warning.
224238423Sjhb	for i in $OLD $TEST; do
225238423Sjhb		mkdir $i/rmdir/conflict
226238423Sjhb	done
227238423Sjhb	mkfifo $OLD/rmdir/conflict/difftype
228238423Sjhb	mkdir $TEST/rmdir/conflict/difftype
229238423Sjhb
230238423Sjhb	## Tests for converting files to directories and vice versa
231238423Sjhb	for i in $OLD $NEW $TEST; do
232238423Sjhb		for j in already old fromdir todir; do
233238423Sjhb			mkdir -p $i/dirchange/$j
234238423Sjhb		done
235238423Sjhb	done
236238423Sjhb
237238423Sjhb	# /dirchange/fromdir/extradir: Convert a directory tree to a
238238423Sjhb	# file.  The test tree includes an extra file in the directory
239238423Sjhb	# that is not present in the old tree.  This should generate a
240238423Sjhb	# warning.
241238423Sjhb	for i in $OLD $TEST; do
242238423Sjhb		mkdir $i/dirchange/fromdir/extradir
243238423Sjhb		echo "foo" > $i/dirchange/fromdir/extradir/file
244238423Sjhb	done
245238423Sjhb	mkfifo $TEST/dirchange/fromdir/extradir/fifo
246238423Sjhb	ln -s "bar" $NEW/dirchange/fromdir/extradir
247238423Sjhb
248238423Sjhb	# /dirchange/fromdir/conflict: Convert a directory tree to a
249238423Sjhb	# file.  The test tree includes a local change that generates
250238423Sjhb	# a warning and prevents the removal of the directory.
251238423Sjhb	for i in $OLD $TEST; do
252238423Sjhb		mkdir $i/dirchange/fromdir/conflict
253238423Sjhb	done
254238423Sjhb	echo "foo" > $OLD/dirchange/fromdir/conflict/somefile
255238423Sjhb	echo "bar" > $TEST/dirchange/fromdir/conflict/somefile
256238423Sjhb	mkfifo $NEW/dirchange/fromdir/conflict
257238423Sjhb
258238423Sjhb	# /dirchange/todir/difffile: Convert a file to a directory
259238423Sjhb	# tree.  The test tree has a locally modified version of the
260238423Sjhb	# file so that the conversion fails with a warning.
261238423Sjhb	echo "foo" > $OLD/dirchange/todir/difffile
262238423Sjhb	mkdir $NEW/dirchange/todir/difffile
263238423Sjhb	echo "baz" > $NEW/dirchange/todir/difffile/file
264238423Sjhb	echo "bar" > $TEST/dirchange/todir/difffile
265238423Sjhb
266238423Sjhb	# /dirchange/todir/difftype: Similar to the previous test, but
267238423Sjhb	# the conflict is due to a change in the file type.
268238423Sjhb	echo "foo" > $OLD/dirchange/todir/difftype
269238423Sjhb	mkdir $NEW/dirchange/todir/difftype
270238423Sjhb	echo "baz" > $NEW/dirchange/todir/difftype/file
271238423Sjhb	mkfifo $TEST/dirchange/todir/difftype
272238423Sjhb}
273238423Sjhb
274238423Sjhb# $1 - relative path to file that should be missing from TEST
275238423Sjhbmissing()
276238423Sjhb{
277238423Sjhb	if [ -e $TEST/$1 -o -L $TEST/$1 ]; then
278238423Sjhb		echo "File $1 should be missing"
279263221Sjmmv		FAILED=yes
280238423Sjhb	fi
281238423Sjhb}
282238423Sjhb
283238423Sjhb# $1 - relative path to file that should be present in TEST
284238423Sjhbpresent()
285238423Sjhb{
286238423Sjhb	if ! [ -e $TEST/$1 -o -L $TEST/$1 ]; then
287238423Sjhb		echo "File $1 should be present"
288263221Sjmmv		FAILED=yes
289238423Sjhb	fi
290238423Sjhb}
291238423Sjhb
292238423Sjhb# $1 - relative path to file that should be a fifo in TEST
293238423Sjhbfifo()
294238423Sjhb{
295238423Sjhb	if ! [ -p $TEST/$1 ]; then
296238423Sjhb		echo "File $1 should be a FIFO"
297263221Sjmmv		FAILED=yes
298238423Sjhb	fi
299238423Sjhb}
300238423Sjhb
301238423Sjhb# $1 - relative path to file that should be a directory in TEST
302238423Sjhbdir()
303238423Sjhb{
304238423Sjhb	if ! [ -d $TEST/$1 ]; then
305238423Sjhb		echo "File $1 should be a directory"
306263221Sjmmv		FAILED=yes
307238423Sjhb	fi
308238423Sjhb}
309238423Sjhb
310238423Sjhb# $1 - relative path to file that should be a symlink in TEST
311238423Sjhb# $2 - optional value of the link
312238423Sjhblink()
313238423Sjhb{
314238423Sjhb	local val
315238423Sjhb
316238423Sjhb	if ! [ -L $TEST/$1 ]; then
317238423Sjhb		echo "File $1 should be a link"
318263221Sjmmv		FAILED=yes
319238423Sjhb	elif [ $# -gt 1 ]; then
320238423Sjhb		val=`readlink $TEST/$1`
321238423Sjhb		if [ "$val" != "$2" ]; then
322238423Sjhb			echo "Link $1 should link to \"$2\""
323263221Sjmmv			FAILED=yes
324238423Sjhb		fi
325238423Sjhb	fi
326238423Sjhb}
327238423Sjhb
328238423Sjhb# $1 - relative path to regular file that should be present in TEST
329238423Sjhb# $2 - optional string that should match file contents
330238423Sjhb# $3 - optional MD5 of the flie contents, overrides $2 if present
331238423Sjhbfile()
332238423Sjhb{
333238423Sjhb	local contents sum
334238423Sjhb
335238423Sjhb	if ! [ -f $TEST/$1 ]; then
336238423Sjhb		echo "File $1 should be a regular file"
337263221Sjmmv		FAILED=yes
338238423Sjhb	elif [ $# -eq 2 ]; then
339238423Sjhb		contents=`cat $TEST/$1`
340238423Sjhb		if [ "$contents" != "$2" ]; then
341238423Sjhb			echo "File $1 has wrong contents"
342263221Sjmmv			FAILED=yes
343238423Sjhb		fi
344238423Sjhb	elif [ $# -eq 3 ]; then
345238423Sjhb		sum=`md5 -q $TEST/$1`
346238423Sjhb		if [ "$sum" != "$3" ]; then
347238423Sjhb			echo "File $1 has wrong contents"
348263221Sjmmv			FAILED=yes
349238423Sjhb		fi
350238423Sjhb	fi
351238423Sjhb}
352238423Sjhb
353238423Sjhb# $1 - relative path to a regular file that should have a conflict
354238423Sjhb# $2 - optional MD5 of the conflict file contents
355238423Sjhbconflict()
356238423Sjhb{
357238423Sjhb	local sum
358238423Sjhb
359238423Sjhb	if ! [ -f $CONFLICTS/$1 ]; then
360238423Sjhb		echo "File $1 missing conflict"
361263221Sjmmv		FAILED=yes
362238423Sjhb	elif [ $# -gt 1 ]; then
363238423Sjhb		sum=`md5 -q $CONFLICTS/$1`
364238423Sjhb		if [ "$sum" != "$2" ]; then
365238423Sjhb			echo "Conflict $1 has wrong contents"
366263221Sjmmv			FAILED=yes
367238423Sjhb		fi
368238423Sjhb	fi
369238423Sjhb}
370238423Sjhb
371238423Sjhb# $1 - relative path to a regular file that should not have a conflict
372238423Sjhbnoconflict()
373238423Sjhb{
374238423Sjhb	if [ -f $CONFLICTS/$1 ]; then
375238423Sjhb		echo "File $1 should not have a conflict"
376263221Sjmmv		FAILED=yes
377238423Sjhb	fi
378238423Sjhb}
379238423Sjhb
380238423Sjhbif [ `id -u` -ne 0 ]; then
381238423Sjhb	echo "must be root"
382263221Sjmmv	exit 0
383238423Sjhbfi
384238423Sjhb
385238423Sjhbif [ -r /etc/etcupdate.conf ]; then
386238423Sjhb	echo "WARNING: /etc/etcupdate.conf settings may break some tests."
387238423Sjhbfi
388238423Sjhb
389238423Sjhb# First run the test ignoring no patterns.
390238423Sjhb
391238423Sjhbbuild_trees
392238423Sjhb
393258063Sjhb$COMMAND -r -d $WORKDIR -D $TEST > $WORKDIR/test.out
394238423Sjhb
395238423Sjhbcat > $WORKDIR/correct.out <<EOF
396238423Sjhb  D /dirchange/fromdir/extradir/file
397238423Sjhb  C /difffiles/difffiles/difffiles/conflict
398238423Sjhb  C /difftype/difftype/difffiles/file
399238423Sjhb  C /second/second/difffiles/file
400238423SjhbWarnings:
401238423Sjhb  Modified regular file remains: /dirchange/fromdir/conflict/somefile
402238423Sjhb  Modified regular file remains: /first/difffiles/second/file
403238423Sjhb  Modified symbolic link remains: /first/difflinks/second/link
404238423Sjhb  Modified directory remains: /first/difftype/second/fifo
405238423Sjhb  Modified directory remains: /rmdir/conflict/difftype
406238423Sjhb  Non-empty directory remains: /rmdir/extra
407238423Sjhb  Non-empty directory remains: /rmdir/conflict
408238423Sjhb  Modified mismatch: /difffiles/difftype/difftype/file (regular file vs fifo file)
409238423Sjhb  Removed file changed: /difffiles/first/first/file
410238423Sjhb  Modified link changed: /difflinks/difflinks/difflinks/link ("old" became "new")
411238423Sjhb  Modified mismatch: /difflinks/difftype/difftype/link (symbolic link vs regular file)
412238423Sjhb  Removed link changed: /difflinks/first/first/link ("old" became "new")
413238423Sjhb  New link conflict: /difftype/difftype/difflinks/link ("new" vs "test")
414238423Sjhb  Modified regular file changed: /difftype/difftype/difftype/one (fifo file became directory)
415238423Sjhb  Modified symbolic link changed: /difftype/difftype/difftype/two (directory became regular file)
416238423Sjhb  Remove mismatch: /difftype/first/first/fifo (fifo file became directory)
417238423Sjhb  Modified directory changed: /dirchange/fromdir/conflict (directory became fifo file)
418238423Sjhb  Modified directory changed: /dirchange/fromdir/extradir (directory became symbolic link)
419238423Sjhb  Modified regular file changed: /dirchange/todir/difffile (regular file became directory)
420238423Sjhb  Modified fifo file changed: /dirchange/todir/difftype (regular file became directory)
421238423Sjhb  New file mismatch: /adddir/conflict (directory vs regular file)
422238423Sjhb  Directory mismatch: $TEST/adddir/conflict (regular file)
423238423Sjhb  Directory mismatch: $TEST/dirchange/todir/difffile (regular file)
424238423Sjhb  Directory mismatch: $TEST/dirchange/todir/difftype (fifo file)
425238423Sjhb  New link conflict: /second/second/difflinks/link ("new link" vs "test link")
426238423Sjhb  New file mismatch: /second/second/difftype/dir (directory vs fifo file)
427238423SjhbEOF
428238423Sjhb
429238423Sjhbecho "Differences for regular:"
430263221Sjmmvdiff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out \
431263221Sjmmv    || FAILED=yes
432238423Sjhb
433238423Sjhb## /first/difftype/second:
434238423Sjhbpresent /first/difftype/second/fifo
435238423Sjhb
436238423Sjhb## /first/difflinks/second:
437238423Sjhblink /first/difflinks/second/link "test link"
438238423Sjhb
439238423Sjhb## /first/difffiles/second:
440238423Sjhbfile /first/difffiles/second/file "bar"
441238423Sjhb
442238423Sjhb## /second/second/difftype:
443238423Sjhbfifo /second/second/difftype/dir
444238423Sjhb
445238423Sjhb## /second/second/difflinks:
446238423Sjhblink /second/second/difflinks/link "test link"
447238423Sjhb
448238423Sjhb## /second/second/difffiles:
449238423Sjhbfile /second/second/difffiles/file "test"
450238423Sjhbconflict /second/second/difffiles/file 4f2ee8620a251fd53f06bb6112eb6ffa
451238423Sjhb
452238423Sjhb## /difftype/first/first:
453238423Sjhbmissing /difftype/first/first/fifo
454238423Sjhb
455238423Sjhb## /difftype/difftype/difftype:
456238423Sjhbfile /difftype/difftype/difftype/one "foo"
457238423Sjhblink /difftype/difftype/difftype/two "bar"
458238423Sjhb
459238423Sjhb## /difftype/difftype/difflinks:
460238423Sjhblink /difftype/difftype/difflinks/link "test"
461238423Sjhb
462238423Sjhb## /difftype/difftype/difffile:
463238423Sjhbconflict /difftype/difftype/difffiles/file 117f2bcd1f6491f6044e79e5a57a9229
464238423Sjhb
465238423Sjhb## /difflinks/first/first:
466238423Sjhbmissing /difflinks/first/first/link
467238423Sjhb
468238423Sjhb## /difflinks/difftype/difftype:
469238423Sjhbfile /difflinks/difftype/difftype/link "test"
470238423Sjhb
471238423Sjhb## /difflinks/difflinks/difflinks:
472238423Sjhblink /difflinks/difflinks/difflinks/link "test"
473238423Sjhb
474238423Sjhb## /difffiles/first/first:
475238423Sjhbmissing /difffiles/first/first/file
476238423Sjhb
477238423Sjhb## /difffiles/difftype/difftype:
478238423Sjhbfifo /difffiles/difftype/difftype/file
479238423Sjhb
480238423Sjhb## /difffiles/difffiles/difffiles:
481238423Sjhbfile /difffiles/difffiles/difffiles/conflict "this is a test file"
482238423Sjhbconflict /difffiles/difffiles/difffiles/conflict \
483238423Sjhb    8261cfdd89280c4a6c26e4ac86541fe9
484238423Sjhb
485238423Sjhb## /adddir/conflict:
486238423Sjhbfile /adddir/conflict
487238423Sjhb
488238423Sjhb## /rmdir/extra:
489238423Sjhbdir /rmdir/extra
490238423Sjhbfile /rmdir/extra/localfile.txt "foo"
491238423Sjhb
492238423Sjhb## /rmdir/conflict:
493238423Sjhbdir /rmdir/conflict/difftype
494238423Sjhbpresent /rmdir/conflict
495238423Sjhb
496238423Sjhb## /dirchange/fromdir/extradir:
497238423Sjhbmissing /dirchange/fromdir/extradir/file
498238423Sjhbfifo /dirchange/fromdir/extradir/fifo
499238423Sjhb
500238423Sjhb## /dirchange/fromdir/conflict:
501238423Sjhbfile /dirchange/fromdir/conflict/somefile "bar"
502238423Sjhb
503238423Sjhb## /dirchange/todir/difffile:
504238423Sjhbfile /dirchange/todir/difffile "bar"
505238423Sjhb
506238423Sjhb## /dirchange/todir/difftype:
507238423Sjhbfifo /dirchange/todir/difftype
508238423Sjhb
509238423Sjhb# Now test with -A '/first*' -A '/second* /*di*'.  This should remove
510238423Sjhb# most of the warnings and conflicts.
511238423Sjhb
512238423Sjhbbuild_trees
513238423Sjhb
514258063Sjhb$COMMAND -r -A '/first*' -A '/second* /*di*' -d $WORKDIR -D $TEST > \
515238423Sjhb    $WORKDIR/test1.out
516238423Sjhb
517238423Sjhbcat > $WORKDIR/correct1.out <<EOF
518238423Sjhb  D /dirchange/fromdir/extradir/file
519238423Sjhb  U /difffiles/difffiles/difffiles/conflict
520238423Sjhb  U /difffiles/difftype/difftype/file
521238423Sjhb  A /difffiles/first/first/file
522238423Sjhb  U /difflinks/difflinks/difflinks/link
523238423Sjhb  U /difflinks/difftype/difftype/link
524238423Sjhb  A /difflinks/first/first/link
525238423Sjhb  U /difftype/difftype/difffiles/file
526238423Sjhb  U /difftype/difftype/difflinks/link
527238423Sjhb  D /difftype/difftype/difftype/one
528238423Sjhb  U /difftype/difftype/difftype/two
529238423Sjhb  U /dirchange/todir/difffile
530238423Sjhb  U /dirchange/todir/difftype
531238423Sjhb  U /adddir/conflict
532238423Sjhb  A /adddir/conflict/newfile
533238423Sjhb  A /dirchange/todir/difffile/file
534238423Sjhb  A /dirchange/todir/difftype/file
535238423Sjhb  U /second/second/difffiles/file
536238423Sjhb  U /second/second/difflinks/link
537238423Sjhb  D /second/second/difftype/dir
538238423SjhbWarnings:
539238423Sjhb  Modified regular file remains: /dirchange/fromdir/conflict/somefile
540238423Sjhb  Modified regular file remains: /first/difffiles/second/file
541238423Sjhb  Modified symbolic link remains: /first/difflinks/second/link
542238423Sjhb  Modified directory remains: /first/difftype/second/fifo
543238423Sjhb  Modified directory remains: /rmdir/conflict/difftype
544238423Sjhb  Non-empty directory remains: /rmdir/extra
545238423Sjhb  Non-empty directory remains: /rmdir/conflict
546238423Sjhb  Modified directory changed: /dirchange/fromdir/conflict (directory became fifo file)
547238423Sjhb  Modified directory changed: /dirchange/fromdir/extradir (directory became symbolic link)
548238423SjhbEOF
549238423Sjhb
550238423Sjhbecho "Differences for -A '/first*' -A '/second* /*di*':"
551263221Sjmmvdiff -u -L "correct" $WORKDIR/correct1.out -L "test" $WORKDIR/test1.out \
552263221Sjmmv    || FAILED=yes
553238423Sjhb
554238423Sjhb## /first/difftype/second:
555238423Sjhbpresent /first/difftype/second/fifo
556238423Sjhb
557238423Sjhb## /first/difflinks/second:
558238423Sjhblink /first/difflinks/second/link "test link"
559238423Sjhb
560238423Sjhb## /first/difffiles/second:
561238423Sjhbfile /first/difffiles/second/file "bar"
562238423Sjhb
563238423Sjhb## /second/second/difftype:
564238423Sjhbmissing /second/second/difftype/dir
565238423Sjhb
566238423Sjhb## /second/second/difflinks:
567238423Sjhblink /second/second/difflinks/link "new link"
568238423Sjhb
569238423Sjhb## /second/second/difffiles:
570238423Sjhbfile /second/second/difffiles/file "new"
571238423Sjhbnoconflict /second/second/difffiles/file
572238423Sjhb
573238423Sjhb## /difftype/first/first:
574238423Sjhbmissing /difftype/first/first/fifo
575238423Sjhb
576238423Sjhb## /difftype/difftype/difftype:
577238423Sjhbmissing /difftype/difftype/difftype/one
578238423Sjhbfile /difftype/difftype/difftype/two "baz"
579238423Sjhb
580238423Sjhb## /difftype/difftype/difflinks:
581238423Sjhblink /difftype/difftype/difflinks/link "new"
582238423Sjhb
583238423Sjhb## /difftype/difftype/difffile:
584238423Sjhbnoconflict /difftype/difftype/difffiles/file
585238423Sjhbfile /difftype/difftype/difffiles/file "foo"
586238423Sjhb
587238423Sjhb## /difflinks/first/first:
588238423Sjhblink /difflinks/first/first/link "new"
589238423Sjhb
590238423Sjhb## /difflinks/difftype/difftype:
591238423Sjhblink /difflinks/difftype/difftype/link "new"
592238423Sjhb
593238423Sjhb## /difflinks/difflinks/difflinks:
594238423Sjhblink /difflinks/difflinks/difflinks/link "new"
595238423Sjhb
596238423Sjhb## /difffiles/first/first:
597238423Sjhbfile /difffiles/first/first/file "bar"
598238423Sjhb
599238423Sjhb## /difffiles/difftype/difftype:
600238423Sjhbfile /difffiles/difftype/difftype/file "new"
601238423Sjhb
602238423Sjhb## /difffiles/difffiles/difffiles:
603238423Sjhbnoconflict /difffiles/difffiles/difffiles/conflict
604238423Sjhbfile /difffiles/difffiles/difffiles/conflict "this is a new file"
605238423Sjhb
606238423Sjhb## /adddir/conflict:
607238423Sjhbfile /adddir/conflict/newfile
608238423Sjhb
609238423Sjhb## /rmdir/extra:
610238423Sjhbdir /rmdir/extra
611238423Sjhbfile /rmdir/extra/localfile.txt "foo"
612238423Sjhb
613238423Sjhb## /rmdir/conflict:
614238423Sjhbdir /rmdir/conflict/difftype
615238423Sjhbpresent /rmdir/conflict
616238423Sjhb
617238423Sjhb## /dirchange/fromdir/extradir:
618238423Sjhbmissing /dirchange/fromdir/extradir/file
619238423Sjhbfifo /dirchange/fromdir/extradir/fifo
620238423Sjhb
621238423Sjhb## /dirchange/fromdir/conflict:
622238423Sjhbfile /dirchange/fromdir/conflict/somefile "bar"
623238423Sjhb
624238423Sjhb## /dirchange/todir/difffile:
625238423Sjhbfile /dirchange/todir/difffile/file "baz"
626238423Sjhb
627238423Sjhb## /dirchange/todir/difftype:
628238423Sjhbfile /dirchange/todir/difftype/file "baz"
629263221Sjmmv
630263221Sjmmv[ "${FAILED}" = no ]
631