def actionExecute(self): # Testing PushHint/PopHint. reporter.testStart('Negative XML #1') oSubXmlFile = reporter.FileWrapperTestPipe() oSubXmlFile.write('<Test timestamp="%s" name="foobar3">\n\n\t\n\r\n' % (utils.getIsoTimestamp(), )) oSubXmlFile.write('<Test timestamp="%s" name="sub3">' % (utils.getIsoTimestamp(), )) oSubXmlFile.write('<Test timestamp="%s" name="subsub1">' % (utils.getIsoTimestamp(), )) oSubXmlFile.close() reporter.testDone() # Missing end, like we had with IRPT at one time. reporter.testStart('Negative XML #2 (IPRT)') oSubXmlFile = reporter.FileWrapperTestPipe() oSubXmlFile.write(""" <?xml version="1.0" encoding="UTF-8" ?> <Test timestamp="2013-05-29T08:59:05.930602000Z" name="tstRTGetOpt"> <Test timestamp="2013-05-29T08:59:05.930656000Z" name="Basics"> <Passed timestamp="2013-05-29T08:59:05.930756000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.930995000Z" name="RTGetOpt - IPv4"> <Passed timestamp="2013-05-29T08:59:05.931036000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931161000Z" name="RTGetOpt - MAC Address"> <Passed timestamp="2013-05-29T08:59:05.931194000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931313000Z" name="RTGetOpt - Option w/ Index"> <Passed timestamp="2013-05-29T08:59:05.931357000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931475000Z" name="RTGetOptFetchValue"> <Passed timestamp="2013-05-29T08:59:05.931516000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931640000Z" name="RTGetOpt - bool on/off"> <Passed timestamp="2013-05-29T08:59:05.931687000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931807000Z" name="Standard options"> <Passed timestamp="2013-05-29T08:59:05.931843000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931963000Z" name="Options first"> <Passed timestamp="2013-05-29T08:59:05.932035000Z"/> </Test> """) oSubXmlFile.close() oSubXmlFile = None reporter.testDone() # The use of testFailure. reporter.testStart('Using testFailure()') reporter.testValue('value-name3', 12345678, 'times') reporter.testFailure('failure detail message') reporter.testDone() return True
def actionExecute(self): # Testing PushHint/PopHint. reporter.testStart('Negative XML #1'); oSubXmlFile = reporter.FileWrapperTestPipe(); oSubXmlFile.write('<Test timestamp="%s" name="foobar3">\n\n\t\n\r\n' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('<Test timestamp="%s" name="sub3">' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('<Test timestamp="%s" name="subsub1">' % (utils.getIsoTimestamp(),)); oSubXmlFile.close(); reporter.testDone(); # Missing end, like we had with IRPT at one time. reporter.testStart('Negative XML #2 (IPRT)'); oSubXmlFile = reporter.FileWrapperTestPipe(); oSubXmlFile.write(""" <?xml version="1.0" encoding="UTF-8" ?> <Test timestamp="2013-05-29T08:59:05.930602000Z" name="tstRTGetOpt"> <Test timestamp="2013-05-29T08:59:05.930656000Z" name="Basics"> <Passed timestamp="2013-05-29T08:59:05.930756000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.930995000Z" name="RTGetOpt - IPv4"> <Passed timestamp="2013-05-29T08:59:05.931036000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931161000Z" name="RTGetOpt - MAC Address"> <Passed timestamp="2013-05-29T08:59:05.931194000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931313000Z" name="RTGetOpt - Option w/ Index"> <Passed timestamp="2013-05-29T08:59:05.931357000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931475000Z" name="RTGetOptFetchValue"> <Passed timestamp="2013-05-29T08:59:05.931516000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931640000Z" name="RTGetOpt - bool on/off"> <Passed timestamp="2013-05-29T08:59:05.931687000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931807000Z" name="Standard options"> <Passed timestamp="2013-05-29T08:59:05.931843000Z"/> </Test> <Test timestamp="2013-05-29T08:59:05.931963000Z" name="Options first"> <Passed timestamp="2013-05-29T08:59:05.932035000Z"/> </Test> """); oSubXmlFile.close(); oSubXmlFile = None; reporter.testDone(); # The use of testFailure. reporter.testStart('Using testFailure()'); reporter.testValue('value-name3', 12345678, 'times'); reporter.testFailure('failure detail message'); reporter.testDone(); return True;
def actionExecute(self): reporter.testStart('reporter.testXXXX API'); reporter.testValue('value-name1', 123456789, 'ms'); reporter.testStart('subtest'); reporter.testValue('value-name2', 11223344, 'times'); reporter.testDone(); reporter.testStart('subtest2'); reporter.testValue('value-name3', 39, 'sec'); reporter.testValue('value-name4', 42, 'ns'); reporter.testDone(); reporter.testStart('subtest3'); reporter.testDone(fSkipped = True); # No spaces in XML. reporter.testStart('subtest4'); oSubXmlFile = reporter.FileWrapperTestPipe(); oSubXmlFile.write('<?xml version="1.0" encoding="UTF-8" ?>'); oSubXmlFile.write('<Test timestamp="%s" name="foobar1">' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('<Test timestamp="%s" name="sub1">' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('<Passed timestamp="%s"/>' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('</Test>'); oSubXmlFile.write('<End timestamp="%s" errors="0"/>' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('</Test>'); oSubXmlFile.close(); oSubXmlFile = None; reporter.testDone(); # Spaces + funny line endings. reporter.testStart('subtest5'); oSubXmlFile = reporter.FileWrapperTestPipe(); oSubXmlFile.write('<?xml version="1.0" encoding="UTF-8" ?>\r\n'); oSubXmlFile.write('<Test timestamp="%s" name="foobar2">\n\n\t\n\r\n' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('<Test timestamp="%s" name="sub2">' % (utils.getIsoTimestamp(),)); oSubXmlFile.write(' <Passed timestamp="%s"/>\n' % (utils.getIsoTimestamp(),)); oSubXmlFile.write(' </Test>\n'); oSubXmlFile.write(' <End timestamp="%s" errors="0"/>\r' % (utils.getIsoTimestamp(),)); oSubXmlFile.write('</Test>'); oSubXmlFile.close(); reporter.testDone(); # A few long log times for WUI log testing. reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \ 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \ 'asdlkfj aljkasdflkj alkjdsf lakjsdf'); reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \ 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \ 'asdlkfj aljkasdflkj alkjdsf lakjsdf'); reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \ 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \ 'asdlkfj aljkasdflkj alkjdsf lakjsdf'); # Upload a file. reporter.addLogFile(__file__, sKind = 'log/release/vm'); reporter.testDone(); return True;
def reportResult(self): """ Reports the test results to the test manager. """ fRc = True if self.sResult is not None: try: asLines = self.sResult.splitlines() for sLine in asLines: sLine = sLine.strip() if sLine.startswith('Children') is True: # Extract the value idxValue = sLine.rfind('=') if idxValue is -1: raise Exception('IozoneTest: Invalid state') idxValue += 1 while sLine[idxValue] == ' ': idxValue += 1 # Get the reported value, cut off after the decimal point # it is not supported by the testmanager yet and is not really # relevant anyway. idxValueEnd = idxValue while sLine[idxValueEnd].isdigit(): idxValueEnd += 1 for sNeedle, sTestVal in self.lstTests: if sLine.rfind(sNeedle) is not -1: reporter.testValue( sTestVal, sLine[idxValue:idxValueEnd], constants.valueunit.g_asNames[ constants.valueunit.KILOBYTES_PER_SEC]) break except: fRc = False else: fRc = False return fRc
def actionExecute(self): # Too many immediate sub-tests. if self.sOptWhich == 'immediate-sub-tests': reporter.testStart('Too many immediate sub-tests (negative)') for i in range(1024): reporter.testStart('subsub%d' % i) reporter.testDone() # Too many sub-tests in total. elif self.sOptWhich == 'total-sub-tests': reporter.testStart('Too many sub-tests (negative)') # 32 * 256 = 2^(5+8) = 2^13 = 8192. for i in range(32): reporter.testStart('subsub%d' % i) for j in range(256): reporter.testStart('subsubsub%d' % j) reporter.testDone() reporter.testDone() # Too many immediate values. elif self.sOptWhich == 'immediate-values': reporter.testStart('Too many immediate values (negative)') for i in range(512): reporter.testValue('value%d' % i, i, 'times') # Too many values in total. elif self.sOptWhich == 'total-values': reporter.testStart('Too many sub-tests (negative)') for i in range(256): reporter.testStart('subsub%d' % i) for j in range(64): reporter.testValue('value%d' % j, i * 10000 + j, 'times') reporter.testDone() # Too many failure reasons (only immediate since the limit is extremely low). elif self.sOptWhich == 'immediate-messages': reporter.testStart('Too many immediate messages (negative)') for i in range(16): reporter.testFailure('Detail %d' % i) else: reporter.testStart('Unknown test %s' % (self.sOptWhich, )) reporter.error('Invalid test selected: %s' % (self.sOptWhich, )) reporter.testDone() return True
def actionExecute(self): # Too many immediate sub-tests. if self.sOptWhich == 'immediate-sub-tests': reporter.testStart('Too many immediate sub-tests (negative)'); for i in range(1024): reporter.testStart('subsub%d' % i); reporter.testDone(); # Too many sub-tests in total. elif self.sOptWhich == 'total-sub-tests': reporter.testStart('Too many sub-tests (negative)'); # 32 * 256 = 2^(5+8) = 2^13 = 8192. for i in range(32): reporter.testStart('subsub%d' % i); for j in range(256): reporter.testStart('subsubsub%d' % j); reporter.testDone(); reporter.testDone(); # Too many immediate values. elif self.sOptWhich == 'immediate-values': reporter.testStart('Too many immediate values (negative)'); for i in range(512): reporter.testValue('value%d' % i, i, 'times'); # Too many values in total. elif self.sOptWhich == 'total-values': reporter.testStart('Too many sub-tests (negative)'); for i in range(256): reporter.testStart('subsub%d' % i); for j in range(64): reporter.testValue('value%d' % j, i * 10000 + j, 'times'); reporter.testDone(); # Too many failure reasons (only immediate since the limit is extremely low). elif self.sOptWhich == 'immediate-messages': reporter.testStart('Too many immediate messages (negative)'); for i in range(16): reporter.testFailure('Detail %d' % i); else: reporter.testStart('Unknown test %s' % (self.sOptWhich,)); reporter.error('Invalid test selected: %s' % (self.sOptWhich,)); reporter.testDone(); return True;
def reportResult(self): """ Reports the test results to the test manager. """ fRc = True; if self.sResult is not None: try: asLines = self.sResult.splitlines(); for sLine in asLines: sLine = sLine.strip(); if sLine.startswith('Children') is True: # Extract the value idxValue = sLine.rfind('='); if idxValue is -1: raise Exception('IozoneTest: Invalid state'); idxValue += 1; while sLine[idxValue] == ' ': idxValue += 1; # Get the reported value, cut off after the decimal point # it is not supported by the testmanager yet and is not really # relevant anyway. idxValueEnd = idxValue; while sLine[idxValueEnd].isdigit(): idxValueEnd += 1; for sNeedle, sTestVal in self.lstTests: if sLine.rfind(sNeedle) is not -1: reporter.testValue(sTestVal, sLine[idxValue:idxValueEnd], constants.valueunit.g_asNames[constants.valueunit.KILOBYTES_PER_SEC]); break; except: fRc = False; else: fRc = False; return fRc;