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 run for the 'update' command. 31238423Sjhb 32263221SjmmvFAILED=no 33238423SjhbWORKDIR=work 34238423Sjhb 35238423Sjhbusage() 36238423Sjhb{ 37258063Sjhb echo "Usage: tests.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 70238423Sjhbbuild_trees() 71238423Sjhb{ 72238423Sjhb local i j k 73238423Sjhb 74238423Sjhb rm -rf $OLD $NEW $TEST $CONFLICTS 75238423Sjhb mkdir -p $OLD/etc $NEW/etc $TEST/etc 76238423Sjhb 77238423Sjhb # For an given file, there are three different pair-wise 78238423Sjhb # relations between the three threes (old, new, and test): old 79238423Sjhb # vs new, old vs test, and new vs test. Each of these 80238423Sjhb # relations takes on one of six different states from the 81238423Sjhb # 'compare()' function in etcupdate: equal, onlyfirst, 82238423Sjhb # onlysecond, difftype, difflinks, difffiles. In addition, 83238423Sjhb # there are special considerations for considering cases such 84238423Sjhb # as a file merge that results in conflicts versus one that 85238423Sjhb # does not, special treatment of directories, etc. The tests 86238423Sjhb # below attempt to enumerate the three dimensional test matrix 87238423Sjhb # by having the path name use the three different tree states 88238423Sjhb # for the parent directories. 89238423Sjhb # 90238423Sjhb # Note that if the old and new files are identical (so first 91238423Sjhb # compare is "equal"), then the second and third comparisons 92238423Sjhb # will be the same. 93238423Sjhb # 94238423Sjhb # Note also that etcupdate only cares about files that are 95238423Sjhb # present in at least one of the old or new trees. Thus, none 96238423Sjhb # of the '*/second/second' cases are relevant. 97238423Sjhb 98238423Sjhb for i in $states; do 99238423Sjhb for j in $states; do 100238423Sjhb for k in $states; do 101238423Sjhb mkdir -p $OLD/$i/$j/$k $NEW/$i/$j/$k \ 102238423Sjhb $TEST/$i/$j/$k 103238423Sjhb done 104238423Sjhb done 105238423Sjhb done 106238423Sjhb 107238423Sjhb # /equal/equal/equal: Everything is equal. Nothing should happen. 108238423Sjhb for i in $OLD $NEW $TEST; do 109238423Sjhb mkfifo $i/equal/equal/equal/fifo 110238423Sjhb echo "foo" > $i/equal/equal/equal/file 111238423Sjhb mkdir $i/equal/equal/equal/dir 112238423Sjhb ln -s "bar" $i/equal/equal/equal/link 113238423Sjhb done 114238423Sjhb 115238423Sjhb # /equal/first/first: The file is missing from the test 116238423Sjhb # directory. Nothing should happen. 117238423Sjhb for i in $OLD $NEW; do 118238423Sjhb mkfifo $i/equal/first/first/fifo 119238423Sjhb echo "foo" > $i/equal/first/first/file 120238423Sjhb mkdir $i/equal/first/first/dir 121238423Sjhb ln -s "bar" $i/equal/first/first/link 122238423Sjhb done 123238423Sjhb 124238423Sjhb # /equal/difftype/difftype: The local file is a different 125238423Sjhb # type. Nothing should happen. 126238423Sjhb for i in $OLD $NEW; do 127238423Sjhb mkfifo $i/equal/difftype/difftype/fifo 128238423Sjhb mkdir $i/equal/difftype/difftype/fromdir 129238423Sjhb done 130238423Sjhb echo "bar" > $TEST/equal/difftype/difftype/fifo 131238423Sjhb ln -s "test" $TEST/equal/difftype/difftype/fromdir 132238423Sjhb 133238423Sjhb # /equal/difflinks/difflinks: The local file is a modified 134238423Sjhb # link. Nothing should happen. 135238423Sjhb for i in $OLD $NEW; do 136238423Sjhb ln -s "foo" $i/equal/difflinks/difflinks/link 137238423Sjhb done 138238423Sjhb ln -s "bar" $TEST/equal/difflinks/difflinks/link 139238423Sjhb 140238423Sjhb # /equal/difffiles/difffiles: The local file is a modified 141238423Sjhb # file. Nothing should happen. 142238423Sjhb for i in $OLD $NEW; do 143238423Sjhb echo "foo" > $i/equal/difffiles/difffiles/file 144238423Sjhb done 145238423Sjhb echo "bar" > $TEST/equal/difffiles/difffiles/file 146238423Sjhb 147238423Sjhb # /first/equal/second: Remove unmodified files. The files 148238423Sjhb # should all be removed. 149238423Sjhb for i in $OLD $TEST; do 150238423Sjhb mkfifo $i/first/equal/second/fifo 151238423Sjhb echo "foo" > $i/first/equal/second/file 152238423Sjhb mkdir $i/first/equal/second/emptydir 153238423Sjhb ln -s "bar" $i/first/equal/second/link 154238423Sjhb mkdir $i/first/equal/second/fulldir 155238423Sjhb echo "foo" > $i/first/equal/second/fulldir/file 156238423Sjhb done 157238423Sjhb 158238423Sjhb # /first/equal/*: Cannot occur. If the file is missing from 159238423Sjhb # new, then new vs test will always be 'second'. 160238423Sjhb 161238423Sjhb # /first/first/equal: Removed files are already removed. 162238423Sjhb # Nothing should happen. 163238423Sjhb mkfifo $OLD/first/first/equal/fifo 164238423Sjhb echo "foo" > $OLD/first/first/equal/file 165238423Sjhb mkdir $OLD/first/first/equal/dir 166238423Sjhb ln -s "bar" $OLD/first/first/equal/link 167238423Sjhb 168238423Sjhb # /first/first/*: Cannot occur. The files are missing from 169238423Sjhb # both new and test. 170238423Sjhb 171238423Sjhb # /first/second/*: Cannot happen, if the file is in old for 172238423Sjhb # old vs new, it cannot be missing for old vs test. 173238423Sjhb 174238423Sjhb # /first/difftype/second: File with different local type 175238423Sjhb # removed. Should generate a warning. 176238423Sjhb mkfifo $OLD/first/difftype/second/fifo 177238423Sjhb mkdir $TEST/first/difftype/second/fifo 178238423Sjhb 179238423Sjhb # /first/difftype/*: Cannot happen since the file is missing 180238423Sjhb # from new but present in test. 181238423Sjhb 182238423Sjhb # /first/difflinks/second: Modified link removed. Should 183238423Sjhb # generate a warning. 184238423Sjhb ln -s "old link" $OLD/first/difflinks/second/link 185238423Sjhb ln -s "test link" $TEST/first/difflinks/second/link 186238423Sjhb 187238423Sjhb # /first/difflinks/*: Cannot happen since the file is missing 188238423Sjhb # from new but present in test. 189238423Sjhb 190238423Sjhb # /first/difffiles/second: Modified file removed. Should 191238423Sjhb # generate a warning. 192238423Sjhb echo "foo" > $OLD/first/difffiles/second/file 193238423Sjhb echo "bar" > $TEST/first/difffiles/second/file 194238423Sjhb 195238423Sjhb # /first/difffiles/*: Cannot happen since the file is missing 196238423Sjhb # from new but present in test. 197238423Sjhb 198238423Sjhb # /second/equal/first: Added a new file that isn't present in 199238423Sjhb # test. The empty directory should be ignored. 200238423Sjhb echo "bar" > $NEW/second/equal/first/file 201238423Sjhb mkfifo $NEW/second/equal/first/fifo 202238423Sjhb ln -s "new" $NEW/second/equal/first/link 203238423Sjhb mkdir $NEW/second/equal/first/emptydir 204238423Sjhb mkdir $NEW/second/equal/first/fulldir 205238423Sjhb echo "foo" > $NEW/second/equal/first/fulldir/file 206238423Sjhb 207238423Sjhb # /second/equal/*: Cannot happen since the file is missing 208238423Sjhb # from test but present in new. 209238423Sjhb 210238423Sjhb # /second/first/*: Cannot happen since the file is missing 211238423Sjhb # from old. 212238423Sjhb 213238423Sjhb # /second/second/equal: Newly added file is already present in 214238423Sjhb # the test directory and identical to the new file. Nothing 215238423Sjhb # should happen. 216238423Sjhb for i in $NEW $TEST; do 217238423Sjhb mkfifo $i/second/second/equal/fifo 218238423Sjhb echo "foo" > $i/second/second/equal/file 219238423Sjhb mkdir $i/second/second/equal/dir 220238423Sjhb ln -s "bar" $i/second/second/equal/link 221238423Sjhb done 222238423Sjhb 223238423Sjhb # /second/second/first: Cannot happen. The file is in dest in 224238423Sjhb # the second test, so it can't be missing from the third test. 225238423Sjhb 226238423Sjhb # /second/second/second: Cannot happen. The file is in new in 227238423Sjhb # the first test, so it can't be missing from the third test. 228238423Sjhb 229238423Sjhb # /second/second/difftype: Newly added file conflicts with 230238423Sjhb # existing file in test tree of a different type. Should 231238423Sjhb # generate a warning. 232238423Sjhb mkdir $NEW/second/second/difftype/dir 233238423Sjhb mkfifo $TEST/second/second/difftype/dir 234238423Sjhb 235238423Sjhb # /second/second/difflinks: Newly added link conflicts with 236238423Sjhb # existing link in test tree. Should generate a warning. 237238423Sjhb ln -s "new link" $NEW/second/second/difflinks/link 238238423Sjhb ln -s "test link" $TEST/second/second/difflinks/link 239238423Sjhb 240238423Sjhb # /second/second/difffiles: Newly added file conflicts with 241238423Sjhb # existing file in test tree. Should generate a warning. 242238423Sjhb echo "new" > $NEW/second/second/difffiles/file 243238423Sjhb echo "test" > $TEST/second/second/difffiles/file 244238423Sjhb 245238423Sjhb # /second/difftype/*: Cannot happen since the file is missing 246238423Sjhb # from old. 247238423Sjhb 248238423Sjhb # /second/difflinks/*: Cannot happen since the file is missing 249238423Sjhb # from old. 250238423Sjhb 251238423Sjhb # /second/difffiles/*: Cannot happen since the file is missing 252238423Sjhb # from old. 253238423Sjhb 254238423Sjhb # /difftype/equal/difftype: Unmodified file has changed type. 255238423Sjhb # File should be updated to the new file. In the 'todir' case 256238423Sjhb # the directory won't actually be created because it is empty. 257238423Sjhb for i in $OLD $TEST; do 258238423Sjhb echo "foo" > $i/difftype/equal/difftype/file 259238423Sjhb mkdir $i/difftype/equal/difftype/fromdir 260238423Sjhb ln -s "old" $i/difftype/equal/difftype/todir 261238423Sjhb done 262238423Sjhb ln -s "test" $NEW/difftype/equal/difftype/file 263238423Sjhb mkfifo $NEW/difftype/equal/difftype/fromdir 264238423Sjhb mkdir $NEW/difftype/equal/difftype/todir 265238423Sjhb 266238423Sjhb # /difftype/equal/*: Cannot happen. Since the old file is a 267238423Sjhb # difftype from the new file and the test file is identical to 268238423Sjhb # the old file, the test file must be a difftype from the new 269238423Sjhb # file. 270238423Sjhb 271238423Sjhb # /difftype/first/first: A removed file has changed type. 272238423Sjhb # This should generate a warning. 273238423Sjhb mkfifo $OLD/difftype/first/first/fifo 274238423Sjhb mkdir $NEW/difftype/first/first/fifo 275238423Sjhb 276238423Sjhb # /difftype/first/*: Cannot happen. Since the new file exists 277238423Sjhb # and the dest file is missing, the last test must be 'first'. 278238423Sjhb 279238423Sjhb # /difftype/second/*: Cannot happen. The old file exists in 280238423Sjhb # the first test, so it cannot be missing in the second test. 281238423Sjhb 282238423Sjhb # /difftype/difftype/equal: A file has changed type, but the 283238423Sjhb # file in the test directory already matches the new file. Do 284238423Sjhb # nothing. 285238423Sjhb echo "foo" > $OLD/difftype/difftype/equal/fifo 286238423Sjhb mkfifo $OLD/difftype/difftype/equal/file 287238423Sjhb for i in $NEW $TEST; do 288238423Sjhb mkfifo $i/difftype/difftype/equal/fifo 289238423Sjhb echo "bar" > $i/difftype/difftype/equal/file 290238423Sjhb done 291238423Sjhb 292238423Sjhb # /difftype/difftype/first: Cannot happen. The dest file 293238423Sjhb # exists in the second test. 294238423Sjhb 295238423Sjhb # /difftype/difftype/second: Cannot happen. The new file 296238423Sjhb # exists in the first test. 297238423Sjhb 298238423Sjhb # /difftype/difftype/difftype: All three files (old, new, and 299238423Sjhb # test) are different types from each other. This should 300238423Sjhb # generate a warning. 301238423Sjhb mkfifo $OLD/difftype/difftype/difftype/one 302238423Sjhb mkdir $NEW/difftype/difftype/difftype/one 303238423Sjhb echo "foo" > $TEST/difftype/difftype/difftype/one 304238423Sjhb mkdir $OLD/difftype/difftype/difftype/two 305238423Sjhb echo "baz" > $NEW/difftype/difftype/difftype/two 306238423Sjhb ln -s "bar" $TEST/difftype/difftype/difftype/two 307238423Sjhb 308238423Sjhb # /difftype/difftype/difflinks: A file has changed from a 309238423Sjhb # non-link to a link in both the new and test trees, but the 310238423Sjhb # target of the new and test links differ. This should 311238423Sjhb # generate a new link conflict. 312238423Sjhb mkfifo $OLD/difftype/difftype/difflinks/link 313238423Sjhb ln -s "new" $NEW/difftype/difftype/difflinks/link 314238423Sjhb ln -s "test" $TEST/difftype/difftype/difflinks/link 315238423Sjhb 316238423Sjhb # /difftype/difftype/difffile: A file has changed from a 317238423Sjhb # non-regular file to a regular file in both the new and test 318238423Sjhb # trees, but the contents in the new and test files differ. 319238423Sjhb # This should generate a new file conflict. 320238423Sjhb ln -s "old" $OLD/difftype/difftype/difffiles/file 321238423Sjhb echo "foo" > $NEW/difftype/difftype/difffiles/file 322238423Sjhb echo "bar" > $TEST/difftype/difftype/difffiles/file 323238423Sjhb 324238423Sjhb # /difflinks/equal/difflinks: An unmodified symlink has 325238423Sjhb # changed. The link should be updated. 326238423Sjhb for i in $OLD $TEST; do 327238423Sjhb ln -s "old" $i/difflinks/equal/difflinks/link 328238423Sjhb done 329238423Sjhb ln -s "new" $NEW/difflinks/equal/difflinks/link 330238423Sjhb 331238423Sjhb # /difflinks/equal/*: Cannot happen. Since old is identical 332238423Sjhb # to test, the third test must be 'difflinks'. 333238423Sjhb 334238423Sjhb # /difflinks/first/first: A modified link is missing in the 335238423Sjhb # test tree. This should generate a warning. 336238423Sjhb ln -s "old" $OLD/difflinks/first/first/link 337238423Sjhb ln -s "new" $NEW/difflinks/first/first/link 338238423Sjhb 339238423Sjhb # /difflinks/first/*: Cannot happen. Since the test file is 340238423Sjhb # missing in the second test, it must be missing in the third 341238423Sjhb # test. 342238423Sjhb 343238423Sjhb # /difflinks/second/*: Cannot happen. The old link is present 344238423Sjhb # in the first test, so it cannot be missing in the second 345238423Sjhb # test. 346238423Sjhb 347238423Sjhb # /difflinks/difftype/difftype: An updated link has been 348238423Sjhb # changed to a different file type in the test tree. This 349238423Sjhb # should generate a warning. 350238423Sjhb ln -s "old" $OLD/difflinks/difftype/difftype/link 351238423Sjhb ln -s "new" $NEW/difflinks/difftype/difftype/link 352238423Sjhb echo "test" > $TEST/difflinks/difftype/difftype/link 353238423Sjhb 354238423Sjhb # /difflinks/difftype/*: Cannot happen. The old and new files 355238423Sjhb # are both links and the test file is not a link, so the third 356238423Sjhb # test must be 'difftype'. 357238423Sjhb 358238423Sjhb # /difflinks/difflinks/equal: An updated link has already been 359238423Sjhb # updated to the new target in the test tree. Nothing should 360238423Sjhb # happen. 361238423Sjhb ln -s "old" $OLD/difflinks/difflinks/equal/link 362238423Sjhb for i in $NEW $TEST; do 363238423Sjhb ln -s "new" $i/difflinks/difflinks/equal/link 364238423Sjhb done 365238423Sjhb 366238423Sjhb # /difflinks/difflinks/difflinks: An updated link has been 367238423Sjhb # modified in the test tree and doesn't match either the old 368238423Sjhb # or new links. This should generate a warning. 369238423Sjhb ln -s "old" $OLD/difflinks/difflinks/difflinks/link 370238423Sjhb ln -s "new" $NEW/difflinks/difflinks/difflinks/link 371238423Sjhb ln -s "test" $TEST/difflinks/difflinks/difflinks/link 372238423Sjhb 373238423Sjhb # /difflinks/difflinks/*: Cannot happen. All three files are 374238423Sjhb # links from the first two tests, so the third test can only 375238423Sjhb # be 'equal' or 'difflink'. 376238423Sjhb 377238423Sjhb # /difflinks/difffiles/*: Cannot happen. The old file is a 378238423Sjhb # link in the first test, so it cannot be a regular file in 379238423Sjhb # the second. 380238423Sjhb 381238423Sjhb # /difffiles/equal/difffiles: An unmodified file has been 382238423Sjhb # changed in new tree. The file should be updated to the new 383238423Sjhb # version. 384238423Sjhb for i in $OLD $TEST; do 385238423Sjhb echo "foo" > $i/difffiles/equal/difffiles/file 386238423Sjhb done 387238423Sjhb echo "bar" > $NEW/difffiles/equal/difffiles/file 388238423Sjhb 389238423Sjhb # /difffiles/equal/*: Cannot happen. Since the old file is 390238423Sjhb # identical to the test file, the third test must be 391238423Sjhb # 'difffiles'. 392238423Sjhb 393238423Sjhb # /difffiles/first/first: A removed file has been changed in 394238423Sjhb # the new tree. This should generate a warning. 395238423Sjhb echo "foo" > $OLD/difffiles/first/first/file 396238423Sjhb echo "bar" > $NEW/difffiles/first/first/file 397238423Sjhb 398238423Sjhb # /difffiles/first/*: Cannot happen. The new file is a 399238423Sjhb # regular file from the first test and the test file is 400238423Sjhb # missing in the second test, so the third test must be 401238423Sjhb # 'first'. 402238423Sjhb 403238423Sjhb # /difffiles/second/*: Cannot happen. The old file is present 404238423Sjhb # in the first test, so it must be present in the second test. 405238423Sjhb 406238423Sjhb # /difffiles/difftype/difftype: An updated regular file has 407238423Sjhb # been changed to a different file type in the test tree. 408238423Sjhb # This should generate a warning. 409238423Sjhb echo "old" > $OLD/difffiles/difftype/difftype/file 410238423Sjhb echo "new" > $NEW/difffiles/difftype/difftype/file 411238423Sjhb mkfifo $TEST/difffiles/difftype/difftype/file 412238423Sjhb 413238423Sjhb # /difffiles/difftype/*: Cannot happen. The new file is known 414238423Sjhb # to be a regular file from the first test, and the test file 415238423Sjhb # is known to exist as a different file type from the second 416238423Sjhb # test. The third test must be 'difftype'. 417238423Sjhb 418238423Sjhb # /difffiles/difflink/*: Cannot happen. The old file is known 419238423Sjhb # to be a regular file from the first test, so it cannot be a 420238423Sjhb # link in the second test. 421238423Sjhb 422238423Sjhb # /difffiles/difffiles/equal: An updated regular file has 423238423Sjhb # already been updated to match the new file in the test tree. 424238423Sjhb # Nothing should happen. 425238423Sjhb echo "foo" > $OLD/difffiles/difffiles/equal/file 426238423Sjhb for i in $NEW $TEST; do 427238423Sjhb echo "bar" > $i/difffiles/difffiles/equal/file 428238423Sjhb done 429238423Sjhb 430238423Sjhb # /difffiles/difffiles/difffiles: A modified regular file was 431238423Sjhb # updated in the new tree. The changes should be merged into 432238423Sjhb # to the new file if possible. If the merge fails, a conflict 433238423Sjhb # should be generated. 434238423Sjhb cat > $OLD/difffiles/difffiles/difffiles/simple <<EOF 435238423Sjhbthis is an old line 436238423Sjhb 437238423SjhbEOF 438238423Sjhb cat > $NEW/difffiles/difffiles/difffiles/simple <<EOF 439238423Sjhbthis is a new line 440238423Sjhb 441238423SjhbEOF 442238423Sjhb cat > $TEST/difffiles/difffiles/difffiles/simple <<EOF 443238423Sjhbthis is an old line 444238423Sjhb 445238423Sjhbthis is a local line 446238423SjhbEOF 447238423Sjhb cat > $OLD/difffiles/difffiles/difffiles/conflict <<EOF 448238423Sjhbthis is an old file 449238423SjhbEOF 450238423Sjhb cat > $NEW/difffiles/difffiles/difffiles/conflict <<EOF 451238423Sjhbthis is a new file 452238423SjhbEOF 453238423Sjhb cat > $TEST/difffiles/difffiles/difffiles/conflict <<EOF 454238423Sjhbthis is a test file 455238423SjhbEOF 456238423Sjhb 457238423Sjhb # /difffiles/difffiles/*: Cannot happen. From the first three 458238423Sjhb # tests, all three files are regular files. The test file can 459238423Sjhb # either be identical to the new file ('equal') or not 460238423Sjhb # ('difffiles'). 461238423Sjhb 462238423Sjhb ## Tests for adding directories 463238423Sjhb mkdir -p $OLD/adddir $NEW/adddir $TEST/adddir 464238423Sjhb 465238423Sjhb # /adddir/conflict: Add a new file in a directory that already 466238423Sjhb # exists as a file. This should generate two warnings. 467238423Sjhb mkdir $NEW/adddir/conflict 468238423Sjhb touch $NEW/adddir/conflict/newfile 469238423Sjhb touch $TEST/adddir/conflict 470238423Sjhb 471238423Sjhb # /adddir/partial: Add a new file in a directory. The 472238423Sjhb # directory already exists in the test tree and contains a 473238423Sjhb # different local file. The new file from the new tree should 474238423Sjhb # be added. 475238423Sjhb for i in $NEW $TEST; do 476238423Sjhb mkdir $i/adddir/partial 477238423Sjhb done 478238423Sjhb echo "foo" > $NEW/adddir/partial/file 479238423Sjhb mkfifo $TEST/adddir/partial/fifo 480238423Sjhb 481238423Sjhb ## Tests for removing directories 482238423Sjhb mkdir -p $OLD/rmdir $NEW/rmdir $TEST/rmdir 483238423Sjhb 484238423Sjhb # /rmdir/extra: Do not remove a directory with an extra local file. 485238423Sjhb # This should generate a warning. 486238423Sjhb for i in $OLD $TEST; do 487238423Sjhb mkdir $i/rmdir/extra 488238423Sjhb done 489238423Sjhb echo "foo" > $TEST/rmdir/extra/localfile.txt 490238423Sjhb 491238423Sjhb # /rmdir/conflict: Do not remove a directory with a conflicted 492238423Sjhb # remove file. This should generate a warning. 493238423Sjhb for i in $OLD $TEST; do 494238423Sjhb mkdir $i/rmdir/conflict 495238423Sjhb done 496238423Sjhb mkfifo $OLD/rmdir/conflict/difftype 497238423Sjhb mkdir $TEST/rmdir/conflict/difftype 498238423Sjhb 499238423Sjhb # /rmdir/partial: Remove a complete hierarchy when part of the 500238423Sjhb # tree has already been removed locally. 501238423Sjhb for i in $OLD $TEST; do 502238423Sjhb mkdir -p $i/rmdir/partial/subdir 503238423Sjhb mkfifo $i/rmdir/partial/subdir/fifo 504238423Sjhb done 505238423Sjhb echo "foo" > $OLD/rmdir/partial/subdir/file 506238423Sjhb 507238423Sjhb ## Tests for converting files to directories and vice versa 508238423Sjhb for i in $OLD $NEW $TEST; do 509238423Sjhb for j in already old fromdir todir; do 510238423Sjhb mkdir -p $i/dirchange/$j 511238423Sjhb done 512238423Sjhb done 513238423Sjhb 514238423Sjhb # /dirchange/already/fromdir: Convert a directory tree to a 515238423Sjhb # file without conflicts where the test tree already has the 516238423Sjhb # new file. Nothing should happen. 517238423Sjhb mkdir $OLD/dirchange/already/fromdir 518238423Sjhb echo "blah" > $OLD/dirchange/already/fromdir/somefile 519238423Sjhb for i in $NEW $TEST; do 520238423Sjhb echo "bar" > $i/dirchange/already/fromdir 521238423Sjhb done 522238423Sjhb 523238423Sjhb # /dirchange/already/todir: Convert an unmodified file to a 524238423Sjhb # directory tree where the test tree already has the new 525238423Sjhb # tree. Nothing should happen. 526238423Sjhb echo "baz" > $OLD/dirchange/already/todir 527238423Sjhb for i in $NEW $TEST; do 528238423Sjhb mkdir $i/dirchange/already/todir 529238423Sjhb echo "blah" > $i/dirchange/already/todir/somefile 530238423Sjhb done 531238423Sjhb 532238423Sjhb # /dirchange/old/fromdir: Convert a directory tree to a file. 533238423Sjhb # The old files are unmodified and should be changed to the new tree. 534238423Sjhb for i in $OLD $TEST; do 535238423Sjhb mkdir $i/dirchange/old/fromdir 536238423Sjhb echo "blah" > $i/dirchange/old/fromdir/somefile 537238423Sjhb done 538238423Sjhb echo "bar" > $NEW/dirchange/old/fromdir 539238423Sjhb 540238423Sjhb # /dirchange/old/todir: Convert a file to a directory tree. 541238423Sjhb # The old file is unmodified and should be changed to the new 542238423Sjhb # tree. 543238423Sjhb for i in $OLD $TEST; do 544238423Sjhb echo "foo" > $i/dirchange/old/todir 545238423Sjhb done 546238423Sjhb mkdir $NEW/dirchange/old/todir 547238423Sjhb echo "bar" > $NEW/dirchange/old/todir/file 548238423Sjhb 549238423Sjhb # /dirchange/fromdir/extradir: Convert a directory tree to a 550238423Sjhb # file. The test tree includes an extra file in the directory 551238423Sjhb # that is not present in the old tree. This should generate a 552238423Sjhb # warning. 553238423Sjhb for i in $OLD $TEST; do 554238423Sjhb mkdir $i/dirchange/fromdir/extradir 555238423Sjhb echo "foo" > $i/dirchange/fromdir/extradir/file 556238423Sjhb done 557238423Sjhb mkfifo $TEST/dirchange/fromdir/extradir/fifo 558238423Sjhb ln -s "bar" $NEW/dirchange/fromdir/extradir 559238423Sjhb 560238423Sjhb # /dirchange/fromdir/conflict: Convert a directory tree to a 561238423Sjhb # file. The test tree includes a local change that generates 562238423Sjhb # a warning and prevents the removal of the directory. 563238423Sjhb for i in $OLD $TEST; do 564238423Sjhb mkdir $i/dirchange/fromdir/conflict 565238423Sjhb done 566238423Sjhb echo "foo" > $OLD/dirchange/fromdir/conflict/somefile 567238423Sjhb echo "bar" > $TEST/dirchange/fromdir/conflict/somefile 568238423Sjhb mkfifo $NEW/dirchange/fromdir/conflict 569238423Sjhb 570238423Sjhb # /dirchange/todir/difffile: Convert a file to a directory 571238423Sjhb # tree. The test tree has a locally modified version of the 572238423Sjhb # file so that the conversion fails with a warning. 573238423Sjhb echo "foo" > $OLD/dirchange/todir/difffile 574238423Sjhb mkdir $NEW/dirchange/todir/difffile 575238423Sjhb echo "baz" > $NEW/dirchange/todir/difffile/file 576238423Sjhb echo "bar" > $TEST/dirchange/todir/difffile 577238423Sjhb 578238423Sjhb # /dirchange/todir/difftype: Similar to the previous test, but 579238423Sjhb # the conflict is due to a change in the file type. 580238423Sjhb echo "foo" > $OLD/dirchange/todir/difftype 581238423Sjhb mkdir $NEW/dirchange/todir/difftype 582238423Sjhb echo "baz" > $NEW/dirchange/todir/difftype/file 583238423Sjhb mkfifo $TEST/dirchange/todir/difftype 584238423Sjhb 585238423Sjhb ## Tests for post-install actions 586238423Sjhb 587238423Sjhb # - Adding /etc/master.passwd should cause pwd_mkdb to be run 588238423Sjhb echo "foo:*:16000:100::0:0:& user:/home/foo:/bin/tcsh" > \ 589238423Sjhb $NEW/etc/master.passwd 590238423Sjhb 591238423Sjhb # - Verify that updating an unmodified /etc/login.conf builds 592238423Sjhb # /etc/login.conf.db. 593238423Sjhb cat > $OLD/etc/login.conf <<EOF 594238423Sjhbdefault:\\ 595238423Sjhb :passwd_format=md5: 596238423SjhbEOF 597238423Sjhb cat > $NEW/etc/login.conf <<EOF 598238423Sjhbdefault:\\ 599238423Sjhb :passwd_format=md5:\\ 600238423Sjhb :copyright=/etc/COPYRIGHT 601238423SjhbEOF 602238423Sjhb cp $OLD/etc/login.conf $TEST/etc/login.conf 603238423Sjhb 604238423Sjhb # - Verify that a merge without conflicts to /etc/mail/aliases 605238423Sjhb # will trigger a newaliases run request. 606238423Sjhb mkdir -p $OLD/etc/mail $NEW/etc/mail $TEST/etc/mail 607238423Sjhb cat > $OLD/etc/mail/aliases <<EOF 608238423Sjhb# root: me@my.domain 609238423Sjhb 610238423Sjhb# Basic system aliases -- these MUST be present 611238423SjhbMAILER-DAEMON: postmaster 612238423Sjhbpostmaster: root 613238423SjhbEOF 614238423Sjhb cat > $NEW/etc/mail/aliases <<EOF 615238423Sjhb# root: me@my.domain 616238423Sjhb 617238423Sjhb# Basic system aliases -- these MUST be present 618238423SjhbMAILER-DAEMON: postmaster 619238423Sjhbpostmaster: root 620238423Sjhb 621238423Sjhb# General redirections for pseudo accounts 622238423Sjhb_dhcp: root 623238423Sjhb_pflogd: root 624238423SjhbEOF 625238423Sjhb cat > $TEST/etc/mail/aliases <<EOF 626238423Sjhbroot: someone@example.com 627238423Sjhb 628238423Sjhb# Basic system aliases -- these MUST be present 629238423SjhbMAILER-DAEMON: postmaster 630238423Sjhbpostmaster: root 631238423SjhbEOF 632259134Sjhb 633259134Sjhb # - Verify that updating an unmodified /etc/services builds 634259134Sjhb # /var/db/services.db. 635259134Sjhb cat > $OLD/etc/services <<EOF 636259134Sjhbrtmp 1/ddp #Routing Table Maintenance Protocol 637259134Sjhbtcpmux 1/tcp #TCP Port Service Multiplexer 638259134Sjhbtcpmux 1/udp #TCP Port Service Multiplexer 639259134SjhbEOF 640259134Sjhb cat > $NEW/etc/services <<EOF 641259134Sjhbrtmp 1/ddp #Routing Table Maintenance Protocol 642259134Sjhbtcpmux 1/tcp #TCP Port Service Multiplexer 643259134Sjhbtcpmux 1/udp #TCP Port Service Multiplexer 644259134Sjhbnbp 2/ddp #Name Binding Protocol 645259134Sjhbcompressnet 2/tcp #Management Utility 646259134Sjhbcompressnet 2/udp #Management Utility 647259134SjhbEOF 648259134Sjhb cp $OLD/etc/services $TEST/etc/services 649259134Sjhb mkdir -p $TEST/var/db 650238423Sjhb} 651238423Sjhb 652238423Sjhb# $1 - relative path to file that should be missing from TEST 653238423Sjhbmissing() 654238423Sjhb{ 655238423Sjhb if [ -e $TEST/$1 -o -L $TEST/$1 ]; then 656238423Sjhb echo "File $1 should be missing" 657263221Sjmmv FAILED=yes 658238423Sjhb fi 659238423Sjhb} 660238423Sjhb 661238423Sjhb# $1 - relative path to file that should be present in TEST 662238423Sjhbpresent() 663238423Sjhb{ 664238423Sjhb if ! [ -e $TEST/$1 -o -L $TEST/$1 ]; then 665238423Sjhb echo "File $1 should be present" 666263221Sjmmv FAILED=yes 667238423Sjhb fi 668238423Sjhb} 669238423Sjhb 670238423Sjhb# $1 - relative path to file that should be a fifo in TEST 671238423Sjhbfifo() 672238423Sjhb{ 673238423Sjhb if ! [ -p $TEST/$1 ]; then 674238423Sjhb echo "File $1 should be a FIFO" 675263221Sjmmv FAILED=yes 676238423Sjhb fi 677238423Sjhb} 678238423Sjhb 679238423Sjhb# $1 - relative path to file that should be a directory in TEST 680238423Sjhbdir() 681238423Sjhb{ 682238423Sjhb if ! [ -d $TEST/$1 ]; then 683238423Sjhb echo "File $1 should be a directory" 684263221Sjmmv FAILED=yes 685238423Sjhb fi 686238423Sjhb} 687238423Sjhb 688238423Sjhb# $1 - relative path to file that should be a symlink in TEST 689238423Sjhb# $2 - optional value of the link 690238423Sjhblink() 691238423Sjhb{ 692238423Sjhb local val 693238423Sjhb 694238423Sjhb if ! [ -L $TEST/$1 ]; then 695238423Sjhb echo "File $1 should be a link" 696263221Sjmmv FAILED=yes 697238423Sjhb elif [ $# -gt 1 ]; then 698238423Sjhb val=`readlink $TEST/$1` 699238423Sjhb if [ "$val" != "$2" ]; then 700238423Sjhb echo "Link $1 should link to \"$2\"" 701263221Sjmmv FAILED=yes 702238423Sjhb fi 703238423Sjhb fi 704238423Sjhb} 705238423Sjhb 706238423Sjhb# $1 - relative path to regular file that should be present in TEST 707238423Sjhb# $2 - optional string that should match file contents 708238423Sjhb# $3 - optional MD5 of the flie contents, overrides $2 if present 709238423Sjhbfile() 710238423Sjhb{ 711238423Sjhb local contents sum 712238423Sjhb 713238423Sjhb if ! [ -f $TEST/$1 ]; then 714238423Sjhb echo "File $1 should be a regular file" 715263221Sjmmv FAILED=yes 716238423Sjhb elif [ $# -eq 2 ]; then 717238423Sjhb contents=`cat $TEST/$1` 718238423Sjhb if [ "$contents" != "$2" ]; then 719238423Sjhb echo "File $1 has wrong contents" 720263221Sjmmv FAILED=yes 721238423Sjhb fi 722238423Sjhb elif [ $# -eq 3 ]; then 723238423Sjhb sum=`md5 -q $TEST/$1` 724238423Sjhb if [ "$sum" != "$3" ]; then 725238423Sjhb echo "File $1 has wrong contents" 726263221Sjmmv FAILED=yes 727238423Sjhb fi 728238423Sjhb fi 729238423Sjhb} 730238423Sjhb 731238423Sjhb# $1 - relative path to a regular file that should have a conflict 732238423Sjhb# $2 - optional MD5 of the conflict file contents 733238423Sjhbconflict() 734238423Sjhb{ 735238423Sjhb local sum 736238423Sjhb 737238423Sjhb if ! [ -f $CONFLICTS/$1 ]; then 738238423Sjhb echo "File $1 missing conflict" 739263221Sjmmv FAILED=yes 740238423Sjhb elif [ $# -gt 1 ]; then 741238423Sjhb sum=`md5 -q $CONFLICTS/$1` 742238423Sjhb if [ "$sum" != "$2" ]; then 743238423Sjhb echo "Conflict $1 has wrong contents" 744263221Sjmmv FAILED=yes 745238423Sjhb fi 746238423Sjhb fi 747238423Sjhb} 748238423Sjhb 749238423Sjhbcheck_trees() 750238423Sjhb{ 751238423Sjhb 752238423Sjhb echo "Checking tree for correct results:" 753238423Sjhb 754238423Sjhb ## /equal/equal/equal: 755238423Sjhb fifo /equal/equal/equal/fifo 756238423Sjhb file /equal/equal/equal/file "foo" 757238423Sjhb dir /equal/equal/equal/dir 758238423Sjhb link /equal/equal/equal/link "bar" 759238423Sjhb 760238423Sjhb ## /equal/first/first: 761238423Sjhb missing /equal/first/first/fifo 762238423Sjhb missing /equal/first/first/file 763238423Sjhb missing /equal/first/first/dir 764238423Sjhb missing /equal/first/first/link 765238423Sjhb 766238423Sjhb ## /equal/difftype/difftype: 767238423Sjhb file /equal/difftype/difftype/fifo "bar" 768238423Sjhb link /equal/difftype/difftype/fromdir "test" 769238423Sjhb 770238423Sjhb ## /equal/difflinks/difflinks: 771238423Sjhb link /equal/difflinks/difflinks/link "bar" 772238423Sjhb 773238423Sjhb ## /equal/difffiles/difffiles: 774238423Sjhb file /equal/difffiles/difffiles/file "bar" 775238423Sjhb 776238423Sjhb ## /first/equal/second: 777238423Sjhb missing /first/equal/second/fifo 778238423Sjhb missing /first/equal/second/file 779238423Sjhb missing /first/equal/second/emptydir 780238423Sjhb missing /first/equal/second/link 781238423Sjhb missing /first/equal/second/fulldir 782238423Sjhb 783238423Sjhb ## /first/first/equal: 784238423Sjhb missing /first/first/equal/fifo 785238423Sjhb missing /first/first/equal/file 786238423Sjhb missing /first/first/equal/dir 787238423Sjhb missing /first/first/equal/link 788238423Sjhb 789238423Sjhb ## /first/difftype/second: 790238423Sjhb present /first/difftype/second/fifo 791238423Sjhb 792238423Sjhb ## /first/difflinks/second: 793238423Sjhb link /first/difflinks/second/link "test link" 794238423Sjhb 795238423Sjhb ## /first/difffiles/second: 796238423Sjhb file /first/difffiles/second/file "bar" 797238423Sjhb 798238423Sjhb ## /second/equal/first: 799238423Sjhb file /second/equal/first/file "bar" 800238423Sjhb fifo /second/equal/first/fifo 801238423Sjhb link /second/equal/first/link "new" 802238423Sjhb missing /second/equal/first/emptydir 803238423Sjhb file /second/equal/first/fulldir/file "foo" 804238423Sjhb 805238423Sjhb ## /second/second/equal: 806238423Sjhb fifo /second/second/equal/fifo 807238423Sjhb file /second/second/equal/file "foo" 808238423Sjhb dir /second/second/equal/dir 809238423Sjhb link /second/second/equal/link "bar" 810238423Sjhb 811238423Sjhb ## /second/second/difftype: 812238423Sjhb fifo /second/second/difftype/dir 813238423Sjhb 814238423Sjhb ## /second/second/difflinks: 815238423Sjhb link /second/second/difflinks/link "test link" 816238423Sjhb 817238423Sjhb ## /second/second/difffiles: 818238423Sjhb file /second/second/difffiles/file "test" 819238423Sjhb conflict /second/second/difffiles/file 4f2ee8620a251fd53f06bb6112eb6ffa 820238423Sjhb 821238423Sjhb ## /difftype/equal/difftype: 822238423Sjhb link /difftype/equal/difftype/file "test" 823238423Sjhb fifo /difftype/equal/difftype/fromdir 824238423Sjhb missing /difftype/equal/difftype/todir 825238423Sjhb 826238423Sjhb ## /difftype/first/first: 827238423Sjhb missing /difftype/first/first/fifo 828238423Sjhb 829238423Sjhb ## /difftype/difftype/equal: 830238423Sjhb fifo /difftype/difftype/equal/fifo 831238423Sjhb file /difftype/difftype/equal/file "bar" 832238423Sjhb 833238423Sjhb ## /difftype/difftype/difftype: 834238423Sjhb file /difftype/difftype/difftype/one "foo" 835238423Sjhb link /difftype/difftype/difftype/two "bar" 836238423Sjhb 837238423Sjhb ## /difftype/difftype/difflinks: 838238423Sjhb link /difftype/difftype/difflinks/link "test" 839238423Sjhb 840238423Sjhb ## /difftype/difftype/difffile: 841238423Sjhb conflict /difftype/difftype/difffiles/file \ 842238423Sjhb 117f2bcd1f6491f6044e79e5a57a9229 843238423Sjhb 844238423Sjhb ## /difflinks/equal/difflinks: 845238423Sjhb link /difflinks/equal/difflinks/link "new" 846238423Sjhb 847238423Sjhb ## /difflinks/first/first: 848238423Sjhb missing /difflinks/first/first/link 849238423Sjhb 850238423Sjhb ## /difflinks/difftype/difftype: 851238423Sjhb file /difflinks/difftype/difftype/link "test" 852238423Sjhb 853238423Sjhb ## /difflinks/difflinks/equal: 854238423Sjhb link /difflinks/difflinks/equal/link "new" 855238423Sjhb 856238423Sjhb ## /difflinks/difflinks/difflinks: 857238423Sjhb link /difflinks/difflinks/difflinks/link "test" 858238423Sjhb 859238423Sjhb ## /difffiles/equal/difffiles: 860238423Sjhb file /difffiles/equal/difffiles/file "bar" 861238423Sjhb 862238423Sjhb ## /difffiles/first/first: 863238423Sjhb missing /difffiles/first/first/file 864238423Sjhb 865238423Sjhb ## /difffiles/difftype/difftype: 866238423Sjhb fifo /difffiles/difftype/difftype/file 867238423Sjhb 868238423Sjhb ## /difffiles/difffiles/equal: 869238423Sjhb file /difffiles/difffiles/equal/file "bar" 870238423Sjhb 871238423Sjhb ## /difffiles/difffiles/difffiles: 872238423Sjhb file /difffiles/difffiles/difffiles/simple "" \ 873238423Sjhb cabc7e5e80b0946d79edd555e9648486 874238423Sjhb file /difffiles/difffiles/difffiles/conflict "this is a test file" 875238423Sjhb conflict /difffiles/difffiles/difffiles/conflict \ 876238423Sjhb 8261cfdd89280c4a6c26e4ac86541fe9 877238423Sjhb 878238423Sjhb ## /adddir/conflict: 879238423Sjhb file /adddir/conflict 880238423Sjhb 881238423Sjhb ## /adddir/partial: 882238423Sjhb file /adddir/partial/file "foo" 883238423Sjhb fifo /adddir/partial/fifo 884238423Sjhb 885238423Sjhb ## /rmdir/extra: 886238423Sjhb dir /rmdir/extra 887238423Sjhb file /rmdir/extra/localfile.txt "foo" 888238423Sjhb 889238423Sjhb ## /rmdir/conflict: 890238423Sjhb dir /rmdir/conflict/difftype 891238423Sjhb present /rmdir/conflict 892238423Sjhb 893238423Sjhb ## /rmdir/partial: 894238423Sjhb missing /rmdir/partial 895238423Sjhb 896238423Sjhb ## /dirchange/already/fromdir: 897238423Sjhb file /dirchange/already/fromdir "bar" 898238423Sjhb 899238423Sjhb ## /dirchange/already/todir: 900238423Sjhb file /dirchange/already/todir/somefile "blah" 901238423Sjhb 902238423Sjhb ## /dirchange/old/fromdir: 903238423Sjhb file /dirchange/old/fromdir "bar" 904238423Sjhb 905238423Sjhb ## /dirchange/old/todir 906238423Sjhb file /dirchange/old/todir/file "bar" 907238423Sjhb 908238423Sjhb ## /dirchange/fromdir/extradir: 909238423Sjhb missing /dirchange/fromdir/extradir/file 910238423Sjhb fifo /dirchange/fromdir/extradir/fifo 911238423Sjhb 912238423Sjhb ## /dirchange/fromdir/conflict: 913238423Sjhb file /dirchange/fromdir/conflict/somefile "bar" 914238423Sjhb 915238423Sjhb ## /dirchange/todir/difffile: 916238423Sjhb file /dirchange/todir/difffile "bar" 917238423Sjhb 918238423Sjhb ## /dirchange/todir/difftype: 919238423Sjhb fifo /dirchange/todir/difftype 920238423Sjhb 921238423Sjhb ## Tests for post-install actions 922238423Sjhb file /etc/master.passwd 923238423Sjhb file /etc/passwd 924238423Sjhb file /etc/pwd.db 925238423Sjhb file /etc/spwd.db 926238423Sjhb file /etc/login.conf "" 7774a0f9a3a372c7c109c32fd31c4b6b 927238423Sjhb file /etc/login.conf.db 928238423Sjhb file /etc/mail/aliases "" 7d598f89ec040ab56af54011bdb83337 929259134Sjhb file /etc/services "" 37fb6a8d1273f3b78329d431f21d9c7d 930259134Sjhb file /var/db/services.db 931238423Sjhb} 932238423Sjhb 933238423Sjhbif [ `id -u` -ne 0 ]; then 934238423Sjhb echo "must be root" 935263221Sjmmv exit 0 936238423Sjhbfi 937238423Sjhb 938238423Sjhbif [ -r /etc/etcupdate.conf ]; then 939238423Sjhb echo "WARNING: /etc/etcupdate.conf settings may break some tests." 940238423Sjhbfi 941238423Sjhb 942238423Sjhbbuild_trees 943238423Sjhb 944258063Sjhb$COMMAND -nr -d $WORKDIR -D $TEST > $WORKDIR/testn.out 945238423Sjhb 946238423Sjhbcat > $WORKDIR/correct.out <<EOF 947238423Sjhb D /dirchange/fromdir/extradir/file 948238423Sjhb D /dirchange/old/fromdir/somefile 949238423Sjhb D /first/equal/second/fifo 950238423Sjhb D /first/equal/second/file 951238423Sjhb D /first/equal/second/fulldir/file 952238423Sjhb D /first/equal/second/link 953238423Sjhb D /rmdir/partial/subdir/fifo 954238423Sjhb D /rmdir/partial/subdir 955238423Sjhb D /rmdir/partial 956238423Sjhb D /first/equal/second/fulldir 957238423Sjhb D /first/equal/second/emptydir 958238423Sjhb C /difffiles/difffiles/difffiles/conflict 959238423Sjhb M /difffiles/difffiles/difffiles/simple 960238423Sjhb U /difffiles/equal/difffiles/file 961238423Sjhb U /difflinks/equal/difflinks/link 962238423Sjhb C /difftype/difftype/difffiles/file 963238423Sjhb U /difftype/equal/difftype/file 964238423Sjhb U /difftype/equal/difftype/fromdir 965238423Sjhb D /difftype/equal/difftype/todir 966238423Sjhb U /dirchange/old/fromdir 967238423Sjhb U /dirchange/old/todir 968238423Sjhb U /etc/login.conf 969238423Sjhb M /etc/mail/aliases 970259134Sjhb U /etc/services 971238423Sjhb A /adddir/partial/file 972238423Sjhb A /dirchange/old/todir/file 973238423Sjhb A /etc/master.passwd 974238423Sjhb A /second/equal/first/fifo 975238423Sjhb A /second/equal/first/file 976238423Sjhb A /second/equal/first/fulldir/file 977238423Sjhb A /second/equal/first/link 978238423Sjhb C /second/second/difffiles/file 979238423SjhbWarnings: 980238423Sjhb Modified regular file remains: /dirchange/fromdir/conflict/somefile 981238423Sjhb Modified regular file remains: /first/difffiles/second/file 982238423Sjhb Modified symbolic link remains: /first/difflinks/second/link 983238423Sjhb Modified directory remains: /first/difftype/second/fifo 984238423Sjhb Modified directory remains: /rmdir/conflict/difftype 985238423Sjhb Non-empty directory remains: /rmdir/extra 986238423Sjhb Non-empty directory remains: /rmdir/conflict 987238423Sjhb Modified mismatch: /difffiles/difftype/difftype/file (regular file vs fifo file) 988238423Sjhb Removed file changed: /difffiles/first/first/file 989238423Sjhb Modified link changed: /difflinks/difflinks/difflinks/link ("old" became "new") 990238423Sjhb Modified mismatch: /difflinks/difftype/difftype/link (symbolic link vs regular file) 991238423Sjhb Removed link changed: /difflinks/first/first/link ("old" became "new") 992238423Sjhb New link conflict: /difftype/difftype/difflinks/link ("new" vs "test") 993238423Sjhb Modified regular file changed: /difftype/difftype/difftype/one (fifo file became directory) 994238423Sjhb Modified symbolic link changed: /difftype/difftype/difftype/two (directory became regular file) 995238423Sjhb Remove mismatch: /difftype/first/first/fifo (fifo file became directory) 996238423Sjhb Modified directory changed: /dirchange/fromdir/conflict (directory became fifo file) 997238423Sjhb Modified directory changed: /dirchange/fromdir/extradir (directory became symbolic link) 998238423Sjhb Modified regular file changed: /dirchange/todir/difffile (regular file became directory) 999238423Sjhb Modified fifo file changed: /dirchange/todir/difftype (regular file became directory) 1000238423Sjhb New file mismatch: /adddir/conflict (directory vs regular file) 1001238423Sjhb Directory mismatch: $TEST/adddir/conflict (regular file) 1002238423Sjhb Directory mismatch: $TEST/dirchange/todir/difffile (regular file) 1003238423Sjhb Directory mismatch: $TEST/dirchange/todir/difftype (fifo file) 1004238423Sjhb New link conflict: /second/second/difflinks/link ("new link" vs "test link") 1005238423Sjhb New file mismatch: /second/second/difftype/dir (directory vs fifo file) 1006238423Sjhb Needs update: /etc/mail/aliases.db (requires manual update via newaliases(1)) 1007238423SjhbEOF 1008238423Sjhb 1009238423Sjhbecho "Differences for -n:" 1010263221Sjmmvdiff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/testn.out \ 1011263221Sjmmv || failed=YES 1012238423Sjhb 1013258063Sjhb$COMMAND -r -d $WORKDIR -D $TEST > $WORKDIR/test.out 1014238423Sjhb 1015238423Sjhbecho "Differences for real:" 1016263221Sjmmvdiff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out \ 1017263221Sjmmv || failed=YES 1018238423Sjhb 1019238423Sjhbcheck_trees 1020263221Sjmmv 1021263221Sjmmv[ "${FAILED}" = no ] 1022