Deleted Added
full compact
always_test.sh (258063) always_test.sh (263221)
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#
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 $
28# $FreeBSD: head/tools/regression/usr.sbin/etcupdate/always.sh 263221 2014-03-16 02:27:27Z jmmv $
29
30# Various regression tests to test the -A flag to the 'update' command.
31
29
30# Various regression tests to test the -A flag to the 'update' command.
31
32FAILED=no
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"
33WORKDIR=work
34
35usage()
36{
37 echo "Usage: always.sh [-s script] [-w workdir]"
38 exit 1
39}
40

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

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

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

422 Directory mismatch: $TEST/adddir/conflict (regular file)
423 Directory mismatch: $TEST/dirchange/todir/difffile (regular file)
424 Directory mismatch: $TEST/dirchange/todir/difftype (fifo file)
425 New link conflict: /second/second/difflinks/link ("new link" vs "test link")
426 New file mismatch: /second/second/difftype/dir (directory vs fifo file)
427EOF
428
429echo "Differences for regular:"
416diff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out
430diff -u -L "correct" $WORKDIR/correct.out -L "test" $WORKDIR/test.out \
431 || FAILED=yes
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*':"
432
433## /first/difftype/second:
434present /first/difftype/second/fifo
435
436## /first/difflinks/second:
437link /first/difflinks/second/link "test link"
438
439## /first/difffiles/second:

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

543 Modified directory remains: /rmdir/conflict/difftype
544 Non-empty directory remains: /rmdir/extra
545 Non-empty directory remains: /rmdir/conflict
546 Modified directory changed: /dirchange/fromdir/conflict (directory became fifo file)
547 Modified directory changed: /dirchange/fromdir/extradir (directory became symbolic link)
548EOF
549
550echo "Differences for -A '/first*' -A '/second* /*di*':"
536diff -u -L "correct" $WORKDIR/correct1.out -L "test" $WORKDIR/test1.out
551diff -u -L "correct" $WORKDIR/correct1.out -L "test" $WORKDIR/test1.out \
552 || FAILED=yes
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"
553
554## /first/difftype/second:
555present /first/difftype/second/fifo
556
557## /first/difflinks/second:
558link /first/difflinks/second/link "test link"
559
560## /first/difffiles/second:

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

621## /dirchange/fromdir/conflict:
622file /dirchange/fromdir/conflict/somefile "bar"
623
624## /dirchange/todir/difffile:
625file /dirchange/todir/difffile/file "baz"
626
627## /dirchange/todir/difftype:
628file /dirchange/todir/difftype/file "baz"
629
630[ "${FAILED}" = no ]