3 # Copyright (c) 2010 Advanced Computing Technologies LLC
4 # Written by: John H. Baldwin <jhb@FreeBSD.org>
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # Various regression tests to run for the 'update' command.
36 echo "Usage: tests.sh [-w workdir]"
40 # Allow the user to specify an alternate work directory.
41 while getopts "w:" option; do
57 CONFLICTS=$WORKDIR/conflicts
62 # The various states of the comparison of a file between two trees.
63 states="equal first second difftype difflinks difffiles"
69 rm -rf $OLD $NEW $TEST $CONFLICTS
70 mkdir -p $OLD/etc $NEW/etc $TEST/etc
72 # For an given file, there are three different pair-wise
73 # relations between the three threes (old, new, and test): old
74 # vs new, old vs test, and new vs test. Each of these
75 # relations takes on one of six different states from the
76 # 'compare()' function in etcupdate: equal, onlyfirst,
77 # onlysecond, difftype, difflinks, difffiles. In addition,
78 # there are special considerations for considering cases such
79 # as a file merge that results in conflicts versus one that
80 # does not, special treatment of directories, etc. The tests
81 # below attempt to enumerate the three dimensional test matrix
82 # by having the path name use the three different tree states
83 # for the parent directories.
85 # Note that if the old and new files are identical (so first
86 # compare is "equal"), then the second and third comparisons
89 # Note also that etcupdate only cares about files that are
90 # present in at least one of the old or new trees. Thus, none
91 # of the '*/second/second' cases are relevant.
96 mkdir -p $OLD/$i/$j/$k $NEW/$i/$j/$k \
102 # /equal/equal/equal: Everything is equal. Nothing should happen.
103 for i in $OLD $NEW $TEST; do
104 mkfifo $i/equal/equal/equal/fifo
105 echo "foo" > $i/equal/equal/equal/file
106 mkdir $i/equal/equal/equal/dir
107 ln -s "bar" $i/equal/equal/equal/link
110 # /equal/first/first: The file is missing from the test
111 # directory. Nothing should happen.
112 for i in $OLD $NEW; do
113 mkfifo $i/equal/first/first/fifo
114 echo "foo" > $i/equal/first/first/file
115 mkdir $i/equal/first/first/dir
116 ln -s "bar" $i/equal/first/first/link
119 # /equal/difftype/difftype: The local file is a different
120 # type. Nothing should happen.
121 for i in $OLD $NEW; do
122 mkfifo $i/equal/difftype/difftype/fifo
123 mkdir $i/equal/difftype/difftype/fromdir
125 echo "bar" > $TEST/equal/difftype/difftype/fifo
126 ln -s "test" $TEST/equal/difftype/difftype/fromdir
128 # /equal/difflinks/difflinks: The local file is a modified
129 # link. Nothing should happen.
130 for i in $OLD $NEW; do
131 ln -s "foo" $i/equal/difflinks/difflinks/link
133 ln -s "bar" $TEST/equal/difflinks/difflinks/link
135 # /equal/difffiles/difffiles: The local file is a modified
136 # file. Nothing should happen.
137 for i in $OLD $NEW; do
138 echo "foo" > $i/equal/difffiles/difffiles/file
140 echo "bar" > $TEST/equal/difffiles/difffiles/file
142 # /first/equal/second: Remove unmodified files. The files
143 # should all be removed.
144 for i in $OLD $TEST; do
145 mkfifo $i/first/equal/second/fifo
146 echo "foo" > $i/first/equal/second/file
147 mkdir $i/first/equal/second/emptydir
148 ln -s "bar" $i/first/equal/second/link
149 mkdir $i/first/equal/second/fulldir
150 echo "foo" > $i/first/equal/second/fulldir/file
153 # /first/equal/*: Cannot occur. If the file is missing from
154 # new, then new vs test will always be 'second'.
156 # /first/first/equal: Removed files are already removed.
157 # Nothing should happen.
158 mkfifo $OLD/first/first/equal/fifo
159 echo "foo" > $OLD/first/first/equal/file
160 mkdir $OLD/first/first/equal/dir
161 ln -s "bar" $OLD/first/first/equal/link
163 # /first/first/*: Cannot occur. The files are missing from
166 # /first/second/*: Cannot happen, if the file is in old for
167 # old vs new, it cannot be missing for old vs test.
169 # /first/difftype/second: File with different local type
170 # removed. Should generate a warning.
171 mkfifo $OLD/first/difftype/second/fifo
172 mkdir $TEST/first/difftype/second/fifo
174 # /first/difftype/*: Cannot happen since the file is missing
175 # from new but present in test.
177 # /first/difflinks/second: Modified link removed. Should
178 # generate a warning.
179 ln -s "old link" $OLD/first/difflinks/second/link
180 ln -s "test link" $TEST/first/difflinks/second/link
182 # /first/difflinks/*: Cannot happen since the file is missing
183 # from new but present in test.
185 # /first/difffiles/second: Modified file removed. Should
186 # generate a warning.
187 echo "foo" > $OLD/first/difffiles/second/file
188 echo "bar" > $TEST/first/difffiles/second/file
190 # /first/difffiles/*: Cannot happen since the file is missing
191 # from new but present in test.
193 # /second/equal/first: Added a new file that isn't present in
194 # test. The empty directory should be ignored.
195 echo "bar" > $NEW/second/equal/first/file
196 mkfifo $NEW/second/equal/first/fifo
197 ln -s "new" $NEW/second/equal/first/link
198 mkdir $NEW/second/equal/first/emptydir
199 mkdir $NEW/second/equal/first/fulldir
200 echo "foo" > $NEW/second/equal/first/fulldir/file
202 # /second/equal/*: Cannot happen since the file is missing
203 # from test but present in new.
205 # /second/first/*: Cannot happen since the file is missing
208 # /second/second/equal: Newly added file is already present in
209 # the test directory and identical to the new file. Nothing
211 for i in $NEW $TEST; do
212 mkfifo $i/second/second/equal/fifo
213 echo "foo" > $i/second/second/equal/file
214 mkdir $i/second/second/equal/dir
215 ln -s "bar" $i/second/second/equal/link
218 # /second/second/first: Cannot happen. The file is in dest in
219 # the second test, so it can't be missing from the third test.
221 # /second/second/second: Cannot happen. The file is in new in
222 # the first test, so it can't be missing from the third test.
224 # /second/second/difftype: Newly added file conflicts with
225 # existing file in test tree of a different type. Should
226 # generate a warning.
227 mkdir $NEW/second/second/difftype/dir
228 mkfifo $TEST/second/second/difftype/dir
230 # /second/second/difflinks: Newly added link conflicts with
231 # existing link in test tree. Should generate a warning.
232 ln -s "new link" $NEW/second/second/difflinks/link
233 ln -s "test link" $TEST/second/second/difflinks/link
235 # /second/second/difffiles: Newly added file conflicts with
236 # existing file in test tree. Should generate a warning.
237 echo "new" > $NEW/second/second/difffiles/file
238 echo "test" > $TEST/second/second/difffiles/file
240 # /second/difftype/*: Cannot happen since the file is missing
243 # /second/difflinks/*: Cannot happen since the file is missing
246 # /second/difffiles/*: Cannot happen since the file is missing
249 # /difftype/equal/difftype: Unmodified file has changed type.
250 # File should be updated to the new file. In the 'todir' case
251 # the directory won't actually be created because it is empty.
252 for i in $OLD $TEST; do
253 echo "foo" > $i/difftype/equal/difftype/file
254 mkdir $i/difftype/equal/difftype/fromdir
255 ln -s "old" $i/difftype/equal/difftype/todir
257 ln -s "test" $NEW/difftype/equal/difftype/file
258 mkfifo $NEW/difftype/equal/difftype/fromdir
259 mkdir $NEW/difftype/equal/difftype/todir
261 # /difftype/equal/*: Cannot happen. Since the old file is a
262 # difftype from the new file and the test file is identical to
263 # the old file, the test file must be a difftype from the new
266 # /difftype/first/first: A removed file has changed type.
267 # This should generate a warning.
268 mkfifo $OLD/difftype/first/first/fifo
269 mkdir $NEW/difftype/first/first/fifo
271 # /difftype/first/*: Cannot happen. Since the new file exists
272 # and the dest file is missing, the last test must be 'first'.
274 # /difftype/second/*: Cannot happen. The old file exists in
275 # the first test, so it cannot be missing in the second test.
277 # /difftype/difftype/equal: A file has changed type, but the
278 # file in the test directory already matches the new file. Do
280 echo "foo" > $OLD/difftype/difftype/equal/fifo
281 mkfifo $OLD/difftype/difftype/equal/file
282 for i in $NEW $TEST; do
283 mkfifo $i/difftype/difftype/equal/fifo
284 echo "bar" > $i/difftype/difftype/equal/file
287 # /difftype/difftype/first: Cannot happen. The dest file
288 # exists in the second test.
290 # /difftype/difftype/second: Cannot happen. The new file
291 # exists in the first test.
293 # /difftype/difftype/difftype: All three files (old, new, and
294 # test) are different types from each other. This should
295 # generate a warning.
296 mkfifo $OLD/difftype/difftype/difftype/one
297 mkdir $NEW/difftype/difftype/difftype/one
298 echo "foo" > $TEST/difftype/difftype/difftype/one
299 mkdir $OLD/difftype/difftype/difftype/two
300 echo "baz" > $NEW/difftype/difftype/difftype/two
301 ln -s "bar" $TEST/difftype/difftype/difftype/two
303 # /difftype/difftype/difflinks: A file has changed from a
304 # non-link to a link in both the new and test trees, but the
305 # target of the new and test links differ. This should
306 # generate a new link conflict.
307 mkfifo $OLD/difftype/difftype/difflinks/link
308 ln -s "new" $NEW/difftype/difftype/difflinks/link
309 ln -s "test" $TEST/difftype/difftype/difflinks/link
311 # /difftype/difftype/difffile: A file has changed from a
312 # non-regular file to a regular file in both the new and test
313 # trees, but the contents in the new and test files differ.
314 # This should generate a new file conflict.
315 ln -s "old" $OLD/difftype/difftype/difffiles/file
316 echo "foo" > $NEW/difftype/difftype/difffiles/file
317 echo "bar" > $TEST/difftype/difftype/difffiles/file
319 # /difflinks/equal/difflinks: An unmodified symlink has
320 # changed. The link should be updated.
321 for i in $OLD $TEST; do
322 ln -s "old" $i/difflinks/equal/difflinks/link
324 ln -s "new" $NEW/difflinks/equal/difflinks/link
326 # /difflinks/equal/*: Cannot happen. Since old is identical
327 # to test, the third test must be 'difflinks'.
329 # /difflinks/first/first: A modified link is missing in the
330 # test tree. This should generate a warning.
331 ln -s "old" $OLD/difflinks/first/first/link
332 ln -s "new" $NEW/difflinks/first/first/link
334 # /difflinks/first/*: Cannot happen. Since the test file is
335 # missing in the second test, it must be missing in the third
338 # /difflinks/second/*: Cannot happen. The old link is present
339 # in the first test, so it cannot be missing in the second
342 # /difflinks/difftype/difftype: An updated link has been
343 # changed to a different file type in the test tree. This
344 # should generate a warning.
345 ln -s "old" $OLD/difflinks/difftype/difftype/link
346 ln -s "new" $NEW/difflinks/difftype/difftype/link
347 echo "test" > $TEST/difflinks/difftype/difftype/link
349 # /difflinks/difftype/*: Cannot happen. The old and new files
350 # are both links and the test file is not a link, so the third
351 # test must be 'difftype'.
353 # /difflinks/difflinks/equal: An updated link has already been
354 # updated to the new target in the test tree. Nothing should
356 ln -s "old" $OLD/difflinks/difflinks/equal/link
357 for i in $NEW $TEST; do
358 ln -s "new" $i/difflinks/difflinks/equal/link
361 # /difflinks/difflinks/difflinks: An updated link has been
362 # modified in the test tree and doesn't match either the old
363 # or new links. This should generate a warning.
364 ln -s "old" $OLD/difflinks/difflinks/difflinks/link
365 ln -s "new" $NEW/difflinks/difflinks/difflinks/link
366 ln -s "test" $TEST/difflinks/difflinks/difflinks/link
368 # /difflinks/difflinks/*: Cannot happen. All three files are
369 # links from the first two tests, so the third test can only
370 # be 'equal' or 'difflink'.
372 # /difflinks/difffiles/*: Cannot happen. The old file is a
373 # link in the first test, so it cannot be a regular file in
376 # /difffiles/equal/difffiles: An unmodified file has been
377 # changed in new tree. The file should be updated to the new
379 for i in $OLD $TEST; do
380 echo "foo" > $i/difffiles/equal/difffiles/file
382 echo "bar" > $NEW/difffiles/equal/difffiles/file
384 # /difffiles/equal/*: Cannot happen. Since the old file is
385 # identical to the test file, the third test must be
388 # /difffiles/first/first: A removed file has been changed in
389 # the new tree. This should generate a warning.
390 echo "foo" > $OLD/difffiles/first/first/file
391 echo "bar" > $NEW/difffiles/first/first/file
393 # /difffiles/first/*: Cannot happen. The new file is a
394 # regular file from the first test and the test file is
395 # missing in the second test, so the third test must be
398 # /difffiles/second/*: Cannot happen. The old file is present
399 # in the first test, so it must be present in the second test.
401 # /difffiles/difftype/difftype: An updated regular file has
402 # been changed to a different file type in the test tree.
403 # This should generate a warning.
404 echo "old" > $OLD/difffiles/difftype/difftype/file
405 echo "new" > $NEW/difffiles/difftype/difftype/file
406 mkfifo $TEST/difffiles/difftype/difftype/file
408 # /difffiles/difftype/*: Cannot happen. The new file is known
409 # to be a regular file from the first test, and the test file
410 # is known to exist as a different file type from the second
411 # test. The third test must be 'difftype'.
413 # /difffiles/difflink/*: Cannot happen. The old file is known
414 # to be a regular file from the first test, so it cannot be a
415 # link in the second test.
417 # /difffiles/difffiles/equal: An updated regular file has
418 # already been updated to match the new file in the test tree.
419 # Nothing should happen.
420 echo "foo" > $OLD/difffiles/difffiles/equal/file
421 for i in $NEW $TEST; do
422 echo "bar" > $i/difffiles/difffiles/equal/file
425 # /difffiles/difffiles/difffiles: A modified regular file was
426 # updated in the new tree. The changes should be merged into
427 # to the new file if possible. If the merge fails, a conflict
428 # should be generated.
429 cat > $OLD/difffiles/difffiles/difffiles/simple <<EOF
433 cat > $NEW/difffiles/difffiles/difffiles/simple <<EOF
437 cat > $TEST/difffiles/difffiles/difffiles/simple <<EOF
442 cat > $OLD/difffiles/difffiles/difffiles/conflict <<EOF
445 cat > $NEW/difffiles/difffiles/difffiles/conflict <<EOF
448 cat > $TEST/difffiles/difffiles/difffiles/conflict <<EOF
452 # /difffiles/difffiles/*: Cannot happen. From the first three
453 # tests, all three files are regular files. The test file can
454 # either be identical to the new file ('equal') or not
457 ## Tests for adding directories
458 mkdir -p $OLD/adddir $NEW/adddir $TEST/adddir
460 # /adddir/conflict: Add a new file in a directory that already
461 # exists as a file. This should generate two warnings.
462 mkdir $NEW/adddir/conflict
463 touch $NEW/adddir/conflict/newfile
464 touch $TEST/adddir/conflict
466 # /adddir/partial: Add a new file in a directory. The
467 # directory already exists in the test tree and contains a
468 # different local file. The new file from the new tree should
470 for i in $NEW $TEST; do
471 mkdir $i/adddir/partial
473 echo "foo" > $NEW/adddir/partial/file
474 mkfifo $TEST/adddir/partial/fifo
476 ## Tests for removing directories
477 mkdir -p $OLD/rmdir $NEW/rmdir $TEST/rmdir
479 # /rmdir/extra: Do not remove a directory with an extra local file.
480 # This should generate a warning.
481 for i in $OLD $TEST; do
484 echo "foo" > $TEST/rmdir/extra/localfile.txt
486 # /rmdir/conflict: Do not remove a directory with a conflicted
487 # remove file. This should generate a warning.
488 for i in $OLD $TEST; do
489 mkdir $i/rmdir/conflict
491 mkfifo $OLD/rmdir/conflict/difftype
492 mkdir $TEST/rmdir/conflict/difftype
494 # /rmdir/partial: Remove a complete hierarchy when part of the
495 # tree has already been removed locally.
496 for i in $OLD $TEST; do
497 mkdir -p $i/rmdir/partial/subdir
498 mkfifo $i/rmdir/partial/subdir/fifo
500 echo "foo" > $OLD/rmdir/partial/subdir/file
502 ## Tests for converting files to directories and vice versa
503 for i in $OLD $NEW $TEST; do
504 for j in already old fromdir todir; do
505 mkdir -p $i/dirchange/$j
509 # /dirchange/already/fromdir: Convert a directory tree to a
510 # file without conflicts where the test tree already has the
511 # new file. Nothing should happen.
512 mkdir $OLD/dirchange/already/fromdir
513 echo "blah" > $OLD/dirchange/already/fromdir/somefile
514 for i in $NEW $TEST; do
515 echo "bar" > $i/dirchange/already/fromdir
518 # /dirchange/already/todir: Convert an unmodified file to a
519 # directory tree where the test tree already has the new
520 # tree. Nothing should happen.
521 echo "baz" > $OLD/dirchange/already/todir
522 for i in $NEW $TEST; do
523 mkdir $i/dirchange/already/todir
524 echo "blah" > $i/dirchange/already/todir/somefile
527 # /dirchange/old/fromdir: Convert a directory tree to a file.
528 # The old files are unmodified and should be changed to the new tree.
529 for i in $OLD $TEST; do
530 mkdir $i/dirchange/old/fromdir
531 echo "blah" > $i/dirchange/old/fromdir/somefile
533 echo "bar" > $NEW/dirchange/old/fromdir
535 # /dirchange/old/todir: Convert a file to a directory tree.
536 # The old file is unmodified and should be changed to the new
538 for i in $OLD $TEST; do
539 echo "foo" > $i/dirchange/old/todir
541 mkdir $NEW/dirchange/old/todir
542 echo "bar" > $NEW/dirchange/old/todir/file
544 # /dirchange/fromdir/extradir: Convert a directory tree to a
545 # file. The test tree includes an extra file in the directory
546 # that is not present in the old tree. This should generate a
548 for i in $OLD $TEST; do
549 mkdir $i/dirchange/fromdir/extradir
550 echo "foo" > $i/dirchange/fromdir/extradir/file
552 mkfifo $TEST/dirchange/fromdir/extradir/fifo
553 ln -s "bar" $NEW/dirchange/fromdir/extradir
555 # /dirchange/fromdir/conflict: Convert a directory tree to a
556 # file. The test tree includes a local change that generates
557 # a warning and prevents the removal of the directory.
558 for i in $OLD $TEST; do
559 mkdir $i/dirchange/fromdir/conflict
561 echo "foo" > $OLD/dirchange/fromdir/conflict/somefile
562 echo "bar" > $TEST/dirchange/fromdir/conflict/somefile
563 mkfifo $NEW/dirchange/fromdir/conflict
565 # /dirchange/todir/difffile: Convert a file to a directory
566 # tree. The test tree has a locally modified version of the
567 # file so that the conversion fails with a warning.
568 echo "foo" > $OLD/dirchange/todir/difffile
569 mkdir $NEW/dirchange/todir/difffile
570 echo "baz" > $NEW/dirchange/todir/difffile/file
571 echo "bar" > $TEST/dirchange/todir/difffile
573 # /dirchange/todir/difftype: Similar to the previous test, but
574 # the conflict is due to a change in the file type.
575 echo "foo" > $OLD/dirchange/todir/difftype
576 mkdir $NEW/dirchange/todir/difftype
577 echo "baz" > $NEW/dirchange/todir/difftype/file
578 mkfifo $TEST/dirchange/todir/difftype
580 ## Tests for post-install actions
582 # - Adding /etc/master.passwd should cause pwd_mkdb to be run
583 echo "foo:*:16000:100::0:0:& user:/home/foo:/bin/tcsh" > \
584 $NEW/etc/master.passwd
586 # - Verify that updating an unmodified /etc/login.conf builds
587 # /etc/login.conf.db.
588 cat > $OLD/etc/login.conf <<EOF
592 cat > $NEW/etc/login.conf <<EOF
594 :passwd_format=md5:\\
595 :copyright=/etc/COPYRIGHT
597 cp $OLD/etc/login.conf $TEST/etc/login.conf
599 # - Verify that a merge without conflicts to /etc/mail/aliases
600 # will trigger a newaliases run request.
601 mkdir -p $OLD/etc/mail $NEW/etc/mail $TEST/etc/mail
602 cat > $OLD/etc/mail/aliases <<EOF
605 # Basic system aliases -- these MUST be present
606 MAILER-DAEMON: postmaster
609 cat > $NEW/etc/mail/aliases <<EOF
612 # Basic system aliases -- these MUST be present
613 MAILER-DAEMON: postmaster
616 # General redirections for pseudo accounts
620 cat > $TEST/etc/mail/aliases <<EOF
621 root: someone@example.com
623 # Basic system aliases -- these MUST be present
624 MAILER-DAEMON: postmaster
629 # $1 - relative path to file that should be missing from TEST
632 if [ -e $TEST/$1 -o -L $TEST/$1 ]; then
633 echo "File $1 should be missing"
637 # $1 - relative path to file that should be present in TEST
640 if ! [ -e $TEST/$1 -o -L $TEST/$1 ]; then
641 echo "File $1 should be present"
645 # $1 - relative path to file that should be a fifo in TEST
648 if ! [ -p $TEST/$1 ]; then
649 echo "File $1 should be a FIFO"
653 # $1 - relative path to file that should be a directory in TEST
656 if ! [ -d $TEST/$1 ]; then
657 echo "File $1 should be a directory"
661 # $1 - relative path to file that should be a symlink in TEST
662 # $2 - optional value of the link
667 if ! [ -L $TEST/$1 ]; then
668 echo "File $1 should be a link"
669 elif [ $# -gt 1 ]; then
670 val=`readlink $TEST/$1`
671 if [ "$val" != "$2" ]; then
672 echo "Link $1 should link to \"$2\""
677 # $1 - relative path to regular file that should be present in TEST
678 # $2 - optional string that should match file contents
679 # $3 - optional MD5 of the flie contents, overrides $2 if present
684 if ! [ -f $TEST/$1 ]; then
685 echo "File $1 should be a regular file"
686 elif [ $# -eq 2 ]; then
687 contents=`cat $TEST/$1`
688 if [ "$contents" != "$2" ]; then
689 echo "File $1 has wrong contents"
691 elif [ $# -eq 3 ]; then
692 sum=`md5 -q $TEST/$1`
693 if [ "$sum" != "$3" ]; then
694 echo "File $1 has wrong contents"
699 # $1 - relative path to a regular file that should have a conflict
700 # $2 - optional MD5 of the conflict file contents
705 if ! [ -f $CONFLICTS/$1 ]; then
706 echo "File $1 missing conflict"
707 elif [ $# -gt 1 ]; then
708 sum=`md5 -q $CONFLICTS/$1`
709 if [ "$sum" != "$2" ]; then
710 echo "Conflict $1 has wrong contents"
718 echo "Checking tree for correct results:"
720 ## /equal/equal/equal:
721 fifo /equal/equal/equal/fifo
722 file /equal/equal/equal/file "foo"
723 dir /equal/equal/equal/dir
724 link /equal/equal/equal/link "bar"
726 ## /equal/first/first:
727 missing /equal/first/first/fifo
728 missing /equal/first/first/file
729 missing /equal/first/first/dir
730 missing /equal/first/first/link
732 ## /equal/difftype/difftype:
733 file /equal/difftype/difftype/fifo "bar"
734 link /equal/difftype/difftype/fromdir "test"
736 ## /equal/difflinks/difflinks:
737 link /equal/difflinks/difflinks/link "bar"
739 ## /equal/difffiles/difffiles:
740 file /equal/difffiles/difffiles/file "bar"
742 ## /first/equal/second:
743 missing /first/equal/second/fifo
744 missing /first/equal/second/file
745 missing /first/equal/second/emptydir
746 missing /first/equal/second/link
747 missing /first/equal/second/fulldir
749 ## /first/first/equal:
750 missing /first/first/equal/fifo
751 missing /first/first/equal/file
752 missing /first/first/equal/dir
753 missing /first/first/equal/link
755 ## /first/difftype/second:
756 present /first/difftype/second/fifo
758 ## /first/difflinks/second:
759 link /first/difflinks/second/link "test link"
761 ## /first/difffiles/second:
762 file /first/difffiles/second/file "bar"
764 ## /second/equal/first:
765 file /second/equal/first/file "bar"
766 fifo /second/equal/first/fifo
767 link /second/equal/first/link "new"
768 missing /second/equal/first/emptydir
769 file /second/equal/first/fulldir/file "foo"
771 ## /second/second/equal:
772 fifo /second/second/equal/fifo
773 file /second/second/equal/file "foo"
774 dir /second/second/equal/dir
775 link /second/second/equal/link "bar"
777 ## /second/second/difftype:
778 fifo /second/second/difftype/dir
780 ## /second/second/difflinks:
781 link /second/second/difflinks/link "test link"
783 ## /second/second/difffiles:
784 file /second/second/difffiles/file "test"
785 conflict /second/second/difffiles/file 4f2ee8620a251fd53f06bb6112eb6ffa
787 ## /difftype/equal/difftype:
788 link /difftype/equal/difftype/file "test"
789 fifo /difftype/equal/difftype/fromdir
790 missing /difftype/equal/difftype/todir
792 ## /difftype/first/first:
793 missing /difftype/first/first/fifo
795 ## /difftype/difftype/equal:
796 fifo /difftype/difftype/equal/fifo
797 file /difftype/difftype/equal/file "bar"
799 ## /difftype/difftype/difftype:
800 file /difftype/difftype/difftype/one "foo"
801 link /difftype/difftype/difftype/two "bar"
803 ## /difftype/difftype/difflinks:
804 link /difftype/difftype/difflinks/link "test"
806 ## /difftype/difftype/difffile:
807 conflict /difftype/difftype/difffiles/file \
808 117f2bcd1f6491f6044e79e5a57a9229
810 ## /difflinks/equal/difflinks:
811 link /difflinks/equal/difflinks/link "new"
813 ## /difflinks/first/first:
814 missing /difflinks/first/first/link
816 ## /difflinks/difftype/difftype:
817 file /difflinks/difftype/difftype/link "test"
819 ## /difflinks/difflinks/equal:
820 link /difflinks/difflinks/equal/link "new"
822 ## /difflinks/difflinks/difflinks:
823 link /difflinks/difflinks/difflinks/link "test"
825 ## /difffiles/equal/difffiles:
826 file /difffiles/equal/difffiles/file "bar"
828 ## /difffiles/first/first:
829 missing /difffiles/first/first/file
831 ## /difffiles/difftype/difftype:
832 fifo /difffiles/difftype/difftype/file
834 ## /difffiles/difffiles/equal:
835 file /difffiles/difffiles/equal/file "bar"
837 ## /difffiles/difffiles/difffiles:
838 file /difffiles/difffiles/difffiles/simple "" \
839 cabc7e5e80b0946d79edd555e9648486
840 file /difffiles/difffiles/difffiles/conflict "this is a test file"
841 conflict /difffiles/difffiles/difffiles/conflict \
842 8261cfdd89280c4a6c26e4ac86541fe9
845 file /adddir/conflict
848 file /adddir/partial/file "foo"
849 fifo /adddir/partial/fifo
853 file /rmdir/extra/localfile.txt "foo"
856 dir /rmdir/conflict/difftype
857 present /rmdir/conflict
860 missing /rmdir/partial
862 ## /dirchange/already/fromdir:
863 file /dirchange/already/fromdir "bar"
865 ## /dirchange/already/todir:
866 file /dirchange/already/todir/somefile "blah"
868 ## /dirchange/old/fromdir:
869 file /dirchange/old/fromdir "bar"
871 ## /dirchange/old/todir
872 file /dirchange/old/todir/file "bar"
874 ## /dirchange/fromdir/extradir:
875 missing /dirchange/fromdir/extradir/file
876 fifo /dirchange/fromdir/extradir/fifo
878 ## /dirchange/fromdir/conflict:
879 file /dirchange/fromdir/conflict/somefile "bar"
881 ## /dirchange/todir/difffile:
882 file /dirchange/todir/difffile "bar"
884 ## /dirchange/todir/difftype:
885 fifo /dirchange/todir/difftype
887 ## Tests for post-install actions
888 file /etc/master.passwd
892 file /etc/login.conf "" 7774a0f9a3a372c7c109c32fd31c4b6b
893 file /etc/login.conf.db
894 file /etc/mail/aliases "" 7d598f89ec040ab56af54011bdb83337
897 if [ `id -u` -ne 0 ]; then
901 if [ -r /etc/etcupdate.conf ]; then
902 echo "WARNING: /etc/etcupdate.conf settings may break some tests."
907 etcupdate -nr -d $WORKDIR -D $TEST > $WORKDIR/testn.out
909 cat > $WORKDIR/correct.out <<EOF
910 D /dirchange/fromdir/extradir/file
911 D /dirchange/old/fromdir/somefile
912 D /first/equal/second/fifo
913 D /first/equal/second/file
914 D /first/equal/second/fulldir/file
915 D /first/equal/second/link
916 D /rmdir/partial/subdir/fifo
917 D /rmdir/partial/subdir
919 D /first/equal/second/fulldir
920 D /first/equal/second/emptydir
921 C /difffiles/difffiles/difffiles/conflict
922 M /difffiles/difffiles/difffiles/simple
923 U /difffiles/equal/difffiles/file
924 U /difflinks/equal/difflinks/link
925 C /difftype/difftype/difffiles/file
926 U /difftype/equal/difftype/file
927 U /difftype/equal/difftype/fromdir
928 D /difftype/equal/difftype/todir
929 U /dirchange/old/fromdir
930 U /dirchange/old/todir
933 A /adddir/partial/file
934 A /dirchange/old/todir/file
936 A /second/equal/first/fifo
937 A /second/equal/first/file
938 A /second/equal/first/fulldir/file
939 A /second/equal/first/link
940 C /second/second/difffiles/file
942 Modified regular file remains: /dirchange/fromdir/conflict/somefile
943 Modified regular file remains: /first/difffiles/second/file
944 Modified symbolic link remains: /first/difflinks/second/link
945 Modified directory remains: /first/difftype/second/fifo
946 Modified directory remains: /rmdir/conflict/difftype
947 Non-empty directory remains: /rmdir/extra
948 Non-empty directory remains: /rmdir/conflict
949 Modified mismatch: /difffiles/difftype/difftype/file (regular file vs fifo file)
950 Removed file changed: /difffiles/first/first/file
951 Modified link changed: /difflinks/difflinks/difflinks/link ("old" became "new")
952 Modified mismatch: /difflinks/difftype/difftype/link (symbolic link vs regular file)
953 Removed link changed: /difflinks/first/first/link ("old" became "new")
954 New link conflict: /difftype/difftype/difflinks/link ("new" vs "test")
955 Modified regular file changed: /difftype/difftype/difftype/one (fifo file became directory)
956 Modified symbolic link changed: /difftype/difftype/difftype/two (directory became regular file)
957 Remove mismatch: /difftype/first/first/fifo (fifo file became directory)
958 Modified directory changed: /dirchange/fromdir/conflict (directory became fifo file)
959 Modified directory changed: /dirchange/fromdir/extradir (directory became symbolic link)
960 Modified regular file changed: /dirchange/todir/difffile (regular file became directory)
961 Modified fifo file changed: /dirchange/todir/difftype (regular file became directory)
962 New file mismatch: /adddir/conflict (directory vs regular file)
963 Directory mismatch: $TEST/adddir/conflict (regular file)
964 Directory mismatch: $TEST/dirchange/todir/difffile (regular file)
965 Directory mismatch: $TEST/dirchange/todir/difftype (fifo file)
966 New link conflict: /second/second/difflinks/link ("new link" vs "test link")
967 New file mismatch: /second/second/difftype/dir (directory vs fifo file)
968 Needs update: /etc/mail/aliases.db (requires manual update via newaliases(1))
971 echo "Differences for -n:"
972 diff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/testn.out
974 etcupdate -r -d $WORKDIR -D $TEST > $WORKDIR/test.out
976 echo "Differences for real:"
977 diff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out