Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 713881 Details for
Bug 921240
FEAT: address prompting quirks from 'hwcert' command refactoring
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
additional improvements against R33
0001-921240-FEAT-address-prompting-quirks-from-hwcert-com.patch (text/plain), 17.37 KB, created by
Greg Nichols
on 2013-03-21 14:16:47 UTC
(
hide
)
Description:
additional improvements against R33
Filename:
MIME Type:
Creator:
Greg Nichols
Created:
2013-03-21 14:16:47 UTC
Size:
17.37 KB
patch
obsolete
>From a41366cfb4005124647d4d288b781605bac8228d Mon Sep 17 00:00:00 2001 >From: Greg Nichols <gnichols@redhat.com> >Date: Thu, 21 Mar 2013 10:15:12 -0400 >Subject: [PATCH] 921240 - FEAT: address prompting quirks from 'hwcert' command > refactoring > >--- > Makefile | 2 +- > hwcert-client.spec.in | 2 +- > hwcert/certificationtest.py | 32 +++++---- > hwcert/deviceclassdocument.py | 18 ++++- > hwcert/documentbase.py | 17 ++++- > hwcert/hardwarecertification.py | 149 +++++++++++++++++++++++++++------------- > hwcert/hardwaretest.py | 18 ++--- > hwcert/testdocument.py | 8 ++- > 8 files changed, 174 insertions(+), 72 deletions(-) > >diff --git a/Makefile b/Makefile >index 2ed7ec1..6559445 100644 >--- a/Makefile >+++ b/Makefile >@@ -14,7 +14,7 @@ > # Author: Greg Nichols > > HWCERT_VERSION := 1.6.4 >-HWCERT_RELEASE := 33 >+HWCERT_RELEASE := 34 > HWCERT_VERSION_RELEASE := $(HWCERT_VERSION)-$(HWCERT_RELEASE) > HWCERT_VERSION_PY := hwcert/version.py > HWCERT_RHEL_VERSION := 6 >diff --git a/hwcert-client.spec.in b/hwcert-client.spec.in >index 63133e9..0c3803a 100644 >--- a/hwcert-client.spec.in >+++ b/hwcert-client.spec.in >@@ -81,7 +81,7 @@ DESTDIR=$RPM_BUILD_ROOT make HWCERT_RHEL_VERSION=%{rhel_version} install > %changelog > * Tue Mar 19 2013 Greg Nichols <gnichols@redhat.com> > >-hwcert-client 1.6.4 R33 >+hwcert-client 1.6.4 R34 > > 921240 - FEAT: address prompting quirks from 'hwcert' command refactoring > >diff --git a/hwcert/certificationtest.py b/hwcert/certificationtest.py >index 25dc35b..f7b28bb 100644 >--- a/hwcert/certificationtest.py >+++ b/hwcert/certificationtest.py >@@ -27,18 +27,17 @@ import version > class CertificationDocument(DocumentBase): > """ CertificationDocument represents the certification in progress on the SUT """ > >- > def __init__(self, topElement=None, document=None, debugging=False): > DocumentBase.__init__(self) > self.element = topElement > self.document = document > self.Debugging = debugging >- >+ > def new(self): > self._new(topElement=Tags.certification_test, stylesheet="/hwcert/css/results.css") > hardwareElement = self.findOrCreateElement(self.document.documentElement, Tags.hardware) > certificationElement = self.findOrCreateElement(self.document.documentElement, Tags.certification) >- >+ > def copy(self, original): > self._new(topElement=Tags.certification_test, stylesheet="/hwcert/css/results.css") > self.element = self.findOrCreateElement(self.document, Tags.certification_test) >@@ -46,8 +45,11 @@ class CertificationDocument(DocumentBase): > self.element.appendChild(hardware) > certification = self.document.importNode(original.findOrCreateElement(original.document.documentElement, Tags.certification), True) > self.element.appendChild(certification) >- >- >+ >+ def copyTestRunSummaries(self, original): >+ # copy device classes and tests, but skip logging >+ self.partialCopyTree(original.document.documentElement, self.element, [Tags.device_class, Tags.test, Tags.run, Tags.summary]) >+ > def setHardware(self, tag, value): > hardwareElement = self.findOrCreateElement(self.document.documentElement, Tags.hardware) > element = self.findOrCreateElement(hardwareElement, tag) >@@ -477,11 +479,17 @@ class ResultsDocument(CertificationDocument): > filename += "-%s" % self.timeStringToTimestamp(runTime) > filename += ".xml" > return filename >-if __name__ == "__main__": >- doc = ResultsDocument() >- doc.load("/var/hwcert/results.xml") >- doc.deleteAttachments() >- doc.save("test.xml") >- print "done" >- > >+def unitTest(): >+ results = ResultsDocument() >+ results.load("/var/hwcert/results.xml") >+ print "loaded results" >+ certification = CertificationDocument() >+ certification.copy(results) >+ certification.copyTestRunSummaries(results) >+ print "copied" >+ certification.save("qq.xml") >+ >+if __name__ == "__main__": >+ unitTest() >+ print "saved qq.xml" >diff --git a/hwcert/deviceclassdocument.py b/hwcert/deviceclassdocument.py >index 0872d21..c632ba2 100644 >--- a/hwcert/deviceclassdocument.py >+++ b/hwcert/deviceclassdocument.py >@@ -76,8 +76,22 @@ class DeviceClassDocument(DocumentWrapper): > if test.getName() == testName and (not udi or udi == test.getUDI()): > return test > return None >- >- >+ >+ def getTest(self, otherTest): >+ bestMatchScore = 0 >+ bestMatch = None >+ for test in self.getTests(): >+ matchScore = 0 >+ if test.getName() == otherTest.getName(): >+ if otherTest.getUDI() == test.getUDI(): >+ matchScore = 2 >+ if otherTest.getLogicalDeviceName() == test.getLogicalDeviceName(): >+ matchScore += 1 >+ if matchScore > bestMatchScore: >+ bestMatch = test >+ bestMatchScore = matchScore >+ return bestMatch >+ > def getTests(self, names="", onlyFailures=False, recursive=False): > tests = list() > if recursive: >diff --git a/hwcert/documentbase.py b/hwcert/documentbase.py >index 73cc1b6..b833dfd 100644 >--- a/hwcert/documentbase.py >+++ b/hwcert/documentbase.py >@@ -225,7 +225,22 @@ class DocumentWrapper: > if tag: > tags.append(tag.data) > return tags >- >+ >+ def partialCopyTree(self, sourceElement, destinationElement, tagList, indent=""): >+ """ copies xml based on a list of tag names, one tag per level >+ example call: >+ self.partialCopyTree(original.document.documentElement, self.element, >+ [Tags.device_class, Tags.test, Tags.run, Tags.summary]) >+ """ >+ for originalElement in sourceElement.getElementsByTagName(tagList[0]): >+ newElement = self.document.importNode(originalElement, False) # False = shallow copy >+ destinationElement.appendChild(newElement) >+ textNode = self.getTextNode(originalElement) >+ if textNode and not textNode.data.isspace(): >+ newElement.appendChild( self.document.createTextNode(textNode.data)) >+ if len(tagList) > 1: >+ self.partialCopyTree(originalElement, newElement, tagList[1:], indent=indent+" ") >+ > class DocumentBase(DocumentWrapper): > > def __init__(self): >diff --git a/hwcert/hardwarecertification.py b/hwcert/hardwarecertification.py >index 1f72e75..07a96d8 100644 >--- a/hwcert/hardwarecertification.py >+++ b/hwcert/hardwarecertification.py >@@ -20,6 +20,7 @@ from optparse import OptionParser > from controller import Controller > from hardwaretest import HardwareTestHarness > from resultsengine import ResultsEngine >+from certificationtest import ResultsDocument > > class HardwareCertification(HardwareTestHarness): > >@@ -28,47 +29,44 @@ class HardwareCertification(HardwareTestHarness): > HardwareTestHarness.__init__(self) > > def run(self): >- print "The Red Had Hardware Certification Test Suite" >+ print "The Red Hat Hardware Certification Test Suite" > if not self.getLock(): > return False >- print "\nPreparing for certification" >- sys.stdout.flush() > > while True: >- self.load() >- if self.testResultsReady(): >- self.submitOrSaveResults() >+ self.submitOrSaveResults() > >- if not self.ui.promptConfirm("Would you like to continue certification testing?"): >- break >- if not self.doCertify(): >+ if not self.certify(): > break > self.releaseLock() >- > return True > >- def testResultsReady(self): >- return self.certification and self.certification.getNumberOfTestRuns() > 0 >- > def submitOrSaveResults(self): >+ self.load() >+ if not self.certification or self.certification.getNumberOfTestRuns() == 0: >+ return >+ >+ # otherwise > if self.catalog.isReachable(): > (submitted, success) = self.catalog.submit(self.certification) > if success and submitted: >- self.removeLogFiles() >+ self.clean() > return True > > if self.doSave(): >- self.removeLogFiles() >+ self.saveResultsToCertificationDoc() >+ self.clean() > return True > > # otherwise > return False > >- def doCertify(self): >+ def certify(self): > """ run only tests needed for certification """ > > if not self.doPlan(): > return False >+ self.disablePassedTests() > > engine = ResultsEngine(self.certification) > tests = engine.getRemainingTests(self.catalog) >@@ -88,40 +86,16 @@ class HardwareCertification(HardwareTestHarness): > print "\nThe following tests are recommended to complete the certification:" > > # test enable/disable loop >- abort = False > while True: >- for test in tests: >- marked = "[ ]" >- if test.getMandatory(): >- marked = " " >- if test.isDisabled(): >- marked = "[X]" >- print "%s %-10s %-10s %-36s" % (marked, test.getName(), test.getLogicalDeviceName(), test.getShortUDI()) >- >- if self.ui.promptConfirm("Ready to begin testing?"): >- break >+ self.showTests(tests) >+ answer = self.ui.prompt("Ready to begin testing?", ["yes", "edit", "quit"]) > >- if not self.ui.promptConfirm("Would you like to enable or disable tests?"): >- abort = True >+ if answer[0] == "q": >+ return False >+ if answer[0] == "y": > break > >- for test in tests: >- if test.getMandatory(): >- continue >- action = "Disable" >- if test.isDisabled(): >- action = "Enable" >- action += " %s test" % test.getName() >- if test.getLogicalDeviceName(): >- action += " on %s" % test.getLogicalDeviceName() >- if self.ui.promptConfirm(action + "?"): >- test.setDisabled(not test.isDisabled()) >- # pause here >- time.sleep(2) >- print "" >- >- if abort: >- return False >+ self.editTests(tests) > > verified = self.verify(tests) > if not verified and not self.ui.promptConfirm("Verification failed, would you like to continue testing?"): >@@ -130,3 +104,86 @@ class HardwareCertification(HardwareTestHarness): > # otherwise > self._doRun(tests) > return True >+ >+ def showTests(self, tests): >+ lineNumber = 1 >+ for test in tests: >+ marked = "->" >+ if test.getMandatory(): >+ marked = "<>" >+ if test.isDisabled(): >+ marked = " " >+ print "%2u %s %-10s %-10s %-36s" % (lineNumber, marked, test.getName(), test.getLogicalDeviceName(), test.getShortUDI()) >+ lineNumber += 1 >+ >+ def editTests(self, tests): >+ while True: >+ os.system("clear") >+ self.showTests(tests) >+ answer = self.ui.prompt("Test Selection (<number>|<name(s)>|select all|remove all|done): ") >+ if answer == "done": >+ return >+ try: >+ number = int(answer) >+ except: >+ number = 0 >+ >+ if number > 0 and number <= len(tests): >+ if not self.checkMandatory(tests[number-1]): >+ tests[number-1].setDisabled(not tests[number-1].isDisabled()) >+ continue >+ >+ if answer == "select all" or answer == "remove all": >+ for test in tests: >+ if not self.checkMandatory(test, silent=True): >+ test.setDisabled(answer == "remove all") >+ continue >+ >+ # otherwise, names? >+ names = answer.split(" ") >+ for name in names: >+ found = False >+ for test in tests: >+ if test.getName() == name.strip(", "): >+ if not self.checkMandatory(test): >+ test.setDisabled(not test.isDisabled()) >+ found = True >+ if not found: >+ print "Test name %s not found." % name.strip(", ") >+ # pause here >+ time.sleep(2) >+ >+ def checkMandatory(self, test, silent=False): >+ if test.getMandatory(): >+ if not silent: >+ print "Mandatory test %s can not be disabled" % test.getName() >+ # pause here >+ time.sleep(2) >+ return True >+ return False >+ >+ def saveResultsToCertificationDoc(self): >+ # saving full results.xml to certification.xml >+ self.certification.save(self.environment.getCertificationPath()) >+ >+ def disablePassedTests(self): >+ """ read any test run summaries from certification.xml and disable tests in results.xml """ >+ # read certification.xml as a results doc to get all the old test run info. >+ certificationDocument = ResultsDocument() >+ certificationDocument.load(self.environment.getCertificationPath()) >+ for oldTest in certificationDocument.getTests(): >+ print "old test: %s" % oldTest.getName() >+ if oldTest.getMandatory(): >+ continue >+ if oldTest.hasPassed() or oldTest.isDisabled(): >+ test = self.certification.getDeviceClass(oldTest.getDeviceClassName()).getTest(oldTest) >+ if test: >+ "new test: %s" % test.getName() >+ if oldTest.hasPassed(): >+ print " PASS" >+ test.setDisabled(True) >+ elif oldTest.isDisabled(): >+ test.setDisabled(True) >+ print " disabled" >+ else: >+ print " -" >diff --git a/hwcert/hardwaretest.py b/hwcert/hardwaretest.py >index e9a0824..77b6d35 100644 >--- a/hwcert/hardwaretest.py >+++ b/hwcert/hardwaretest.py >@@ -55,6 +55,7 @@ class HardwareTestHarness(Controller): > self.getOptions() > Controller.__init__(self, self.options.debug) > self.environment = Environment() >+ self.makeDirectoryPath(self.environment.getDataDirectory()) > self.testServer = self.options.server > self.Debugging = self.options.debug != Constants.off > self.debugLevel = self.options.debug # "off", "low", "medium", or 'high' >@@ -184,7 +185,6 @@ class HardwareTestHarness(Controller): > > if not self.getLock(): > return False >- self.makeDirectoryPath(self.environment.getDataDirectory()) > > result = False > # do the command >@@ -986,7 +986,7 @@ class HardwareTestHarness(Controller): > if self.catalog.isReachable() and self.options.mode != Constants.auto: > (submitted, success) = self.catalog.submit(self.certification) > if success and submitted and self.ui.promptConfirm("Would you like to clean current test results from this system?"): >- self.removeLogFiles() >+ self.clean() > > # otherwise > return True >@@ -1061,9 +1061,9 @@ class HardwareTestHarness(Controller): > > > if self.ui.promptConfirm("Are you sure you want to delete all test results?"): >- self.removeLogFiles() >+ self.clean() > if subcommand == Constants.all and self.ui.promptConfirm("Also remove certification data?"): >- self.removeCertificationFiles() >+ self.cleanAll() > return True > > >@@ -1335,16 +1335,18 @@ class HardwareTestHarness(Controller): > return time.gmtime(time.time()) > > # YK: to remove HwCert log files after the result rpm is generated >- def removeLogFiles(self): >+ def clean(self): > # is the rug going to be pulled out from under us? > if self.environment.getLogDirectory() in os.getcwd(): > os.chdir("/var/log") >- print "removing HwCert logs ..." >+ if self.debugLevel != Constants.off: >+ print "removing HwCert logs ..." > os.system("rm -rf %s" % self.environment.getLogDirectory()) >- print "removing HwCert results..." >+ if self.debugLevel != Constants.off: >+ print "removing HwCert results..." > os.system("rm -f %s" % self.environment.getResultsPath()) > >- def removeCertificationFiles(self): >+ def cleanAll(self): > os.system("rm -f %s" % self.environment.getCertificationPath()) > > def getLock(self): >diff --git a/hwcert/testdocument.py b/hwcert/testdocument.py >index 9668360..bcdf608 100644 >--- a/hwcert/testdocument.py >+++ b/hwcert/testdocument.py >@@ -212,7 +212,13 @@ class TestDocument(DocumentWrapper): > if run.wasRun() and run.getSummary() == Constants.FAIL: > return True > return False >- >+ >+ def hasPassed(self): >+ for run in self.getRuns(): >+ if run.wasRun() and run.getSummary() == Constants.PASS: >+ return True >+ return False >+ > def appendRuns(self, originalTest): > for originalRun in originalTest.getRuns(): > run = self.getRun(originalRun.getNumber()) >-- >1.8.1.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 921240
:
712653
| 713881 |
714697
|
716615