示例#1
0
    def _installVBoxOnWindows(self):
        """ Installs VBox on Windows."""
        sExe = self._findFile('^VirtualBox-.*-(MultiArch|Win).exe$')
        if sExe is None:
            return False

        # Uninstall any previous vbox version first.
        fRc = self._uninstallVBoxOnWindows()
        if fRc is not True:
            return None
            # There shouldn't be anything to uninstall, and if there is, it's not our fault.

        # Install the new one.
        asArgs = [sExe, '-vvvv', '--silent', '--logging']
        asArgs.extend(['--msiparams', 'REBOOT=ReallySuppress'])
        sVBoxInstallPath = os.environ.get('VBOX_INSTALL_PATH', None)
        if sVBoxInstallPath is not None:
            asArgs.extend(['INSTALLDIR="%s"' % (sVBoxInstallPath, )])
        fRc2, iRc = self._sudoExecuteSync(asArgs)
        if fRc2 is False:
            if iRc == 3010:  # ERROR_SUCCESS_REBOOT_REQUIRED
                reporter.log(
                    'Note: Installer required a reboot to complete installation'
                )
                # Optional, don't fail.
            else:
                fRc = False
        sLogFile = os.path.join(tempfile.gettempdir(), 'VirtualBox',
                                'VBoxInstallLog.txt')
        if      sLogFile is not None \
            and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/installer',
                                "Verbose MSI installation log file")
        self._waitForTestManagerConnectivity(30)
        return fRc
示例#2
0
    def _installVBoxOnWindows(self):
        """ Installs VBox on Windows."""
        sExe = self._findFile('^VirtualBox-.*-(MultiArch|Win).exe$')
        if sExe is None:
            return False

        # TEMPORARY HACK - START
        # It seems that running the NDIS cleanup script upon uninstallation is not
        # a good idea, so let's run it before installing VirtualBox.
        sHostName = socket.getfqdn()
        if    not sHostName.startswith('testboxwin3') \
          and not sHostName.startswith('testboxharp2') \
          and utils.getHostOsVersion() in ['8', '8.1', '9', '2008Server', '2008ServerR2', '2012Server']:
            reporter.log('Peforming extra NDIS cleanup...')
            sMagicScript = os.path.abspath(
                os.path.join(g_ksValidationKitDir, 'testdriver',
                             'win-vbox-net-uninstall.ps1'))
            fRc2, _ = self._sudoExecuteSync([
                'powershell.exe', '-Command',
                'set-executionpolicy unrestricted'
            ])
            if not fRc2:
                reporter.log('set-executionpolicy failed.')
            self._sudoExecuteSync(
                ['powershell.exe', '-Command', 'get-executionpolicy'])
            fRc2, _ = self._sudoExecuteSync(
                ['powershell.exe', '-File', sMagicScript])
            if not fRc2:
                reporter.log('NDIS cleanup failed.')
        # TEMPORARY HACK - END

        # Uninstall any previous vbox version first.
        fRc = self._uninstallVBoxOnWindows()
        if fRc is not True:
            return None
            # There shouldn't be anything to uninstall, and if there is, it's not our fault.

        # Install the new one.
        asArgs = [sExe, '-vvvv', '--silent', '--logging']
        asArgs.extend(['--msiparams', 'REBOOT=ReallySuppress'])
        sVBoxInstallPath = os.environ.get('VBOX_INSTALL_PATH', None)
        if sVBoxInstallPath is not None:
            asArgs.extend(['INSTALLDIR="%s"' % (sVBoxInstallPath, )])
        fRc2, iRc = self._sudoExecuteSync(asArgs)
        if fRc2 is False:
            if iRc == 3010:  # ERROR_SUCCESS_REBOOT_REQUIRED
                reporter.log(
                    'Note: Installer required a reboot to complete installation'
                )
                # Optional, don't fail.
            else:
                fRc = False
        sLogFile = os.path.join(tempfile.gettempdir(), 'VirtualBox',
                                'VBoxInstallLog.txt')
        if      sLogFile is not None \
            and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/installer',
                                "Verbose MSI installation log file")
        self._waitForTestManagerConnectivity(30)
        return fRc
    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;
    def _uninstallVBoxOnWindows(self):
        """
        Uninstalls VBox on Windows, all installations we find to be on the safe side...
        """

        import win32com.client; # pylint: disable=F0401
        win32com.client.gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0);
        oInstaller = win32com.client.Dispatch('WindowsInstaller.Installer',
                                              resultCLSID = '{000C1090-0000-0000-C000-000000000046}')

        # Search installed products for VirtualBox.
        asProdCodes = [];
        for sProdCode in oInstaller.Products:
            try:
                sProdName = oInstaller.ProductInfo(sProdCode, "ProductName");
            except:
                reporter.logXcpt();
                continue;
            #reporter.log('Info: %s=%s' % (sProdCode, sProdName));
            if  sProdName.startswith('Oracle VM VirtualBox') \
             or sProdName.startswith('Sun VirtualBox'):
                asProdCodes.append([sProdCode, sProdName]);

        # Before we start uninstalling anything, just ruthlessly kill any
        # msiexec process we might find hanging around.
        cKilled = 0;
        for oProcess in utils.processListAll():
            sBase = oProcess.getBaseImageNameNoExeSuff();
            if sBase is not None and sBase.lower() in [ 'msiexec', ]:
                reporter.log('Killing MSI process: %s (%s)' % (oProcess.iPid, sBase));
                utils.processKill(oProcess.iPid);
                cKilled += 1;
        if cKilled > 0:
            time.sleep(16); # fudge.

        # Do the uninstalling.
        fRc = True;
        sLogFile = os.path.join(self.sScratchPath, 'VBoxUninstallLog.txt');
        for sProdCode, sProdName in asProdCodes:
            reporter.log('Uninstalling %s (%s)...' % (sProdName, sProdCode));
            fRc2, iRc = self._sudoExecuteSync(['msiexec', '/uninstall', sProdCode, '/quiet', '/passive', '/norestart',
                                               '/L*v', '%s' % (sLogFile), ]);
            if fRc2 is False:
                if iRc == 3010: # ERROR_SUCCESS_REBOOT_REQUIRED
                    reporter.log('Note: Uninstaller required a reboot to complete uninstallation');
                    # Optional, don't fail.
                else:
                    fRc = False;
            reporter.addLogFile(sLogFile, 'log/uninstaller', "Verbose MSI uninstallation log file");

        self._waitForTestManagerConnectivity(30);
        if fRc is False and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/uninstaller');
        return fRc;
    def _installVBoxOnWindows(self):
        """ Installs VBox on Windows."""
        sExe = self._findFile('^VirtualBox-.*-(MultiArch|Win).exe$');
        if sExe is None:
            return False;

        # TEMPORARY HACK - START
        # It seems that running the NDIS cleanup script upon uninstallation is not
        # a good idea, so let's run it before installing VirtualBox.
        #sHostName = socket.getfqdn();
        #if    not sHostName.startswith('testboxwin3') \
        #  and not sHostName.startswith('testboxharp2') \
        #  and not sHostName.startswith('wei01-b6ka-3') \
        #  and utils.getHostOsVersion() in ['8', '8.1', '9', '2008Server', '2008ServerR2', '2012Server']:
        #    reporter.log('Peforming extra NDIS cleanup...');
        #    sMagicScript = os.path.abspath(os.path.join(g_ksValidationKitDir, 'testdriver', 'win-vbox-net-uninstall.ps1'));
        #    fRc2, _ = self._sudoExecuteSync(['powershell.exe', '-Command', 'set-executionpolicy unrestricted']);
        #    if not fRc2:
        #        reporter.log('set-executionpolicy failed.');
        #    self._sudoExecuteSync(['powershell.exe', '-Command', 'get-executionpolicy']);
        #    fRc2, _ = self._sudoExecuteSync(['powershell.exe', '-File', sMagicScript]);
        #    if not fRc2:
        #        reporter.log('NDIS cleanup failed.');
        # TEMPORARY HACK - END

        # Uninstall any previous vbox version first.
        fRc = self._uninstallVBoxOnWindows();
        if fRc is not True:
            return None; # There shouldn't be anything to uninstall, and if there is, it's not our fault.

        # Install the new one.
        asArgs = [sExe, '-vvvv', '--silent', '--logging'];
        asArgs.extend(['--msiparams', 'REBOOT=ReallySuppress']);
        sVBoxInstallPath = os.environ.get('VBOX_INSTALL_PATH', None);
        if sVBoxInstallPath is not None:
            asArgs.extend(['INSTALLDIR="%s"' % (sVBoxInstallPath,)]);
        fRc2, iRc = self._sudoExecuteSync(asArgs);
        if fRc2 is False:
            if iRc == 3010: # ERROR_SUCCESS_REBOOT_REQUIRED
                reporter.log('Note: Installer required a reboot to complete installation');
                # Optional, don't fail.
            else:
                fRc = False;
        sLogFile = os.path.join(tempfile.gettempdir(), 'VirtualBox', 'VBoxInstallLog.txt');
        if      sLogFile is not None \
            and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/installer', "Verbose MSI installation log file");
        self._waitForTestManagerConnectivity(30);
        return fRc;
示例#7
0
    def testUsbOneCfg(self, sVmName, sUsbCtrl, sSpeed, sUsbTest):
        """
        Runs the specified VM thru one specified test.

        Returns a success indicator on the general test execution. This is not
        the actual test result.
        """
        oVM = self.getVmByName(sVmName)

        # Reconfigure the VM
        fRc = True
        oSession = self.openSession(oVM)
        if oSession is not None:
            fRc = fRc and oSession.enableVirtEx(True)
            fRc = fRc and oSession.enableNestedPaging(True)

            # Make sure controllers are disabled initially.
            fRc = fRc and oSession.enableUsbOhci(False)
            fRc = fRc and oSession.enableUsbEhci(False)
            fRc = fRc and oSession.enableUsbXhci(False)

            if sUsbCtrl == 'OHCI':
                fRc = fRc and oSession.enableUsbOhci(True)
            elif sUsbCtrl == 'EHCI':
                fRc = fRc and oSession.enableUsbEhci(True)
            elif sUsbCtrl == 'XHCI':
                fRc = fRc and oSession.enableUsbXhci(True)
            fRc = fRc and oSession.saveSettings()
            fRc = oSession.close() and fRc and True
            # pychecker hack.
            oSession = None
        else:
            fRc = False

        # Start up.
        if fRc is True:
            self.logVmInfo(oVM)
            oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(
                sVmName, fCdWait=False, fNatForwardingForTxs=False)
            if oSession is not None:
                self.addTask(oSession)

                # Fudge factor - Allow the guest to finish starting up.
                self.sleep(5)

                sCaptureFile = None
                if self.fUsbCapture:
                    sCaptureFile = self.getCaptureFilePath(sUsbCtrl, sSpeed)

                if sUsbTest == 'Compliance':
                    fRc = self.testUsbCompliance(oSession, oTxsSession,
                                                 sUsbCtrl, sSpeed,
                                                 sCaptureFile)
                elif sUsbTest == 'Reattach':
                    fRc = self.testUsbReattach(oSession, oTxsSession, sUsbCtrl,
                                               sSpeed, sCaptureFile)

                # cleanup.
                self.removeTask(oTxsSession)
                self.terminateVmBySession(oSession)

                # Add the traffic dump if it exists and the test failed
                if reporter.testErrorCount() > 0 \
                   and sCaptureFile is not None \
                   and os.path.exists(sCaptureFile):
                    reporter.addLogFile(sCaptureFile, 'misc/other',
                                        'USB traffic dump')
            else:
                fRc = False
        return fRc
示例#8
0
    def runTests(self, oTestVm, oSession, oTxsSession, sDesc, sTag, asTests):
        """
        Runs one or more tests using VKAT on the host, which in turn will
        communicate with VKAT running on the guest and the Validation Kit
        audio driver ATS (Audio Testing Service).
        """
        _ = oTestVm, oSession, oTxsSession

        sPathTemp = self.sScratchPath
        sPathAudioOut = os.path.join(sPathTemp, 'vkat-host-out-%s' % (sTag))
        sPathAudioTemp = os.path.join(sPathTemp, 'vkat-host-temp-%s' % (sTag))

        reporter.log('Host audio test temp path is \"%s\"' % (sPathAudioOut))
        reporter.log('Host audio test output path is \"%s\"' %
                     (sPathAudioTemp))
        reporter.log('Host audio test tag is \"%s\"' % (sTag))

        reporter.testStart(sDesc)

        sVkatExe = self.getBinTool('vkat')

        reporter.log('Using VKAT on host at: \"%s\"' % (sVkatExe))

        # Build the base command line, exclude all tests by default.
        asArgs = [ sVkatExe, 'test', '--mode', 'host', '--probe-backends', \
                             '--tempdir', sPathAudioTemp, '--outdir', sPathAudioOut, '-a', \
                             '--tag', sTag, \
                             '--no-verify' ]
        # We do the verification separately in the step below.

        for _ in range(1, reporter.getVerbosity()
                       ):  # Verbosity always is initialized at 1.
            asArgs.extend(['-v'])

        if self.asVkatTestArgs:
            asArgs += self.asVkatTestArgs

        # ... and extend it with wanted tests.
        asArgs.extend(asTests)

        #
        # Let VKAT on the host run synchronously.
        #
        fRc = self.executeHst("VKAT Host", asArgs)

        reporter.testDone()

        if fRc:
            #
            # When running the test(s) above were successful, do the verification step next.
            # This gives us a bit more fine-grained test results in the test manager.
            #
            reporter.testStart('Verifying audio data')

            sNameSetHst = '%s-host.tar.gz' % (sTag)
            sPathSetHst = os.path.join(sPathAudioOut, sNameSetHst)
            sNameSetGst = '%s-guest.tar.gz' % (sTag)
            sPathSetGst = os.path.join(sPathAudioOut, sNameSetGst)

            asArgs = [sVkatExe, 'verify', sPathSetHst, sPathSetGst]

            for _ in range(1, reporter.getVerbosity()
                           ):  # Verbosity always is initialized at 1.
                asArgs.extend(['-v'])

            if self.asVkatVerifyArgs:
                asArgs += self.asVkatVerifyArgs

            fRc = self.executeHst("VKAT Host Verify", asArgs)
            if fRc:
                reporter.log("Verification audio data successful")
            else:
                #
                # Add the test sets to the test manager for later (manual) diagnosis.
                #
                reporter.addLogFile(sPathSetGst, 'misc/other',
                                    'Guest audio test set')
                reporter.addLogFile(sPathSetHst, 'misc/other',
                                    'Host audio test set')

                reporter.error("Verification of audio data failed")

            reporter.testDone()

        return fRc
示例#9
0
    def _uninstallVBoxOnWindows(self, fIgnoreServices=False):
        """
        Uninstalls VBox on Windows, all installations we find to be on the safe side...
        """

        import win32com.client
        # pylint: disable=F0401
        win32com.client.gencache.EnsureModule(
            '{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0)
        oInstaller = win32com.client.Dispatch(
            'WindowsInstaller.Installer',
            resultCLSID='{000C1090-0000-0000-C000-000000000046}')

        # Search installed products for VirtualBox.
        asProdCodes = []
        for sProdCode in oInstaller.Products:
            try:
                sProdName = oInstaller.ProductInfo(sProdCode, "ProductName")
            except:
                reporter.logXcpt()
                continue
            #reporter.log('Info: %s=%s' % (sProdCode, sProdName));
            if  sProdName.startswith('Oracle VM VirtualBox') \
             or sProdName.startswith('Sun VirtualBox'):
                asProdCodes.append([sProdCode, sProdName])

        # Before we start uninstalling anything, just ruthlessly kill any cdb,
        # msiexec, drvinst and some rundll process we might find hanging around.
        if self._isProcessPresent('rundll32'):
            cTimes = 0
            while cTimes < 3:
                cTimes += 1
                cKilled = self._terminateProcessesByNameAndArgSubstr(
                    'rundll32', 'InstallSecurityPromptRunDllW',
                    'MSI driver installation')
                if cKilled <= 0:
                    break
                time.sleep(10)
                # Give related drvinst process a chance to clean up after we killed the verification dialog.

        if self._isProcessPresent('drvinst'):
            time.sleep(15)
            # In the hope that it goes away.
            cTimes = 0
            while cTimes < 4:
                cTimes += 1
                cKilled = self._killProcessesByName('drvinst',
                                                    'MSI driver installation',
                                                    True)
                if cKilled <= 0:
                    break
                time.sleep(10)
                # Give related MSI process a chance to clean up after we killed the driver installer.

        if self._isProcessPresent('msiexec'):
            cTimes = 0
            while cTimes < 3:
                reporter.log('found running msiexec process, waiting a bit...')
                time.sleep(20)  # In the hope that it goes away.
                if not self._isProcessPresent('msiexec'):
                    break
                cTimes += 1
            ## @todo this could also be the msiexec system service, try to detect this case!
            if cTimes >= 6:
                cKilled = self._killProcessesByName('msiexec',
                                                    'MSI driver installation')
                if cKilled > 0:
                    time.sleep(16)
                    # fudge.

        # cdb.exe sometimes stays running (from utils.getProcessInfo), blocking
        # the scratch directory. No idea why.
        if self._isProcessPresent('cdb'):
            cTimes = 0
            while cTimes < 3:
                cKilled = self._killProcessesByName(
                    'cdb', 'cdb.exe from getProcessInfo')
                if cKilled <= 0:
                    break
                time.sleep(2)
                # fudge.

        # Do the uninstalling.
        fRc = True
        sLogFile = os.path.join(self.sScratchPath, 'VBoxUninstallLog.txt')
        for sProdCode, sProdName in asProdCodes:
            reporter.log('Uninstalling %s (%s)...' % (sProdName, sProdCode))
            fRc2, iRc = self._sudoExecuteSync([
                'msiexec',
                '/uninstall',
                sProdCode,
                '/quiet',
                '/passive',
                '/norestart',
                '/L*v',
                '%s' % (sLogFile),
            ])
            if fRc2 is False:
                if iRc == 3010:  # ERROR_SUCCESS_REBOOT_REQUIRED
                    reporter.log(
                        'Note: Uninstaller required a reboot to complete uninstallation'
                    )
                    reporter.addLogFile(sLogFile, 'log/uninstaller_reboot', \
                                        "Verbose MSI uninstallation log file (reboot required)")
                    # Optional, don't fail.
                else:
                    fRc = False

        self._waitForTestManagerConnectivity(30)
        if fRc is False and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/uninstaller',
                                "Verbose MSI uninstallation log file")

        # Log driver service states (should ls \Driver\VBox* and \Device\VBox*).
        for sService in self.kasWindowsServices:
            fRc2, _ = self._sudoExecuteSync(['sc.exe', 'query', sService])
            if fIgnoreServices is False and fRc2 is True:
                fRc = False

        return fRc
示例#10
0
    def _uninstallVBoxOnWindows(self):
        """
        Uninstalls VBox on Windows, all installations we find to be on the safe side...
        """

        import win32com.client
        # pylint: disable=F0401
        win32com.client.gencache.EnsureModule(
            '{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0)
        oInstaller = win32com.client.Dispatch(
            'WindowsInstaller.Installer',
            resultCLSID='{000C1090-0000-0000-C000-000000000046}')

        # Search installed products for VirtualBox.
        asProdCodes = []
        for sProdCode in oInstaller.Products:
            try:
                sProdName = oInstaller.ProductInfo(sProdCode, "ProductName")
            except:
                reporter.logXcpt()
                continue
            #reporter.log('Info: %s=%s' % (sProdCode, sProdName));
            if  sProdName.startswith('Oracle VM VirtualBox') \
             or sProdName.startswith('Sun VirtualBox'):
                asProdCodes.append([sProdCode, sProdName])

        # Before we start uninstalling anything, just ruthlessly kill any
        # msiexec process we might find hanging around.
        cKilled = 0
        for oProcess in utils.processListAll():
            sBase = oProcess.getBaseImageNameNoExeSuff()
            if sBase is not None and sBase.lower() in [
                    'msiexec',
            ]:
                reporter.log('Killing MSI process: %s (%s)' %
                             (oProcess.iPid, sBase))
                utils.processKill(oProcess.iPid)
                cKilled += 1
        if cKilled > 0:
            time.sleep(16)
            # fudge.

        # Do the uninstalling.
        fRc = True
        sLogFile = os.path.join(self.sScratchPath, 'VBoxUninstallLog.txt')
        for sProdCode, sProdName in asProdCodes:
            reporter.log('Uninstalling %s (%s)...' % (sProdName, sProdCode))
            fRc2, iRc = self._sudoExecuteSync([
                'msiexec',
                '/uninstall',
                sProdCode,
                '/quiet',
                '/passive',
                '/norestart',
                '/L*v',
                '%s' % (sLogFile),
            ])
            if fRc2 is False:
                if iRc == 3010:  # ERROR_SUCCESS_REBOOT_REQUIRED
                    reporter.log(
                        'Note: Uninstaller required a reboot to complete uninstallation'
                    )
                    # Optional, don't fail.
                else:
                    fRc = False
            reporter.addLogFile(sLogFile, 'log/uninstaller',
                                "Verbose MSI uninstallation log file")

        self._waitForTestManagerConnectivity(30)
        if fRc is False and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/uninstaller')
        return fRc
示例#11
0
    def _uninstallVBoxOnWindows(self, sMode):
        """
        Uninstalls VBox on Windows, all installations we find to be on the safe side...
        """
        assert sMode in [
            'install',
            'uninstall',
        ]

        import win32com.client
        # pylint: disable=import-error
        win32com.client.gencache.EnsureModule(
            '{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0)
        oInstaller = win32com.client.Dispatch(
            'WindowsInstaller.Installer',
            resultCLSID='{000C1090-0000-0000-C000-000000000046}')

        # Search installed products for VirtualBox.
        asProdCodes = []
        for sProdCode in oInstaller.Products:
            try:
                sProdName = oInstaller.ProductInfo(sProdCode, "ProductName")
            except:
                reporter.logXcpt()
                continue
            #reporter.log('Info: %s=%s' % (sProdCode, sProdName));
            if  sProdName.startswith('Oracle VM VirtualBox') \
             or sProdName.startswith('Sun VirtualBox'):
                asProdCodes.append([sProdCode, sProdName])

        # Before we start uninstalling anything, just ruthlessly kill any cdb,
        # msiexec, drvinst and some rundll process we might find hanging around.
        if self._isProcessPresent('rundll32'):
            cTimes = 0
            while cTimes < 3:
                cTimes += 1
                cKilled = self._terminateProcessesByNameAndArgSubstr(
                    'rundll32', 'InstallSecurityPromptRunDllW',
                    'MSI driver installation')
                if cKilled <= 0:
                    break
                time.sleep(10)
                # Give related drvinst process a chance to clean up after we killed the verification dialog.

        if self._isProcessPresent('drvinst'):
            time.sleep(15)
            # In the hope that it goes away.
            cTimes = 0
            while cTimes < 4:
                cTimes += 1
                cKilled = self._killProcessesByName('drvinst',
                                                    'MSI driver installation',
                                                    True)
                if cKilled <= 0:
                    break
                time.sleep(10)
                # Give related MSI process a chance to clean up after we killed the driver installer.

        if self._isProcessPresent('msiexec'):
            cTimes = 0
            while cTimes < 3:
                reporter.log('found running msiexec process, waiting a bit...')
                time.sleep(20)  # In the hope that it goes away.
                if not self._isProcessPresent('msiexec'):
                    break
                cTimes += 1
            ## @todo this could also be the msiexec system service, try to detect this case!
            if cTimes >= 6:
                cKilled = self._killProcessesByName('msiexec',
                                                    'MSI driver installation')
                if cKilled > 0:
                    time.sleep(16)
                    # fudge.

        # cdb.exe sometimes stays running (from utils.getProcessInfo), blocking
        # the scratch directory. No idea why.
        if self._isProcessPresent('cdb'):
            cTimes = 0
            while cTimes < 3:
                cKilled = self._killProcessesByName(
                    'cdb', 'cdb.exe from getProcessInfo')
                if cKilled <= 0:
                    break
                time.sleep(2)
                # fudge.

        # Do the uninstalling.
        fRc = True
        sLogFile = os.path.join(self.sScratchPath, 'VBoxUninstallLog.txt')
        for sProdCode, sProdName in asProdCodes:
            reporter.log('Uninstalling %s (%s)...' % (sProdName, sProdCode))
            fRc2, iRc = self._sudoExecuteSync([
                'msiexec',
                '/uninstall',
                sProdCode,
                '/quiet',
                '/passive',
                '/norestart',
                '/L*v',
                '%s' % (sLogFile),
            ])
            if fRc2 is False:
                if iRc == 3010:  # ERROR_SUCCESS_REBOOT_REQUIRED
                    reporter.error(
                        'Uninstaller required a reboot to complete uninstallation'
                    )
                else:
                    reporter.error('Uninstaller failed, exit code: %s' %
                                   (iRc, ))
                fRc = False

        self._waitForTestManagerConnectivity(30)

        # Upload the log on failure.  Do it early if the extra cleanups below causes trouble.
        if fRc is False and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/uninstaller',
                                "Verbose MSI uninstallation log file")
            sLogFile = None

        # Log driver service states (should ls \Driver\VBox* and \Device\VBox*).
        fHadLeftovers = False
        asLeftovers = []
        for sService in reversed(self.kasWindowsServices):
            cTries = 0
            while True:
                fRc2, _ = self._sudoExecuteSync(['sc.exe', 'query', sService])
                if not fRc2:
                    break
                fHadLeftovers = True

                cTries += 1
                if cTries > 3:
                    asLeftovers.append(sService, )
                    break

                # Get the status output.
                try:
                    sOutput = utils.sudoProcessOutputChecked(
                        ['sc.exe', 'query', sService])
                except:
                    reporter.logXcpt()
                else:
                    if re.search(r'STATE\s+:\s*1\s*STOPPED', sOutput) is None:
                        reporter.log('Trying to stop %s...' % (sService, ))
                        fRc2, _ = self._sudoExecuteSync(
                            ['sc.exe', 'stop', sService])
                        time.sleep(1)
                        # fudge

                    reporter.log('Trying to delete %s...' % (sService, ))
                    self._sudoExecuteSync(['sc.exe', 'delete', sService])

                time.sleep(1)
                # fudge

        if asLeftovers:
            reporter.log('Warning! Leftover VBox drivers: %s' %
                         (', '.join(asLeftovers), ))
            fRc = False

        if fHadLeftovers:
            self._waitForTestManagerConnectivity(30)

        # Upload the log if we have any leftovers and didn't upload it already.
        if sLogFile is not None and (
                fRc is False or fHadLeftovers) and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/uninstaller',
                                "Verbose MSI uninstallation log file")

        return fRc
    def _uninstallVBoxOnWindows(self):
        """
        Uninstalls VBox on Windows, all installations we find to be on the safe side...
        """

        import win32com.client
        # pylint: disable=F0401
        win32com.client.gencache.EnsureModule(
            '{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0)
        oInstaller = win32com.client.Dispatch(
            'WindowsInstaller.Installer',
            resultCLSID='{000C1090-0000-0000-C000-000000000046}')

        # Search installed products for VirtualBox.
        asProdCodes = []
        for sProdCode in oInstaller.Products:
            try:
                sProdName = oInstaller.ProductInfo(sProdCode, "ProductName")
            except:
                reporter.logXcpt()
                continue
            #reporter.log('Info: %s=%s' % (sProdCode, sProdName));
            if  sProdName.startswith('Oracle VM VirtualBox') \
             or sProdName.startswith('Sun VirtualBox'):
                asProdCodes.append([sProdCode, sProdName])

        # Before we start uninstalling anything, just ruthlessly kill any
        # msiexec and drvinst process we might find hanging around.
        if self._isProcessPresent('drvinst'):
            time.sleep(15)
            # In the hope that it goes away.
            cTimes = 0
            while cTimes < 4:
                cTimes += 1
                cKilled = self._killProcessesByName('drvinst',
                                                    'MSI driver installation',
                                                    True)
                if cKilled <= 0:
                    break
                time.sleep(10)
                # Give related MSI process a chance to clean up after we killed the driver installer.

        if self._isProcessPresent('msiexec'):
            time.sleep(15)
            # In the hope that it goes away.
            cKilled = self._killProcessesByName('msiexec',
                                                'MSI driver installation')
            if cKilled > 0:
                time.sleep(16)
                # fudge.

        # Do the uninstalling.
        fRc = True
        sLogFile = os.path.join(self.sScratchPath, 'VBoxUninstallLog.txt')
        for sProdCode, sProdName in asProdCodes:
            reporter.log('Uninstalling %s (%s)...' % (sProdName, sProdCode))
            fRc2, iRc = self._sudoExecuteSync([
                'msiexec',
                '/uninstall',
                sProdCode,
                '/quiet',
                '/passive',
                '/norestart',
                '/L*v',
                '%s' % (sLogFile),
            ])
            if fRc2 is False:
                if iRc == 3010:  # ERROR_SUCCESS_REBOOT_REQUIRED
                    reporter.log(
                        'Note: Uninstaller required a reboot to complete uninstallation'
                    )
                    # Optional, don't fail.
                else:
                    fRc = False
            reporter.addLogFile(sLogFile, 'log/uninstaller',
                                "Verbose MSI uninstallation log file")

        self._waitForTestManagerConnectivity(30)
        if fRc is False and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/uninstaller')

        # Log driver service states (should ls \Driver\VBox* and \Device\VBox*).
        for sService in self.kasWindowsServices:
            self._sudoExecuteSync(['sc.exe', 'query', sService])

        return fRc
    def _uninstallVBoxOnWindows(self, fIgnoreServices = False):
        """
        Uninstalls VBox on Windows, all installations we find to be on the safe side...
        """

        import win32com.client; # pylint: disable=F0401
        win32com.client.gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0);
        oInstaller = win32com.client.Dispatch('WindowsInstaller.Installer',
                                              resultCLSID = '{000C1090-0000-0000-C000-000000000046}')

        # Search installed products for VirtualBox.
        asProdCodes = [];
        for sProdCode in oInstaller.Products:
            try:
                sProdName = oInstaller.ProductInfo(sProdCode, "ProductName");
            except:
                reporter.logXcpt();
                continue;
            #reporter.log('Info: %s=%s' % (sProdCode, sProdName));
            if  sProdName.startswith('Oracle VM VirtualBox') \
             or sProdName.startswith('Sun VirtualBox'):
                asProdCodes.append([sProdCode, sProdName]);

        # Before we start uninstalling anything, just ruthlessly kill any cdb,
        # msiexec, drvinst and some rundll process we might find hanging around.
        if self._isProcessPresent('rundll32'):
            cTimes = 0;
            while cTimes < 3:
                cTimes += 1;
                cKilled = self._terminateProcessesByNameAndArgSubstr('rundll32', 'InstallSecurityPromptRunDllW',
                                                                     'MSI driver installation');
                if cKilled <= 0:
                    break;
                time.sleep(10); # Give related drvinst process a chance to clean up after we killed the verification dialog.

        if self._isProcessPresent('drvinst'):
            time.sleep(15);     # In the hope that it goes away.
            cTimes = 0;
            while cTimes < 4:
                cTimes += 1;
                cKilled = self._killProcessesByName('drvinst', 'MSI driver installation', True);
                if cKilled <= 0:
                    break;
                time.sleep(10); # Give related MSI process a chance to clean up after we killed the driver installer.

        if self._isProcessPresent('msiexec'):
            cTimes = 0;
            while cTimes < 3:
                reporter.log('found running msiexec process, waiting a bit...');
                time.sleep(20)  # In the hope that it goes away.
                if not self._isProcessPresent('msiexec'):
                    break;
                cTimes += 1;
            ## @todo this could also be the msiexec system service, try to detect this case!
            if cTimes >= 6:
                cKilled = self._killProcessesByName('msiexec', 'MSI driver installation');
                if cKilled > 0:
                    time.sleep(16); # fudge.

        # cdb.exe sometimes stays running (from utils.getProcessInfo), blocking
        # the scratch directory. No idea why.
        if self._isProcessPresent('cdb'):
            cTimes = 0;
            while cTimes < 3:
                cKilled = self._killProcessesByName('cdb', 'cdb.exe from getProcessInfo');
                if cKilled <= 0:
                    break;
                time.sleep(2); # fudge.

        # Do the uninstalling.
        fRc = True;
        sLogFile = os.path.join(self.sScratchPath, 'VBoxUninstallLog.txt');
        for sProdCode, sProdName in asProdCodes:
            reporter.log('Uninstalling %s (%s)...' % (sProdName, sProdCode));
            fRc2, iRc = self._sudoExecuteSync(['msiexec', '/uninstall', sProdCode, '/quiet', '/passive', '/norestart',
                                               '/L*v', '%s' % (sLogFile), ]);
            if fRc2 is False:
                if iRc == 3010: # ERROR_SUCCESS_REBOOT_REQUIRED
                    reporter.log('Note: Uninstaller required a reboot to complete uninstallation');
                    reporter.addLogFile(sLogFile, 'log/uninstaller_reboot', \
                                        "Verbose MSI uninstallation log file (reboot required)");
                    # Optional, don't fail.
                else:
                    fRc = False;

        self._waitForTestManagerConnectivity(30);
        if fRc is False and os.path.isfile(sLogFile):
            reporter.addLogFile(sLogFile, 'log/uninstaller', "Verbose MSI uninstallation log file");

        # Log driver service states (should ls \Driver\VBox* and \Device\VBox*).
        for sService in self.kasWindowsServices:
            fRc2, _ = self._sudoExecuteSync(['sc.exe', 'query', sService]);
            if fIgnoreServices is False and fRc2 is True:
                fRc = False

        return fRc;
    def testUsbOneCfg(self, sVmName, sUsbCtrl, sSpeed, sUsbTest):
        """
        Runs the specified VM thru one specified test.

        Returns a success indicator on the general test execution. This is not
        the actual test result.
        """
        oVM = self.getVmByName(sVmName);

        # Reconfigure the VM
        fRc = True;
        oSession = self.openSession(oVM);
        if oSession is not None:
            fRc = fRc and oSession.enableVirtEx(True);
            fRc = fRc and oSession.enableNestedPaging(True);

            # Make sure controllers are disabled initially.
            fRc = fRc and oSession.enableUsbOhci(False);
            fRc = fRc and oSession.enableUsbEhci(False);
            fRc = fRc and oSession.enableUsbXhci(False);

            if sUsbCtrl == 'OHCI':
                fRc = fRc and oSession.enableUsbOhci(True);
            elif sUsbCtrl == 'EHCI':
                fRc = fRc and oSession.enableUsbEhci(True);
            elif sUsbCtrl == 'XHCI':
                fRc = fRc and oSession.enableUsbXhci(True);
            fRc = fRc and oSession.saveSettings();
            fRc = oSession.close() and fRc and True; # pychecker hack.
            oSession = None;
        else:
            fRc = False;

        # Start up.
        if fRc is True:
            self.logVmInfo(oVM);
            oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = False);
            if oSession is not None:
                self.addTask(oTxsSession);

                # Fudge factor - Allow the guest to finish starting up.
                self.sleep(5);

                sCaptureFile = None;
                if self.fUsbCapture:
                    sCaptureFile = self.getCaptureFilePath(sUsbCtrl, sSpeed);

                if sUsbTest == 'Compliance':
                    fRc = self.testUsbCompliance(oSession, oTxsSession, sUsbCtrl, sSpeed, sCaptureFile);
                elif sUsbTest == 'Reattach':
                    fRc = self.testUsbReattach(oSession, oTxsSession, sUsbCtrl, sSpeed, sCaptureFile);

                # cleanup.
                self.removeTask(oTxsSession);
                self.terminateVmBySession(oSession)

                # Add the traffic dump if it exists and the test failed
                if reporter.testErrorCount() > 0 \
                   and sCaptureFile is not None \
                   and os.path.exists(sCaptureFile):
                    reporter.addLogFile(sCaptureFile, 'misc/other', 'USB traffic dump');
            else:
                fRc = False;
        return fRc;