You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Hudson <gh...@MIT.EDU> on 2004/09/12 19:59:08 UTC
[PATCH] Command prefixes for the test suite (for valgrind et al)
I figured it might be nice if, every so often, one of us runs the test
suite through valgrind. Lacking any convenient way to do so, I hacked
up the following patch to allow command prefixes in the test suite.
Then, by specifying a prefix of "valgrind -q --tool=memcheck", I can
make each of the test suite commands run through valgrind. This is
rather slow (maybe 2-3 times slower than the regular test suite run),
but it works.
There's no way to put arguments with spaces into a multi-word shell
variable, so while I added a CMD_PREFIX variable for the "make check"
target, it only works if your command prefix is a single word, so to
use this convenience you'd have to make a script which runs valgrind
with the desired options.
I'm not sure what I think of this patch. It seems kind of hackish,
but I'm not sure if there's a better way to do what I want, and it's a
noble goal.
As a small aside, if you run build/run_tests.py with invalid
arguments, it just prints "None" and exits. It's trying to print
__doc__; I guess python (2.3.3) doesn't work that way?
* Makefile.in: Add CMD_PREFIX option to check target
* build/run_tests.py (__init__, _run_test, main): Add --cmd-prefix
support, similar to --fs-type and --url.
* subversion/tests/clients/cmdline/svntest/main.py
(cmd_prefix): New global containing the command prefix.
(run_command): If cmd_prefix is set, prepend it to command.
(main): Set cmd_prefix variable if --cmd-prefix option specified.
Index: Makefile.in
===================================================================
--- Makefile.in (revision 10923)
+++ Makefile.in (working copy)
@@ -348,6 +348,9 @@
if test "$(FS_TYPE)" != ""; then \
flags="--fs-type $(FS_TYPE) $$flags"; \
fi; \
+ if test "$(CMD_PREFIX)" != ""; then \
+ flags="--cmd-prefix $(CMD_PREFIX) $$flags"; \
+ fi; \
$(PYTHON) $(top_srcdir)/build/run_tests.py $$flags \
'$(abs_srcdir)' '$(abs_builddir)' '$(PYTHON)' '$(SHELL)' \
$(TESTS); \
Index: build/run_tests.py
===================================================================
--- build/run_tests.py (revision 10923)
+++ build/run_tests.py (working copy)
@@ -10,7 +10,8 @@
'''
def __init__(self, abs_srcdir, abs_builddir, python, shell, logfile,
- base_url=None, fs_type=None, verbose=None, cleanup=None):
+ base_url=None, fs_type=None, cmd_prefix=None, verbose=None,
+ cleanup=None):
'''Construct a TestHarness instance.
ABS_SRCDIR and ABS_BUILDDIR are the source and build directories.
@@ -19,6 +20,7 @@
LOGFILE is the name of the log file.
BASE_URL is the base url for DAV tests.
FS_TYPE is the FS type for repository creation.
+ CMD_PREFIX is the prefix for commands.
'''
self.srcdir = abs_srcdir
self.builddir = abs_builddir
@@ -27,6 +29,7 @@
self.logfile = logfile
self.base_url = base_url
self.fs_type = fs_type
+ self.cmd_prefix = cmd_prefix
self.verbose = verbose
self.cleanup = cleanup
self.log = None
@@ -87,6 +90,8 @@
cmdline.append(quote('--url=' + self.base_url))
if self.fs_type is not None:
cmdline.append(quote('--fs-type=' + self.fs_type))
+ if self.cmd_prefix is not None:
+ cmdline.append(quote('--cmd-prefix=' + self.cmd_prefix))
elif progbase[-3:] == '.sh':
progname = self.shell
cmdline = [quote(progname),
@@ -103,6 +108,8 @@
cmdline.append('--cleanup')
if self.fs_type is not None:
cmdline.append(quote('--fs-type=' + self.fs_type))
+ if self.cmd_prefix is not None:
+ cmdline.append(quote('--cmd-prefix=' + self.cmd_prefix))
else:
print 'Don\'t know what to do about ' + progbase
sys.exit(1)
@@ -151,7 +158,7 @@
def main():
'''Usage: run_tests.py [--url=<base-url>] [--fs-type=<fs-type>]
- [--verbose] [--cleanup]
+ [--cmd-prefix=<prefix>] [--verbose] [--cleanup]
<abs_srcdir> <abs_builddir> <python> <shell>
<prog ...>
@@ -162,7 +169,8 @@
try:
opts, args = getopt.getopt(sys.argv[1:], '',
- ['url=', 'fs-type=', 'verbose', 'cleanup'])
+ ['url=', 'fs-type=', 'cmd-prefix=', 'verbose',
+ 'cleanup'])
except getopt.GetoptError:
args = []
@@ -170,12 +178,15 @@
print __doc__
sys.exit(2)
- base_url, fs_type, verbose, cleanup = None, None, None, None
+ base_url, fs_type, cmd_prefix, verbose = None, None, None, None
+ cleanup = None
for opt, val in opts:
if opt == '--url':
base_url = val
elif opt == '--fs-type':
fs_type = val
+ elif opt == '--cmd-prefix':
+ cmd_prefix = val
elif opt == '--verbose':
verbose = 1
elif opt == '--cleanup':
@@ -185,7 +196,7 @@
th = TestHarness(args[0], args[1], args[2], args[3],
os.path.abspath('tests.log'),
- base_url, fs_type, verbose, cleanup)
+ base_url, fs_type, cmd_prefix, verbose, cleanup)
failed = th.run(args[4:])
if failed:
Index: subversion/tests/clients/cmdline/svntest/main.py
===================================================================
--- subversion/tests/clients/cmdline/svntest/main.py (revision 10923)
+++ subversion/tests/clients/cmdline/svntest/main.py (working copy)
@@ -113,6 +113,9 @@
# Global variable indicating the FS type for repository creations.
fs_type = None
+# Global variable to be used as a prefix for commands we run.
+cmd_prefix = None
+
# Where we want all the repositories and working copies to live.
# Each test will have its own!
general_repo_dir = "repositories"
@@ -212,6 +215,8 @@
else:
mode = 't'
+ if cmd_prefix is not None:
+ command = cmd_prefix + " " + command
start = time.time()
infile, outfile, errfile = os.popen3(command + args, mode)
@@ -546,6 +551,7 @@
global test_area_url
global fs_type
+ global cmd_prefix
global verbose_mode
global cleanup_mode
testnum = None
@@ -556,7 +562,8 @@
try:
opts, args = getopt.getopt(sys.argv[1:], 'v',
- ['url=', 'fs-type=', 'verbose', 'cleanup'])
+ ['url=', 'fs-type=', 'cmd-prefix=', 'verbose',
+ 'cleanup'])
except getopt.GetoptError:
args = []
@@ -587,6 +594,9 @@
elif opt == "--fs-type":
fs_type = val
+ elif opt == "--cmd-prefix":
+ cmd_prefix = val
+
elif opt == "-v" or opt == "--verbose":
verbose_mode = 1
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Command prefixes for the test suite (for valgrind et
al)
Posted by Greg Hudson <gh...@MIT.EDU>.
On Sun, 2004-09-12 at 16:22, Philip Martin wrote:
> If you are using shared libraries I suspect this won't do what you
> want.
True; I usually do --disable-shared builds for easier debugging.
> When I run the tests using valgrind I edit the
> subversion/clients/cmdline/svn script and change the exec line to
> invoke valgrind.
Perhaps that's a better answer than my hack. (For a static build, you'd
have to create a new script and interpose it in place of the original,
but that's not terribly difficult either.)
> 2-3 doesn't sound right, valgrind is much slower than that on my
> machine. Hence, I suspect you are only running valgrind on the shell.
Nope; I already found a memory error in rev_hunt.c.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] Command prefixes for the test suite (for valgrind et
al)
Posted by Philip Martin <ph...@codematters.co.uk>.
Greg Hudson <gh...@MIT.EDU> writes:
> I figured it might be nice if, every so often, one of us runs the test
> suite through valgrind. Lacking any convenient way to do so, I hacked
> up the following patch to allow command prefixes in the test suite.
If you are using shared libraries I suspect this won't do what you
want. The libtool "executable" is a shell script that invokes the
real executable, so running
valgrind subversion/clients/cmdline/svn
runs valgrind on the transient shell used to invoke the real
executable. When I run the tests using valgrind I edit the
subversion/clients/cmdline/svn script and change the exec line to
invoke valgrind.
I suppose it might work if you disabled the shared libraries, if
that causes libtool to avoid the intermediate script.
> Then, by specifying a prefix of "valgrind -q --tool=memcheck", I can
> make each of the test suite commands run through valgrind. This is
> rather slow (maybe 2-3 times slower than the regular test suite run),
> but it works.
2-3 doesn't sound right, valgrind is much slower than that on my
machine. Hence, I suspect you are only running valgrind on the shell.
--
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org