/src/freebsd/contrib/cvs/src/sanity.sh
Shell | 1901 lines | 1360 code | 228 blank | 313 comment | 104 complexity | 6f832bed8d77cb0f940f92906595fc5d MD5 | raw file
Possible License(s): CC0-1.0, MIT, LGPL-2.0, LGPL-3.0, WTFPL, GPL-2.0, BSD-2-Clause, AGPL-3.0, CC-BY-SA-3.0, MPL-2.0, JSON, BSD-3-Clause-No-Nuclear-License-2014, LGPL-2.1, CPL-1.0, AGPL-1.0, 0BSD, ISC, Apache-2.0, GPL-3.0, IPL-1.0, MPL-2.0-no-copyleft-exception, BSD-3-Clause
- #! /bin/sh
- :
- # sanity.sh -- a growing testsuite for cvs.
- #
- # The copyright notice said: "Copyright (C) 1992, 1993 Cygnus Support"
- # I'm not adding new copyright notices for new years as our recent
- # practice has been to include copying terms without copyright notices.
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2, or (at your option)
- # any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # Original Author: K. Richard Pixley
- # usage:
- usage ()
- {
- echo "Usage: `basename $0` --help"
- echo "Usage: `basename $0` [-eklrv] [-f FROM-TEST] [-h HOSTNAME] CVS-TO-TEST [TESTS-TO-RUN...]"
- }
- exit_usage ()
- {
- usage 1>&2
- exit 2
- }
- exit_help ()
- {
- usage
- echo
- echo "-H|--help Display this text."
- echo "-e|--skipfail Treat tests that would otherwise be nonfatally skipped"
- echo " for reasons like missing tools as failures, exiting"
- echo " with an error message. Also treat warnings as"
- echo " failures."
- echo "-f FROM-TEST Run TESTS-TO-RUN, skipping all tests in the list before"
- echo " FROM-TEST."
- echo "-h HOSTNAME Use :ext:HOSTNAME to run remote tests rather than"
- echo " :fork:. Implies --remote and assumes that \$TESTDIR"
- echo " resolves to the same directory on both the client and"
- echo " the server."
- echo "-k|--keep Try to keep directories created by individual tests"
- echo " around, exiting after the first test which supports"
- echo " --keep."
- echo "-l|--link-root"
- echo " Test CVS using a symlink to a real CVSROOT."
- echo "-r|--remote Test remote instead of local cvs."
- echo "-v|--verbose List test names as they are executed."
- echo
- echo "CVS-TO-TEST The path to the CVS executable to be tested."
- echo "TESTS-TO-RUN The names of the tests to run (defaults to all tests)."
- exit 2
- }
- # See TODO list at end of file.
- # required to make this script work properly.
- unset CVSREAD
- # This will cause malloc to run slower but should also catch some common errors
- # when CVS is linked with glibc 2.x.
- MALLOC_CHECK_=2; export MALLOC_CHECK_
- # We want to invoke a predictable set of i18n behaviors, not whatever
- # the user running this script might have set.
- # In particular:
- # 'sort' and tabs and spaces (LC_COLLATE).
- # Messages from getopt (LC_MESSAGES) (in the future, CVS itself might
- # also alter its messages based on LC_MESSAGES).
- LANG=C
- export LANG
- LC_ALL=C
- export LC_ALL
- #
- # Initialize the test counts.
- #
- passed=0
- skipped=0
- warnings=0
- #
- # read our options
- #
- unset fromtest
- unset remotehost
- keep=false
- linkroot=false
- remote=false
- skipfail=false
- verbose=false
- while getopts ef:h:Hklrv-: option ; do
- # convert the long opts to short opts
- if test x$option = x-; then
- case "$OPTARG" in
- [hH]|[hH][eE]|[hH][eE][lL]|[hH][eE][lL][pP])
- option=H;
- OPTARG=
- ;;
- [kK]|[kK][eE]|[kK][eE][eE]|[kK][eE][eE][pP])
- option=k;
- OPTARG=
- ;;
- l|li|lin|link|link-|link-r]|link-ro|link-roo|link-root)
- option=l;
- OPTARG=
- ;;
- [rR]|[rR][eE]|[rR][eE][mM]|[rR][eE][mM][oO]|[rR][eE][mM][oO][tT]|[rR][eE][mM][oO][tT][eE])
- option=k;
- OPTARG=
- ;;
- s|sk|ski|skip|skipf|skipfa|skipfai|skipfail)
- option=e
- OPTARG=
- ;;
- v|ve|ver|verb|verbo|verbos|verbose)
- option=v
- OPTARG=
- ;;
- *)
- option=\?
- OPTARG=
- esac
- fi
- case "$option" in
- e)
- skipfail=:
- ;;
- f)
- fromtest="$OPTARG"
- ;;
- h)
- # Set a remotehost to run the remote tests on via :ext:
- # Implies `-r' and assumes that $TESTDIR resolves to the same
- # directory on the client and the server.
- remotehost="$OPTARG"
- remote=:
- ;;
- H)
- exit_help
- ;;
- k)
- # The -k (keep) option will eventually cause all the tests to
- # leave around the contents of the /tmp directory; right now only
- # some implement it. Not originally intended to be useful with
- # more than one test, but this should work if each test uses a
- # uniquely named dir (use the name of the test).
- keep=:
- ;;
- l)
- linkroot=:
- ;;
- r)
- remote=:
- ;;
- v)
- verbose=:
- ;;
- \?)
- exit_usage
- ;;
- esac
- done
- # boot the arguments we used above
- while test $OPTIND -gt 1 ; do
- shift
- OPTIND=`expr $OPTIND - 1`
- done
- # Use full path for CVS executable, so that CVS_SERVER gets set properly
- # for remote.
- case $1 in
- "")
- exit_usage
- ;;
- /*)
- testcvs=$1
- ;;
- *)
- testcvs=`pwd`/$1
- ;;
- esac
- shift
- # If $remotehost is set, warn if $TESTDIR isn't since we are pretty sure
- # that its default value of `/tmp/cvs-sanity' will not resolve to the same
- # directory on two different machines.
- if test -n "$remotehost" && test -z "$TESTDIR"; then
- echo "WARNING: CVS server hostname is set and \$TESTDIR is not. If" >&2
- echo "$remotehost is not the local machine, then it is unlikely that" >&2
- echo "the default value assigned to \$TESTDIR will resolve to the same" >&2
- echo "directory on both this client and the CVS server." >&2
- fi
- ###
- ### GUTS
- ###
- # "debugger"
- #set -x
- echo 'This test should produce no other output than this message, and a final "OK".'
- echo '(Note that the test can take an hour or more to run and periodically stops'
- echo 'for as long as one minute. Do not assume there is a problem just because'
- echo 'nothing seems to happen for a long time. If you cannot live without'
- echo 'running status, use the -v option or try the command:'
- echo "\`tail -f check.log' from another window.)"
- # Regexp to match what CVS will call itself in output that it prints.
- # FIXME: we don't properly quote this--if the name contains . we'll
- # just spuriously match a few things; if the name contains other regexp
- # special characters we are probably in big trouble.
- PROG=`basename ${testcvs}`
- # Match the hostname
- hostname="[-_.a-zA-Z0-9]*"
- # Regexp to match the name of a temporary file (from cvs_temp_name).
- # This appears in certain diff output.
- tempname="[-a-zA-Z0-9/.%_]*"
- # Regexp to match a date in RFC822 format (as amended by RFC1123).
- RFCDATE="[a-zA-Z0-9 ][a-zA-Z0-9 ]* [0-9:][0-9:]* -0000"
- RFCDATE_EPOCH="1 Jan 1970 00:00:00 -0000"
- # Regexp to match a date in standard Unix format as used by rdiff
- # FIXCVS: There's no reason for rdiff to use a different date format
- # than diff does
- DATE="[a-zA-Z]* [a-zA-Z]* [ 1-3][0-9] [0-9:]* [0-9]*"
- # Which directories should Which and find_tool search for executables?
- SEARCHPATH=$PATH:/usr/local/bin:/usr/contrib/bin:/usr/contrib:/usr/gnu/bin:/local/bin:/local/gnu/bin:/gnu/bin:/sw/bin:/usr/pkg/bin
- # Do not assume that `type -p cmd` is portable
- # Usage: Which [-a] [-x|-f|-r] prog [$SEARCHPATH:/with/directories:/to/search]
- Which() {
- # Optional first argument for file type, defaults to -x.
- # Second argument is the file or directory to be found.
- # Third argument is the PATH to search.
- # By default, print only the first file that matches,
- # -a will cause all matches to be printed.
- notevery=:
- if [ "x$1" = "x-a" ]; then notevery=false; shift; fi
- case "$1" in
- -*) t=$1; shift ;;
- *) t=-x ;;
- esac
- case "$1" in
- # FIXME: Someday this may need to be fixed
- # to deal better with C:\some\path\to\ssh values...
- /*) test $t $1 && echo $1 ;;
- *) for d in `IFS=:; echo ${2-$SEARCHPATH}`
- do
- test $t $d/$1 && { echo $d/$1; if $notevery; then break; fi; }
- done
- ;;
- esac
- }
- # On cygwin32, we may not have /bin/sh.
- if test -r /bin/sh; then
- TESTSHELL="/bin/sh"
- else
- TESTSHELL=`Which -f sh`
- if test ! -r "$TESTSHELL"; then
- TESTSHELL="/bin/sh"
- fi
- fi
- # FIXME: try things (what things? checkins?) without -m.
- #
- # Some of these tests are written to expect -Q. But testing with
- # -Q is kind of bogus, it is not the way users actually use CVS (usually).
- # So new tests probably should invoke ${testcvs} directly, rather than ${CVS}.
- # and then they've obviously got to do something with the output....
- #
- CVS="${testcvs} -Q"
- LOGFILE=`pwd`/check.log
- # Save the previous log in case the person running the tests decides
- # they want to look at it. The extension ".plog" is chosen for consistency
- # with dejagnu.
- if test -f check.log; then
- mv check.log check.plog
- fi
- # Create the log file so check.log can be tailed almost immediately after
- # this script is started. Otherwise it can take up to a minute or two before
- # the log file gets created when $remotehost is specified on some systems,
- # which makes for a lot of failed `tail -f' attempts.
- touch check.log
- # Workaround any X11Forwarding by ssh. Otherwise this text:
- # Warning: No xauth data; using fake authentication data for X11 forwarding.
- # has been known to end up in the test results below
- # causing the test to fail.
- [ -n "$DISPLAY" ] && unset DISPLAY
-
- # The default value of /tmp/cvs-sanity for TESTDIR is dubious,
- # because it loses if two people/scripts try to run the tests
- # at the same time. Some possible solutions:
- # 1. Use /tmp/cvs-test$$. One disadvantage is that the old
- # cvs-test* directories would pile up, because they wouldn't
- # necessarily get removed.
- # 2. Have everyone/everything running the testsuite set
- # TESTDIR to some appropriate directory.
- # 3. Have the default value of TESTDIR be some variation of
- # `pwd`/cvs-sanity. The biggest problem here is that we have
- # been fairly careful to test that CVS prints in messages the
- # actual pathnames that we pass to it, rather than a different
- # pathname for the same directory, as may come out of `pwd`.
- # So this would be lost if everything was `pwd`-based. I suppose
- # if we wanted to get baroque we could start making symlinks
- # to ensure the two are different.
- : ${CVS_RSH=rsh}; export CVS_RSH
- if test -n "$remotehost"; then
- # We need to set $tmp on the server since $TMPDIR is compared against
- # messages generated by the server.
- tmp=`$CVS_RSH $remotehost 'cd /tmp; /bin/pwd || pwd' 2>/dev/null`
- if test $? != 0; then
- echo "$CVS_RSH $remotehost failed." >&2
- exit 1
- fi
- else
- tmp=`(cd /tmp; /bin/pwd || pwd) 2>/dev/null`
- fi
- # Now:
- # 1) Set TESTDIR if it's not set already
- # 2) Remove any old test remnants
- # 3) Create $TESTDIR
- # 4) Normalize TESTDIR with `cd && (/bin/pwd || pwd)`
- # (This will match CVS output later)
- : ${TESTDIR=$tmp/cvs-sanity}
- # clean any old remnants (we need the chmod because some tests make
- # directories read-only)
- if test -d ${TESTDIR}; then
- chmod -R a+wx ${TESTDIR}
- rm -rf ${TESTDIR}
- fi
- # These exits are important. The first time I tried this, if the `mkdir && cd`
- # failed then the build directory would get blown away. Some people probably
- # wouldn't appreciate that.
- mkdir ${TESTDIR} || exit 1
- cd ${TESTDIR} || exit 1
- # Ensure $TESTDIR is absolute
- if echo "${TESTDIR}" |grep '^[^/]'; then
- # Don't resolve this unless we have to. This keeps symlinks intact. This
- # is important at least when testing using -h $remotehost, because the same
- # value for $TESTDIR must resolve to the same directory on the client and
- # the server and we likely used Samba, and possibly symlinks, to do this.
- TESTDIR=`(/bin/pwd || pwd) 2>/dev/null`
- fi
- if test -z "${TESTDIR}" || echo "${TESTDIR}" |grep '^[^/]'; then
- echo "Unable to resolve TESTDIR to an absolute directory." >&2
- exit 1
- fi
- cd ${TESTDIR}
- # Now set $TMPDIR if the user hasn't overridden it.
- #
- # We use a $TMPDIR under $TESTDIR by default so that two tests may be run at
- # the same time without bumping heads without requiring the user to specify
- # more than $TESTDIR. See the test for leftover cvs-serv* directories near the
- # end of this script at the end of "The big loop".
- : ${TMPDIR=$TESTDIR/tmp}
- export TMPDIR
- if test -d $TMPDIR; then :; else
- mkdir $TMPDIR
- fi
- # Make sure various tools work the way we expect, or try to find
- # versions that do.
- : ${AWK=awk}
- : ${EXPR=expr}
- : ${ID=id}
- : ${TR=tr}
- # Keep track of tools that are found, but do NOT work as we hope
- # in order to avoid them in future
- badtools=
- set_bad_tool ()
- {
- badtools=$badtools:$1
- }
- is_bad_tool ()
- {
- case ":$badtools:" in *:$1:*) return 0 ;; *) return 1 ; esac
- }
- version_test ()
- {
- vercmd=$1
- verbad=:
- if RES=`$vercmd --version </dev/null 2>&1`; then
- if test "X$RES" != "X--version" && test "X$RES" != "X" ; then
- echo "$RES"
- verbad=false
- fi
- fi
- if $verbad; then
- echo "The command \`$vercmd' does not support the --version option."
- fi
- # It does not really matter that --version is not supported
- return 0
- }
- # Try to find a tool that satisfies all of the tests.
- # Usage: list:of:colon:separated:alternatives test1 test2 test3 test4...
- # Example: find_tool awk:gawk:nawk awk_tooltest1 awk_tooltest2
- find_tool ()
- {
- default_TOOL=$1
- echo find_tool: ${1+"$@"} >>$LOGFILE
- cmds="`IFS=:; echo $1`"; shift; tooltests="${1+$@}"
- if test -z "$tooltests"; then tooltests=version_test; fi
- clist=; for cmd in $cmds; do clist="$clist `Which -a $cmd`"; done
- # Make sure the default tool is just the first real command name
- for default_TOOL in $clist `IFS=:; echo $default_TOOL`; do break; done
- TOOL=""
- for trytool in $clist ; do
- pass=:
- for tooltest in $tooltests; do
- result=`eval $tooltest $trytool`
- rc=$?
- echo "Running $tooltest $trytool" >>$LOGFILE
- if test -n "$result"; then
- echo "$result" >>$LOGFILE
- fi
- if test "$rc" = "0"; then
- echo "PASS: $tooltest $trytool" >>$LOGFILE
- elif test "$rc" = "77"; then
- echo "MARGINAL: $tooltest $trytool; rc=$rc" >>$LOGFILE
- TOOL=$trytool
- pass=false
- else
- set_bad_tool $trytool
- echo "FAIL: $tooltest $trytool; rc=$rc" >>$LOGFILE
- pass=false
- fi
- done
- if $pass; then
- echo $trytool
- return 0
- fi
- done
- if test -n "$TOOL"; then
- echo "Notice: The default version of \`$default_TOOL' is defective." >>$LOGFILE
- echo "using \`$TOOL' and hoping for the best." >>$LOGFILE
- echo "Notice: The default version of \`$default_TOOL' is defective." >&2
- echo "using \`$TOOL' and hoping for the best." >&2
- echo $TOOL
- else
- echo $default_TOOL
- fi
- }
- id_tool_test ()
- {
- id=$1
- if $id -u >/dev/null 2>&1 && $id -un >/dev/null 2>&1; then
- return 0
- else
- echo "Running these tests requires an \`id' program that understands the"
- echo "-u and -n flags. Make sure that such an id (GNU, or many but not"
- echo "all vendor-supplied versions) is in your path."
- return 1
- fi
- }
- ID=`find_tool id version_test id_tool_test`
- echo "Using ID=$ID" >>$LOGFILE
- # You can't run CVS as root; print a nice error message here instead
- # of somewhere later, after making a mess.
- for pass in false :; do
- case "`$ID -u 2>/dev/null`" in
- "0")
- echo "Test suite does not work correctly when run as root" >&2
- exit 1
- ;;
- *)
- break
- ;;
- esac
- done
- # Cause NextStep 3.3 users to lose in a more graceful fashion.
- expr_tooltest1 ()
- {
- expr=$1
- if $expr 'abc
- def' : 'abc
- def' >/dev/null; then
- # good, it works
- return 0
- else
- echo 'Running these tests requires an "expr" program that can handle'
- echo 'multi-line patterns. Make sure that such an expr (GNU, or many but'
- echo 'not all vendor-supplied versions) is in your path.'
- return 1
- fi
- }
- # Warn SunOS, SysVr3.2, etc., users that they may be partially losing
- # if we can't find a GNU expr to ease their troubles...
- expr_tooltest2 ()
- {
- expr=$1
- if $expr 'a
- b' : 'a
- c' >/dev/null; then
- echo 'WARNING: you are using a version of expr that does not correctly'
- echo 'match multi-line patterns. Some tests may spuriously pass or fail.'
- echo 'You may wish to make sure GNU expr is in your path.'
- return 1
- else
- return 0
- fi
- }
- expr_create_bar ()
- {
- echo 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' >${TESTDIR}/foo
- cat ${TESTDIR}/foo ${TESTDIR}/foo ${TESTDIR}/foo ${TESTDIR}/foo >${TESTDIR}/bar
- cat ${TESTDIR}/bar ${TESTDIR}/bar ${TESTDIR}/bar ${TESTDIR}/bar >${TESTDIR}/foo
- cat ${TESTDIR}/foo ${TESTDIR}/foo ${TESTDIR}/foo ${TESTDIR}/foo >${TESTDIR}/bar
- rm -f ${TESTDIR}/foo
- }
- expr_tooltest3 ()
- {
- expr=$1
- # More SunOS lossage...
- test ! -f ${TESTDIR}/bar && expr_create_bar
- if $expr "`cat ${TESTDIR}/bar`" : "`cat ${TESTDIR}/bar`" >/dev/null; then
- : good, it works
- else
- echo 'WARNING: you are using a version of expr that does not correctly'
- echo 'match large patterns. Some tests may spuriously pass or fail.'
- echo 'You may wish to make sure GNU expr is in your path.'
- return 1
- fi
- if $expr "`cat ${TESTDIR}/bar`x" : "`cat ${TESTDIR}/bar`y" >/dev/null; then
- echo 'WARNING: you are using a version of expr that does not correctly'
- echo 'match large patterns. Some tests may spuriously pass or fail.'
- echo 'You may wish to make sure GNU expr is in your path.'
- return 1
- fi
- # good, it works
- return 0
- }
- # That we should have to do this is total bogosity, but GNU expr
- # version 1.9.4-1.12 uses the emacs definition of "$" instead of the unix
- # (e.g. SunOS 4.1.3 expr) one. Rumor has it this will be fixed in the
- # next release of GNU expr after 1.12 (but we still have to cater to the old
- # ones for some time because they are in many linux distributions).
- ENDANCHOR="$"
- expr_set_ENDANCHOR ()
- {
- expr=$1
- ENDANCHOR="$"
- if $expr 'abc
- def' : 'abc$' >/dev/null; then
- ENDANCHOR='\'\'
- echo "Notice: An ENDANCHOR of dollar does not work."
- echo "Using a workaround for GNU expr versions 1.9.4 thru 1.12"
- fi
- return 0
- }
- # Work around another GNU expr (version 1.10-1.12) bug/incompatibility.
- # "." doesn't appear to match a newline (it does with SunOS 4.1.3 expr).
- # Note that the workaround is not a complete equivalent of .* because
- # the first parenthesized expression in the regexp must match something
- # in order for expr to return a successful exit status.
- # Rumor has it this will be fixed in the
- # next release of GNU expr after 1.12 (but we still have to cater to the old
- # ones for some time because they are in many linux distributions).
- DOTSTAR='.*'
- expr_set_DOTSTAR ()
- {
- expr=$1
- DOTSTAR='.*'
- if $expr 'abc
- def' : "a${DOTSTAR}f" >/dev/null; then
- : good, it works
- else
- DOTSTAR='\(.\|
- \)*'
- echo "Notice: DOTSTAR changed from sane \`.*' value to \`$DOTSTAR\`"
- echo "to workaround GNU expr version 1.10 thru 1.12 bug where \`.'"
- echo "does not match a newline."
- fi
- return 0
- }
- # Now that we have DOTSTAR, make sure it works with big matches
- expr_tooltest_DOTSTAR ()
- {
- expr=$1
- test ! -f ${TESTDIR}/bar && expr_create_bar
- if $expr "`cat ${TESTDIR}/bar`" : "${DOTSTAR}xyzABC${DOTSTAR}$" >/dev/null; then
- # good, it works
- return 0
- else
- echo 'WARNING: you are using a version of expr that does not correctly'
- echo 'match large patterns. Some tests may spuriously pass or fail.'
- echo 'You may wish to make sure GNU expr is in your path.'
- return 77
- fi
- }
- # FreeBSD 5.2 and 6.1 support 'expr [-e] expression'
- # They get confused unless '--' is used before the expressions
- # when those expressions begin with a '-' character, such as the
- # output of an ls -l command. The EXPR_COMPAT environment variable may
- # be used to go back to the non-POSIX behavior as an alternative.
- # (GNU expr appears to accept the '--' argument and work correctly or
- # not have it and still get the results we want.)
- exprDASHDASH='false'
- expr_set_DASHDASH ()
- {
- expr=$1
- exprDASHDASH='false'
- # Not POSIX, but works on a lot of expr versions.
- if $expr "-rw-rw-r--" : "-rw-rw-r--" >/dev/null 2>&1; then
- # good, it works
- return 0
- else
- # Do things in the POSIX manner.
- if $expr -- "-rw-rw-r--" : "-rw-rw-r--" >/dev/null 2>&1; then
- exprDASHDASH=':'
- return 0
- else
- echo 'WARNING: Your $expr does not correctly handle'
- echo 'leading "-" characters in regular expressions to'
- echo 'be matched. You may wish to see if there is an'
- echo 'environment variable or other setting to allow'
- echo 'POSIX functionality to be enabled.'
- return 77
- fi
- fi
- }
- EXPR=`find_tool ${EXPR}:gexpr \
- version_test expr_tooltest1 expr_tooltest2 expr_tooltest3 \
- expr_set_ENDANCHOR expr_set_DOTSTAR expr_tooltest_DOTSTAR`
- # Set the ENDANCHOR and DOTSTAR for the chosen expr version.
- expr_set_ENDANCHOR ${EXPR} >/dev/null
- expr_tooltest_DOTSTAR ${EXPR} >/dev/null
- # Is $EXPR a POSIX or non-POSIX implementation
- # with regard to command-line arguments?
- expr_set_DASHDASH ${EXPR}
- $exprDASHDASH && EXPR="$EXPR --"
- echo "Using EXPR=$EXPR" >>$LOGFILE
- echo "Using ENDANCHOR=$ENDANCHOR" >>$LOGFILE
- echo "Using DOTSTAR=$DOTSTAR" >>$LOGFILE
- # Cleanup
- rm -f ${TESTDIR}/bar
- # Work around yet another GNU expr (version 1.10) bug/incompatibility.
- # "+" is a special character, yet for unix expr (e.g. SunOS 4.1.3)
- # it is not. I doubt that POSIX allows us to use \+ and assume it means
- # (non-special) +, so here is another workaround
- # Rumor has it this will be fixed in the
- # next release of GNU expr after 1.12 (but we still have to cater to the old
- # ones for some time because they are in many linux distributions).
- PLUS='+'
- if $EXPR 'a +b' : "a ${PLUS}b" >/dev/null; then
- : good, it works
- else
- PLUS='\+'
- fi
- # Likewise, for ?
- QUESTION='?'
- if $EXPR 'a?b' : "a${QUESTION}b" >/dev/null; then
- : good, it works
- else
- QUESTION='\?'
- fi
- # Now test the username to make sure it contains only valid characters
- username=`$ID -un`
- if $EXPR "${username}" : "${username}" >/dev/null; then
- : good, it works
- else
- echo "Test suite does not work correctly when run by a username" >&2
- echo "containing regular expression meta-characters." >&2
- exit 1
- fi
- # Only 8 characters of $username appear in some output.
- if test `echo $username |wc -c` -gt 8; then
- username8=`echo $username |sed 's/^\(........\).*/\1/'`
- else
- username8=$username
- fi
- # Rarely, we need to match any username, not just the name of the user
- # running this test.
- #
- # I'm not really sure what characters should be here. a-zA-Z obviously.
- # People complained when 0-9 were not allowed in usernames. Other than that
- # I'm not sure.
- anyusername="[-a-zA-Z0-9][-a-zA-Z0-9]*"
- # now make sure that tr works on NULs
- tr_tooltest1 ()
- {
- tr=$1
- if $EXPR `echo "123" | $tr '2' '\0'` : "123" >/dev/null 2>&1; then
- echo 'Warning: you are using a version of tr which does not correctly'
- echo 'handle NUL bytes. Some tests may spuriously pass or fail.'
- echo 'You may wish to make sure GNU tr is in your path.'
- return 77
- fi
- # good, it works
- return 0
- }
- TR=`find_tool ${TR}:gtr version_test tr_tooltest1`
- echo "Using TR=$TR" >>$LOGFILE
- # Awk testing
- awk_tooltest1 ()
- {
- awk=$1
- $awk 'BEGIN {printf("one\ntwo\nthree\nfour\nfive\nsix")}' </dev/null >abc
- if $EXPR "`cat abc`" : \
- 'one
- two
- three
- four
- five
- six'; then
- rm abc
- return 0
- else
- rm abc
- echo "Notice: awk BEGIN clause or printf is not be working properly."
- return 1
- fi
- }
- # Format item %c check
- awk_tooltest2 ()
- {
- awk=$1
- $awk 'BEGIN { printf "%c%c%c", 2, 3, 4 }' </dev/null \
- | ${TR} '\002\003\004' '123' >abc
- if $EXPR "`cat abc`" : "123" ; then
- : good, found it
- else
- echo "Notice: awk format %c string may not be working properly."
- rm abc
- return 77
- fi
- rm abc
- return 0
- }
- AWK=`find_tool gawk:nawk:awk version_test awk_tooltest1 awk_tooltest2`
- echo "Using AWK=$AWK" >>$LOGFILE
- # Test that $1 works as a remote shell. If so, set $host, $CVS_RSH, &
- # $save_CVS_RSH to match and return 0. Otherwise, set $skipreason and return
- # 77.
- depends_on_rsh ()
- {
- host=${remotehost-"`hostname`"}
- result=`$1 $host 'echo test'`
- rc=$?
- if test $? != 0 || test "x$result" != "xtest"; then
- skipreason="\`$1 $host' failed rc=$rc result=$result"
- return 77
- fi
- save_CVS_RSH=$CVS_RSH
- CVS_RSH=$1; export CVS_RSH
- return 0
- }
- # Find a usable SSH. When a usable ssh is found, set $host, $CVS_RSH, and
- # $save_CVS_RSH and return 0. Otherwise, set $skipreason and return 77.
- depends_on_ssh ()
- {
- case "$CVS_RSH" in
- *ssh*|*putty*)
- tryssh=`Which $CVS_RSH`
- if [ ! -n "$tryssh" ]; then
- skipreason="Unable to find CVS_RSH=$CVS_RSH executable"
- return 77
- elif [ ! -x "$tryssh" ]; then
- skipreason="Unable to execute $tryssh program"
- return 77
- fi
- ;;
- *)
- # Look in the user's PATH for "ssh"
- tryssh=`Which ssh`
- if test ! -r "$tryssh"; then
- skipreason="Unable to find ssh program"
- return 77
- fi
- ;;
- esac
- depends_on_rsh "$tryssh"
- return $?
- }
- pass ()
- {
- echo "PASS: $1" >>${LOGFILE}
- passed=`expr $passed + 1`
- }
- # Like skip(), but don't fail when $skipfail is set.
- skip_always ()
- {
- echo "SKIP: $1${2+ ($2)}" >>$LOGFILE
- skipped=`expr $skipped + 1`
- }
- skip ()
- {
- if $skipfail; then
- fail "$1${2+ ($2)}"
- else
- echo "SKIP: $1${2+ ($2)}" >>$LOGFILE
- fi
- skipped=`expr $skipped + 1`
- }
- warn ()
- {
- if $skipfail; then
- fail "$1${2+ ($2)}"
- else
- echo "WARNING: $1${2+ ($2)}" >>$LOGFILE
- fi
- warnings=`expr $warnings + 1`
- }
- # Convenience function for skipping tests run only in local mode.
- localonly ()
- {
- skip_always $1 "only tested in local mode"
- }
- fail ()
- {
- echo "FAIL: $1" | tee -a ${LOGFILE}
- echo "*** Please see the \`TESTS' and \`check.log' files for more information." >&2
- # This way the tester can go and see what remnants were left
- exit 1
- }
- verify_tmp_empty ()
- {
- # Test our temp directory for cvs-serv* directories and cvsXXXXXX temp
- # files. We would like to not leave any behind.
- if $remote && ls $TMPDIR/cvs-serv* >/dev/null 2>&1; then
- # A true value means ls found files/directories with these names.
- # Give the server some time to finish, then retry.
- sleep 1
- if ls $TMPDIR/cvs-serv* >/dev/null 2>&1; then
- warn "$1" "Found cvs-serv* directories in $TMPDIR."
- # The above will exit if $skipfail
- rm -rf $TMPDIR/cvs-serv*
- fi
- fi
- if ls $TMPDIR/cvs?????? >/dev/null 2>&1; then
- # A true value means ls found files/directories with these names.
- warn "$1" "Found cvsXXXXXX temp files in $TMPDIR."
- # The above will exit if $skipfail
- rm -f ls $TMPDIR/cvs??????
- fi
- }
- # Restore changes to CVSROOT admin files.
- restore_adm ()
- {
- rm -rf $CVSROOT_DIRNAME/CVSROOT
- cp -Rp $TESTDIR/CVSROOT.save $CVSROOT_DIRNAME/CVSROOT
- }
- # See dotest and dotest_fail for explanation (this is the parts
- # of the implementation common to the two).
- dotest_internal ()
- {
- if $EXPR "`cat ${TESTDIR}/dotest.tmp`" : "$3${ENDANCHOR}" >/dev/null; then
- # Why, I hear you ask, do we write this to the logfile
- # even when the test passes? The reason is that the test
- # may give us the regexp which we were supposed to match,
- # but sometimes it may be useful to look at the exact
- # text which was output. For example, suppose one wants
- # to grep for a particular warning, and make _sure_ that
- # CVS never hits it (even in cases where the tests might
- # match it with .*). Or suppose one wants to see the exact
- # date format output in a certain case (where the test will
- # surely use a somewhat non-specific pattern).
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- pass "$1"
- verify_tmp_empty "$1"
- # expr can't distinguish between "zero characters matched" and "no match",
- # so special-case it.
- elif test -z "$3" && test ! -s ${TESTDIR}/dotest.tmp; then
- pass "$1"
- verify_tmp_empty "$1"
- elif test x"$4" != x; then
- if $EXPR "`cat ${TESTDIR}/dotest.tmp`" : "$4${ENDANCHOR}" >/dev/null; then
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- pass "$1"
- verify_tmp_empty "$1"
- else
- echo "** expected: " >>${LOGFILE}
- echo "$3" >>${LOGFILE}
- echo "$3" > ${TESTDIR}/dotest.ex1
- echo "** or: " >>${LOGFILE}
- echo "$4" >>${LOGFILE}
- echo "$4" > ${TESTDIR}/dotest.ex2
- echo "** got: " >>${LOGFILE}
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- fail "$1"
- fi
- else
- echo "** expected: " >>${LOGFILE}
- echo "$3" >>${LOGFILE}
- echo "$3" > ${TESTDIR}/dotest.exp
- echo "** got: " >>${LOGFILE}
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- fail "$1"
- fi
- }
- dotest_all_in_one ()
- {
- if $EXPR "`cat ${TESTDIR}/dotest.tmp`" : \
- "`cat ${TESTDIR}/dotest.exp`" >/dev/null; then
- return 0
- fi
- return 1
- }
- # WARNING: this won't work with REs that match newlines....
- #
- dotest_line_by_line ()
- {
- line=1
- while [ $line -le `wc -l <${TESTDIR}/dotest.tmp` ] ; do
- if $EXPR "`sed -n ${line}p ${TESTDIR}/dotest.tmp`" : \
- "`sed -n ${line}p ${TESTDIR}/dotest.exp`" >/dev/null; then
- :
- elif test -z "`sed -n ${line}p ${TESTDIR}/dotest.tmp`" &&
- test -z "`sed -n ${line}p ${TESTDIR}/dotest.exp`"; then
- :
- else
- echo "Line $line:" >> ${LOGFILE}
- echo "**** expected: " >>${LOGFILE}
- sed -n ${line}p ${TESTDIR}/dotest.exp >>${LOGFILE}
- echo "**** got: " >>${LOGFILE}
- sed -n ${line}p ${TESTDIR}/dotest.tmp >>${LOGFILE}
- unset line
- return 1
- fi
- line=`expr $line + 1`
- done
- unset line
- return 0
- }
- # If you are having trouble telling which line of a multi-line
- # expression is not being matched, replace calls to dotest_internal()
- # with calls to this function:
- #
- dotest_internal_debug ()
- {
- if test -z "$3"; then
- if test -s ${TESTDIR}/dotest.tmp; then
- echo "** expected: " >>${LOGFILE}
- echo "$3" >>${LOGFILE}
- echo "$3" > ${TESTDIR}/dotest.exp
- rm -f ${TESTDIR}/dotest.ex2
- echo "** got: " >>${LOGFILE}
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- fail "$1"
- else
- pass "$1"
- verify_tmp_empty "$1"
- fi
- else
- echo "$3" > ${TESTDIR}/dotest.exp
- if dotest_line_by_line "$1" "$2"; then
- pass "$1"
- verify_tmp_empty "$1"
- else
- if test x"$4" != x; then
- mv ${TESTDIR}/dotest.exp ${TESTDIR}/dotest.ex1
- echo "$4" > ${TESTDIR}/dotest.exp
- if dotest_line_by_line "$1" "$2"; then
- pass "$1"
- verify_tmp_empty "$1"
- else
- mv ${TESTDIR}/dotest.exp ${TESTDIR}/dotest.ex2
- echo "** expected: " >>${LOGFILE}
- echo "$3" >>${LOGFILE}
- echo "** or: " >>${LOGFILE}
- echo "$4" >>${LOGFILE}
- echo "** got: " >>${LOGFILE}
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- fail "$1"
- fi
- else
- echo "** expected: " >>${LOGFILE}
- echo "$3" >>${LOGFILE}
- echo "** got: " >>${LOGFILE}
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- fail "$1"
- fi
- fi
- fi
- }
- # Usage:
- # dotest TESTNAME COMMAND OUTPUT [OUTPUT2]
- # TESTNAME is the name used in the log to identify the test.
- # COMMAND is the command to run; for the test to pass, it exits with
- # exitstatus zero.
- # OUTPUT is a regexp which is compared against the output (stdout and
- # stderr combined) from the test. It is anchored to the start and end
- # of the output, so should start or end with ".*" if that is what is desired.
- # Trailing newlines are stripped from the command's actual output before
- # matching against OUTPUT.
- # If OUTPUT2 is specified and the output matches it, then it is also
- # a pass (partial workaround for the fact that some versions of expr
- # lack \|).
- dotest ()
- {
- rm -f ${TESTDIR}/dotest.ex? 2>&1
- eval "$2" >${TESTDIR}/dotest.tmp 2>&1
- status=$?
- if test "$status" != 0; then
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- echo "exit status was $status" >>${LOGFILE}
- fail "$1"
- fi
- dotest_internal "$@"
- }
- # Like dotest except only 2 args and result must exactly match stdin
- dotest_lit ()
- {
- rm -f ${TESTDIR}/dotest.ex? 2>&1
- eval "$2" >${TESTDIR}/dotest.tmp 2>&1
- status=$?
- if test "$status" != 0; then
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- echo "exit status was $status" >>${LOGFILE}
- fail "$1"
- fi
- cat >${TESTDIR}/dotest.exp
- if cmp ${TESTDIR}/dotest.exp ${TESTDIR}/dotest.tmp >/dev/null 2>&1; then
- pass "$1"
- verify_tmp_empty "$1"
- else
- echo "** expected: " >>${LOGFILE}
- cat ${TESTDIR}/dotest.exp >>${LOGFILE}
- echo "** got: " >>${LOGFILE}
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- fail "$1"
- fi
- }
- # Like dotest except exitstatus should be nonzero.
- dotest_fail ()
- {
- rm -f ${TESTDIR}/dotest.ex? 2>&1
- eval "$2" >${TESTDIR}/dotest.tmp 2>&1
- status=$?
- if test "$status" = 0; then
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
- echo "exit status was $status" >>${LOGFILE}
- fail "$1"
- fi
- dotest_internal "$@"
- }
- # Like dotest except output is sorted.
- dotest_sort ()
- {
- rm -f ${TESTDIR}/dotest.ex? 2>&1
- eval "$2" >${TESTDIR}/dotest.tmp1 2>&1
- status=$?
- if test "$status" != 0; then
- cat ${TESTDIR}/dotest.tmp1 >>${LOGFILE}
- echo "exit status was $status" >>${LOGFILE}
- fail "$1"
- fi
- ${TR} ' ' ' ' < ${TESTDIR}/dotest.tmp1 | sort > ${TESTDIR}/dotest.tmp
- dotest_internal "$@"
- }
- # A function for fetching the timestamp of a revison of a file
- getrlogdate () {
- ${testcvs} -n rlog -N ${1+"$@"} |
- while read token value; do
- case "$token" in
- date:)
- echo $value | sed "s,;.*,,"
- break;
- ;;
- esac
- done
- }
- # Avoid picking up any stray .cvsrc, etc., from the user running the tests
- mkdir home
- HOME=${TESTDIR}/home; export HOME
- # Make sure this variable is not defined to anything that would
- # change the format of rcs dates. Otherwise people using e.g.,
- # RCSINIT=-zLT get lots of spurious failures.
- RCSINIT=; export RCSINIT
- # Remaining arguments are the names of tests to run.
- #
- # The testsuite is broken up into (hopefully manageably-sized)
- # independently runnable tests, so that one can quickly get a result
- # from a cvs or testsuite change, and to facilitate understanding the
- # tests.
- if test x"$*" = x; then
- # Basic/miscellaneous functionality
- tests="version basica basicb basicc basic1 deep basic2"
- tests="${tests} parseroot parseroot2 files spacefiles commit-readonly"
- tests="${tests} commit-add-missing"
- tests="$tests add-restricted"
- tests="${tests} status"
- # Branching, tagging, removing, adding, multiple directories
- tests="${tests} rdiff rdiff-short"
- tests="${tests} rdiff2 diff diffnl death death2 death-rtag"
- tests="${tests} rm-update-message rmadd rmadd2 rmadd3 resurrection"
- tests="${tests} dirs dirs2 branches branches2 tagc tagf "
- tests="${tests} tag-log tag-space"
- tests="${tests} rcslib multibranch import importb importc import-CVS"
- tests="$tests import-quirks"
- tests="${tests} update-p import-after-initial branch-after-import"
- tests="${tests} join join2 join3 join4 join5 join6 join7 join8 join9"
- tests="${tests} join-readonly-conflict join-admin join-admin-2"
- tests="${tests} join-rm"
- tests="${tests} new newb conflicts conflicts2 conflicts3 conflicts4"
- tests="${tests} clean"
- # Checking out various places (modules, checkout -d, &c)
- tests="${tests} modules modules2 modules3 modules4 modules5 modules6"
- tests="${tests} modules7 mkmodules co-d"
- tests="${tests} cvsadm emptydir abspath abspath2 toplevel toplevel2"
- tests="${tests} rstar-toplevel trailingslashes checkout_repository"
- # Log messages, error messages.
- tests="${tests} mflag editor errmsg1 errmsg2 adderrmsg opterrmsg"
- # Watches, binary files, history browsing, &c.
- tests="${tests} devcom devcom2 devcom3 watch4 watch5 watch6"
- tests="${tests} unedit-without-baserev"
- tests="${tests} ignore ignore-on-branch binfiles binfiles2 binfiles3"
- tests="${tests} mcopy binwrap binwrap2"
- tests="${tests} binwrap3 mwrap info taginfo config"
- tests="${tests} serverpatch log log2 logopt ann ann-id"
- # Repository Storage (RCS file format, CVS lock files, creating
- # a repository without "cvs init", &c).
- tests="${tests} crerepos crerepos-extssh rcs rcs2 rcs3 rcs4 rcs5 rcs6"
- tests="$tests lockfiles backuprecover"
- tests="${tests} sshstdio"
- # More history browsing, &c.
- tests="${tests} history"
- tests="${tests} big modes modes2 modes3 stamps"
- # PreservePermissions stuff: permissions, symlinks et al.
- # tests="${tests} perms symlinks symlinks2 hardlinks"
- # More tag and branch tests, keywords.
- tests="${tests} sticky keyword keywordlog keywordname keyword2"
- tests="${tests} head tagdate multibranch2 tag8k"
- # "cvs admin", reserved checkouts.
- tests="${tests} admin reserved"
- # Nuts and bolts of diffing/merging (diff library, &c)
- tests="${tests} diffmerge1 diffmerge2"
- # Release of multiple directories
- tests="${tests} release"
- tests="${tests} recase"
- # Multiple root directories and low-level protocol tests.
- tests="${tests} multiroot multiroot2 multiroot3 multiroot4"
- tests="$tests rmroot reposmv pserver server server2 server3"
- tests="$tests client client2"
- tests="${tests} dottedroot fork commit-d"
- else
- tests="$*"
- fi
- # Now check the -f argument for validity.
- if test -n "$fromtest"; then
- # Don't allow spaces - they are our delimiters in tests
- count=0
- for sub in $fromtest; do
- count=`expr $count + 1`
- done
- if test $count != 1; then
- echo "No such test \`$fromtest'." >&2
- exit 2
- fi
- # make sure it is in $tests
- case " $tests " in
- *" $fromtest "*)
- ;;
- *)
- echo "No such test \`$fromtest'." >&2
- exit 2
- ;;
- esac
- fi
- # a simple function to compare directory contents
- #
- # Returns: 0 for same, 1 for different
- #
- directory_cmp ()
- {
- OLDPWD=`pwd`
- DIR_1=$1
- DIR_2=$2
- cd $DIR_1
- find . -print | fgrep -v /CVS | sort > $TESTDIR/dc$$d1
- # go back where we were to avoid symlink hell...
- cd $OLDPWD
- cd $DIR_2
- find . -print | fgrep -v /CVS | sort > $TESTDIR/dc$$d2
- if diff $TESTDIR/dc$$d1 $TESTDIR/dc$$d2 >/dev/null 2>&1
- then
- :
- else
- return 1
- fi
- cd $OLDPWD
- while read a
- do
- if test -f $DIR_1/"$a" ; then
- cmp -s $DIR_1/"$a" $DIR_2/"$a"
- if test $? -ne 0 ; then
- return 1
- fi
- fi
- done < $TESTDIR/dc$$d1
- rm -f $TESTDIR/dc$$*
- return 0
- }
- #
- # The following 4 functions are used by the diffmerge1 test case. They set up,
- # respectively, the four versions of the files necessary:
- #
- # 1. Ancestor revisions.
- # 2. "Your" changes.
- # 3. "My" changes.
- # 4. Expected merge result.
- #
- # Create ancestor revisions for diffmerge1
- diffmerge_create_older_files() {
- # This test case was supplied by Noah Friedman:
- cat >testcase01 <<EOF
- // Button.java
- package random.application;
- import random.util.*;
- public class Button
- {
- /* Instantiates a Button with origin (0, 0) and zero width and height.
- * You must call an initializer method to properly initialize the Button.
- */
- public Button ()
- {
- super ();
- _titleColor = Color.black;
- _disabledTitleColor = Color.gray;
- _titleFont = Font.defaultFont ();
- }
- /* Convenience constructor for instantiating a Button with
- * bounds x, y, width, and height. Equivalent to
- * foo = new Button ();
- * foo.init (x, y, width, height);
- */
- public Button (int x, int y, int width, int height)
- {
- this ();
- init (x, y, width, height);
- }
- }
- EOF
- # This test case was supplied by Jacob Burckhardt:
- cat >testcase02 <<EOF
- a
- a
- a
- a
- a
- EOF
- # This test case was supplied by Karl Tomlinson who also wrote the
- # patch which lets CVS correctly handle this and several other cases:
- cat >testcase03 <<EOF
- x
- s
- a
- b
- s
- y
- EOF
- # This test case was supplied by Karl Tomlinson:
- cat >testcase04 <<EOF
- s
- x
- m
- m
- x
- s
- v
- s
- x
- m
- m
- x
- s
- EOF
- # This test case was supplied by Karl Tomlinson:
- cat >testcase05 <<EOF
- s
- x
- m
- m
- x
- x
- x
- x
- x
- x
- x
- x
- x
- x
- s
- s
- s
- s
- s
- s
- s
- s
- s
- s
- v
- EOF
- # This test case was supplied by Jacob Burckhardt:
- cat >testcase06 <<EOF
- g
- i
- EOF
- # This test is supposed to verify that the horizon lines are the same
- # for both 2-way diffs, but unfortunately, it does not fail with the
- # old version of cvs. However, Karl Tomlinson still thought it would
- # be good to test it anyway:
- cat >testcase07 <<EOF
- h
- f
- g
- r
- i
- i
- EOF
- # This test case was supplied by Jacob Burckhardt:
- cat >testcase08 <<EOF
- Both changes move this line to the end of the file.
- no
- changes
- here
- First change will delete this line.
- First change will also delete this line.
- no
- changes
- here
- Second change will change it here.
- no
- changes
- here
- EOF
- # This test case was supplied by Jacob Burckhardt. Note that I do not
- # think cvs has ever failed with this case, but I include it anyway,
- # since I think it is a hard case. It is hard because Peter Miller's
- # fmerge utility fails on it:
- cat >testcase09 <<EOF
- m
- a
- {
- }
- b
- {
- }
- EOF
- # This test case was supplied by Martin Dorey and simplified by Jacob
- # Burckhardt:
- cat >testcase10 <<EOF
- petRpY ( MtatRk );
- fV ( MtatRk != Zy ) UDTXUK_DUUZU ( BGKT_ZFDK_qjT_HGTG );
- MtatRk = MQfr_GttpfIRte_MtpeaL ( &acI, jfle_Uecopd_KRLIep * jfle_Uecopd_MfJe_fY_nEtek );
- OjZy MtatRk = Uead_GttpfIRte_MtpeaL ( &acI, jfle_Uecopd_MfJe_fY_nEtek, nRVVep );
- Bloke_GttpfIRte_MtpeaL ( &acI );
- MTGTXM Uead_Ktz_qjT_jfle_Uecopd ( fYt Y, uofd *nRVVep )
- {
- fV ( Y < 16 )
- {
- petRpY ( Uead_Mectopk ( noot_Uecopd.qVtHatabcY0 * noot_Uecopd.MectopkFepBlRktep +
- Y * jfle_Uecopd_MfJe_fY_Mectopk,
- jfle_Uecopd_MfJe_fY_Mectopk,
- nRVVep ) );
- }
- elke
- {
- petRpY ( Uead_Mectopk ( noot_Uecopd.qVtqfppHatabcY0 * noot_Uecopd.MectopkFepBlRktep +
- ( Y - 16 ) * jfle_Uecopd_MfJe_fY_Mectopk,
- jfle_Uecopd_MfJe_fY_Mectopk,
- nRVVep ) );
- }
- }
- /****************************************************************************
- * *
- * Uead Mectopk ( Uelatfue to tze cRppeYt raptftfoY ) *
- * *
- ****************************************************************************/
- MTGTXM Uead_Mectopk ( RfYt64 Mtapt_Mectop, RfYt64 KRL_Mectopk, uofd *nRVVep )
- {
- MTGTXM MtatRk = Zy;
- MtatRk = Uead_HfkQ ( FaptftfoY_TaIle.Uelatfue_Mectop + Mtapt_Mectop, KRL_Mectopk, nRVVep );
- petRpY ( MtatRk );
- }
- HfkQipfte ( waYdle, /* waYdle */
- waYdleFok, /* ZVVket VpoL ktapt oV dfkQ */
- (coYkt RfYt8*) nRVVep, /* nRVVep */
- 0, /* MRrepVlRoRk KfxoYfkL */
- beYgtz /* nEtek to Apfte */
- );
- petRpY ( Zy );
- }
- EOF
- }
- # Create "your" revisions for diffmerge1
- diffmerge_create_your_files() {
- # remove the Button() method
- cat >testcase01 <<\EOF
- // Button.java
- package random.application;
- import random.util.*;
- public class Button
- {
- /* Instantiates a Button with origin (0, 0) and zero width and height.
- * You must call an initializer method to properly initialize the Button.
- */
- public Button ()
- {
- super ();
- _titleColor = Color.black;
- _disabledTitleColor = Color.gray;
- _titleFont = Font.defaultFont ();
- }
- }
- EOF
- cat >testcase02 <<\EOF
- y
- a
- a
- a
- a
- EOF
- cat >testcase03 <<\EOF
- x
- s
- a
- b
- s
- b
- s
- y
- EOF
- cat >testcase04 <<\EOF
- s
- m
- s
- v
- s
- m
- s
- EOF
- cat >testcase05 <<\EOF
- v
- s
- m
- s
- s
- s
- s
- s
- s
- s
- s
- s
- s
- v
- EOF
- # Test case 6 and test case 7 both use the same input files, but they
- # order the input files differently. In one case, a certain file is
- # used as the older file, but in the other test case, that same file
- # is used as the file which has changes. I could have put echo
- # commands here, but since the echo lines would be the same as those
- # in the previous function, I decided to save space and avoid repeating
- # several lines of code. Instead, I merely swap the files:
- mv testcase07 tmp
- mv testcase06 testcase07
- mv tmp testcase06
- # Make the date newer so that cvs thinks that the files are changed:
- touch testcase06 testcase07
- cat >testcase08 <<\EOF
- no
- changes
- here
- First change has now added this in.
- no
- changes
- here
- Second change will change it here.
- no
- changes
- here
- Both changes move this line to the end of the file.
- EOF
- cat >testcase09 <<\EOF
- m
- a
- {
- }
- b
- {
- }
- c
- {
- }
- EOF
- cat >testcase10 <<\EOF
- fV ( BzQkV_URYYfYg ) (*jfle_Uecopdk)[0].jfle_Uecopd_KRLIep = ZpfgfYal_jUK;
- petRpY ( MtatRk );
- fV ( MtatRk != Zy ) UDTXUK_DUUZU ( BGKT_ZFDK_qjT_HGTG );
- fV ( jfle_Uecopd_KRLIep < 16 )
- {
- MtatRk = Uead_Ktz_qjT_jfle_Uecopd ( jfle_Uecopd_KRLIep, (uofd*)nRVVep );
- }
- elke
- {
- MtatRk = ZreY_GttpfIRte_MtpeaL ( qjT_jfle_Uecopdk, qjT_jfle_Uecopd_BoRYt, HGTG_TvFD, KXbb, KXbb, &acI );
- fV ( MtatRk != Zy ) UDTXUK_DUUZU ( BGKT_ZFDK_qjT_HGTG );
- MtatRk = MQfr_GttpfIRte_MtpeaL ( &acI, jfle_Uecopd_KRLIep * jfle_Uecopd_MfJe_fY_nEtek );
- OjZy MtatRk = Uead_GttpfIRte_MtpeaL ( &acI, jfle_Uecopd_MfJe_fY_nEtek, nRVVep );
- Bloke_GttpfIRte_MtpeaL ( &acI );
- MTGTXM Uead_Ktz_qjT_jfle_Uecopd ( fYt Y, uofd *nRVVep )
- {
- MTGTXM MtatRk = Zy;
- fV ( Y < 16 )
- {
- petRpY ( Uead_Mectopk ( noot_Uecopd.qVtHatabcY0 * noot_Uecopd.MectopkFepBlRktep +
- Y * jfle_Uecopd_MfJe_fY_Mectopk,
- jfle_Uecopd_MfJe_fY_Mectopk,
- nRVVep ) );
- }
- elke
- {
- petRpY ( Uead_Mectopk ( noot_Uecopd.qVtqfppHatabcY0 * noot_Uecopd.MectopkFepBlRktep +
- ( Y - 16 ) * jfle_Uecopd_MfJe_fY_Mectopk,
- jfle_Uecopd_MfJe_fY_Mectopk,
- nRVVep ) );
- }
- petRpY ( MtatRk );
- }
- /****************************************************************************
- * *
- * Uead Mectopk ( Uelatfue to tze cRppeYt raptftfoY ) *
- * *
- ****************************************************************************/
- MTGTXM Uead_Mectopk ( RfYt64 Mtapt_Mectop, RfYt64 KRL_Mectopk, uofd *nRVVep )
- {
- MTGTXM MtatRk = Zy;
- MtatRk = Uead_HfkQ ( FaptftfoY_TaIle.Uelatfue_Mectop + Mtapt_Mectop, KRL_Mectopk, nRVVep );
- petRpY ( MtatRk );
- }
- HfkQipfte ( waYdle, /* waYdle */
- waYdleFok, /* ZVVket VpoL ktapt oV dfkQ */
- (coYkt RfYt8*) nRVVep, /* nRVVep */
- 0, /* MRrepVlRoRk KfxoYfkL */
- beYgtz /* nEtek to Apfte */
- );
- petRpY ( Zy );
- }
- EOF
- }
- # Create "my" revisions for diffmerge1
- diffmerge_create_my_files() {
- # My working copy still has the Button() method, but I
- # comment out some code at the top of the class.
- cat >testcase01 <<\EOF
- // Button.java
- package random.application;
- import random.util.*;
- public class Button
- {
- /* Instantiates a Button with origin (0, 0) and zero width and height.
- * You must call an initializer method to properly initialize the Button.
- */
- public Button ()
- {
- super ();
- // _titleColor = Color.black;
- // _disabledTitleColor = Color.gray;
- // _titleFont = Font.defaultFont ();
- }
- /* Convenience constructor for instantiating a Button with
- * bounds x, y, width, and height. Equivalent to
- * foo = new Button ();
- * foo.init (x, y, width, height);
- */
- public Button (int x, int y, int width, int height)
- {
- this ();
- init (x, y, width, height);
- }
- }
- EOF
- cat >testcase02 <<\EOF
- a
- a
- a
- a
- m
- EOF
- cat >testcase03 <<\EOF
- x
- s
- c
- s
- b
- s
- y
- EOF
- cat >testcase04 <<\EOF
- v
- s
- x
- m
- m
- x
- s
- v
- s
- x
- m
- m
- x
- s
- v
- EOF
- # Note that in test case 5, there are no changes in the "mine"
- # section, which explains why there is no command here which writes to
- # file testcase05.
- # no changes for testcase06
- # The two branches make the same changes:
- cp ../yours/testcase07 .
- cat >testcase08 <<\EOF
- no
- changes
- here
- First change will delete this line.
- First change will also delete this line.
- no
- changes
- here
- Second change has now changed it here.
- no
- changes
- here
- Both changes move this line to the end of the file.
- EOF
- cat >testcase09 <<\EOF
- m
- a
- {
- }
- b
- {
- }
- c
- {
- }
- EOF
- cat >testcase10 <<\EOF
- petRpY ( MtatRk );
- fV ( MtatRk != Zy ) UDTXUK_DUUZU ( BGKT_ZFDK_qjT_HGTG );
- MtatRk = MQfr_GttpfIRte_MtpeaL ( &acI, jfle_Uecopd_KRLIep * jfle_Uecopd_MfJe_fY_nEtek );
- OjZy MtatRk = Uead_GttpfIRte_MtpeaL ( &acI, jfle_Uecopd_MfJe_fY_nEtek, nRVVep );
- Bloke_GttpfIRte_MtpeaL ( &acI );
- MTGTXM Uead_Ktz_qjT_jfle_Uecopd ( fYt Y, uofd *nRVVep )
- {
- fV ( Y < 16 )
- {
- petRpY ( Uead_Mectopk ( noot_Uecopd.qVtHatabcY0 * noot_Uecopd.MectopkFepBlRktep +
- Y * jfle_Uecopd_MfJe_fY_Mectopk,
- jfle_Uecopd_MfJe_fY_Mectopk,
- nRVVep ) );
- }
- elke
- {
- petRpY ( Uead_Mectopk ( noot_Uecopd.qVtqfppHatabcY0 * noot_Uecopd.MectopkFepBlRktep +
- ( Y - 16 ) * jfle_Uecopd_MfJe_fY_Mectopk,
- jfle_Uecopd_MfJe_fY_Mectopk,
- nRVVep ) );
- }
- }
- /****************************************************************************
- * *
- * Uead Mectopk ( Uelatfue to tze cRppeYt raptftfoY ) *
- * *
- ****************************************************************************/
- MTGTXM Uead_Mectopk ( RfYt64 Mtapt_Mectop, RfYt64 KRL_Mectopk, uofd *nRVVep )
- {
- MTGTXM MtatRk = Zy;
- MtatRk = Uead_HfkQ ( FaptftfoY_TaIle.Uelatfue_Mectop + Mtapt_Mectop, KRL_Mectopk, nRVVep );
- petRpY ( MtatRk );
- }
- HfkQipfte ( waYdle, /* waYdle