VirtualBox

Ignore:
Timestamp:
Jun 10, 2019 10:56:46 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131227
Message:

ValKit: Refactored sub-test driver initialization so it can have both a shortish name for --disable-sub-driver (new) and a test name for reporter.testStart. Working on extending tdGuestOsUnattendedInst1.py to do GA testings. bugref:9151

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/installation/tdGuestOsUnattendedInst1.py

    r79056 r79067  
    5050from testdriver import vboxtestvms;
    5151
     52# Sub-test driver imports.
     53sys.path.append(os.path.join(g_ksValidationKitDir, 'tests', 'additions'));
     54from tdAddGuestCtrl      import SubTstDrvAddGuestCtrl;
     55from tdAddSharedFolders1 import SubTstDrvAddSharedFolders1;
     56
    5257
    5358class UnattendedVm(vboxtestvms.BaseTestVm):
     
    6469    kasIdeIrqDelay   = [ 'VBoxInternal/Devices/piix3ide/0/Config/IRQDelay:1', ];
    6570
    66     ## Install ISO paths relative to the testrsrc root.
    67     kasIosPathBases  = [ os.path.join('6.0', 'isos'), os.path.join('6.1', 'isos'), ];
    68 
    6971    def __init__(self, oSet, sVmName, sKind, sInstallIso, fFlags = 0):
    7072        vboxtestvms.BaseTestVm.__init__(self, sVmName, oSet = oSet, sKind = sKind,
    7173                                        fRandomPvPModeCrap = False if (fFlags & self.kfNoWin81Paravirt) else True);
    72         self.sInstallIso    = sInstallIso;
    73         self.fInstVmFlags   = fFlags;
     74        self.sInstallIso            = sInstallIso;
     75        self.fInstVmFlags           = fFlags;
    7476
    7577        # Adjustments over the defaults.
    76         self.iOptRamAdjust  = 0;
    77         self.fOptIoApic     = None;
    78         self.fOptPae        = None;
    79         self.fOptInstallGAs = False;
    80         self.asOptExtraData = [];
     78        self.iOptRamAdjust          = 0;
     79        self.fOptIoApic             = None;
     80        self.fOptPae                = None;
     81        self.fOptInstallAdditions  = False;
     82        self.asOptExtraData         = [];
    8183        if fFlags & self.kfIdeIrqDelay:
    82             self.asOptExtraData = self.kasIdeIrqDelay;
     84            self.asOptExtraData     = self.kasIdeIrqDelay;
    8385
    8486    def _unattendedConfigure(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
     
    104106        # Install GAs?
    105107        #
    106         if self.fOptInstallGAs:
     108        if self.fOptInstallAdditions:
    107109            try:    oIUnattended.installGuestAdditions = True;
    108110            except: return reporter.errorXcpt();
     
    179181    #
    180182
     183    def getResourceSet(self):
     184        if not os.path.isabs(self.sInstallIso):
     185            return [self.sInstallIso,];
     186        return [];
     187
    181188    def _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage):
    182189        #
     
    190197        fRc = True;
    191198
    192         # Set proper boot order (needed?)
    193         fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
    194         fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_DVD)
     199        ## Set proper boot order - IUnattended::reconfigureVM does this, doesn't it?
     200        #fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
     201        #fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_DVD)
    195202
    196203        # Adjust memory if requested.
    197204        if self.iOptRamAdjust != 0:
    198205            try:    cMbRam = oSession.o.machine.memorySize;
    199             except: fRc   = reporter.errorXcpt();
     206            except: fRc    = reporter.errorXcpt();
    200207            else:
    201                 fRc = fRc and oSession.setRamSize(cMbRam + self.iOptRamAdjust);
     208                fRc = oSession.setRamSize(cMbRam + self.iOptRamAdjust) and fRc;
    202209
    203210        # I/O APIC:
    204211        if self.fOptIoApic is not None:
    205             fRc = fRc and oSession.enableIoApic(self.fOptIoApic);
     212            fRc = oSession.enableIoApic(self.fOptIoApic) and fRc;
    206213
    207214        # I/O APIC:
    208215        if self.fOptPae is not None:
    209             fRc = fRc and oSession.enablePae(self.fOptPae);
     216            fRc = oSession.enablePae(self.fOptPae) and fRc;
    210217
    211218        # Set extra data
    212219        for sExtraData in self.asOptExtraData:
    213             try:
    214                 sKey, sValue = sExtraData.split(':')
    215             except ValueError:
    216                 raise base.InvalidOption('Invalid extradata specified: %s' % sExtraData)
     220            sKey, sValue = sExtraData.split(':');
    217221            reporter.log('Set extradata: %s => %s' % (sKey, sValue))
    218             fRc = fRc and oSession.setExtraData(sKey, sValue)
     222            fRc = oSession.setExtraData(sKey, sValue) and fRc;
    219223
    220224        # Save the settings.
     
    272276        return True;
    273277
     278
    274279    #
    275280    # Our methods.
     
    330335class tdGuestOsInstTest1(vbox.TestDriver):
    331336    """
    332     Guest OS installation tests.
     337    Unattended Guest OS installation tests using IUnattended.
    333338
    334339    Scenario:
    335         - Create new VM that corresponds specified installation ISO image.
    336         - Create HDD that corresponds to OS type that will be installed.
    337         - Boot VM from ISO image (i.e. install guest OS).
    338         - Wait for incomming TCP connection (guest should initiate such a
    339           connection in case installation has been completed successfully).
     340        - Create a new VM with default settings using IMachine::applyDefaults.
     341        - Setup unattended installation using IUnattended.
     342        - Start the VM and do the installation.
     343        - Wait for TXS to report for service.
     344        - If installing GAs:
     345            - Wait for GAs to report operational runlevel.
     346        - Save & restore state.
     347        - If installing GAs:
     348            - Test guest properties (todo).
     349            - Test guest controls.
     350            - Test shared folders.
    340351    """
    341352
     
    349360        assert self.fEnableVrdp; # in parent driver.
    350361
     362
    351363        #
    352364        # Our install test VM set.
     
    354366        oSet = vboxtestvms.TestVmSet(self.oTestVmManager, fIgnoreSkippedVm = True);
    355367        oSet.aoTestVms.extend([
    356             UnattendedVm(oSet, 'tst-w7-32', 'Windows7', 'en_windows_7_enterprise_x86_dvd_x15-70745.iso'),
     368            UnattendedVm(oSet, 'tst-w7-32', 'Windows7', '6.0/uaisos/en_windows_7_enterprise_x86_dvd_x15-70745.iso'),
    357369        ]);
    358370        self.oTestVmSet = oSet;
     
    363375        # Number of VMs to test in parallel:
    364376        self.cInParallel = 1;
     377
     378        # Whether to do the save-and-restore test.
     379        self.fTestSaveAndRestore = True;
     380
     381        #
     382        # Sub-test drivers.
     383        #
     384        self.addSubTestDriver(SubTstDrvAddSharedFolders1(self));
     385        self.addSubTestDriver(SubTstDrvAddGuestCtrl(self));
     386
    365387
    366388    #
     
    450472        elif asArgs[iArg] == '--set-extradata':
    451473            iArg = self.requireMoreArgs(1, asArgs, iArg)
    452             for oTestVm in self.aoSelectedVms:
    453                 oTestVm.asOptExtraData.append(asArgs[iArg]);
     474            sExtraData = asArgs[iArg];
     475            try:     _, _ = sExtraData.split(':');
     476            except: raise base.InvalidOption('Invalid extradata specified: %s' % (sExtraData, ));
     477            for oTestVm in self.aoSelectedVms:
     478                oTestVm.asOptExtraData.append(sExtraData);
    454479        elif asArgs[iArg] == '--ioapic':
    455480            for oTestVm in self.aoSelectedVms:
     
    466491        elif asArgs[iArg] == '--install-additions':
    467492            for oTestVm in self.aoSelectedVms:
    468                 oTestVm.fOptInstallGAs = True;
     493                oTestVm.fOptInstallAdditions = True;
    469494        elif asArgs[iArg] == '--no-install-additions':
    470495            for oTestVm in self.aoSelectedVms:
    471                 oTestVm.fOptInstallGAs = False;
     496                oTestVm.fOptInstallAdditions = False;
    472497        else:
    473498            return vbox.TestDriver.parseOption(self, asArgs, iArg);
     
    491516
    492517        self.logVmInfo(oVM)
    493         reporter.testStart('Installing %s%s' % (oTestVm.sVmName, ' with GAs' if oTestVm.fOptInstallGAs else ''))
     518        reporter.testStart('Installing %s%s' % (oTestVm.sVmName, ' with GAs' if oTestVm.fOptInstallAdditions else ''))
    494519
    495520        cMsTimeout = 40*60000;
     
    497522            cMsTimeout = 180 * 60000; # will be adjusted down.
    498523
    499         oSession, _ = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
     524        oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
    500525        #oSession = self.startVmByName(oTestVm.sVmName); # (for quickly testing waitForGAs)
    501526        if oSession is not None:
    502527            # The guest has connected to TXS.
    503528            reporter.log('Guest reported success via TXS.');
    504             #reporter.log('VM started...');              # (for quickly testing waitForGAs)
     529            reporter.testDone();
    505530
    506531            # If we're installing GAs, wait for them to come online:
    507532            fRc = True;
    508             if oTestVm.fOptInstallGAs:
     533            if oTestVm.fOptInstallAdditions:
     534                reporter.testStart('Guest additions');
    509535                aenmRunLevels = [vboxcon.AdditionsRunLevelType_Userland,];
    510536                if oTestVm.isLoggedOntoDesktop():
    511537                    aenmRunLevels.append(vboxcon.AdditionsRunLevelType_Desktop);
    512538                fRc = self.waitForGAs(oSession, cMsTimeout = cMsTimeout / 2, aenmWaitForRunLevels = aenmRunLevels);
     539                reporter.testDone();
    513540
    514541            # Now do a save & restore test:
    515             if fRc is True:
    516                 pass; ## @todo Do save + restore.
     542            if fRc is True and self.fTestSaveAndRestore:
     543                fRc, oSession, oTxsSession = self.testSaveAndRestore(oSession, oTxsSession, oTestVm);
    517544
    518545            # Test GAs if requested:
    519             if oTestVm.fOptInstallGAs and fRc is True:
    520                 pass;
    521 
    522             reporter.testDone()
    523             fRc = self.terminateVmBySession(oSession) and fRc;
     546            if oTestVm.fOptInstallAdditions and fRc is True:
     547                for oSubTstDrv in self.aoSubTstDrvs:
     548                    if oSubTstDrv.fEnabled:
     549                        reporter.testStart(oSubTstDrv.sTestName);
     550                        fRc2, oTxsSession = oSubTstDrv.testIt(oTestVm, oSession, oTxsSession);
     551                        reporter.testDone(fRc2 is None);
     552                        if fRc2 is False:
     553                            fRc = False;
     554
     555            if oSession is not None:
     556                fRc = self.terminateVmBySession(oSession) and fRc;
    524557            return fRc is True
    525558
     
    529562        return False
    530563
     564    def testSaveAndRestore(self, oSession, oTxsSession, oTestVm):
     565        """
     566        Tests saving and restoring the VM.
     567        """
     568        _ = oTestVm;
     569        reporter.testStart('Save');
     570        ## @todo
     571        reporter.testDone();
     572        reporter.testStart('Restore');
     573        ## @todo
     574        reporter.testDone();
     575        return (True, oSession, oTxsSession);
     576
    531577if __name__ == '__main__':
    532578    sys.exit(tdGuestOsInstTest1().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