Author: justi9
Date: 2008-08-21 14:24:50 -0400 (Thu, 21 Aug 2008)
New Revision: 2339
Modified:
mgmt/trunk/cumin/bin/cumin-bench
mgmt/trunk/cumin/python/wooly/devel.py
Log:
Add a check-xml mode to cumin-bench
Modified: mgmt/trunk/cumin/bin/cumin-bench
===================================================================
--- mgmt/trunk/cumin/bin/cumin-bench 2008-08-21 17:42:43 UTC (rev 2338)
+++ mgmt/trunk/cumin/bin/cumin-bench 2008-08-21 18:24:50 UTC (rev 2339)
@@ -8,7 +8,7 @@
from cumin.test import *
from cumin.util import *
-def do_main(home, data, spec, hits):
+def do_main(home, data, spec, hits, check_xml):
app = Cumin(home, data, spec)
app.enable_debug()
@@ -23,7 +23,7 @@
app.init()
- harness = BenchmarkHarness(app)
+ harness = BenchmarkHarness(app, check_xml)
try:
try:
@@ -44,6 +44,9 @@
summ = "Enable profiling"
config.add_param("profile", bool, False, summ)
+ summ = "Check that page output is well-formed XML"
+ config.add_param("check-xml", bool, False, summ)
+
config.init()
if "-h" in sys.argv or "--help" in sys.argv:
@@ -58,6 +61,7 @@
spec = config.spec
hits = config.hits
profile = config.profile
+ check_xml = config.check_xml
if config.profile:
from profile import Profile
@@ -66,8 +70,8 @@
prof = Profile()
try:
- statement = "do_main('%s', '%s', '%s', %i)"
% \
- (home, data, spec, hits)
+ statement = "do_main('%s', '%s', '%s', %i,
%r)" % \
+ (home, data, spec, hits, check_xml)
prof.run(statement)
@@ -89,7 +93,7 @@
stats.strip_dirs()
else:
- do_main(home, data, spec, hits)
+ do_main(home, data, spec, hits, check_xml)
if __name__ == "__main__":
main()
Modified: mgmt/trunk/cumin/python/wooly/devel.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/devel.py 2008-08-21 17:42:43 UTC (rev 2338)
+++ mgmt/trunk/cumin/python/wooly/devel.py 2008-08-21 18:24:50 UTC (rev 2339)
@@ -1,13 +1,18 @@
import sys, os
from random import sample
from time import clock
+from xml.parsers.expat import ParserCreate
from wooly import *
class BenchmarkHarness(object):
- def __init__(self, app):
+ def __init__(self, app, check_xml=False):
self.app = app
+ self.parser = None
+ if check_xml:
+ self.parser = ParserCreate()
+
def run(self, max=-1):
visited = set()
self.app.debug.urls.add("")
@@ -31,6 +36,17 @@
html = page.render(session)
+ if self.parser:
+ try:
+ self.parser.Parse(html)
+ except Exception, e:
+ lines = html.split(os.linesep)
+
+ for i, line in enumerate(lines):
+ print "%4i %s" % (i + 1, line)
+
+ raise e
+
bytes = len(html)
millis = (clock() - start) * 1000