VirtualBox

Changeset 84615 in vbox


Ignore:
Timestamp:
May 29, 2020 3:47:55 PM (5 years ago)
Author:
vboxsync
Message:

Main: bugref:9341: Testcase: removed redundant creation of guest sessions

File:
1 edited

Legend:

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

    r84590 r84615  
    414414        return (fRc, uExitStatus, iExitCode, aBuf);
    415415
    416     def uploadString(self, oSession, sSrcString, sDst):
     416    def uploadString(self, oGuestSession, sSrcString, sDst):
    417417        """
    418418        Upload the string into guest.
    419419        """
    420 
    421         fRc, oGuestSession = self.createSession(oSession, 'vbox session for installing guest additions',
    422                                                 'vbox', 'password', cMsTimeout = 10 * 1000, fIsError = True);
    423         if fRc is not True:
    424             return reporter.errorXcpt('Upload string failed: Could not create session for vbox');
    425 
     420        fRc = True;
    426421        try:
    427422            oFile = oGuestSession.fileOpenEx(sDst, vboxcon.FileAccessMode_ReadWrite, vboxcon.FileOpenAction_CreateOrReplace,
     
    439434            fRc = reporter.errorXcpt('Upload string failed. Could not close the file %s' % sDst);
    440435
    441         self.closeSession(oGuestSession);
    442         return fRc;
    443 
    444     def uploadFile(self, oSession, sSrc, sDst):
     436        return fRc;
     437
     438    def uploadFile(self, oGuestSession, sSrc, sDst):
    445439        """
    446440        Upload the string into guest.
    447441        """
    448 
    449         fRc, oGuestSession = self.createSession(oSession, 'vbox session for upload the file',
    450                                                 'vbox', 'password', cMsTimeout = 10 * 1000, fIsError = True);
    451         if fRc is not True:
    452             return reporter.errorXcpt('Upload file failed: Could not create session for vbox');
    453 
     442        fRc = True;
    454443        try:
    455444            if self.fpApiVer >= 5.0:
     
    472461                fRc = reporter.error('No progress object returned');
    473462
    474         self.closeSession(oGuestSession);
    475         return fRc;
    476 
    477     def downloadFile(self, oSession, sSrc, sDst, fIgnoreErrors = False):
     463        return fRc;
     464
     465    def downloadFile(self, oGuestSession, sSrc, sDst, fIgnoreErrors = False):
    478466        """
    479467        Upload the string into guest.
    480468        """
    481 
    482         fRc, oGuestSession = self.createSession(oSession, 'vbox session for download the file',
    483                                                 'vbox', 'password', cMsTimeout = 10 * 1000, fIsError = True);
    484         if fRc is not True:
    485             if not fIgnoreErrors:
    486                 return reporter.errorXcpt('Download file failed: Could not create session for vbox');
    487             reporter.log('warning: Download file failed: Could not create session for vbox');
    488             return False;
    489 
     469        fRc = True;
    490470        try:
    491471            if self.fpApiVer >= 5.0:
     
    514494                fRc = False;
    515495
    516         self.closeSession(oGuestSession);
    517         return fRc;
    518 
    519     def downloadFiles(self, oSession, asFiles, fIgnoreErrors = False):
     496        return fRc;
     497
     498    def downloadFiles(self, oGuestSession, asFiles, fIgnoreErrors = False):
    520499        """
    521500        Convenience function to get files from the guest and stores it
     
    535514            ## @todo Check for already existing files on the host and create a new
    536515            #        name for the current file to download.
    537             fRc = self.downloadFile(oSession, sGstFile, sTmpFile, fIgnoreErrors);
     516            fRc = self.downloadFile(oGuestSession, sGstFile, sTmpFile, fIgnoreErrors);
    538517            if fRc:
    539518                reporter.addLogFile(sTmpFile, 'misc/other', 'guest - ' + sGstFile);
     
    560539        """
    561540        Waits the VM is ready after start or reboot.
     541        Returns result (true or false) and guest session obtained
    562542        """
    563543        # Give the VM a time to reboot
     
    568548
    569549        cAttempt = 0;
    570 
     550        oGuestSession = None;
    571551        while cAttempt < 30:
    572552            fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
     
    577557                                                          ['ifconfig',],
    578558                                                          False, False);
    579                 fRc = self.closeSession(oGuestSession, False) and fRc and True; # pychecker hack.
    580 
    581559            if fRc:
    582560                break;
     
    585563            cAttempt += 1;
    586564
    587         return fRc;
    588 
    589     def rebootVMAndCheckReady(self, oSession):
     565        return (fRc, oGuestSession);
     566
     567    def rebootVMAndCheckReady(self, oSession, oGuestSession):
    590568        """
    591569        Reboot the VM and wait the VM is ready.
    592         """
    593 
    594         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    595                                             'vbox', 'password', 10 * 1000, True);
    596         if not fRc:
    597             return fRc;
    598 
     570        Returns result and guest session obtained after reboot
     571        """
    599572        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM',
    600573                                                  30 * 1000, '/usr/bin/sudo',
     
    602575                                                  False, True);
    603576        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    604         fRc = fRc and self.waitVMisReady(oSession);
    605         return fRc;
    606 
    607     def powerDownVM(self, oSession):
     577        if fRc:
     578            (fRc, oGuestSession) = self.waitVMisReady(oSession);
     579        return (fRc, oGuestSession);
     580
     581    def powerDownVM(self, oGuestSession):
    608582        """
    609583        Power down the VM by calling guest process without wating
    610         the VM is really powered off.
     584        the VM is really powered off. Also, closes the guest session.
    611585        It helps the terminateBySession to stop the VM without aborting.
    612586        """
    613 
    614         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    615                                             'vbox', 'password', 10 * 1000, True);
    616         if not fRc:
    617             return fRc;
     587       
     588        if oGuestSession is None:
     589            return False;
    618590
    619591        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
     
    624596        return fRc;
    625597
    626     def installAdditions(self, oSession, oVM):
     598    def installAdditions(self, oSession, oGuestSession, oVM):
    627599        """
    628600        Install guest additions in the guest.
    629601        """
    630         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    631                                             'vbox', 'password', 10 * 1000, True);
    632         if not fRc:
    633             return fRc;
    634 
     602       
     603        fRc = False;
    635604        # Install Kernel headers, which are required for actually installing the Linux Additions.
    636605        if oVM.OSTypeId.startswith('Debian') \
     
    671640
    672641        else:
    673             reporter.error('Installing Linux Additions for kind "%s" is not supported yet' % oVM.sKind);
     642            reporter.error('Installing Linux Additions for the "%s" is not supported yet' % oVM.OSTypeId);
    674643            fRc = False;
    675644
     
    688657                # Due to the GA updates as separate process the above function returns before
    689658                # the actual installation finished. So just wait until the GA installed
    690                 fRc = self.waitVMisReady(oSession);
     659                fRc = self.closeSession(oGuestSession);
     660                if fRc:
     661                    (fRc, oGuestSession) = self.waitVMisReady(oSession);
    691662
    692663                # Download log files.
     
    696667                    asLogFile = [];
    697668                    asLogFile.append('/var/log/vboxadd-install.log');
    698                     self.downloadFiles(oSession, asLogFile, fIgnoreErrors = True);
    699 
    700         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    701         if fRc:
    702             fRc = self.rebootVMAndCheckReady(oSession);
    703 
    704         return fRc;
    705 
    706     def installVirtualBox(self, oSession):
     669                    self.downloadFiles(oGuestSession, asLogFile, fIgnoreErrors = True);
     670
     671        if fRc:
     672            (fRc, oGuestSession) = self.rebootVMAndCheckReady(oSession, oGuestSession);
     673
     674        return (fRc, oGuestSession);
     675
     676    def installVirtualBox(self, oGuestSession):
    707677        """
    708678        Install VirtualBox in the guest.
     
    711681            return False;
    712682
    713         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    714                                             'vbox', 'password', 10 * 1000, True);
    715         if not fRc:
    716             return fRc;
    717 
    718         fRc = self.uploadFile(oSession, self.sTestBuild,
     683        fRc = self.uploadFile(oGuestSession, self.sTestBuild,
    719684                              '/tmp/' + os.path.basename(self.sTestBuild));
    720685
     
    732697                                                       '/tmp/' + os.path.basename(self.sTestBuild),],
    733698                                                      False, True);
    734 
    735         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    736         return fRc;
    737 
    738     def configureAutostart(self, oSession, sDefaultPolicy = 'allow',
     699        return fRc;
     700
     701    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow',
    739702                           asUserAllow = (), asUserDeny = ()):
    740703        """
    741704        Configures the autostart feature in the guest.
    742705        """
    743 
    744         fRc, oGuestSession = self.createSession(oSession, 'Session for confiure autostart',
    745                                                 'vbox', 'password', 10 * 1000, True);
    746         if not fRc:
    747             return fRc;
    748706
    749707        # Create autostart database directory writeable for everyone
     
    755713        sVBoxCfg =   'VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg\n' \
    756714                   + 'VBOXAUTOSTART_DB=/etc/vbox/autostart.d\n';
    757         fRc = fRc and self.uploadString(oSession, sVBoxCfg, '/tmp/virtualbox');
     715        fRc = fRc and self.uploadString(oGuestSession, sVBoxCfg, '/tmp/virtualbox');
    758716        if fRc:
    759717            (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Moving to destination',
     
    770728
    771729        sVBoxCfg = self._createAutostartCfg(sDefaultPolicy, asUserAllow, asUserDeny);
    772         fRc = fRc and self.uploadString(oSession, sVBoxCfg, '/tmp/autostart.cfg');
     730        fRc = fRc and self.uploadString(oGuestSession, sVBoxCfg, '/tmp/autostart.cfg');
    773731        if fRc:
    774732            (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Moving to destination',
     
    783741                                                       '/etc/vbox/autostart.cfg'],
    784742                                                      False, True);
    785         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    786         return fRc;
    787 
    788     def createUser(self, oSession, sUser):
     743        return fRc;
     744
     745    def createUser(self, oGuestSession, sUser):
    789746        """
    790747        Create a new user with the given name
    791748        """
    792749
    793         fRc, oGuestSession = self.createSession(oSession, 'Creating new user',
    794                                                 'vbox', 'password', 10 * 1000, True);
    795         if fRc:
    796             (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Creating new user',
    797                                                       30 * 1000, '/usr/bin/sudo',
    798                                                       ['/usr/bin/sudo', '/usr/sbin/useradd', '-m', '-U',
    799                                                        sUser], False, True);
    800         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
     750        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Creating new user',
     751                                                  30 * 1000, '/usr/bin/sudo',
     752                                                  ['/usr/bin/sudo', '/usr/sbin/useradd', '-m', '-U',
     753                                                   sUser], False, True);
    801754        return fRc;
    802755
    803756    # pylint: enable=too-many-arguments
    804757
    805     def createTestVM(self, oSession, sUser, sVmName):
     758    def createTestVM(self, oSession, oGuestSession, sUser, sVmName):
    806759        """
    807760        Create a test VM in the guest and enable autostart.
     
    809762        all calls will be perfomed using 'sudo -u sUser'
    810763        """
    811 
    812         fRc, oGuestSession = self.createSession(oSession, 'Session for create VM for user: %s' % (sUser,),
    813                                                 'vbox', 'password', 10 * 1000, True);
    814         if not fRc:
    815             return fRc;
     764       
     765        _ = oSession;
    816766
    817767        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Configuring autostart database',
     
    832782                                                       '/opt/VirtualBox/VBoxManage', 'modifyvm',
    833783                                                      sVmName, '--autostart-enabled', 'on'], False, True);
    834         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    835         return fRc;
    836 
    837     def checkForRunningVM(self, oSession, sUser, sVmName):
     784        return fRc;
     785
     786    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
    838787        """
    839788        Check for VM running in the guest after autostart.
     
    842791        """
    843792
    844         fRc, oGuestSession = self.createSession(oSession, 'Session for checking running VMs for user: %s' % (sUser,),
    845                                                 'vbox', 'password', 10 * 1000, True);
    846         if not fRc:
    847             return fRc;
     793        _ = oSession;
    848794
    849795        (fRc, _, _, aBuf) = self.guestProcessExecute(oGuestSession, 'Check for running VM',
     
    857803            fRc = bufWrapper.sVmRunning == sVmName;
    858804
    859         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    860805        return fRc;
    861806
     
    906851
    907852        cAttempt = 0;
    908 
     853        oGuestSession = None;
    909854        while cAttempt < 10:
    910855            fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
     
    915860                                                          ['C:\\Windows\\System32\\ipconfig.exe',],
    916861                                                          False, False);
    917                 fRc = self.closeSession(oGuestSession, False) and fRc and True; # pychecker hack.
    918 
    919862            if fRc:
    920863                break;
     
    923866            cAttempt += 1;
    924867
    925         return fRc;
    926 
    927     def rebootVMAndCheckReady(self, oSession):
     868        return (fRc, oGuestSession);
     869
     870    def rebootVMAndCheckReady(self, oSession, oGuestSession):
    928871        """
    929872        Reboot the VM and wait the VM is ready.
    930873        """
    931 
    932         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    933                                             'vbox', 'password', 10 * 1000, True);
    934         if not fRc:
    935             return fRc;
    936874
    937875        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM',
     
    941879                                                  False, True);
    942880        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    943 
    944         fRc = fRc and self.waitVMisReady(oSession);
    945         return fRc;
    946 
    947     def powerDownVM(self, oSession):
     881        if fRc:
     882            (fRc, oGuestSession) = self.waitVMisReady(oSession);
     883        return (fRc, oGuestSession);
     884
     885    def powerDownVM(self, oGuestSession):
    948886        """
    949887        Power down the VM by calling guest process without wating
    950         the VM is really powered off.
     888        the VM is really powered off. Also, closes the guest session.
    951889        It helps the terminateBySession to stop the VM without aborting.
    952890        """
    953 
    954         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    955                                             'vbox', 'password', 10 * 1000, True);
    956         if not fRc:
    957             return fRc;
     891       
     892        if oGuestSession is None:
     893            return False;
    958894
    959895        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
     
    965901        return fRc;
    966902
    967     def installAdditions(self, oSession, oVM):
     903    def installAdditions(self, oSession, oGuestSession, oVM):
    968904        """
    969905        Installs the Windows guest additions using the test execution service.
    970906        """
    971         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    972                                             'vbox', 'password', 10 * 1000, True);
    973         if not fRc:
    974             return fRc;
    975907        #
    976908        # Delete relevant log files.
     
    1000932            except: pass;
    1001933
    1002         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
     934        fRc = self.closeSession(oGuestSession, True); # pychecker hack.
    1003935
    1004936        try:
     
    1020952
    1021953        if fRc:
    1022             fRc = self.rebootVMAndCheckReady(oSession);
     954            fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
     955                                            'vbox', 'password', 10 * 1000, True);
    1023956            if fRc is True:
    1024                 # Add the Windows Guest Additions installer files to the files we want to download
    1025                 # from the guest.
    1026                 sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
    1027                 asLogFiles.append(sGuestAddsDir + 'install.log');
    1028                 # Note: There won't be a install_ui.log because of the silent installation.
    1029                 asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
    1030                 asLogFiles.append('C:/Windows/setupapi.log');
    1031 
    1032                 # Note: setupapi.dev.log only is available since Windows 2000.
    1033                 if fHaveSetupApiDevLog:
    1034                     asLogFiles.append('C:/Windows/setupapi.dev.log');
    1035 
    1036                 #
    1037                 # Download log files.
    1038                 # Ignore errors as all files above might not be present (or in different locations)
    1039                 # on different Windows guests.
    1040                 #
    1041                 self.downloadFiles(oSession, asLogFiles, fIgnoreErrors = True);
    1042 
    1043         return fRc;
    1044 
    1045     def installVirtualBox(self, oSession):
     957                (fRc, oGuestSession) = self.rebootVMAndCheckReady(oSession, oGuestSession);
     958                if fRc is True:
     959                    # Add the Windows Guest Additions installer files to the files we want to download
     960                    # from the guest.
     961                    sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
     962                    asLogFiles.append(sGuestAddsDir + 'install.log');
     963                    # Note: There won't be a install_ui.log because of the silent installation.
     964                    asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
     965                    asLogFiles.append('C:/Windows/setupapi.log');
     966   
     967                    # Note: setupapi.dev.log only is available since Windows 2000.
     968                    if fHaveSetupApiDevLog:
     969                        asLogFiles.append('C:/Windows/setupapi.dev.log');
     970   
     971                    #
     972                    # Download log files.
     973                    # Ignore errors as all files above might not be present (or in different locations)
     974                    # on different Windows guests.
     975                    #
     976                    self.downloadFiles(oGuestSession, asLogFiles, fIgnoreErrors = True);
     977
     978        return (fRc, oGuestSession);
     979
     980    def installVirtualBox(self, oGuestSession):
    1046981        """
    1047982        Install VirtualBox in the guest.
     
    1051986            return False;
    1052987
    1053         fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    1054                                             'vbox', 'password', 10 * 1000, True);
    1055         if not fRc:
    1056             return fRc;
    1057 
    1058988        # Used windows image already contains the C:\Temp
    1059         fRc = fRc and self.uploadFile(oSession, self.sTestBuild,
    1060                                       'C:\\Temp\\' + os.path.basename(self.sTestBuild));
     989        fRc = self.uploadFile(oGuestSession, self.sTestBuild,
     990                              'C:\\Temp\\' + os.path.basename(self.sTestBuild));
    1061991
    1062992        if fRc:
     
    10721002                                                        ['C:\\Temp\\' + os.path.basename(self.sTestBuild), '--silent'],
    10731003                                                        False, True);
    1074 
    1075         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    1076         return fRc;
    1077 
    1078     def configureAutostart(self, oSession, sDefaultPolicy = 'allow',
     1004        return fRc;
     1005
     1006    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow',
    10791007                           asUserAllow = (), asUserDeny = ()):
    10801008        """
    10811009        Configures the autostart feature in the guest.
    10821010        """
    1083 
    1084         fRc, oGuestSession = self.createSession(oSession, 'Session for confiure autostart',
    1085                                                 'vbox', 'password', 10 * 1000, True);
    1086         if not fRc:
    1087             return fRc;
    10881011
    10891012        # Create autostart database directory writeable for everyone
     
    10981021
    10991022        sVBoxCfg = self._createAutostartCfg(sDefaultPolicy, asUserAllow, asUserDeny);
    1100         fRc = fRc and self.uploadString(oSession, sVBoxCfg, 'C:\\ProgramData\\autostart.cfg');
    1101         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    1102         return fRc;
    1103 
    1104     def createTestVM(self, oSession, sUser, sVmName):
     1023        fRc = fRc and self.uploadString(oGuestSession, sVBoxCfg, 'C:\\ProgramData\\autostart.cfg');
     1024        return fRc;
     1025
     1026    def createTestVM(self, oSession, oGuestSession, sUser, sVmName):
    11051027        """
    11061028        Create a test VM in the guest and enable autostart.
    11071029        """
     1030        _ = oGuestSession;
    11081031
    11091032        fRc, oGuestSession = self.createSession(oSession, 'Session for user: %s' % (sUser,),
     
    11231046                                         ['C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe',
    11241047                                          'modifyvm', sVmName, '--autostart-enabled', 'on'], False, True);
    1125         fRc = fRc and self.uploadString(oSession, 'password', 'C:\\ProgramData\\password.cfg');
     1048        fRc = fRc and self.uploadString(oGuestSession, 'password', 'C:\\ProgramData\\password.cfg');
    11261049        if fRc:
    11271050            (fRc, _, _, _) = \
     
    11361059        return fRc;
    11371060
    1138     def checkForRunningVM(self, oSession, sUser, sVmName):
     1061    def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName):
    11391062        """
    11401063        Check for VM running in the guest after autostart.
    11411064        """
    11421065
     1066        _ = oGuestSession;
     1067       
    11431068        fRc, oGuestSession = self.createSession(oSession, 'Session for user: %s' % (sUser,),
    11441069                                                sUser, 'password', 10 * 1000, True);
     
    11591084        return fRc;
    11601085
    1161     def createUser(self, oSession, sUser):
     1086    def createUser(self, oGuestSession, sUser):
    11621087        """
    11631088        Create a new user with the given name
    11641089        """
    1165 
    1166         fRc, oGuestSession = self.createSession(oSession, 'Creating user %s to run a VM' % sUser,
    1167                                                 'vbox', 'password', 10 * 1000, True);
    1168         if not fRc:
    1169             return fRc;
    11701090
    11711091        # Create user
     
    12161136WScript.Echo "Logon As A Service Right granted to user '"& strUserName &"'"
    12171137                           """ % sUser;
    1218         fRc = fRc and self.uploadString(oSession, sSecPolicyEditor, 'C:\\Temp\\adjustsec.vbs');
     1138        fRc = fRc and self.uploadString(oGuestSession, sSecPolicyEditor, 'C:\\Temp\\adjustsec.vbs');
    12191139        if fRc:
    12201140            (fRc, _, _, _) = self.guestProcessExecute(oGuestSession,
     
    12261146        except:
    12271147            fRc = reporter.errorXcpt('Removing policy script failed');
    1228 
    1229         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    12301148        return fRc;
    12311149
     
    12451163        vbox.TestDriver.__init__(self);
    12461164        self.asRsrcs            = None;
    1247         self.asTestVMsDef       = [self.ksOsLinux, self.ksOsWindows];
     1165        self.asTestVMsDef       = [self.ksOsWindows, self.ksOsLinux]; #[self.ksOsLinux, self.ksOsWindows];
    12481166        self.asTestVMs          = self.asTestVMsDef;
    12491167        self.asSkipVMs          = [];
     
    14281346        if oGuestOsHlp is not None:
    14291347            #wait the VM is ready after starting
    1430             fRc = oGuestOsHlp.waitVMisReady(oSession);
     1348            (fRc, oGuestSession) = oGuestOsHlp.waitVMisReady(oSession);
    14311349            #install fresh guest additions
    1432             fRc = fRc and oGuestOsHlp.installAdditions(oSession, oVM);
     1350            if fRc:
     1351                (fRc, oGuestSession) = oGuestOsHlp.installAdditions(oSession, oGuestSession, oVM);
    14331352            # Create two new users
    1434             fRc = fRc and oGuestOsHlp.createUser(oSession, sTestUserAllow);
    1435             fRc = fRc and oGuestOsHlp.createUser(oSession, sTestUserDeny);
     1353            fRc = fRc and oGuestOsHlp.createUser(oGuestSession, sTestUserAllow);
     1354            fRc = fRc and oGuestOsHlp.createUser(oGuestSession, sTestUserDeny);
    14361355            if fRc is True:
    14371356                # Install VBox first
    1438                 fRc = oGuestOsHlp.installVirtualBox(oSession);
     1357                fRc = oGuestOsHlp.installVirtualBox(oGuestSession);
    14391358                if fRc is True:
    1440                     fRc = oGuestOsHlp.configureAutostart(oSession, 'allow', (sTestUserAllow,), (sTestUserDeny,));
     1359                    fRc = oGuestOsHlp.configureAutostart(oGuestSession, 'allow', (sTestUserAllow,), (sTestUserDeny,));
    14411360                    if fRc is True:
    14421361                        # Create a VM with autostart enabled in the guest for both users
    1443                         fRc = oGuestOsHlp.createTestVM(oSession, sTestUserAllow, sTestVmName);
    1444                         fRc = fRc and oGuestOsHlp.createTestVM(oSession, sTestUserDeny, sTestVmName);
     1362                        fRc = oGuestOsHlp.createTestVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);
     1363                        fRc = fRc and oGuestOsHlp.createTestVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);
    14451364                        if fRc is True:
    14461365                            # Reboot the guest
    1447                             fRc = oGuestOsHlp.rebootVMAndCheckReady(oSession);
     1366                            (fRc, oGuestSession) = oGuestOsHlp.rebootVMAndCheckReady(oSession, oGuestSession);
    14481367                            if fRc is True:
    14491368                                # Fudge factor - Allow the guest to finish starting up.
    14501369                                self.sleep(30);
    1451                                 fRc = oGuestOsHlp.checkForRunningVM(oSession, sTestUserAllow, sTestVmName);
     1370                                fRc = oGuestOsHlp.checkForRunningVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);
    14521371                                if fRc is True:
    1453                                     fRc = oGuestOsHlp.checkForRunningVM(oSession, sTestUserDeny, sTestVmName);
     1372                                    fRc = oGuestOsHlp.checkForRunningVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);
    14541373                                    if fRc is True:
    14551374                                        reporter.error('Test VM is running inside the guest for denied user');
     
    14681387                reporter.log('Creating test users failed');
    14691388
    1470             try:    oGuestOsHlp.powerDownVM(oSession);
    1471             except: pass;
    1472 
     1389            if oGuestSession is not None:
     1390                try:    oGuestOsHlp.powerDownVM(oGuestSession);
     1391                except: pass;
    14731392        else:
    14741393            reporter.log('Guest OS helper not created for VM %s' % (sVmName));
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