Deleted Added
sdiff udiff text old ( 258063 ) new ( 263221 )
full compact
1#!/bin/sh
2#
3# Copyright (c) 2010 Advanced Computing Technologies LLC
4# Written by: John H. Baldwin <jhb@FreeBSD.org>
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

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
26# SUCH DAMAGE.
27#
28# $FreeBSD: head/tools/regression/usr.sbin/etcupdate/always.sh 258063 2013-11-12 19:15:06Z jhb $
29
30# Various regression tests to test the -A flag to the 'update' command.
31
32WORKDIR=work
33
34usage()
35{
36 echo "Usage: always.sh [-s script] [-w workdir]"
37 exit 1
38}
39

--- 230 unchanged lines hidden (view full) ---

270 mkfifo $TEST/dirchange/todir/difftype
271}
272
273# $1 - relative path to file that should be missing from TEST
274missing()
275{
276 if [ -e $TEST/$1 -o -L $TEST/$1 ]; then
277 echo "File $1 should be missing"
278 fi
279}
280
281# $1 - relative path to file that should be present in TEST
282present()
283{
284 if ! [ -e $TEST/$1 -o -L $TEST/$1 ]; then
285 echo "File $1 should be present"
286 fi
287}
288
289# $1 - relative path to file that should be a fifo in TEST
290fifo()
291{
292 if ! [ -p $TEST/$1 ]; then
293 echo "File $1 should be a FIFO"
294 fi
295}
296
297# $1 - relative path to file that should be a directory in TEST
298dir()
299{
300 if ! [ -d $TEST/$1 ]; then
301 echo "File $1 should be a directory"
302 fi
303}
304
305# $1 - relative path to file that should be a symlink in TEST
306# $2 - optional value of the link
307link()
308{
309 local val
310
311 if ! [ -L $TEST/$1 ]; then
312 echo "File $1 should be a link"
313 elif [ $# -gt 1 ]; then
314 val=`readlink $TEST/$1`
315 if [ "$val" != "$2" ]; then
316 echo "Link $1 should link to \"$2\""
317 fi
318 fi
319}
320
321# $1 - relative path to regular file that should be present in TEST
322# $2 - optional string that should match file contents
323# $3 - optional MD5 of the flie contents, overrides $2 if present
324file()
325{
326 local contents sum
327
328 if ! [ -f $TEST/$1 ]; then
329 echo "File $1 should be a regular file"
330 elif [ $# -eq 2 ]; then
331 contents=`cat $TEST/$1`
332 if [ "$contents" != "$2" ]; then
333 echo "File $1 has wrong contents"
334 fi
335 elif [ $# -eq 3 ]; then
336 sum=`md5 -q $TEST/$1`
337 if [ "$sum" != "$3" ]; then
338 echo "File $1 has wrong contents"
339 fi
340 fi
341}
342
343# $1 - relative path to a regular file that should have a conflict
344# $2 - optional MD5 of the conflict file contents
345conflict()
346{
347 local sum
348
349 if ! [ -f $CONFLICTS/$1 ]; then
350 echo "File $1 missing conflict"
351 elif [ $# -gt 1 ]; then
352 sum=`md5 -q $CONFLICTS/$1`
353 if [ "$sum" != "$2" ]; then
354 echo "Conflict $1 has wrong contents"
355 fi
356 fi
357}
358
359# $1 - relative path to a regular file that should not have a conflict
360noconflict()
361{
362 if [ -f $CONFLICTS/$1 ]; then
363 echo "File $1 should not have a conflict"
364 fi
365}
366
367if [ `id -u` -ne 0 ]; then
368 echo "must be root"
369fi
370
371if [ -r /etc/etcupdate.conf ]; then
372 echo "WARNING: /etc/etcupdate.conf settings may break some tests."
373fi
374
375# First run the test ignoring no patterns.
376

--- 31 unchanged lines hidden (view full) ---

408 Directory mismatch: $TEST/adddir/conflict (regular file)
409 Directory mismatch: $TEST/dirchange/todir/difffile (regular file)
410 Directory mismatch: $TEST/dirchange/todir/difftype (fifo file)
411 New link conflict: /second/second/difflinks/link ("new link" vs "test link")
412 New file mismatch: /second/second/difftype/dir (directory vs fifo file)
413EOF
414
415echo "Differences for regular:"
416diff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out
417
418## /first/difftype/second:
419present /first/difftype/second/fifo
420
421## /first/difflinks/second:
422link /first/difflinks/second/link "test link"
423
424## /first/difffiles/second:

--- 103 unchanged lines hidden (view full) ---

528 Modified directory remains: /rmdir/conflict/difftype
529 Non-empty directory remains: /rmdir/extra
530 Non-empty directory remains: /rmdir/conflict
531 Modified directory changed: /dirchange/fromdir/conflict (directory became fifo file)
532 Modified directory changed: /dirchange/fromdir/extradir (directory became symbolic link)
533EOF
534
535echo "Differences for -A '/first*' -A '/second* /*di*':"
536diff -u -L "correct" $WORKDIR/correct1.out -L "test" $WORKDIR/test1.out
537
538## /first/difftype/second:
539present /first/difftype/second/fifo
540
541## /first/difflinks/second:
542link /first/difflinks/second/link "test link"
543
544## /first/difffiles/second:

--- 60 unchanged lines hidden (view full) ---

605## /dirchange/fromdir/conflict:
606file /dirchange/fromdir/conflict/somefile "bar"
607
608## /dirchange/todir/difffile:
609file /dirchange/todir/difffile/file "baz"
610
611## /dirchange/todir/difftype:
612file /dirchange/todir/difftype/file "baz"