VirtualBox

Changeset 79067 in vbox


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

Location:
trunk/src/VBox/ValidationKit
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/Config.kmk

    r79019 r79067  
    166166#
    167167if1of ($(KBUILD_TARGET), win os2)
    168  VBOX_PYTHONPATH_VALIDATIONKIT = $(PYTHONPATH);$(VBOX_PATH_VALIDATIONKIT_SRC);$(VBOX_PATH_VALIDATIONKIT_SRC)/testboxscript;$(VBOX_PATH_VALIDATIONKIT_SRC)/testmanager:$(VBOX_PATH_VALIDATIONKIT_SRC)/../VMM/VMMAll
     168 VBOX_PYTHONPATH_VALIDATIONKIT = $(PYTHONPATH);$(VBOX_PATH_VALIDATIONKIT_SRC);$(VBOX_PATH_VALIDATIONKIT_SRC)/testboxscript;$(VBOX_PATH_VALIDATIONKIT_SRC)/testmanager;$(VBOX_PATH_VALIDATIONKIT_SRC)/tests/additions;$(VBOX_PATH_VALIDATIONKIT_SRC)/../VMM/VMMAll
    169169else
    170  VBOX_PYTHONPATH_VALIDATIONKIT = $(PYTHONPATH):$(VBOX_PATH_VALIDATIONKIT_SRC):$(VBOX_PATH_VALIDATIONKIT_SRC)/testboxscript:$(VBOX_PATH_VALIDATIONKIT_SRC)/testmanager;$(VBOX_PATH_VALIDATIONKIT_SRC)/../VMM/VMMAll
     170 VBOX_PYTHONPATH_VALIDATIONKIT = $(PYTHONPATH):$(VBOX_PATH_VALIDATIONKIT_SRC):$(VBOX_PATH_VALIDATIONKIT_SRC)/testboxscript:$(VBOX_PATH_VALIDATIONKIT_SRC)/testmanager:$(VBOX_PATH_VALIDATIONKIT_SRC)/tests/additions:$(VBOX_PATH_VALIDATIONKIT_SRC)/../VMM/VMMAll
    171171endif
    172172BLDDIRS += $(PATH_TARGET)/pylint $(PATH_TARGET)/pyunittest
  • trunk/src/VBox/ValidationKit/testdriver/base.py

    r78973 r79067  
    741741    """
    742742
    743     def __init__(self, sName, oTstDrv):
    744         self.sName              = sName;
    745         self.oTstDrv            = oTstDrv   # type: TestDriverBase
    746         self.asRsrcs            = [];
     743    def __init__(self, oTstDrv, sName, sTestName):
     744        self.oTstDrv            = oTstDrv       # type: TestDriverBase
     745        self.sName              = sName;        # For use with options (--enable-sub-driver sName:sName2)
     746        self.sTestName          = sTestName;    # More descriptive for passing to reporter.testStart().
     747        self.asRsrcs            = []            # type: List(str)
     748        self.fEnabled           = True;         # TestDriverBase --enable-sub-driver and --disable-sub-driver.
    747749
    748750    def showUsage(self):
     
    753755        """
    754756        reporter.log('');
    755         reporter.log('Options for sub-test driver %s:' % (self.sName,));
     757        reporter.log('Options for sub-test driver %s (%s):' % (self.sTestName, self.sName,));
    756758        return True;
    757759
     
    981983                return iNext;
    982984        return iArgs;
     985
     986    def findSubTstDrvByShortName(self, sShortName):
     987        """
     988        Locates a sub-test driver by it's short name.
     989        Returns sub-test driver object reference if found, None if not.
     990        """
     991        for oSubTstDrv in self.aoSubTstDrvs:
     992            if oSubTstDrv.sName == sShortName:
     993                return oSubTstDrv;
     994        return None;
    983995
    984996
     
    13201332        reporter.log('      Do not wipe clean the scratch area during the two clean up');
    13211333        reporter.log('      actions.  This is for facilitating nested test driver execution.');
     1334        if self.aoSubTstDrvs:
     1335            reporter.log('  --enable-sub-driver <sub1>[:..]');
     1336            reporter.log('  --disable-sub-driver <sub1>[:..]');
     1337            reporter.log('     Enables or disables one or more of the sub drivers: %s'
     1338                         % (', '.join([oSubTstDrv.sName for oSubTstDrv in self.aoSubTstDrvs]),));
    13221339        return True;
    13231340
     
    13481365        elif asArgs[iArg] == '--no-wipe-clean':
    13491366            self.fNoWipeClean = True;
     1367        elif asArgs[iArg] in ('--enable-sub-driver', '--disable-sub-driver') and self.aoSubTstDrvs:
     1368            sOption = asArgs[iArg];
     1369            iArg = self.requireMoreArgs(1, asArgs, iArg);
     1370            for sSubTstDrvName in asArgs[iArg].split(':'):
     1371                oSubTstDrv = self.findSubTstDrvByShortName(sSubTstDrvName);
     1372                if oSubTstDrv is None:
     1373                    raise InvalidOption('Unknown sub-test driver given to %s: %s' % (sOption, sSubTstDrvName,));
     1374                oSubTstDrv.fEnabled = sOption == '--enable-sub-driver';
    13501375        elif (asArgs[iArg] == 'all' or asArgs[iArg] in self.asNormalActions) \
    13511376          and self.asActions in self.asSpecialActions:
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddBasic1.py

    r78797 r79067  
    4747from testdriver import vboxcon;
    4848
    49 # Sub test driver imports.
     49# Sub-test driver imports.
    5050sys.path.append(os.path.dirname(os.path.abspath(__file__))); # For sub-test drivers.
    5151from tdAddGuestCtrl import SubTstDrvAddGuestCtrl;
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r78636 r79067  
    944944
    945945    def __init__(self, oTstDrv):
    946         base.SubTestDriverBase.__init__(self, 'add-guest-ctrl', oTstDrv);
     946        base.SubTestDriverBase.__init__(self, oTstDrv, 'add-guest-ctrl', 'Guest Control');
    947947
    948948        ## @todo base.TestBase.
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddSharedFolders1.py

    r78797 r79067  
    5252
    5353    def __init__(self, oTstDrv):
    54         base.SubTestDriverBase.__init__(self, 'add-shared-folders', oTstDrv);
     54        base.SubTestDriverBase.__init__(self, oTstDrv, 'add-shared-folders', 'Shared Folders');
    5555
    5656        self.asTestsDef  = [ 'fsperf', ];
  • trunk/src/VBox/ValidationKit/tests/api/tdAppliance1.py

    r77777 r79067  
    5454
    5555    def __init__(self, oTstDrv):
    56         base.SubTestDriverBase.__init__(self, 'appliance', oTstDrv);
     56        base.SubTestDriverBase.__init__(self, oTstDrv, 'appliance', 'Applicance');
    5757
    5858    def testIt(self):
  • trunk/src/VBox/ValidationKit/tests/api/tdCreateVMWithDefaults1.py

    r79066 r79067  
    5353
    5454    def __init__(self, oTstDrv):
    55         base.SubTestDriverBase.__init__(self, 'create-vm-with-defaults', oTstDrv)
    56         self.asRsrcs = []
     55        base.SubTestDriverBase.__init__(self, oTstDrv, 'create-vm-with-defaults', 'Create VMs with defaults');
    5756
    5857    def testIt(self):
     
    6160        """
    6261        reporter.log('ValidationKit folder is "%s"' % (g_ksValidationKitDir,))
    63         reporter.testStart('Create VMs with defaults');
     62        reporter.testStart(self.sTestName);
    6463        fRc = self.testCreateVMWithDefaults();
    6564        reporter.testDone();
  • trunk/src/VBox/ValidationKit/tests/api/tdMoveMedium1.py

    r78391 r79067  
    5454
    5555    def __init__(self, oTstDrv):
    56         base.SubTestDriverBase.__init__(self, 'move-medium', oTstDrv)
     56        base.SubTestDriverBase.__init__(self, oTstDrv, 'move-medium', 'Move Medium');
    5757
    5858    def testIt(self):
  • trunk/src/VBox/ValidationKit/tests/api/tdMoveVM1.py

    r78460 r79067  
    5757
    5858    def __init__(self, oTstDrv):
    59         base.SubTestDriverBase.__init__(self, 'move-vm', oTstDrv)
     59        base.SubTestDriverBase.__init__(self, oTstDrv, 'move-vm', 'Move VM');
    6060
    6161        # Note! Hardcoded indexing in test code further down.
     
    8080        Execute the sub-testcase.
    8181        """
     82        reporter.testStart(self.sTestName);
    8283        reporter.log('ValidationKit folder is "%s"' % (g_ksValidationKitDir,))
    83         return self.testVMMove()
     84        fRc = self.testVMMove();
     85        return reporter.testDone(fRc is None)[1] == 0;
    8486
    8587    #
     
    562564        Test machine moving.
    563565        """
    564         reporter.testStart('machine moving')
    565 
    566566        if not self.oTstDrv.importVBoxApi():
    567567            return False
     
    572572        if fSupported is False:
    573573            reporter.log('API version %s is too old. Just skip this test.' % (self.oTstDrv.fpApiVer))
    574             return reporter.testDone()[1] == 0
    575         else:
    576             reporter.log('API version is "%s".' % (self.oTstDrv.fpApiVer))
     574            return None;
     575        reporter.log('API version is "%s".' % (self.oTstDrv.fpApiVer))
    577576
    578577        # Scenarios
     
    638637                if fRc is False:
    639638                    reporter.testFailure('!!!!!!!!!!!!!!!!!! 1st scenario: Check locations failed... !!!!!!!!!!!!!!!!!!')
    640                     return reporter.testDone()[1] == 0
     639                    return False;
    641640            else:
    642641                reporter.testFailure('!!!!!!!!!!!!!!!!!! 1st scenario: Move VM failed... !!!!!!!!!!!!!!!!!!')
    643                 return reporter.testDone()[1] == 0
     642                return False;
    644643
    645644            fRc = oSession.saveSettings()
     
    660659            fRc = self.__testScenario_2(oSession, oMachine, sNewLoc, sOldLoc)
    661660            if fRc is False:
    662                 return reporter.testDone()[1] == 0
     661                return False;
    663662
    664663            #
     
    674673            fRc = self.__testScenario_3(oSession, oMachine, sNewLoc)
    675674            if fRc is False:
    676                 return reporter.testDone()[1] == 0
     675                return False;
    677676
    678677            #
     
    698697            fRc = self.__testScenario_4(oMachine, sNewLoc)
    699698            if fRc is False:
    700                 return reporter.testDone()[1] == 0
     699                return False;
    701700
    702701            #
     
    712711            fRc = self.__testScenario_5(oMachine, sNewLoc, sOldLoc)
    713712            if fRc is False:
    714                 return reporter.testDone()[1] == 0
     713                return False;
    715714
    716715            #
     
    726725            fRc = self.__testScenario_6(oMachine, sNewLoc, sOldLoc)
    727726            if fRc is False:
    728                 return reporter.testDone()[1] == 0
     727                return False;
    729728
    730729#            #
     
    743742            reporter.errorXcpt()
    744743
    745         return reporter.testDone()[1] == 0
     744        return fRc;
    746745
    747746
  • trunk/src/VBox/ValidationKit/tests/api/tdPython1.py

    r76553 r79067  
    5454
    5555    def __init__(self, oTstDrv):
    56         base.SubTestDriverBase.__init__(self, 'python-binding', oTstDrv)
     56        base.SubTestDriverBase.__init__(self, oTstDrv, 'python-binding', 'Python bindings');
    5757
    5858    def testIt(self):
  • trunk/src/VBox/ValidationKit/tests/api/tdTreeDepth1.py

    r76553 r79067  
    5353
    5454    def __init__(self, oTstDrv):
    55         base.SubTestDriverBase.__init__(self, 'tree-depth', oTstDrv)
     55        base.SubTestDriverBase.__init__(self, oTstDrv, 'tree-depth', 'Media and Snapshot tree depths');
    5656
    5757    def testIt(self):
  • 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