Author: gnichols Date: 2011-03-08 12:57:20 +0000 (Tue, 08 Mar 2011) New Revision: 790
Added: trunk/v7/http.py Modified: trunk/v7/Makefile trunk/v7/command.py trunk/v7/commandLineUI.py trunk/v7/deviceDetector.py trunk/v7/reporthtml.py trunk/v7/resultsengine.py trunk/v7/test.py Log: 678984 - can't find tape device on RHEL6.1
Modified: trunk/v7/Makefile =================================================================== --- trunk/v7/Makefile 2011-03-08 12:50:45 UTC (rev 789) +++ trunk/v7/Makefile 2011-03-08 12:57:20 UTC (rev 790) @@ -24,7 +24,9 @@ COMMAND_PY := command.py endif
+UNITS := redhatrelease.py
+ install: rm -rf $(DESTDIR)$(V7_CLASS_LIB)/v7 mkdir -p $(DESTDIR)$(V7_CLASS_LIB)/v7 @@ -34,3 +36,8 @@ clean: rm -rf $(DESTDIR)$(V7_CLASS_LIB)/v7 + + +unit-test: install + for unit in $(UNITS); do python $(DESTDIR)$(V7_CLASS_LIB)/v7/$$unit > unit-test.log; done +
Modified: trunk/v7/command.py =================================================================== --- trunk/v7/command.py 2011-03-08 12:50:45 UTC (rev 789) +++ trunk/v7/command.py 2011-03-08 12:57:20 UTC (rev 790) @@ -72,7 +72,8 @@ if self.output: for line in self.output: sys.stdout.write( line ) - sys.stdout.flush() + sys.stdout.write("\n") + sys.stdout.flush() if self.returnValue != 0: raise V7CommandException(self, "returned %d" % self.returnValue) if self.signal != 0: @@ -230,7 +231,7 @@ def poll(self): if self.pipe: return self.pipe.poll() - # otherwise, commmand never started + # otherwise, command never started raise V7CommandException(self.command, "call to poll() before start()")
Modified: trunk/v7/commandLineUI.py =================================================================== --- trunk/v7/commandLineUI.py 2011-03-08 12:50:45 UTC (rev 789) +++ trunk/v7/commandLineUI.py 2011-03-08 12:57:20 UTC (rev 790) @@ -16,7 +16,7 @@ import string, os, sys, copy, re
-from v7.tags import Constants +from tags import Constants
class CommandLineUI: # utilities
Modified: trunk/v7/deviceDetector.py =================================================================== --- trunk/v7/deviceDetector.py 2011-03-08 12:50:45 UTC (rev 789) +++ trunk/v7/deviceDetector.py 2011-03-08 12:57:20 UTC (rev 790) @@ -18,8 +18,8 @@ import string, os, sys, copy
-from v7.tags import Constants -from v7.commandLineUI import CommandLineUI +from tags import Constants +from commandLineUI import CommandLineUI
class DeviceDetector:
Added: trunk/v7/http.py =================================================================== --- trunk/v7/http.py (rev 0) +++ trunk/v7/http.py 2011-03-08 12:57:20 UTC (rev 790) @@ -0,0 +1,87 @@ +#!/usr/bin/python +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. This copyrighted material +# is made available to anyone wishing to use, modify, copy, or +# redistribute it subject to the terms and conditions of the GNU General +# Public License v.2. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Author: Greg Nichols gnichols@redhat.com +# +# HTTP library for v7's tests + +import os, urllib2, httplib + +class V7Http: + + def __init__(self, host, url): + self.host = host + self.url = url + self.fields = list() + self.files = list() + + def __encode(self): + boundary = 'v7v7v7v7v7v7v7' + lines = list() + for (name, value) in self.fields: + lines.append('--' + boundary) + lines.append('Content-Disposition: form-data; name="%s"' % name) + lines.append('') + lines.append(value) + for (name, filename, contents) in self.files: + lines.append('--' + boundary) + lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (name, filename)) + lines.append('Content-Type: application/octet-stream') + lines.append('') + lines.append(contents) + lines.append('--' + boundary + '--') + lines.append('') + self.body = '\r\n'.join(lines) + self.contentType = 'multipart/form-data; boundary=%s' % boundary + encoded = True + + def addFile(self, filepath): + try: + contents = open(filepath, "rb").read().encode("base64") + except IOError, exception: + print "Error: could not add file " + filepath + print exception + return False + + self.files.append(("file", os.path.basename(filepath), contents)) + return True + + def addField(self, name, value): + self.fields.append((name, value)) + + def send(self): + self.__encode() + request = httplib.HTTP(self.host) + request.putrequest('POST', self.url) + request.putheader('content-type', self.contentType) + request.putheader('content-length', str(len(self.body))) + request.endheaders() + request.send(self.body) + responseCode, responseMessage, headers = request.getreply() + if responseCode != 200: + print "Error: could not send message (response code %s)" % responseCode + print "Message: %s" % responseMessage + return (0, None) + + return (len(self.body), request.file.read()) + + +if __name__ == "__main__": + + request = V7Http("localhost", "/v7/cgi/networkTest.py") + request.addFile("/var/v7/images/logo_rh_home.png") + result = request.send() + print result + + \ No newline at end of file
Modified: trunk/v7/reporthtml.py =================================================================== --- trunk/v7/reporthtml.py 2011-03-08 12:50:45 UTC (rev 789) +++ trunk/v7/reporthtml.py 2011-03-08 12:57:20 UTC (rev 790) @@ -158,7 +158,7 @@ result = run.getSummary() if result == Constants.PASS and run.getMode() == Constants.auto and test.isInteractive(): result = "auto" - print "<td class="%s"><a href="v7web.py?test=%s&udi=%s&device=%s&run=%u">%s</a></td>" % (result.lower(), test.getName(), test.getUDI(), test.getLogicalDeviceName(), runNumber, result.lower()) + print "<td class="%s"><a href="v7xml.py?test=%s&udi=%s&device=%s&run=%u">%s</a></td>" % (result.lower(), test.getName(), test.getUDI(), test.getLogicalDeviceName(), runNumber, result.lower()) else: print "<td> </td>" print "</tr>" @@ -262,7 +262,8 @@ print "<strong>run:</strong> %s<br/>" % self.options.run print "<strong>start:</strong> %s<br/>" % run.getRunTime() print "<strong>end:</strong> %s<br/>" % run.getEndTime() - print "<strong>duration:</strong> %s<br/>" % run.duration(run.getRunTime(), run.getEndTime()) + if len(run.getRunTime()) > 0 and len(run.getEndTime()): + print "<strong>duration:</strong> %s<br/>" % run.duration(run.getRunTime(), run.getEndTime()) print "<strong>mode:</strong> %s<br/>" % run.getMode().lower() if run.getSummary().lower() == "fail": print "<strong>result:</strong> <font class="error">fail</font><br/>"
Modified: trunk/v7/resultsengine.py =================================================================== --- trunk/v7/resultsengine.py 2011-03-08 12:50:45 UTC (rev 789) +++ trunk/v7/resultsengine.py 2011-03-08 12:57:20 UTC (rev 790) @@ -48,12 +48,12 @@ if test.getRun(runNumber).passed(): print test.getRun(runNumber).passed() print "added %s to passed tests" % test.getName() - passedTests[test.getName()] = test + passedTests[test.getKey()] = test
remainingTests = list() for test in self.certification.getTests(): try: - check = passedTests[test.getName()] + check = passedTests[test.getKey()] except: if not test.isDeleted(): remainingTests.append(test)
Modified: trunk/v7/test.py =================================================================== --- trunk/v7/test.py 2011-03-08 12:50:45 UTC (rev 789) +++ trunk/v7/test.py 2011-03-08 12:57:20 UTC (rev 790) @@ -13,7 +13,7 @@ # # Author: Greg Nichols # -import string, os, sys, copy, commands, time +import string, os, sys, copy, commands, time, datetime
from v7.tags import Constants, TestTag @@ -424,12 +424,12 @@ self.markOutput(name, description) sys.stdout.flush() sys.stderr.flush() - try: - result = subtestFunction() - except Exception, exception: - print "Error: Subtest raised unhandled exception:" - print exception - result = False + #try: + result = subtestFunction() + #except Exception, exception: + # print "Error: Subtest raised unhandled exception:" + # print exception + # result = False sys.stdout.flush() sys.stderr.flush() self.markSummary(result) @@ -558,7 +558,7 @@
# 2) try and get them from the testDocument self.testDocument = testDocument - map = [(Constants.DEVICE, testDocument.getLogicalDeviceName)] + map = [(Constants.DEVICE, testDocument.getLogicalDeviceName), (Constants.UDI, testDocument.getUDI)] for (name, function) in map: self.parameters[name] = function()
@@ -577,6 +577,8 @@ def set(self, name, value): self.parameters[name] = value
+ +
v7-commits@lists.stg.fedorahosted.org