VirtualBox

Changeset 87113 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Dec 22, 2020 3:59:02 PM (4 years ago)
Author:
vboxsync
Message:

Main: bugref:9341: Changed the testcase to use BaseTestVM functionality

File:
1 edited

Legend:

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

    r86558 r87113  
    11#!/usr/bin/env python
    22# -*- coding: utf-8 -*-
    3 
    43"""
    54Autostart testcase using.
    65"""
    76#from pykickstart.commands import repo
    8 
    97__copyright__ = \
    108"""
    119Copyright (C) 2013-2020 Oracle Corporation
    12 
    1310This file is part of VirtualBox Open Source Edition (OSE), as
    1411available from http://www.virtualbox.org. This file is free software;
     
    1815VirtualBox OSE distribution. VirtualBox OSE is distributed in the
    1916hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    20 
    2117The contents of this file may alternatively be used under the terms
    2218of the Common Development and Distribution License Version 1.0
     
    2420VirtualBox OSE distribution, in which case the provisions of the
    2521CDDL are applicable instead of those of the GPL.
    26 
    2722You may elect to license modified versions of this file under the
    2823terms and conditions of either the GPL or the CDDL or both.
    2924"""
    3025__version__ = "$Id$"
    31 
    32 
    3326# Standard Python imports.
    3427import os;
    3528import sys;
    3629import re;
    37 
    3830# Only the main script needs to modify the path.
    3931try:    __file__
     
    4133g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
    4234sys.path.append(g_ksValidationKitDir);
    43 
    4435# Validation Kit imports.
    4536from testdriver import reporter;
     
    4738from testdriver import vbox;
    4839from testdriver import vboxcon;
     40from testdriver import vboxtestvms;
    4941from testdriver import vboxwrappers;
    50 
    51 
    5242class VBoxManageStdOutWrapper(object):
    5343    """ Parser for VBoxManage list runningvms """
    5444    def __init__(self):
    5545        self.sVmRunning = '';
    56 
    5746    def __del__(self):
    5847        self.close();
    59 
    6048    def close(self):
    6149        """file.close"""
    6250        return;
    63 
    6451    def read(self, cb):
    6552        """file.read"""
    6653        _ = cb;
    6754        return "";
    68 
    6955    def write(self, sText):
    7056        """VBoxManage stdout write"""
    7157        if sText is None:
    7258            return None;
    73 
    7459        try:    sText = str(sText); # pylint: disable=redefined-variable-type
    7560        except: pass;
    76 
    7761        asLines = sText.splitlines();
    7862        for sLine in asLines:
    7963            sLine = sLine.strip();
    80 
    8164            reporter.log('Logging: ' + sLine);
    82 
    8365                # Extract the value
    8466            idxVmNameStart = sLine.find('"');
    8567            if idxVmNameStart == -1:
    8668                raise Exception('VBoxManageStdOutWrapper: Invalid output');
    87 
    8869            idxVmNameStart += 1;
    8970            idxVmNameEnd = idxVmNameStart;
    9071            while sLine[idxVmNameEnd] != '"':
    9172                idxVmNameEnd += 1;
    92 
    9373            self.sVmRunning = sLine[idxVmNameStart:idxVmNameEnd];
    9474            reporter.log('Logging: ' + self.sVmRunning);
    95 
    9675        return None;
    97 
    98 
    99 class tdAutostartOs(object):
     76class tdAutostartOs(vboxtestvms.BaseTestVm):
    10077    """
    10178    Base autostart helper class to provide common methods.
    10279    """
    103 
    104     def __init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso):
     80    def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None,  \
     81                 cCpus = 1, fPae = None, sGuestAdditionsIso = None):
     82        vboxtestvms.BaseTestVm.__init__(self, sVmName, oSet = oSet, sKind = sKind);
    10583        self.oTstDrv = oTstDrv;
    106         self.fpApiVer = fpApiVer;
     84        self.sHdd = sHdd;
     85        self.eNic0Type = eNic0Type;
     86        self.cMbRam = cMbRam;
     87        self.cCpus = cCpus;
     88        self.fPae = fPae;
    10789        self.sGuestAdditionsIso = sGuestAdditionsIso;
    108 
     90        self._asTestBuildDirs = [];
     91        self.sVBoxInstaller = "";
     92        self.asVirtModesSup = ['hwvirt-np',];
     93        self.asParavirtModesSup = ['default',];
     94    @property
     95    def asTestBuildDirs(self):
     96        return self._asTestBuildDirs;
     97    @asTestBuildDirs.setter
     98    def asTestBuildDirs(self, value):
     99        self._asTestBuildDirs = value;
     100        self.sTestBuild = self._findFile(self.sVBoxInstaller, value);
     101        if not self.sTestBuild:
     102            raise base.GenError("VirtualBox install package not found");
    109103    def _findFile(self, sRegExp, asTestBuildDirs):
    110104        """
     
    112106        or None if no matching file is found.
    113107        """
    114 
    115108        oRegExp = re.compile(sRegExp);
    116109        for sTestBuildDir in asTestBuildDirs:
     
    128121            except:
    129122                pass;
    130 
    131123        reporter.error('Failed to find a file matching "%s" in %s.' % (sRegExp, ','.join(asTestBuildDirs)));
    132124        return None;
    133 
    134125    def _createAutostartCfg(self, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
    135126        """
    136127        Creates a autostart config for VirtualBox
    137128        """
    138 
    139129        sVBoxCfg = 'default_policy=' + sDefaultPolicy + '\n';
    140 
    141130        for sUserAllow in asUserAllow:
    142131            sVBoxCfg = sVBoxCfg + sUserAllow + ' = {\n allow = true\n }\n';
    143 
    144132        for sUserDeny in asUserDeny:
    145133            sVBoxCfg = sVBoxCfg + sUserDeny + ' = {\n allow = false\n }\n';
    146 
    147134        return sVBoxCfg;
    148 
    149135    def _waitAdditionsIsRunning(self, oGuest, fWaitTrayControl):
    150136        """
     
    166152                    if fRc:
    167153                        break;
    168 
    169154            self.oTstDrv.sleep(10);
    170155            cAttempt += 1;
    171156        return fRc;
    172 
    173157    def createSession(self, oSession, sName, sUser, sPassword, cMsTimeout = 10 * 1000, fIsError = True):
    174158        """
     
    179163        if sName is None:
    180164            sName = "<untitled>";
    181 
    182165        reporter.log('Creating session "%s" ...' % (sName,));
    183166        try:
     
    188171                                  % (sName, sUser, sPassword));
    189172            return (False, None);
    190 
    191173        reporter.log('Waiting for session "%s" to start within %dms...' % (sName, cMsTimeout));
    192174        aeWaitFor = [ vboxcon.GuestSessionWaitForFlag_Start, ];
    193175        try:
    194176            waitResult = oGuestSession.waitForArray(aeWaitFor, cMsTimeout);
    195 
    196177            #
    197178            # Be nice to Guest Additions < 4.3: They don't support session handling and
     
    209190            return (False, None);
    210191        return (True, oGuestSession);
    211 
    212192    def closeSession(self, oGuestSession, fIsError = True):
    213193        """
     
    219199            except:
    220200                return reporter.errorXcpt();
    221 
    222201            reporter.log('Closing session "%s" ...' % (sName,));
    223202            try:
     
    229208                return False;
    230209        return True;
    231 
    232210    def guestProcessExecute(self, oGuestSession, sTestName, cMsTimeout, sExecName, asArgs = (),
    233211                            fGetStdOut = True, fIsError = True):
     
    238216        _ = sTestName;
    239217        fRc = True; # Be optimistic.
    240 
    241218        reporter.log2('Using session user=%s, name=%s, timeout=%d'
    242219                      % (oGuestSession.user, oGuestSession.name, oGuestSession.timeout,));
    243 
    244220        #
    245221        # Start the process:
     
    253229        try:
    254230            oProcess = oGuestSession.processCreate(sExecName,
    255                                                    asArgs if self.fpApiVer >= 5.0 else asArgs[1:],
     231                                                   asArgs if self.oTstDrv.fpApiVer >= 5.0 else asArgs[1:],
    256232                                                   [], fTaskFlags, cMsTimeout);
    257233        except:
     
    260236        if oProcess is None:
    261237            return (reporter.error('oProcess is None! (%s)' % (asArgs,)), 0, 0, None);
    262 
    263238        #time.sleep(5); # try this if you want to see races here.
    264 
    265239        # Wait for the process to start properly:
    266240        reporter.log2('Process start requested, waiting for start (%dms) ...' % (cMsTimeout,));
     
    281255            else:
    282256                reporter.log2('Wait result returned: %d, current process status is: %d' % (eWaitResult, eStatus,));
    283 
    284257                #
    285258                # Wait for the process to run to completion if necessary.
     
    289262                #
    290263                if eStatus == vboxcon.ProcessStatus_Started:
    291 
    292264                    # What to wait for:
    293265                    aeWaitFor = [ vboxcon.ProcessWaitForFlag_Terminate,
    294266                                  vboxcon.ProcessWaitForFlag_StdOut,
    295267                                  vboxcon.ProcessWaitForFlag_StdErr];
    296 
    297268                    reporter.log2('Process (PID %d) started, waiting for termination (%dms), aeWaitFor=%s ...'
    298269                                  % (iPid, cMsTimeout, aeWaitFor));
     
    310281                            break;
    311282                        reporter.log2('Wait returned: %d' % (eWaitResult,));
    312 
    313283                        # Process output:
    314284                        for eFdResult, iFd, sFdNm in [ (vboxcon.ProcessWaitResult_StdOut, 1, 'stdout'),
     
    339309                                        else:
    340310                                            aBuf = sBuf;
    341 
    342311                        ## Process input (todo):
    343312                        #if eWaitResult in (vboxcon.ProcessWaitResult_StdIn, vboxcon.ProcessWaitResult_WaitFlagNotSupported):
    344313                        #    reporter.log2('Process (PID %d) needs stdin data' % (iPid,));
    345 
    346314                        # Termination or error?
    347315                        if eWaitResult in (vboxcon.ProcessWaitResult_Terminate,
     
    353321                                          % (iPid, eWaitResult, eStatus,));
    354322                            break;
    355 
    356323                    # End of the wait loop.
    357324                    _, cbStdOut, cbStdErr = acbFdOut;
    358 
    359325                    try:    eStatus = oProcess.status;
    360326                    except: fRc = reporter.errorXcpt('asArgs=%s' % (asArgs,));
    361327                    reporter.log2('Final process status (PID %d) is: %d' % (iPid, eStatus));
    362328                    reporter.log2('Process (PID %d) %d stdout, %d stderr' % (iPid, cbStdOut, cbStdErr));
    363 
    364329        #
    365330        # Get the final status and exit code of the process.
     
    371336            fRc = reporter.errorXcpt('asArgs=%s' % (asArgs,));
    372337        reporter.log2('Process (PID %d) has exit code: %d; status: %d ' % (iPid, iExitCode, uExitStatus));
    373 
    374338        return (fRc, uExitStatus, iExitCode, aBuf);
    375 
    376339    def uploadString(self, oGuestSession, sSrcString, sDst):
    377340        """
     
    393356        except:
    394357            fRc = reporter.errorXcpt('Upload string failed. Could not close the file %s' % sDst);
    395 
    396         return fRc;
    397 
     358        return fRc;
    398359    def uploadFile(self, oGuestSession, sSrc, sDst):
    399360        """
     
    402363        fRc = True;
    403364        try:
    404             if self.fpApiVer >= 5.0:
     365            if self.oTstDrv.fpApiVer >= 5.0:
    405366                oCurProgress = oGuestSession.fileCopyToGuest(sSrc, sDst, [0]);
    406367            else:
     
    419380            else:
    420381                fRc = reporter.error('No progress object returned');
    421 
    422         return fRc;
    423 
     382        return fRc;
    424383    def downloadFile(self, oGuestSession, sSrc, sDst, fIgnoreErrors = False):
    425384        """
     
    428387        fRc = True;
    429388        try:
    430             if self.fpApiVer >= 5.0:
     389            if self.oTstDrv.fpApiVer >= 5.0:
    431390                oCurProgress = oGuestSession.fileCopyFromGuest(sSrc, sDst, [0]);
    432391            else:
     
    452411                    reporter.log('warning: No progress object returned');
    453412                fRc = False;
    454 
    455         return fRc;
    456 
     413        return fRc;
    457414    def downloadFiles(self, oGuestSession, asFiles, fIgnoreErrors = False):
    458415        """
    459416        Convenience function to get files from the guest and stores it
    460417        into the scratch directory for later (manual) review.
    461 
    462418        Returns True on success.
    463 
    464419        Returns False on failure, logged.
    465420        """
     
    485440                reporter.log('warning: file "%s" was not downloaded, ignoring.' % (sGstFile,));
    486441        return True;
    487 
    488 
    489 class tdAutostartOsLinux(tdAutostartOs):
    490     """
    491     Autostart support methods for Linux guests.
    492     """
    493 
    494     def __init__(self, oTstDrv, asTestBuildDirs, fpApiVer, sGuestAdditionsIso):
    495         tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
    496         self.sTestBuild = self._findFile('^VirtualBox-.*\\.run$', asTestBuildDirs);
    497         if not self.sTestBuild:
    498             raise base.GenError("VirtualBox install package not found");
    499 
     442    def _checkVmIsReady(self, oGuestSession):
     443        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
     444                                                  30 * 1000, '/sbin/ifconfig',
     445                                                  ['ifconfig',],
     446                                                  False, False);
     447        return fRc;
    500448    def waitVmIsReady(self, oSession, fWaitTrayControl):
    501449        """
     
    506454        # Give the VM a time to reboot
    507455        self.oTstDrv.sleep(30);
    508 
    509456        # Waiting the VM is ready.
    510457        # To do it, one will try to open the guest session and start the guest process in loop
    511 
    512458        if not self._waitAdditionsIsRunning(oSession.o.console.guest, False):
    513459            return (False, None);
    514 
    515460        cAttempt = 0;
    516461        oGuestSession = None;
     
    520465                                                    'vbox', 'password', 10 * 1000, False);
    521466            if fRc:
    522                 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
    523                                                           30 * 1000, '/sbin/ifconfig',
    524                                                           ['ifconfig',],
    525                                                           False, False);
     467                fRc = self._checkVmIsReady(oGuestSession);
    526468                if fRc:
    527469                    break;
    528 
    529470                self.closeSession(oGuestSession, False);
    530 
    531471            self.oTstDrv.sleep(10);
    532472            cAttempt += 1;
    533 
    534473        return (fRc, oGuestSession);
    535 
    536     def rebootVMAndCheckReady(self, oSession, oGuestSession):
    537         """
    538         Reboot the VM and wait the VM is ready.
    539         Returns result and guest session obtained after reboot
    540         """
    541         reporter.testStart('Reboot VM and wait for readiness');
     474    def _rebootVM(self, oGuestSession):
    542475        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM',
    543476                                                  30 * 1000, '/usr/bin/sudo',
     
    546479        if not fRc:
    547480            reporter.error('Calling the reboot utility failed');
     481        return fRc;
     482    def rebootVMAndCheckReady(self, oSession, oGuestSession):
     483        """
     484        Reboot the VM and wait the VM is ready.
     485        Returns result and guest session obtained after reboot
     486        """
     487        reporter.testStart('Reboot VM and wait for readiness');
     488        fRc = self._rebootVM(oGuestSession);
    548489        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    549490        if fRc:
    550491            (fRc, oGuestSession) = self.waitVmIsReady(oSession, False);
    551 
    552492        if not fRc:
    553493            reporter.error('VM is not ready after reboot');
    554494        reporter.testDone();
    555495        return (fRc, oGuestSession);
    556 
    557     def powerDownVM(self, oGuestSession):
    558         """
    559         Power down the VM by calling guest process without wating
    560         the VM is really powered off. Also, closes the guest session.
    561         It helps the terminateBySession to stop the VM without aborting.
    562         """
    563 
    564         if oGuestSession is None:
    565             return False;
    566 
    567         reporter.testStart('Power down the VM');
    568 
     496    def _powerDownVM(self, oGuestSession):
    569497        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
    570498                                                  30 * 1000, '/usr/bin/sudo',
     
    573501        if not fRc:
    574502            reporter.error('Calling the poweroff utility failed');
     503        return fRc;
     504    def powerDownVM(self, oGuestSession):
     505        """
     506        Power down the VM by calling guest process without wating
     507        the VM is really powered off. Also, closes the guest session.
     508        It helps the terminateBySession to stop the VM without aborting.
     509        """
     510        if oGuestSession is None:
     511            return False;
     512        reporter.testStart('Power down the VM');
     513        fRc = self._powerDownVM(oGuestSession);
    575514        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    576 
    577515        if not fRc:
    578516            reporter.error('Power down the VM failed');
    579517        reporter.testDone();
    580518        return fRc;
    581 
    582519    def installAdditions(self, oSession, oGuestSession, oVM):
    583520        """
     521        Installs the Windows guest additions using the test execution service.
     522        """
     523        _ = oSession;
     524        _ = oGuestSession;
     525        _ = oVM;
     526        reporter.error('Not implemented');
     527        return False;
     528    def installVirtualBox(self, oGuestSession):
     529        """
     530        Install VirtualBox in the guest.
     531        """
     532        _ = oGuestSession;
     533        reporter.error('Not implemented');
     534        return False;
     535    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
     536        """
     537        Configures the autostart feature in the guest.
     538        """
     539        _ = oGuestSession;
     540        _ = sDefaultPolicy;
     541        _ = asUserAllow;
     542        _ = asUserDeny;
     543        reporter.error('Not implemented');
     544        return False;
     545    def createUser(self, oGuestSession, sUser):
     546        """
     547        Create a new user with the given name
     548        """
     549        _ = oGuestSession;
     550        _ = sUser;
     551        reporter.error('Not implemented');
     552        return False;
     553    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
     554        """
     555        Check for VM running in the guest after autostart.
     556        Due to the sUser is created whithout password,
     557        all calls will be perfomed using 'sudo -u sUser'
     558        """
     559        _ = oSession;
     560        _ = oGuestSession;
     561        _ = sUser;
     562        _ = sVmName;
     563        reporter.error('Not implemented');
     564        return False;
     565    def getResourceSet(self):
     566        asRet = [];
     567        if not os.path.isabs(self.sHdd):
     568            asRet.append(self.sHdd);
     569        return asRet;
     570    def _createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage):
     571        """
     572        Creates the VM.
     573        Returns Wrapped VM object on success, None on failure.
     574        """
     575        _ = eNic0AttachType;
     576        _ = sDvdImage;
     577        return oTestDrv.createTestVM(self.sVmName, self.iGroup, self.sHdd, sKind = self.sKind, \
     578                                     fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
     579                                     eNic0Type = self.eNic0Type, cMbRam = self.cMbRam, \
     580                                     sHddControllerType = "SATA Controller", fPae = self.fPae, \
     581                                     cCpus = self.cCpus, sDvdImage = self.sGuestAdditionsIso);
     582    def _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage):
     583        _ = eNic0AttachType;
     584        _ = sDvdImage;
     585        fRc = True;
     586        oSession = oTestDrv.openSession(oVM);
     587        if oSession is not None:
     588            fRc = fRc and oSession.enableVirtEx(True);
     589            fRc = fRc and oSession.enableNestedPaging(True);
     590            fRc = fRc and oSession.enableNestedHwVirt(True);
     591            # disable 3D until the error is fixed.
     592            fRc = fRc and oSession.setAccelerate3DEnabled(False);
     593            fRc = fRc and oSession.setVRamSize(256);
     594            fRc = fRc and oSession.setVideoControllerType(vboxcon.GraphicsControllerType_VBoxSVGA);
     595            fRc = fRc and oSession.enableUsbOhci(True);
     596            fRc = fRc and oSession.enableUsbHid(True);
     597            fRc = fRc and oSession.saveSettings();
     598            fRc = oSession.close() and fRc and True; # pychecker hack.
     599            oSession = None;
     600        else:
     601            fRc = False;
     602        return oVM if fRc else None;
     603    def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
     604        #
     605        # Current test uses precofigured VMs. This override disables any changes in the machine.
     606        #
     607        _ = cCpus;
     608        _ = sVirtMode;
     609        _ = sParavirtMode;
     610        oVM = oTestDrv.getVmByName(self.sVmName);
     611        if oVM is None:
     612            return (False, None);
     613        return (True, oVM);
     614class tdAutostartOsLinux(tdAutostartOs):
     615    """
     616    Autostart support methods for Linux guests.
     617    """
     618    def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None,  \
     619                 cCpus = 1, fPae = None, sGuestAdditionsIso = None):
     620        tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \
     621                               cCpus, fPae, sGuestAdditionsIso);
     622        self.sVBoxInstaller = '^VirtualBox-.*\\.run$';
     623        return;
     624    def installAdditions(self, oSession, oGuestSession, oVM):
     625        """
    584626        Install guest additions in the guest.
    585627        """
    586628        reporter.testStart('Install Guest Additions');
    587 
    588629        fRc = False;
    589630        # Install Kernel headers, which are required for actually installing the Linux Additions.
     
    604645                if not fRc:
    605646                    reporter.error('Error installing additional installer dependencies');
    606 
    607647        elif oVM.OSTypeId.startswith('OL') \
    608648          or oVM.OSTypeId.startswith('Oracle') \
     
    623663                if not fRc:
    624664                    reporter.error('Error installing additional installer dependencies');
    625 
    626665        else:
    627666            reporter.error('Installing Linux Additions for the "%s" is not supported yet' % oVM.OSTypeId);
    628667            fRc = False;
    629 
    630668        if fRc:
    631669            #
     
    633671            # Also tell the installer to produce the appropriate log files.
    634672            #
    635 
    636673            (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Installing guest additions',
    637674                                                      10 * 60 *1000, '/usr/bin/sudo',
     
    645682                if fRc:
    646683                    (fRc, oGuestSession) = self.waitVmIsReady(oSession, False);
    647 
    648684                # Download log files.
    649685                # Ignore errors as all files above might not be present for whatever reason.
     
    655691            else:
    656692                reporter.error('Installing guest additions failed: Error occured during vbox installer execution')
    657 
    658693        if fRc:
    659694            (fRc, oGuestSession) = self.rebootVMAndCheckReady(oSession, oGuestSession);
     
    662697        reporter.testDone();
    663698        return (fRc, oGuestSession);
    664 
    665699    def installVirtualBox(self, oGuestSession):
    666700        """
     
    669703        if self.sTestBuild is None:
    670704            return False;
    671 
    672705        reporter.testStart('Install Virtualbox into the guest VM');
    673706        reporter.log("Virtualbox install file: %s" % os.path.basename(self.sTestBuild));
    674 
    675707        fRc = self.uploadFile(oGuestSession, self.sTestBuild,
    676708                              '/tmp/' + os.path.basename(self.sTestBuild));
     
    696728        reporter.testDone();
    697729        return fRc;
    698 
    699730    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
    700731        """
     
    732763            if not fRc:
    733764                reporter.error('Setting permissions for the virtualbox failed');
    734 
    735765        if fRc:
    736766            sVBoxCfg = self._createAutostartCfg(sDefaultPolicy, asUserAllow, asUserDeny);
     
    738768            if not fRc:
    739769                reporter.error('Upload to /tmp/autostart.cfg failed');
    740 
    741770        if fRc:
    742771            (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Moving to destination',
     
    757786        reporter.testDone();
    758787        return fRc;
    759 
    760788    def createUser(self, oGuestSession, sUser):
    761789        """
     
    771799        reporter.testDone();
    772800        return fRc;
    773 
    774801    # pylint: enable=too-many-arguments
    775 
    776802    def createTestVM(self, oSession, oGuestSession, sUser, sVmName):
    777803        """
     
    780806        all calls will be perfomed using 'sudo -u sUser'
    781807        """
    782 
    783808        _ = oSession;
    784 
    785809        reporter.testStart('Create test VM for user %s' % sUser);
    786 
    787810        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Configuring autostart database',
    788811                                                  30 * 1000, '/usr/bin/sudo',
     
    810833        reporter.testDone();
    811834        return fRc;
    812 
    813835    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
    814836        """
     
    817839        all calls will be perfomed using 'sudo -u sUser'
    818840        """
    819 
    820841        self.oTstDrv.sleep(30);
    821 
    822842        _ = oSession;
    823 
    824843        reporter.testStart('Check the VM %s is running for user %s' % (sVmName, sUser));
    825844        (fRc, _, _, aBuf) = self.guestProcessExecute(oGuestSession, 'Check for running VM',
     
    834853            bufWrapper.write(aBuf);
    835854            fRc = bufWrapper.sVmRunning == sVmName;
    836 
    837855        reporter.testDone();
    838856        return fRc;
    839 
    840 
    841857class tdAutostartOsDarwin(tdAutostartOs):
    842858    """
    843859    Autostart support methods for Darwin guests.
    844860    """
    845 
    846     def __init__(self, oTstDrv, sTestBuildDir, fpApiVer, sGuestAdditionsIso):
    847         _ = sTestBuildDir;
    848         tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
     861    def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None,  \
     862                 cCpus = 1, fPae = None, sGuestAdditionsIso = None):
     863        tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \
     864                               cCpus, fPae, sGuestAdditionsIso);
    849865        raise base.GenError('Testing the autostart functionality for Darwin is not implemented');
    850 
    851 
    852866class tdAutostartOsSolaris(tdAutostartOs):
    853867    """
    854868    Autostart support methods for Solaris guests.
    855869    """
    856 
    857     def __init__(self, oTstDrv, sTestBuildDir, fpApiVer, sGuestAdditionsIso):
    858         _ = sTestBuildDir;
    859         tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
     870    def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None,  \
     871                 cCpus = 1, fPae = None, sGuestAdditionsIso = None):
     872        tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \
     873                               cCpus, fPae, sGuestAdditionsIso);
    860874        raise base.GenError('Testing the autostart functionality for Solaris is not implemented');
    861 
    862 
    863875class tdAutostartOsWin(tdAutostartOs):
    864876    """
    865877    Autostart support methods for Windows guests.
    866878    """
    867 
    868     def __init__(self, oTstDrv, asTestBuildDirs, fpApiVer, sGuestAdditionsIso):
    869         tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
    870         self.sTestBuild = self._findFile('^VirtualBox-.*\\.(exe|msi)$', asTestBuildDirs);
    871         if not self.sTestBuild:
    872             raise base.GenError("VirtualBox install package not found");
     879    def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None,  \
     880                 cCpus = 1, fPae = None, sGuestAdditionsIso = None):
     881        tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \
     882                               cCpus, fPae, sGuestAdditionsIso);
     883        self.sVBoxInstaller = '^VirtualBox-.*\\.(exe|msi)$';
    873884        return;
    874 
    875     def waitVmIsReady(self, oSession, fWaitTrayControl, fWaitFacility = True):
    876         """
    877         Waits the VM is ready after start or reboot.
    878         """
    879         # Give the VM a time to reboot
    880         self.oTstDrv.sleep(30);
    881 
    882         # Waiting the VM is ready.
    883         # To do it, one will try to open the guest session and start the guest process in loop
    884 
    885         if fWaitFacility and not self._waitAdditionsIsRunning(oSession.o.console.guest, fWaitTrayControl):
    886             return (False, None);
    887 
    888         cAttempt = 0;
    889         oGuestSession = None;
    890         while cAttempt < 10:
    891             fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox', 'vbox', 'password', 10 * 1000, False);
    892             if fRc:
    893                 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
    894                                                           30 * 1000, 'C:\\Windows\\System32\\ipconfig.exe',
    895                                                           ['C:\\Windows\\System32\\ipconfig.exe',],
    896                                                           False, False);
    897                 if fRc:
    898                     break;
    899                 self.closeSession(oGuestSession, False);
    900 
    901             self.oTstDrv.sleep(10);
    902             cAttempt += 1;
    903 
    904         return (fRc, oGuestSession);
    905 
    906     def rebootVMAndCheckReady(self, oSession, oGuestSession):
    907         """
    908         Reboot the VM and wait the VM is ready.
    909         """
    910         reporter.testStart('Reboot VM and wait for readiness');
     885    def _checkVmIsReady(self, oGuestSession):
     886        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
     887                                                  30 * 1000, 'C:\\Windows\\System32\\ipconfig.exe',
     888                                                  ['C:\\Windows\\System32\\ipconfig.exe',],
     889                                                  False, False);
     890        return fRc;
     891    def _rebootVM(self, oGuestSession):
    911892        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM',
    912893                                                  30 * 1000, 'C:\\Windows\\System32\\shutdown.exe',
     
    916897        if not fRc:
    917898            reporter.error('Calling the shutdown utility failed');
    918         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    919         if fRc:
    920             (fRc, oGuestSession) = self.waitVmIsReady(oSession, True);
    921         if not fRc:
    922             reporter.error('VM is not ready after reboot');
    923         reporter.testDone();
    924         return (fRc, oGuestSession);
    925 
    926     def powerDownVM(self, oGuestSession):
    927         """
    928         Power down the VM by calling guest process without wating
    929         the VM is really powered off. Also, closes the guest session.
    930         It helps the terminateBySession to stop the VM without aborting.
    931         """
    932 
    933         if oGuestSession is None:
    934             return False;
    935 
    936         reporter.testStart('Power down the VM');
     899        return fRc;
     900    def _powerDownVM(self, oGuestSession):
    937901        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
    938902                                                  30 * 1000, 'C:\\Windows\\System32\\shutdown.exe',
     
    942906        if not fRc:
    943907            reporter.error('Calling the shutdown utility failed');
    944         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    945         if not fRc:
    946             reporter.error('Power down the VM failed');
    947         reporter.testDone();
    948         return fRc;
    949 
     908        return fRc;
    950909    def installAdditions(self, oSession, oGuestSession, oVM):
    951910        """
     
    955914        reporter.testStart('Install Guest Additions');
    956915        asLogFiles = [];
    957 
    958916        fRc = self.closeSession(oGuestSession, True); # pychecker hack.
    959 
    960917        try:
    961918            oCurProgress = oSession.o.console.guest.updateGuestAdditions(self.sGuestAdditionsIso, ['/l',], None);
     
    974931            else:
    975932                fRc = reporter.error('No progress object returned');
    976 
    977933        #---------------------------------------
    978934        #
     
    1016972        #        (fRc, oGuestSession) = self.waitVmIsReady(oSession, False, False);
    1017973        #---------------------------------------
    1018 
    1019974        # Store the result and try download logs anyway.
    1020975        fGaRc = fRc;
     
    1030985                # Note: There won't be a install_ui.log because of the silent installation.
    1031986                asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
    1032 
    1033987                # Download log files.
    1034988                # Ignore errors as all files above might not be present (or in different locations)
     
    1042996        reporter.testDone();
    1043997        return (fRc and fGaRc, oGuestSession);
    1044 
    1045998    def installVirtualBox(self, oGuestSession):
    1046999        """
    10471000        Install VirtualBox in the guest.
    10481001        """
    1049 
    10501002        if self.sTestBuild is None:
    10511003            return False;
     
    10861038                    reporter.log('Content of  VirtualBxox folder:');
    10871039                    reporter.log(str(aBuf));
    1088 
    10891040            asLogFiles = [sLogFile,];
    10901041            self.downloadFiles(oGuestSession, asLogFiles, fIgnoreErrors = True);
    1091 
    10921042        reporter.testDone();
    10931043        return fRc;
    1094 
    10951044    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
    10961045        """
     
    10981047        """
    10991048        reporter.testStart('Configure autostart');
    1100 
    11011049        # Create autostart database directory writeable for everyone
    11021050        (fRc, _, _, _) = \
     
    11151063        else:
    11161064            reporter.error('Setting the autostart environment variable failed');
    1117 
    11181065        reporter.testDone();
    11191066        return fRc;
    1120 
    11211067    def createTestVM(self, oSession, oGuestSession, sUser, sVmName):
    11221068        """
     
    11241070        """
    11251071        _ = oGuestSession;
    1126 
    11271072        reporter.testStart('Create test VM for user %s' % sUser);
    1128 
    11291073        fRc, oGuestSession = self.createSession(oSession, 'Session for user: %s' % (sUser,),
    11301074                                                sUser, 'password', 10 * 1000, True);
     
    11671111        reporter.testDone();
    11681112        return fRc;
    1169 
    11701113    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
    11711114        """
    11721115        Check for VM running in the guest after autostart.
    11731116        """
    1174 
    11751117        self.oTstDrv.sleep(30);
    1176 
    11771118        _ = oGuestSession;
    1178 
    11791119        reporter.testStart('Check the VM %s is running for user %s' % (sVmName, sUser));
    1180 
    11811120        fRc, oGuestSession = self.createSession(oSession, 'Session for user: %s' % (sUser,),
    11821121                                                sUser, 'password', 10 * 1000, True);
     
    11841123            reporter.error('Create session for user %s failed' % sUser);
    11851124        else:
    1186 
    1187 
    11881125            (fRc, _, _, aBuf) = self.guestProcessExecute(oGuestSession, 'Check for running VM',
    11891126                                                         60 * 1000, 'C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe',
     
    11931130                reporter.error('Checking the VM %s is running for user %s failed' % (sVmName, sUser));
    11941131            else:
    1195 
    11961132                bufWrapper = VBoxManageStdOutWrapper();
    11971133                bufWrapper.write(aBuf);
    11981134                fRc = bufWrapper.sVmRunning == sVmName;
    1199 
    12001135            fRc1 = self.closeSession(oGuestSession, True);
    12011136            if not fRc1:
     
    12041139        reporter.testDone();
    12051140        return fRc;
    1206 
    12071141    def createUser(self, oGuestSession, sUser):
    12081142        """
     
    12231157            if not fRc:
    12241158                reporter.error('Adding the user %s to Administrators group failed' % sUser);
    1225 
    12261159        #Allow the user to logon as service
    12271160        if fRc:
     
    12771210        reporter.testDone();
    12781211        return fRc;
    1279 
    1280 
    12811212class tdAutostart(vbox.TestDriver):                                      # pylint: disable=too-many-instance-attributes
    12821213    """
    12831214    Autostart testcase.
    12841215    """
    1285 
    12861216    ksOsLinux   = 'tst-linux'
    12871217    ksOsWindows = 'tst-win'
     
    12891219    ksOsSolaris = 'tst-solaris'
    12901220    ksOsFreeBSD = 'tst-freebsd'
    1291 
    12921221    def __init__(self):
    12931222        vbox.TestDriver.__init__(self);
     
    13001229        self.asTestBuildDirs    = None; #'D:/AlexD/TestBox/TestAdditionalFiles';
    13011230        self.sGuestAdditionsIso = None; #'D:/AlexD/TestBox/TestAdditionalFiles/VBoxGuestAdditions_6.1.2.iso';
    1302 
     1231        oSet = vboxtestvms.TestVmSet(self.oTestVmManager, acCpus = [2], fIgnoreSkippedVm = True);
     1232        # pylint: disable=line-too-long
     1233        oSet.aoTestVms.extend([
     1234            tdAutostartOsWin(oSet, self, self.ksOsWindows, 'Windows7_64', \
     1235                             '6.0/windows7piglit/windows7piglit.vdi', eNic0Type = None, cMbRam = 2048,  \
     1236                             cCpus = 2, fPae = True, sGuestAdditionsIso = self.getGuestAdditionsIso()),
     1237            tdAutostartOsLinux(oSet, self, self.ksOsLinux, 'Ubuntu_64', \
     1238                               '6.0/ub1804piglit/ub1804piglit.vdi', eNic0Type = None, \
     1239                               cMbRam = 2048, cCpus = 2, fPae = None, sGuestAdditionsIso = self.getGuestAdditionsIso())
     1240        ]);
     1241        # pylint: enable=line-too-long
     1242        self.oTestVmSet = oSet;
    13031243    #
    13041244    # Overridden methods.
     
    13121252        reporter.log('      without any default value. The test raises an exception if the');
    13131253        reporter.log('      option is not specified. At least, one directory should be pointed.');
    1314         reporter.log('  --test-vms      <vm1[:vm2[:...]]>');
    1315         reporter.log('      Test the specified VMs in the given order. Use this to change');
    1316         reporter.log('      the execution order or limit the choice of VMs');
    1317         reporter.log('      Default: %s  (all)' % (':'.join(self.asTestVMsDef)));
    1318         reporter.log('  --skip-vms      <vm1[:vm2[:...]]>');
    1319         reporter.log('      Skip the specified VMs when testing.');
    13201254        return rc;
    1321 
    13221255    def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements
    13231256        if asArgs[iArg] == '--test-build-dirs':
     
    13251258            if iArg >= len(asArgs): raise base.InvalidOption('The "--test-build-dirs" takes a paths argument');
    13261259            self.asTestBuildDirs = asArgs[iArg].split(',');
    1327         elif asArgs[iArg] == '--test-vms':
    1328             iArg += 1;
    1329             if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list');
    1330             self.asTestVMs = asArgs[iArg].split(':');
    1331             for s in self.asTestVMs:
    1332                 if s not in self.asTestVMsDef:
    1333                     raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
    1334                         % (s, ' '.join(self.asTestVMsDef)));
    1335         elif asArgs[iArg] == '--skip-vms':
    1336             iArg += 1;
    1337             if iArg >= len(asArgs): raise base.InvalidOption('The "--skip-vms" takes colon separated list');
    1338             self.asSkipVMs = asArgs[iArg].split(':');
    1339             for s in self.asSkipVMs:
    1340                 if s not in self.asTestVMsDef:
    1341                     reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s));
     1260            for oTestVm in self.oTestVmSet.aoTestVms:
     1261                oTestVm.asTestBuildDirs = self.asTestBuildDirs;
    13421262        else:
    13431263            return vbox.TestDriver.parseOption(self, asArgs, iArg);
    13441264        return iArg + 1;
    1345 
    13461265    def completeOptions(self):
    13471266        # Remove skipped VMs from the test list.
     
    13511270            try:    self.asTestVMs.remove(sVM);
    13521271            except: pass;
    1353 
    13541272        return vbox.TestDriver.completeOptions(self);
    1355 
    1356     def getResourceSet(self):
    1357         # Construct the resource list the first time it's queried.
    1358         if self.asRsrcs is None:
    1359             self.asRsrcs = [];
    1360             if self.ksOsLinux in self.asTestVMs:
    1361                 self.asRsrcs.append('6.0/ub1804piglit/ub1804piglit.vdi');
    1362             if self.ksOsWindows in self.asTestVMs:
    1363                 self.asRsrcs.append('6.0/windows7piglit/windows7piglit.vdi');
    1364             #disabled
    1365             #if self.ksOsSolaris in self.asTestVMs:
    1366             #    self.asRsrcs.append('4.2/autostart/tst-solaris.vdi');
    1367 
    1368         return self.asRsrcs;
    1369 
    13701273    def actionConfig(self):
    1371 
    1372         # Make sure vboxapi has been imported so we can use the constants.
    1373         if not self.importVBoxApi():
     1274        if not self.importVBoxApi(): # So we can use the constant below.
    13741275            return False;
    1375         #
    1376         # Configure the VMs we're going to use.
    1377         #
    1378 
    1379         fRc = True;
    1380 
    1381         # Linux VMs
    1382         if self.ksOsLinux in self.asTestVMs:
    1383             # ub1804piglit is created with 2 CPUs.
    1384             oVM = self.createTestVM(self.ksOsLinux, 1, '6.0/ub1804piglit/ub1804piglit.vdi', sKind = 'Ubuntu_64', \
    1385                                     fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
    1386                                     eNic0Type = vboxcon.NetworkAdapterType_Am79C973, cMbRam = 2048, \
    1387                                     cCpus = 2, sDvdImage = self.getGuestAdditionsIso());
    1388             if oVM is None:
    1389                 return False;
    1390         # Windows VMs
    1391         if self.ksOsWindows in self.asTestVMs:
    1392             # windows7piglit is created with PAE enabled and 2 CPUs.
    1393             # changed cMbRam to 2GB due to #9618
    1394             oVM = self.createTestVM(self.ksOsWindows, 1, '6.0/windows7piglit/windows7piglit.vdi', sKind = 'Windows7_64', \
    1395                                     fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
    1396                                     sHddControllerType = "SATA Controller", cMbRam = 2048, fPae = True, cCpus = 2, \
    1397                                     sDvdImage = self.getGuestAdditionsIso());
    1398             if oVM is None:
    1399                 return False;
    1400 
    1401             # additional options used during the windows7piglit creation
    1402             oSession = self.openSession(oVM);
    1403             if oSession is not None:
    1404                 fRc = fRc and oSession.setVRamSize(256);
    1405                 fRc = fRc and oSession.setVideoControllerType(vboxcon.GraphicsControllerType_VBoxSVGA)
    1406                 fRc = fRc and oSession.setAccelerate3DEnabled(False);
    1407                 fRc = fRc and oSession.enableUsbOhci(True);
    1408                 fRc = fRc and oSession.enableUsbHid(True);
    1409                 fRc = fRc and oSession.saveSettings();
    1410                 fRc = oSession.close() and fRc and True; # pychecker hack.
    1411                 oSession = None;
    1412             else:
    1413                 fRc = False;
    1414 
    1415         # disabled
    1416         # Solaris VMs
    1417         #if self.ksOsSolaris in self.asTestVMs:
    1418         #    oVM = self.createTestVM(self.ksOsSolaris, 1, '4.2/autostart/tst-solaris.vdi', sKind = 'Solaris_64', \
    1419         #                            fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
    1420         #                            sHddControllerType = "SATA Controller");
    1421         #    if oVM is None:
    1422         #        return False;
    1423 
    1424         return fRc;
    1425 
     1276        return self.oTestVmSet.actionConfig(self);
    14261277    def actionExecute(self):
    14271278        """
    14281279        Execute the testcase.
    14291280        """
    1430         fRc = self.testAutostart();
    1431         return fRc;
    1432 
     1281        return self.oTestVmSet.actionExecute(self, self.testAutostartOneVfg)
    14331282    #
    14341283    # Test execution helpers.
    14351284    #
    1436     def testAutostartRunProgs(self, oSession, sVmName, oVM):
    1437         """
    1438         Test VirtualBoxs autostart feature in a VM.
    1439         """
    1440         reporter.testStart('Autostart ' + sVmName);
    1441 
    1442         oGuestOsHlp = None              # type: tdAutostartOs
    1443         if sVmName == self.ksOsLinux:
    1444             oGuestOsHlp = tdAutostartOsLinux(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1445                                              self.getGuestAdditionsIso());
    1446         elif sVmName == self.ksOsSolaris:
    1447             oGuestOsHlp = tdAutostartOsSolaris(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1448                                                self.getGuestAdditionsIso());
    1449         elif sVmName == self.ksOsDarwin:
    1450             oGuestOsHlp = tdAutostartOsDarwin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1451                                               self.getGuestAdditionsIso());
    1452         elif sVmName == self.ksOsWindows:
    1453             oGuestOsHlp = tdAutostartOsWin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1454                                            self.getGuestAdditionsIso());
    1455 
    1456         sTestUserAllow = 'test1';
    1457         sTestUserDeny = 'test2';
    1458         sTestVmName = 'TestVM';
    1459 
    1460         if oGuestOsHlp is not None:
     1285    def testAutostartOneVfg(self, oVM, oTestVm):
     1286        # Reconfigure the VM
     1287        fRc = True;
     1288        self.logVmInfo(oVM);
     1289        oSession = self.startVmByName(oTestVm.sVmName);
     1290        if oSession is not None:
     1291            sTestUserAllow = 'test1';
     1292            sTestUserDeny = 'test2';
     1293            sTestVmName = 'TestVM';
    14611294            #wait the VM is ready after starting
    1462             (fRc, oGuestSession) = oGuestOsHlp.waitVmIsReady(oSession, True);
     1295            (fRc, oGuestSession) = oTestVm.waitVmIsReady(oSession, True);
    14631296            #install fresh guest additions
    14641297            if fRc:
    1465                 (fRc, oGuestSession) = oGuestOsHlp.installAdditions(oSession, oGuestSession, oVM);
     1298                (fRc, oGuestSession) = oTestVm.installAdditions(oSession, oGuestSession, oVM);
    14661299            # Create two new users
    1467             fRc = fRc and oGuestOsHlp.createUser(oGuestSession, sTestUserAllow);
    1468             fRc = fRc and oGuestOsHlp.createUser(oGuestSession, sTestUserDeny);
     1300            fRc = fRc and oTestVm.createUser(oGuestSession, sTestUserAllow);
     1301            fRc = fRc and oTestVm.createUser(oGuestSession, sTestUserDeny);
    14691302            if fRc is True:
    14701303                # Install VBox first
    1471                 fRc = oGuestOsHlp.installVirtualBox(oGuestSession);
     1304                fRc = oTestVm.installVirtualBox(oGuestSession);
    14721305                if fRc is True:
    1473                     fRc = oGuestOsHlp.configureAutostart(oGuestSession, 'allow', (sTestUserAllow,), (sTestUserDeny,));
     1306                    fRc = oTestVm.configureAutostart(oGuestSession, 'allow', (sTestUserAllow,), (sTestUserDeny,));
    14741307                    if fRc is True:
    14751308                        # Create a VM with autostart enabled in the guest for both users
    1476                         fRc = oGuestOsHlp.createTestVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);
    1477                         fRc = fRc and oGuestOsHlp.createTestVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);
     1309                        fRc = oTestVm.createTestVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);
     1310                        fRc = fRc and oTestVm.createTestVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);
    14781311                        if fRc is True:
    14791312                            # Reboot the guest
    1480                             (fRc, oGuestSession) = oGuestOsHlp.rebootVMAndCheckReady(oSession, oGuestSession);
     1313                            (fRc, oGuestSession) = oTestVm.rebootVMAndCheckReady(oSession, oGuestSession);
    14811314                            if fRc is True:
    14821315                                # Fudge factor - Allow the guest VMs to finish starting up.
    14831316                                self.sleep(60);
    1484                                 fRc = oGuestOsHlp.checkForRunningVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);
     1317                                fRc = oTestVm.checkForRunningVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);
    14851318                                if fRc is True:
    1486                                     fRc = oGuestOsHlp.checkForRunningVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);
     1319                                    fRc = oTestVm.checkForRunningVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);
    14871320                                    if fRc is True:
    14881321                                        reporter.error('Test VM is running inside the guest for denied user');
     
    15001333            else:
    15011334                reporter.error('Creating test users failed');
    1502 
    15031335            if oGuestSession is not None:
    1504                 try:    oGuestOsHlp.powerDownVM(oGuestSession);
     1336                try:    oTestVm.powerDownVM(oGuestSession);
    15051337                except: pass;
    1506         else:
    1507             reporter.error('Guest OS helper not created for VM %s' % (sVmName));
    1508             fRc = False;
    1509 
    1510         reporter.testDone();
    1511         return fRc;
    1512 
    1513     def testAutostartOneCfg(self, sVmName):
    1514         """
    1515         Runs the specified VM thru test #1.
    1516 
    1517         Returns a success indicator on the general test execution. This is not
    1518         the actual test result.
    1519         """
    1520         oVM = self.getVmByName(sVmName);
    1521 
    1522         # Reconfigure the VM
    1523         fRc = True;
    1524         oSession = self.openSession(oVM);
    1525         if oSession is not None:
    1526             fRc = fRc and oSession.enableVirtEx(True);
    1527             fRc = fRc and oSession.enableNestedPaging(True);
    1528             fRc = fRc and oSession.enableNestedHwVirt(True);
    1529             # disable 3D until the error is fixed.
    1530             fRc = fRc and oSession.setAccelerate3DEnabled(False);
    1531             fRc = fRc and oSession.saveSettings();
     1338            try:    self.terminateVmBySession(oSession);
     1339            except: pass;
    15321340            fRc = oSession.close() and fRc and True; # pychecker hack.
    15331341            oSession = None;
    15341342        else:
    15351343            fRc = False;
    1536 
    1537         # Start up.
    1538         if fRc is True:
    1539             self.logVmInfo(oVM);
    1540             oSession = self.startVmByName(sVmName);
    1541             if oSession is not None:
    1542                 fRc = self.testAutostartRunProgs(oSession, sVmName, oVM);
    1543                 try:    self.terminateVmBySession(oSession);
    1544                 except: pass;
    1545             else:
    1546                 fRc = False;
    1547         return fRc;
    1548 
    1549     def testAutostartForOneVM(self, sVmName):
    1550         """
    1551         Runs one VM thru the various configurations.
    1552         """
    1553         reporter.testStart(sVmName);
    1554         fRc = True;
    1555         self.testAutostartOneCfg(sVmName);
    1556         reporter.testDone();
    1557         return fRc;
    1558 
    1559     def testAutostart(self):
    1560         """
    1561         Executes autostart test.
    1562         """
    1563 
    1564         # Loop thru the test VMs.
    1565         for sVM in self.asTestVMs:
    1566             # run test on the VM.
    1567             if not self.testAutostartForOneVM(sVM):
    1568                 fRc = False;
    1569             else:
    1570                 fRc = True;
    1571 
    1572         return fRc;
    1573 
    1574 
    1575 
     1344        return fRc;
    15761345if __name__ == '__main__':
    15771346    sys.exit(tdAutostart().main(sys.argv));
    1578 
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