VirtualBox

Ignore:
Timestamp:
Jan 11, 2021 4:03:56 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142171
Message:

Main: bugref:9341: Testcase: some formatting changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py

    r87116 r87216  
    2727"""
    2828__version__ = "$Id$"
     29
    2930# Standard Python imports.
    3031import os;
    3132import sys;
    3233import re;
     34
    3335# Only the main script needs to modify the path.
    3436try:    __file__
     
    3638g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
    3739sys.path.append(g_ksValidationKitDir);
     40
    3841# Validation Kit imports.
    3942from testdriver import reporter;
     
    4346from testdriver import vboxtestvms;
    4447from testdriver import vboxwrappers;
     48
    4549class VBoxManageStdOutWrapper(object):
    4650    """ Parser for VBoxManage list runningvms """
     51
    4752    def __init__(self):
    4853        self.sVmRunning = '';
     54
    4955    def __del__(self):
    5056        self.close();
     57
    5158    def close(self):
    5259        """file.close"""
    5360        return;
     61
    5462    def read(self, cb):
    5563        """file.read"""
    5664        _ = cb;
    5765        return "";
     66
    5867    def write(self, sText):
    5968        """VBoxManage stdout write"""
     
    7786            reporter.log('Logging: ' + self.sVmRunning);
    7887        return None;
     88
    7989class tdAutostartOs(vboxtestvms.BaseTestVm):
    8090    """
     
    97107        self.asVirtModesSup = ['hwvirt-np',];
    98108        self.asParavirtModesSup = ['default',];
     109
    99110    @property
    100111    def asTestBuildDirs(self):
    101112        return self._asTestBuildDirs;
     113
    102114    @asTestBuildDirs.setter
    103115    def asTestBuildDirs(self, value):
     
    106118        if not self.sTestBuild:
    107119            raise base.GenError("VirtualBox install package not found");
     120
    108121    def _findFile(self, sRegExp, asTestBuildDirs):
    109122        """
     
    128141        reporter.error('Failed to find a file matching "%s" in %s.' % (sRegExp, ','.join(asTestBuildDirs)));
    129142        return None;
     143
    130144    def _createAutostartCfg(self, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
    131145        """
     
    138152            sVBoxCfg = sVBoxCfg + sUserDeny + ' = {\n allow = false\n }\n';
    139153        return sVBoxCfg;
     154
    140155    def _waitAdditionsIsRunning(self, oGuest, fWaitTrayControl):
    141156        """
     
    160175            cAttempt += 1;
    161176        return fRc;
     177
    162178    def createSession(self, oSession, sName, sUser, sPassword, cMsTimeout = 10 * 1000, fIsError = True):
    163179        """
     
    195211            return (False, None);
    196212        return (True, oGuestSession);
     213
    197214    def closeSession(self, oGuestSession, fIsError = True):
    198215        """
     
    213230                return False;
    214231        return True;
     232
    215233    def guestProcessExecute(self, oGuestSession, sTestName, cMsTimeout, sExecName, asArgs = (),
    216234                            fGetStdOut = True, fIsError = True):
     
    342360        reporter.log2('Process (PID %d) has exit code: %d; status: %d ' % (iPid, iExitCode, uExitStatus));
    343361        return (fRc, uExitStatus, iExitCode, aBuf);
     362
    344363    def uploadString(self, oGuestSession, sSrcString, sDst):
    345364        """
     
    362381            fRc = reporter.errorXcpt('Upload string failed. Could not close the file %s' % sDst);
    363382        return fRc;
     383
    364384    def uploadFile(self, oGuestSession, sSrc, sDst):
    365385        """
     
    386406                fRc = reporter.error('No progress object returned');
    387407        return fRc;
     408
    388409    def downloadFile(self, oGuestSession, sSrc, sDst, fIgnoreErrors = False):
    389410        """
     
    417438                fRc = False;
    418439        return fRc;
     440
    419441    def downloadFiles(self, oGuestSession, asFiles, fIgnoreErrors = False):
    420442        """
     
    445467                reporter.log('warning: file "%s" was not downloaded, ignoring.' % (sGstFile,));
    446468        return True;
     469
    447470    def _checkVmIsReady(self, oGuestSession):
    448471        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
     
    451474                                                  False, False);
    452475        return fRc;
     476
    453477    def waitVmIsReady(self, oSession, fWaitTrayControl):
    454478        """
     
    477501            cAttempt += 1;
    478502        return (fRc, oGuestSession);
     503
    479504    def _rebootVM(self, oGuestSession):
    480505        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM',
     
    485510            reporter.error('Calling the reboot utility failed');
    486511        return fRc;
     512
    487513    def rebootVMAndCheckReady(self, oSession, oGuestSession):
    488514        """
     
    499525        reporter.testDone();
    500526        return (fRc, oGuestSession);
     527
    501528    def _powerDownVM(self, oGuestSession):
    502529        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
     
    507534            reporter.error('Calling the poweroff utility failed');
    508535        return fRc;
     536
    509537    def powerDownVM(self, oGuestSession):
    510538        """
     
    522550        reporter.testDone();
    523551        return fRc;
     552
    524553    def installAdditions(self, oSession, oGuestSession, oVM):
    525554        """
     
    531560        reporter.error('Not implemented');
    532561        return False;
     562
    533563    def installVirtualBox(self, oGuestSession):
    534564        """
     
    538568        reporter.error('Not implemented');
    539569        return False;
     570
    540571    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
    541572        """
     
    548579        reporter.error('Not implemented');
    549580        return False;
     581
    550582    def createUser(self, oGuestSession, sUser):
    551583        """
     
    556588        reporter.error('Not implemented');
    557589        return False;
     590
    558591    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
    559592        """
     
    568601        reporter.error('Not implemented');
    569602        return False;
     603
    570604    def getResourceSet(self):
    571605        asRet = [];
     
    573607            asRet.append(self.sHdd);
    574608        return asRet;
     609
    575610    def _createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage):
    576611        """
     
    585620                                     sHddControllerType = "SATA Controller", fPae = self.fPae, \
    586621                                     cCpus = self.cCpus, sDvdImage = self.sGuestAdditionsIso);
     622
    587623    def _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage):
    588624        _ = eNic0AttachType;
     
    606642            fRc = False;
    607643        return oVM if fRc else None;
     644
    608645    def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
    609646        #
     
    617654            return (False, None);
    618655        return (True, oVM);
     656
    619657class tdAutostartOsLinux(tdAutostartOs):
    620658    """
     
    628666        self.sVBoxInstaller = '^VirtualBox-.*\\.run$';
    629667        return;
     668
    630669    def installAdditions(self, oSession, oGuestSession, oVM):
    631670        """
     
    703742        reporter.testDone();
    704743        return (fRc, oGuestSession);
     744
    705745    def installVirtualBox(self, oGuestSession):
    706746        """
     
    734774        reporter.testDone();
    735775        return fRc;
     776
    736777    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
    737778        """
     
    792833        reporter.testDone();
    793834        return fRc;
     835
    794836    def createUser(self, oGuestSession, sUser):
    795837        """
     
    805847        reporter.testDone();
    806848        return fRc;
     849
    807850    # pylint: enable=too-many-arguments
    808851    def createTestVM(self, oSession, oGuestSession, sUser, sVmName):
     
    839882        reporter.testDone();
    840883        return fRc;
     884
    841885    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
    842886        """
     
    861905        reporter.testDone();
    862906        return fRc;
     907
    863908class tdAutostartOsDarwin(tdAutostartOs):
    864909    """
     
    871916                               cCpus, fPae, sGuestAdditionsIso);
    872917        raise base.GenError('Testing the autostart functionality for Darwin is not implemented');
     918
    873919class tdAutostartOsSolaris(tdAutostartOs):
    874920    """
     
    881927                               cCpus, fPae, sGuestAdditionsIso);
    882928        raise base.GenError('Testing the autostart functionality for Solaris is not implemented');
     929
    883930class tdAutostartOsWin(tdAutostartOs):
    884931    """
     
    892939        self.sVBoxInstaller = '^VirtualBox-.*\\.(exe|msi)$';
    893940        return;
     941
    894942    def _checkVmIsReady(self, oGuestSession):
    895943        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
     
    898946                                                  False, False);
    899947        return fRc;
     948
    900949    def _rebootVM(self, oGuestSession):
    901950        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM',
     
    907956            reporter.error('Calling the shutdown utility failed');
    908957        return fRc;
     958
    909959    def _powerDownVM(self, oGuestSession):
    910960        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
     
    916966            reporter.error('Calling the shutdown utility failed');
    917967        return fRc;
     968
    918969    def installAdditions(self, oSession, oGuestSession, oVM):
    919970        """
     
    10051056        reporter.testDone();
    10061057        return (fRc and fGaRc, oGuestSession);
     1058
    10071059    def installVirtualBox(self, oGuestSession):
    10081060        """
     
    10511103        reporter.testDone();
    10521104        return fRc;
     1105
    10531106    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
    10541107        """
     
    10741127        reporter.testDone();
    10751128        return fRc;
     1129
    10761130    def createTestVM(self, oSession, oGuestSession, sUser, sVmName):
    10771131        """
     
    11201174        reporter.testDone();
    11211175        return fRc;
     1176
    11221177    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
    11231178        """
     
    11481203        reporter.testDone();
    11491204        return fRc;
     1205
    11501206    def createUser(self, oGuestSession, sUser):
    11511207        """
     
    12191275        reporter.testDone();
    12201276        return fRc;
     1277
    12211278class tdAutostart(vbox.TestDriver):                                      # pylint: disable=too-many-instance-attributes
    12221279    """
     
    12501307        # pylint: enable=line-too-long
    12511308        self.oTestVmSet = oSet;
     1309
    12521310    #
    12531311    # Overridden methods.
    12541312    #
     1313
    12551314    def showUsage(self):
    12561315        rc = vbox.TestDriver.showUsage(self);
     
    12621321        reporter.log('      option is not specified. At least, one directory should be pointed.');
    12631322        return rc;
     1323
    12641324    def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements
    12651325        if asArgs[iArg] == '--test-build-dirs':
     
    12721332            return vbox.TestDriver.parseOption(self, asArgs, iArg);
    12731333        return iArg + 1;
     1334
    12741335    def completeOptions(self):
    12751336        # Remove skipped VMs from the test list.
     
    12801341            except: pass;
    12811342        return vbox.TestDriver.completeOptions(self);
     1343
    12821344    def actionConfig(self):
    12831345        if not self.importVBoxApi(): # So we can use the constant below.
    12841346            return False;
    12851347        return self.oTestVmSet.actionConfig(self);
     1348
    12861349    def actionExecute(self):
    12871350        """
     
    12891352        """
    12901353        return self.oTestVmSet.actionExecute(self, self.testAutostartOneVfg)
     1354
    12911355    #
    12921356    # Test execution helpers.
     
    13521416            fRc = False;
    13531417        return fRc;
     1418
    13541419if __name__ == '__main__':
    13551420    sys.exit(tdAutostart().main(sys.argv));
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette