Hello! I have finished my patch for sanity.sh that lets the user choose between methods "fork" and "ext", so that every test can be run in both of those modes. My patch conflicts (formally) with that of Stephen Cameron. Both of those patches introduce a loop for option parsing. But it should be easy (for a human) to merge our patches. Issues addressed by my patch: 1) Better help message 2) Option processing in the loop 3) Long (GNU-style) options 4) --fork runs tests using method "fork" only 5) --remote runs tests using method "ext" only 6) --verbose prints names of tests being run 7) More sanity checks, e.g. checking that CVS-TO-TEST can be run 8) Checking that there is no .cvsrc on the remote side (i.e. in the real home directory) when using "ext". Perhaps a wrapper setting $HOME will be a better solution. Comments are welcome. 9) Some tweaks to make "fork" work where "ext" was used and vice versa. The patch has been tested in all three modes (local, fork, remote) and is known to work on RedHat Linux 6.2, i586, ssh-1.2.27 I recommend applying the patch by Stephen first so that I could merge the changes and resubmit my patch with ChangeLog entries and possibly further enhancements. Regards, Pavel Roskin =================================================== --- sanity.sh 2000/07/03 19:35:21 1.609 +++ sanity.sh 2000/07/03 22:39:15 @@ -18,10 +18,15 @@ # # Original Author: K. Richard Pixley -# usage: sanity.sh [-r] @var{cvs-to-test} @var{tests-to-run} -# -r means to test remote instead of local cvs. -# @var{tests-to-run} are the names of the tests to run; if omitted run all -# tests. +# Usage: +# sanity.sh OPTIONS CVS-TO-TEST [TESTS-TO-RUN...]" 1>&2 +# Options: +# -r | --remote Use method :ext: +# -f | --fork Use method :fork: +# -k | --keep Keep temporary files +# -v | --verbose Report the progress +# CVS-TO-TEST is the CVS executable to be tested +# TESTS-TO-RUN are the names of the tests to run (default: run all) # See TODO list at end of file. @@ -59,32 +64,62 @@ # "debugger" #set -x -echo 'This test should produce no other output than this line, and a final "OK".' +# default values +remote=no +method=local +keep=no +verbose=no + +stop_now= +while test x"$stop_now" = x +do + case "$1" in + # Use method :ext: + # You must have "$CVS_RSH localhost" working without the password + # to use this mode. $CVS_RSH defaults to "rsh" + -r|--remote) + method=ext + shift;; + # Use method :fork: + -f|--fork) + method=fork + shift;; + # The --keep option will eventually cause all the tests to leave around the + # contents of the /tmp directory; right now only some implement it. Not + # useful if you are running more than one test. + -k|--keep) + keep=yes + shift;; + # List the tests as they are run + -v|--verbose) + verbose=yes + shift;; + *) + stop_now=yes + esac +done -if test x"$1" = x"-r"; then - shift - remote=yes -else +if test $method = "local"; then remote=no -fi - -# The --keep option will eventually cause all the tests to leave around the -# contents of the /tmp directory; right now only some implement it. Not -# useful if you are running more than one test. -# FIXME: need some real option parsing so this doesn't depend on the order -# in which they are specified. -if test x"$1" = x"--keep"; then - shift - keep=yes else - keep=no + remote=yes fi # Use full path for CVS executable, so that CVS_SERVER gets set properly # for remote. case $1 in "") - echo "Usage: `basename $0` [-r] [--keep] CVS-TO-TEST [TESTS-TO-RUN...]" 1>&2 + cat 1>&2 << EOF +Usage: + `basename $0` OPTIONS CVS-TO-TEST [TESTS-TO-RUN...]" 1>&2 +Options: + -r | --remote Use method :ext: + -f | --fork Use method :fork: + -k | --keep Keep temporary files + -v | --verbose Report the progress +CVS-TO-TEST is the CVS executable to be tested +TESTS-TO-RUN are the names of the tests to run (default: run all) +EOF exit 1 ;; /*) @@ -95,8 +130,19 @@ ;; esac +if $testcvs --help >/dev/null 2>/dev/null || test $? = 1; then + : +else + echo "Cannot run $testcvs" + exit 1 +fi + shift +if test x"$verbose" != xyes; then + echo 'This test should produce no other output than this line, and a final +"OK".' +fi + # 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 @@ -352,6 +398,9 @@ { # expr can't distinguish between "zero characters matched" and "no match", # so special-case it. + if test x"$verbose" = xyes; then + echo "$1" + fi if test -z "$3"; then if test -s ${TESTDIR}/dotest.tmp; then if test x"$4" != x; then @@ -718,14 +767,36 @@ CVSROOT_DIRNAME=${TESTDIR}/cvsroot CVSROOT=${CVSROOT_DIRNAME} ; export CVSROOT if test "x$remote" = xyes; then - # Currently we test :fork: and :ext: (see crerepos test). + # Currently we test :fork: and :ext: # Testing :pserver: would be hard (inetd issues). - # Also :ext: and :fork support CVS_SERVER in a convenient way. - # If you want to edit this script to change the next line to - # :ext:, you can run the tests that way. There is a known - # difference in modes-15 (see comments there). - CVSROOT=:fork:${CVSROOT_DIRNAME} ; export CVSROOT + # Also :ext: and :fork: support CVS_SERVER in a convenient way. + # There is a known difference between :ext: and :fork: + # in modes-15 (see comments there). + case $method in + "fork") + method_host=":fork:" + # Just to make sure that :ext: is disallowed + CVS_RSH=/bin/false + ;; + "ext") + host="`hostname`" + method_host=":ext:${host}:" + # If we're going to do remote testing, make sure 'rsh' works first. + if test "x`${CVS_RSH-rsh} $host -n 'echo hi'`" != "xhi"; then + echo "ERROR: cannot test remote CVS, because \`${CVS_RSH-rsh} +$host' fails." >&2 + exit 1 + fi + # Redefining HOME will not save us from .cvsrc on the remote end + # Maybe CVS_SERVER should be set to a wrapper + remcvsrc=`${CVS_RSH-rsh} localhost ls .cvsrc 2>/dev/null` + if test x != x"$remcvsrc"; then + echo "Remote testing will fail unless you move .cvsrc away +from your home directrory" >&2 + exit 1 + fi + ;; + esac CVS_SERVER=${testcvs}; export CVS_SERVER + CVSROOT=${method_host}${CVSROOT_DIRNAME}; export CVSROOT fi dotest 1 "${testcvs} init" '' @@ -10665,7 +10736,7 @@ # gets around to sending data to it) or "broken pipe" (if it # is the other way around). dotest_fail devcom3-9a "${testcvs} edit w1" \ -"${PROG} \[edit aborted\]: cannot exec ${TESTDIR}/cvs-none: ${DOTSTAR}" +"${DOTSTAR}${PROG} \[edit aborted\]${DOTSTAR}" dotest devcom3-9b "test -w w1" "" dotest devcom3-9c "cat CVS/Notify" \ "Ew1 [SMTWF][uoehra][neduit] [JFAMSOND][aepuco][nbrylgptvc] [0-9 ][0-9] [0-9:]* [0-9][0-9][0-9][0-9] GMT [-a-zA-Z_.0-9]* ${TESTDIR}/1/first-dir EUC" @@ -13293,7 +13364,7 @@ # Because this test is all about -d options and such, it # at least to some extent needs to be different for remote vs. # local. - if test "x$remote" = "xno"; then + if test "x$method" != "xext"; then # First, if the repository doesn't exist at all... dotest_fail crerepos-1 \ @@ -13341,29 +13412,11 @@ mkdir crerepos mkdir crerepos/CVSROOT - # Use :ext: rather than :fork:. Most of the tests use :fork:, - # so we want to make sure that we test :ext: _somewhere_. + CREREPOS_ROOT=${method_host}${TESTDIR}/crerepos - # Maybe a bit dubious in the sense that people need to - # have rsh working to run the tests, but at least it - # isn't inetd :-). Might want to think harder about this - - # maybe try :ext:, and if it fails, print a (single, nice) - # message and fall back to :fork:. Maybe testing :ext: - # with our own CVS_RSH rather than worrying about a system one - # would do the trick. - - # Note that we set CVS_SERVER at the beginning. - CREREPOS_ROOT=:ext:`hostname`:${TESTDIR}/crerepos - - # If we're going to do remote testing, make sure 'rsh' works first. - host="`hostname`" - if test "x`${CVS_RSH-rsh} $host -n 'echo hi'`" != "xhi"; then - echo "ERROR: cannot test remote CVS, because \`rsh $host' fails." >&2 - exit 1 - fi fi - if test "x$remote" = "xno"; then + if test "x$method" != "xext"; then # Test that CVS rejects a relative path in CVSROOT. mkdir 1; cd 1 dotest_fail crerepos-6a "${testcvs} -q -d ../crerepos get ." \ @@ -13384,14 +13437,14 @@ # here. The point is that malicious clients might send all # manner of things and the server better protect itself. dotest_fail crerepos-6a \ -"${testcvs} -q -d :ext:`hostname`:../crerepos get ." \ +"${testcvs} -q -d ${method_host}../crerepos get ." \ "Root ../crerepos must be an absolute pathname" cd .. rm -r 1 mkdir 1; cd 1 dotest_fail crerepos-6b \ -"${testcvs} -d :ext:`hostname`:crerepos init" \ +"${testcvs} -d ${method_host}crerepos init" \ "Root crerepos must be an absolute pathname" cd .. rm -r 1 @@ -14712,7 +14765,7 @@ ${TESTDIR}/cvsroot/first-dir/Attic/ac,v <-- ac new revision: 1\.1\.2\.1; previous revision: 1\.1 done" - if test "x$remote" = xyes; then + if test x"${method}" = xext; then # The problem here is that the CVSUMASK environment variable # needs to be set on the server (e.g. .bashrc). This is, of # course, bogus, but that is the way it is currently. The @@ -18361,8 +18414,8 @@ CVSROOT1=${CVSROOT1_DIRNAME} ; export CVSROOT1 CVSROOT2=${CVSROOT2_DIRNAME} ; export CVSROOT2 if test "x$remote" = xyes; then - CVSROOT1=:fork:${CVSROOT1_DIRNAME} ; export CVSROOT1 - CVSROOT2=:fork:${CVSROOT2_DIRNAME} ; export CVSROOT2 + CVSROOT1=${method_host}${CVSROOT1_DIRNAME} ; export CVSROOT1 + CVSROOT2=${method_host}${CVSROOT2_DIRNAME} ; export CVSROOT2 fi testcvs1="${testcvs} -d ${CVSROOT1}" testcvs2="${testcvs} -d ${CVSROOT2}" @@ -19554,8 +19607,8 @@ CVSROOT1=${CVSROOT1_DIRNAME} ; export CVSROOT1 CVSROOT2=${CVSROOT2_DIRNAME} ; export CVSROOT2 if test "x$remote" = xyes; then - CVSROOT1=:fork:${CVSROOT1_DIRNAME} ; export CVSROOT1 - CVSROOT2=:fork:${CVSROOT2_DIRNAME} ; export CVSROOT2 + CVSROOT1=${method_host}${CVSROOT1_DIRNAME} ; export CVSROOT1 + CVSROOT2=${method_host}${CVSROOT2_DIRNAME} ; export CVSROOT2 fi dotest multiroot2-1 "${testcvs} -d ${CVSROOT1} init" "" @@ -19689,8 +19742,8 @@ # different stuff. if test "x$remote" = xyes; then - CVSROOT1=:fork:${TESTDIR}/root1 ; export CVSROOT1 - CVSROOT2=:fork:${TESTDIR}/root2 ; export CVSROOT2 + CVSROOT1=${method_host}${TESTDIR}/root1 ; export CVSROOT1 + CVSROOT2=${method_host}${TESTDIR}/root2 ; export CVSROOT2 else CVSROOT1=${TESTDIR}/root1 ; export CVSROOT1 CVSROOT2=${TESTDIR}/root2 ; export CVSROOT2 @@ -19800,8 +19853,8 @@ # similarly-named directories and we try to see that CVS can # keep them separate. if test "x$remote" = xyes; then - CVSROOT1=:fork:${TESTDIR}/root1 ; export CVSROOT1 - CVSROOT2=:fork:${TESTDIR}/root2 ; export CVSROOT2 + CVSROOT1=${method_host}${TESTDIR}/root1 ; export CVSROOT1 + CVSROOT2=${method_host}${TESTDIR}/root2 ; export CVSROOT2 else CVSROOT1=${TESTDIR}/root1 ; export CVSROOT1 CVSROOT2=${TESTDIR}/root2 ; export CVSROOT2 @@ -19913,8 +19966,8 @@ # enough. if test "x$remote" = xyes; then - CVSROOT1=:fork:${TESTDIR}/root1 ; export CVSROOT1 - CVSROOT_MOVED=:fork:${TESTDIR}/root-moved ; export CVSROOT1 + CVSROOT1=${method_host}${TESTDIR}/root1 ; export CVSROOT1 + CVSROOT_MOVED=${method_host}${TESTDIR}/root-moved ; export CVSROOT1 else CVSROOT1=${TESTDIR}/root1 ; export CVSROOT1 CVSROOT_MOVED=${TESTDIR}/root-moved ; export CVSROOT1 @@ -19966,7 +20019,7 @@ CVSROOT=${CVSROOT_SAVED}; export CVSROOT else CVSROOT_SAVED=${CVSROOT} - CVSROOT=:fork:${TESTDIR}/root-moved; export CVSROOT + CVSROOT=${method_host}${TESTDIR}/root-moved; export CVSROOT dotest_fail reposmv-3 "${testcvs} update" \ "Cannot access ${TESTDIR}/root1/CVSROOT No such file or directory" @@ -19986,7 +20039,7 @@ CVSROOT=${CVSROOT_SAVED}; export CVSROOT else CVSROOT_SAVED=${CVSROOT} - CVSROOT=:fork:${TESTDIR}/root-none; export CVSROOT + CVSROOT=${method_host}${TESTDIR}/root-none; export CVSROOT dotest_fail reposmv-4 "${testcvs} update" \ "Cannot access ${TESTDIR}/root1/CVSROOT No such file or directory" ===================================================