Fix integer type used by ESet
[xapian.git] / xapian-core / tests / submitperftest.in
blob2106669507884dc12efec1699a61bc06b83ca879
1 #!/usr/bin/env python
3 # Copyright 2008 Lemur Consulting Ltd
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18 # USA
19 """Run a performance test, and submit the results to the public archive.
21 Usage:
23 submitperftest
25 """
27 import sys
28 sys.path.insert(0, r"@srcdir@")
30 import os
31 import re
32 import urllib2
33 import urllib2_file
35 # URL to send submissions to.
36 submission_path = "http://tartarus.org/richard/perftest/upload.cgi"
38 class fdwrapper:
39 def __init__(self, fd, callback):
40 self.fd = fd
42 def __getattr__(self, attr):
43 print "getattr", attr
44 return getattr(self.fd, attr)
46 def submit_perftest(filepath):
47 """Send the performance test results in a file to the server.
49 Returns a code number which can be used to find the results on the server
50 again.
52 """
53 fd = open(filepath, "r")
54 req = urllib2.Request(submission_path, {'file': fd})
55 try:
56 response = urllib2.urlopen(req)
57 except urllib2.HTTPError, e:
58 print "HTTPError: ", e.message, ": ", e.strerror
59 return
61 resdata = response.read()
62 g_begin = re.search('<!-- MSG_BEGIN[^\n]*\n', resdata)
63 g_end = re.search('MSG_END -->\n', resdata)
64 if g_begin is None or g_end is None:
65 print "Invalid return from submission server - test may not have been uploaded successfully"
66 return
67 lines = resdata[g_begin.end():g_end.start()].strip().split('\n')
68 if len(lines) < 2:
69 print "Unexpected return from submission server - test may not have been uploaded successfully"
70 return
71 if lines[0] != 'OK':
72 print "Unsuccessful submission: server said:\n" + '\n'.join(lines[1:])
73 return
74 print "Successful submission: server said:\n"
75 print '\n'.join(lines[1:])
78 def main():
79 submit_perftest(os.path.join(r"@builddir@", "perflog.xml"))
81 if __name__ == '__main__':
82 main()