#!/bin/sh # # Copyright (c) 2010 Hudson River Trading LLC # Written by: John H. Baldwin # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD: stable/11/usr.sbin/etcupdate/tests/fbsdid_test.sh 281887 2015-04-23 14:22:20Z jhb $ # Various regression tests to test the -F flag to the 'update' command. FAILED=no WORKDIR=work usage() { echo "Usage: fbsdid.sh [-s script] [-w workdir]" exit 1 } # Allow the user to specify an alternate work directory or script. COMMAND=etcupdate while getopts "s:w:" option; do case $option in s) COMMAND="sh $OPTARG" ;; w) WORKDIR=$OPTARG ;; *) echo usage ;; esac done shift $((OPTIND - 1)) if [ $# -ne 0 ]; then usage fi CONFLICTS=$WORKDIR/conflicts OLD=$WORKDIR/old NEW=$WORKDIR/current TEST=$WORKDIR/test # Store a FreeBSD ID string in a specified file. The first argument # is the file, the remaining arguments are the comment to use. store_id() { local file file=$1 shift echo -n '# $FreeBSD' >> $file echo -n "$@" >> $file echo '$' >> $file } # These tests deal with FreeBSD ID string conflicts. We run the test # twice, once without -F and once with -F. build_trees() { local i rm -rf $OLD $NEW $TEST $CONFLICTS mkdir -p $OLD $NEW $TEST # remove: Remove a file where the only local difference is a # change in the FreeBSD ID string. store_id $OLD/remove store_id $TEST/remove ": head/remove 12345 jhb " # old: Modify a file where the only local difference between # the old and test files is a change in the FreeBSD ID string. store_id $OLD/old ": src/old,v 1.1 jhb Exp " store_id $NEW/old ": head/old 12345 jhb " store_id $TEST/old ": head/old 12000 jhb " for i in $OLD $TEST; do cat >> $i/old <> $NEW/old <> $OLD/already <> $i/already <> $OLD/conflict <> $NEW/conflict <> $TEST/conflict <> $i/local <> $i/local <> $TEST/local <> $i/local-already <> $TEST/local-already <> $i/local-remove < $WORKDIR/test.out cat > $WORKDIR/correct.out < $WORKDIR/testF.out cat > $WORKDIR/correctF.out < $WORKDIR/testAF.out cat > $WORKDIR/correctAF.out <