VirtualBox

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


Ignore:
Timestamp:
Jun 25, 2019 3:12:26 PM (6 years ago)
Author:
vboxsync
Message:

ValKit/tdAddGuestCtrl.py: Cleanups. bugref:9320

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r79330 r79332  
    12491249    Test updating the Guest Additions inside the guest.
    12501250    """
    1251     def __init__(self, sSrc = "", asArgs = None, fFlags = None, oCreds = None):
     1251    def __init__(self, sSrc = "", asArgs = None, afFlags = None, oCreds = None):
    12521252        tdTestGuestCtrlBase.__init__(self, oCreds = oCreds);
    12531253        self.sSrc = sSrc;
    12541254        self.asArgs = asArgs;
    1255         self.fFlags = fFlags;
     1255        self.afFlags = afFlags;
    12561256
    12571257class tdTestResult(object):
     
    46954695        """
    46964696
     4697        ## @todo currently disabled everywhere.
     4698        if self.oTstDrv.fpApiVer < 100.0:
     4699            reporter.log("Skipping updating GAs everywhere for now...");
     4700            return None;
     4701
    46974702        # Skip test for updating Guest Additions if we run on a too old (Windows) guest.
    46984703        ##
     
    47064711            return (None, oTxsSession);
    47074712
    4708         # Some stupid trickery to guess the location of the iso.
    4709         sVBoxValidationKitISO = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxValidationKit.iso'));
    4710         if not os.path.isfile(sVBoxValidationKitISO):
    4711             sVBoxValidationKitISO = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxTestSuite.iso'));
    4712         if not os.path.isfile(sVBoxValidationKitISO):
    4713             sCur = os.getcwd();
    4714             for i in xrange(0, 10):
    4715                 sVBoxValidationKitISO = os.path.join(sCur, 'validationkit/VBoxValidationKit.iso');
    4716                 if os.path.isfile(sVBoxValidationKitISO):
    4717                     break;
    4718                 sVBoxValidationKitISO = os.path.join(sCur, 'testsuite/VBoxTestSuite.iso');
    4719                 if os.path.isfile(sVBoxValidationKitISO):
    4720                     break;
    4721                 sCur = os.path.abspath(os.path.join(sCur, '..'));
    4722                 if i is None: pass; # shut up pychecker/pylint.
    4723         if os.path.isfile(sVBoxValidationKitISO):
    4724             reporter.log('Validation Kit .ISO found at: %s' % (sVBoxValidationKitISO,));
    4725         else:
    4726             reporter.log('Warning: Validation Kit .ISO not found -- some tests might fail');
     4713        sVBoxValidationKitIso = self.oTstDrv.sVBoxValidationKitIso;
     4714        if not os.path.isfile(sVBoxValidationKitIso):
     4715            return reporter.log('Validation Kit .ISO not found at "%s"' % (sVBoxValidationKitIso,));
    47274716
    47284717        sScratch = os.path.join(self.oTstDrv.sScratchPath, "testGctrlUpdateAdditions");
     
    47314720        except OSError as e:
    47324721            if e.errno != errno.EEXIST:
    4733                 reporter.error('Failed: Unable to create scratch directory \"%s\"' % (sScratch,));
    4734                 return (False, oTxsSession);
     4722                return reporter.error('Failed: Unable to create scratch directory \"%s\"' % (sScratch,));
    47354723        reporter.log('Scratch path is: %s' % (sScratch,));
    47364724
     
    47414729                [ tdTestUpdateAdditions(sSrc = ''), tdTestResultFailure() ],
    47424730
    4743                 # Wrong fFlags.
     4731                # Wrong flags.
    47444732                [ tdTestUpdateAdditions(sSrc = self.oTstDrv.getGuestAdditionsIso(),
    4745                                         fFlags = [ 1234 ]), tdTestResultFailure() ],
     4733                                        afFlags = [ 1234 ]), tdTestResultFailure() ],
    47464734
    47474735                # Non-existing .ISO.
     
    47494737
    47504738                # Wrong .ISO.
    4751                 [ tdTestUpdateAdditions(sSrc = sVBoxValidationKitISO), tdTestResultFailure() ],
     4739                [ tdTestUpdateAdditions(sSrc = sVBoxValidationKitIso), tdTestResultFailure() ],
    47524740
    47534741                # The real thing.
     
    47684756
    47694757        fRc = True;
    4770         for (i, aTest) in enumerate(atTests):
    4771             oCurTest = aTest[0]; # tdTestExec, use an index, later.
    4772             oCurRes  = aTest[1]; # tdTestResult
    4773             reporter.log('Testing #%d, sSrc="%s", fFlags="%s" ...' % \
    4774                          (i, oCurTest.sSrc, oCurTest.fFlags));
     4758        for (i, tTest) in enumerate(atTests):
     4759            oCurTest = tTest[0]  # type: tdTestUpdateAdditions
     4760            oCurRes  = tTest[1]  # type: tdTestResult
     4761            reporter.log('Testing #%d, sSrc="%s", afFlags="%s" ...' % (i, oCurTest.sSrc, oCurTest.afFlags,));
     4762
    47754763            oCurTest.setEnvironment(oSession, oTxsSession, oTestVm);
    47764764            fRc, _ = oCurTest.createSession('Test #%d' % (i,));
    4777             if fRc is False:
    4778                 reporter.error('Test #%d failed: Could not create session' % (i,));
     4765            if fRc is not True:
     4766                fRc = reporter.error('Test #%d failed: Could not create session' % (i,));
    47794767                break;
    4780             try:
    4781                 oCurProgress = oCurTest.oGuest.updateGuestAdditions(oCurTest.sSrc, oCurTest.asArgs, oCurTest.fFlags);
     4768
     4769            try:
     4770                oCurProgress = oCurTest.oGuest.updateGuestAdditions(oCurTest.sSrc, oCurTest.asArgs, oCurTest.afFlags);
     4771            except:
     4772                reporter.maybeErrXcpt(oCurRes.fRc, 'Updating Guest Additions exception for sSrc="%s", afFlags="%s":'
     4773                                      % (oCurTest.sSrc, oCurTest.afFlags,));
     4774                fRc = False;
     4775            else:
    47824776                if oCurProgress is not None:
    4783                     oProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTstDrv.oVBoxMgr, self.oTstDrv, "gctrlUpGA");
    4784                     try:
    4785                         oProgress.wait();
    4786                         if not oProgress.isSuccess():
    4787                             oProgress.logResult(fIgnoreErrors = True);
    4788                             fRc = False;
    4789                     except:
    4790                         reporter.logXcpt('Waiting exception for updating Guest Additions:');
     4777                    oWrapperProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTstDrv.oVBoxMgr,
     4778                                                                    self.oTstDrv, "gctrlUpGA");
     4779                    oWrapperProgress.wait();
     4780                    if not oWrapperProgress.isSuccess():
     4781                        oWrapperProgress.logResult(fIgnoreErrors = not oCurRes.fRc);
    47914782                        fRc = False;
    47924783                else:
    4793                     reporter.error('No progress object returned');
    4794                     fRc = False;
    4795             except:
    4796                 # Just log, don't assume an error here (will be done in the main loop then).
    4797                 reporter.logXcpt('Updating Guest Additions exception for sSrc="%s", fFlags="%s":' \
    4798                                  % (oCurTest.sSrc, oCurTest.fFlags));
    4799                 fRc = False;
     4784                    fRc = reporter.error('No progress object returned');
     4785
    48004786            oCurTest.closeSession();
    48014787            if fRc is oCurRes.fRc:
    48024788                if fRc:
    48034789                    ## @todo Verify if Guest Additions were really updated (build, revision, ...).
     4790                    ## @todo r=bird: Not possible since you're installing the same GAs as before...
     4791                    ##               Maybe check creation dates on certain .sys/.dll/.exe files?
    48044792                    pass;
    48054793            else:
    4806                 reporter.error('Test #%d failed: Got %s, expected %s' % (i, fRc, oCurRes.fRc));
    4807                 fRc = False;
     4794                fRc = reporter.error('Test #%d failed: Got %s, expected %s' % (i, fRc, oCurRes.fRc));
    48084795                break;
    48094796
     
    49414928        asArgs = [ sCmd, '/C', 'dir', '/S', 'c:\\windows' ];
    49424929        aEnv = [];
    4943         fFlags = [];
     4930        afFlags = [];
    49444931
    49454932        for _ in xrange(100):
    49464933            oProc = oGuestSession.processCreate(sCmd, asArgs if self.fpApiVer >= 5.0 else asArgs[1:],
    4947                                                 aEnv, fFlags, 30 * 1000);
     4934                                                aEnv, afFlags, 30 * 1000);
    49484935
    49494936            aWaitFor = [ vboxcon.ProcessWaitForFlag_Terminate ];
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