예제 #1
0
    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
예제 #2
0
파일: tdSelfTest3.py 프로젝트: mcenirm/vbox
    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;
예제 #3
0
    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;
예제 #4
0
    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;
예제 #5
0
파일: reporter.py 프로젝트: mcenirm/vbox
    def __init__(self):
        ReporterBase.__init__(self);
        self.oLogFile   = None;
        self.oXmlFile   = None;
        self.fXmlOk     = True;
        self.iSubXml    = 0;
        self.iOtherFile = 0;
        self.fnGetIsoTimestamp  = utils.getIsoTimestamp;    # Hack to get a timestamp in __del__.
        self.oStdErr            = sys.stderr;               # Hack for __del__ output.

        #
        # Figure the main log directory.
        #
        try:
            import user;
            self.sDefLogDir = os.path.abspath(os.path.join(user.home, "VBoxTestLogs"));
        except:
            self.sDefLogDir = os.path.abspath("VBoxTestLogs");
        try:
            sLogDir = os.path.abspath(os.environ.get('TESTBOX_REPORTER_LOG_DIR', self.sDefLogDir));
            if not os.path.isdir(sLogDir):
                os.makedirs(sLogDir, 0750);
        except:
            sLogDir = self.sDefLogDir;
            if not os.path.isdir(sLogDir):
                os.makedirs(sLogDir, 0750);

        #
        # Make a subdirectory for this test run.
        #
        sTs = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H-%M-%S.log');
        self.sLogDir = sLogDir = os.path.join(sLogDir, '%s-%s' % (sTs, self.sName));
        try:
            os.makedirs(self.sLogDir, 0750);
        except:
            self.sLogDir = '%s-%s' % (self.sLogDir, os.getpid());
            os.makedirs(self.sLogDir, 0750);

        #
        # Open the log file and write a header.
        #
        sLogName = os.path.join(self.sLogDir, 'testsuite.log');
        sTsIso = utils.getIsoTimestamp();
        self.oLogFile = utils.openNoInherit(sLogName, "w");
        self.oLogFile.write(('Created log file at %s.\nRunning: %s' % (sTsIso, sys.argv)).encode('utf-8'));

        #
        # Open the xml log file and write the mandatory introduction.
        #
        # Note! This is done here and not in the base class because the remote
        #       logger doesn't really need this.  It doesn't need the outer
        #       test wrapper either.
        #
        sXmlName = os.path.join(self.sLogDir, 'testsuite.xml');
        self.oXmlFile = utils.openNoInherit(sXmlName, "w");
        self._xmlWrite([ '<?xml version="1.0" encoding="UTF-8" ?>',
                         '<Test timestamp="%s" name="%s">' % (sTsIso, self._xmlEscAttr(self.sName),), ],
                       fIndent = False);
예제 #6
0
파일: reporter.py 프로젝트: mcenirm/vbox
 def subXmlStart(self, oFileWrapper):
     # Open a new file and just include it from the main XML.
     iSubXml = self.iSubXml;
     self.iSubXml += 1;
     sSubXmlName = os.path.join(self.sLogDir, 'sub-%d.xml' % (iSubXml,));
     try:
         oFileWrapper.oSubXmlFile = utils.openNoInherit(sSubXmlName, "w");
     except:
         errorXcpt('open(%s)' % oFileWrapper.oSubXmlName);
         oFileWrapper.oSubXmlFile = None;
     else:
         self._xmlWrite('<Include timestamp="%s" filename="%s"/>\n'
                 % (utils.getIsoTimestamp(), self._xmlEscAttr(os.path.basename(sSubXmlName))));
     return None;
예제 #7
0
 def subXmlStart(self, oFileWrapper):
     # Open a new file and just include it from the main XML.
     iSubXml = self.iSubXml
     self.iSubXml += 1
     sSubXmlName = os.path.join(self.sLogDir, 'sub-%d.xml' % (iSubXml, ))
     try:
         oFileWrapper.oSubXmlFile = utils.openNoInherit(sSubXmlName, "w")
     except:
         errorXcpt('open(%s)' % oFileWrapper.oSubXmlName)
         oFileWrapper.oSubXmlFile = None
     else:
         self._xmlWrite('<Include timestamp="%s" filename="%s"/>\n' %
                        (utils.getIsoTimestamp(),
                         self._xmlEscAttr(os.path.basename(sSubXmlName))))
     return None
예제 #8
0
파일: reporter.py 프로젝트: mcenirm/vbox
                    self.log(0, 'error reading %s: %s' % (sSrcFilename, oXcpt), sCaller, sTsPrf);
                else:
                    try:
                        oDstFile.write(abBuf);
                    except Exception, oXcpt:
                        fRc = False;
                        self.log(0, 'error writing %s: %s' % (sDstFilename, oXcpt), sCaller, sTsPrf);
                    else:
                        if len(abBuf) > 0:
                            continue;
                break;
            oDstFile.close();

            # Leave a mark in the XML log.
            self._xmlWrite('<LogFile timestamp="%s" filename="%s" source="%s" kind="%s" ok="%s">%s</LogFile>\n'
                % (utils.getIsoTimestamp(), self._xmlEscAttr(os.path.basename(sDstFilename)), self._xmlEscAttr(sSrcFilename), \
                   self._xmlEscAttr(sKind), fRc, self._xmlEscAttr(sDescription)) );
        _ = sAltName;
        return fRc;

    def subXmlStart(self, oFileWrapper):
        # Open a new file and just include it from the main XML.
        iSubXml = self.iSubXml;
        self.iSubXml += 1;
        sSubXmlName = os.path.join(self.sLogDir, 'sub-%d.xml' % (iSubXml,));
        try:
            oFileWrapper.oSubXmlFile = utils.openNoInherit(sSubXmlName, "w");
        except:
            errorXcpt('open(%s)' % oFileWrapper.oSubXmlName);
            oFileWrapper.oSubXmlFile = None;
        else:
예제 #9
0
    def __init__(self):
        ReporterBase.__init__(self)
        self.oLogFile = None
        self.oXmlFile = None
        self.fXmlOk = True
        self.iSubXml = 0
        self.iOtherFile = 0
        self.fnGetIsoTimestamp = utils.getIsoTimestamp
        # Hack to get a timestamp in __del__.
        self.oStdErr = sys.stderr
        # Hack for __del__ output.

        #
        # Figure the main log directory.
        #
        try:
            import user
            self.sDefLogDir = os.path.abspath(
                os.path.join(user.home, "VBoxTestLogs"))
        except:
            self.sDefLogDir = os.path.abspath("VBoxTestLogs")
        try:
            sLogDir = os.path.abspath(
                os.environ.get('TESTBOX_REPORTER_LOG_DIR', self.sDefLogDir))
            if not os.path.isdir(sLogDir):
                os.makedirs(sLogDir, 0750)
        except:
            sLogDir = self.sDefLogDir
            if not os.path.isdir(sLogDir):
                os.makedirs(sLogDir, 0750)

        #
        # Make a subdirectory for this test run.
        #
        sTs = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H-%M-%S.log')
        self.sLogDir = sLogDir = os.path.join(sLogDir,
                                              '%s-%s' % (sTs, self.sName))
        try:
            os.makedirs(self.sLogDir, 0750)
        except:
            self.sLogDir = '%s-%s' % (self.sLogDir, os.getpid())
            os.makedirs(self.sLogDir, 0750)

        #
        # Open the log file and write a header.
        #
        sLogName = os.path.join(self.sLogDir, 'testsuite.log')
        sTsIso = utils.getIsoTimestamp()
        self.oLogFile = utils.openNoInherit(sLogName, "w")
        self.oLogFile.write(('Created log file at %s.\nRunning: %s' %
                             (sTsIso, sys.argv)).encode('utf-8'))

        #
        # Open the xml log file and write the mandatory introduction.
        #
        # Note! This is done here and not in the base class because the remote
        #       logger doesn't really need this.  It doesn't need the outer
        #       test wrapper either.
        #
        sXmlName = os.path.join(self.sLogDir, 'testsuite.xml')
        self.oXmlFile = utils.openNoInherit(sXmlName, "w")
        self._xmlWrite([
            '<?xml version="1.0" encoding="UTF-8" ?>',
            '<Test timestamp="%s" name="%s">' % (
                sTsIso,
                self._xmlEscAttr(self.sName),
            ),
        ],
                       fIndent=False)
예제 #10
0
                    try:
                        oDstFile.write(abBuf)
                    except Exception, oXcpt:
                        fRc = False
                        self.log(
                            0, 'error writing %s: %s' % (sDstFilename, oXcpt),
                            sCaller, sTsPrf)
                    else:
                        if len(abBuf) > 0:
                            continue
                break
            oDstFile.close()

            # Leave a mark in the XML log.
            self._xmlWrite('<LogFile timestamp="%s" filename="%s" source="%s" kind="%s" ok="%s">%s</LogFile>\n'
                % (utils.getIsoTimestamp(), self._xmlEscAttr(os.path.basename(sDstFilename)), self._xmlEscAttr(sSrcFilename), \
                   self._xmlEscAttr(sKind), fRc, self._xmlEscAttr(sDescription)) )
        _ = sAltName
        return fRc

    def subXmlStart(self, oFileWrapper):
        # Open a new file and just include it from the main XML.
        iSubXml = self.iSubXml
        self.iSubXml += 1
        sSubXmlName = os.path.join(self.sLogDir, 'sub-%d.xml' % (iSubXml, ))
        try:
            oFileWrapper.oSubXmlFile = utils.openNoInherit(sSubXmlName, "w")
        except:
            errorXcpt('open(%s)' % oFileWrapper.oSubXmlName)
            oFileWrapper.oSubXmlFile = None
        else: