Hello!

I have slightly improved my patch for sanity.sh since the last time I
posted it. Now you don't have to remove ~/.cvsrc when using :ext:

The command line interface also has changed. Now you should specify the
method using the "--method" switch. The "-r" option is equivalent to
"--method ext" but is obsolete and is not documented.

Detailed description of the patch, almost line-by-line:

1) We don't want to have the usage information in two places - once as a
comment, then as the real text. So the usage() function goes to the
beginning.

2) Instead of having an "-r" option that turned on testing with methods
"fork" and "ext" we now have a fine-grained control on what method we want
to test. If "--method ext" is specified, method "fork" will not be used
and vice versa. Working rsh is not required to test "fork". On the other
side you can run the full testsuite with your rsh/ssh/ssh2/whatever.

3) All the long options (there was only one, "--keep") now have short
forms.

4) New option "--verbose" turns on some feedback on what tests (actually
groups of tests) are running. The message "This test should produce no
other output..." is meaningless in this case and is omitted.

5) The command line parser has been rewritten so that the options are now
interchangeable.

6) We now test whether CVS-TO-TEST can be run.

7) New variable "method_host" is the method name plus the host name if the
method requires it. It is handy to replace some hardcoded occurences of
:fork: and :ext:

8) When testing method "ext" CVS_SERVER has "-f" so that .cvsrc is not
used by the server.

9) When testing method "fork" CVS_RSH is set to /bin/false to disallow any
possible use of the "ext" method.

10) devcom3-9a tests "disconnected edit", i.e. edit with a faked
CVS_SERVER. "fork" and "ext" fail differently, so the pattern has been
adjusted to accomodate both.

11) A long comment in the "crerepos" test is no longer relevant and has
been removed.

Feel free to ask for more details or changes.
Now when remote CVS is used for many projects it needs a decent test.

Regards,
Pavel Roskin


=========================
diff -u -r1.1941 ChangeLog
--- src/ChangeLog       2000/07/20 17:52:06     1.1941
+++ src/ChangeLog       2000/07/20 18:52:05
@@ -1,3 +1,11 @@
+2000-07-20  Pavel Roskin  <[EMAIL PROTECTED]>
+
+       * sanity.sh: New parser for the command line. The access method
+       can be specified for the whole testsuite and can be "local",
+       "fork" or "ext". Some tests adjusted to use the specified
+       method only.
+       (usage): New function
+
 2000-07-17  Larry Jones  <[EMAIL PROTECTED]>
 
        * sanity.sh (modules5-7, cvsadm-1e, emptydir-2): Allow for a nil
diff -u -r1.616 sanity.sh
--- src/sanity.sh       2000/07/20 17:52:06     1.616
+++ src/sanity.sh       2000/07/20 18:52:08
@@ -17,14 +17,23 @@
 # GNU General Public License for more details.
 #
 # 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.
-
+#
 # See TODO list at end of file.
 
+usage() {
+       cat 1>&2 << EOF
+Usage:
+       `basename $0` OPTIONS CVS-TO-TEST [TESTS-TO-RUN...]" 1>&2
+Options:
+       -m | --method METHOD    Use METHOD: local (default), fork or ext
+       -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
+}
+
 # required to make this script work properly.
 unset CVSREAD
 
@@ -59,33 +68,53 @@
 # "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
+
+more_args=yes
+while test x"$more_args" = xyes
+do
+       case "$1" in
+       # Undocumented "-r" option sets method=ext for backward compatability
+       # You must have "$CVS_RSH localhost" working without the password
+       # to use this mode. $CVS_RSH defaults to "rsh" if not set
+       -r|--remote)
+               method=ext
+               shift;;
+       # Use method :fork:
+       -m|--method)
+               shift
+               method="$1"
+               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;;
+       *)
+               more_args=no
+       esac
+done
 
-if test x"$1" = x"-r"; then
-       shift
-       remote=yes
-else
+if test x"$method" = xlocal; 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
-  exit 1
+  usage
   ;;
 /*)
   testcvs=$1
@@ -95,8 +124,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
@@ -718,14 +758,37 @@
 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
-       CVS_SERVER=${testcvs}; export CVS_SERVER
+       # 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
+               CVS_SERVER=${testcvs}
+               ;;
+       "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
+               # The remote cvs would see .cvsrc in the real $HOME
+               # -f is meant to prevent it
+               CVS_SERVER="${testcvs} -f"
+               ;;
+       *)
+               echo "Only methods local, fork and ext are supported" 1>&2
+               exit 1
+               ;;
+       esac
+       export CVS_SERVER
+       CVSROOT=${method_host}${CVSROOT_DIRNAME}; export CVSROOT
 fi
 
 dotest 1 "${testcvs} init" ''
@@ -733,6 +796,9 @@
 
 ### The big loop
 for what in $tests; do
+       if test x"$verbose" = xyes; then
+               echo "Now running $what"
+       fi
        case $what in
        basica)
          # Similar in spirit to some of the basic1, and basic2
@@ -10932,7 +10998,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"
@@ -13544,7 +13610,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 \
@@ -13592,29 +13658,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 ." \
@@ -13635,14 +13683,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
@@ -14963,7 +15011,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
@@ -18612,8 +18660,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}"
@@ -19805,8 +19853,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" ""
@@ -19940,8 +19988,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
@@ -20051,8 +20099,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
@@ -20164,8 +20212,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
@@ -20217,7 +20265,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"
@@ -20237,7 +20285,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"
=========================


Reply via email to