VirtualBox

Ignore:
Timestamp:
Aug 21, 2020 2:18:59 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
140036
Message:

Main: bugref:9341: Autostart test: removed redundant script option. Some improvements

File:
1 edited

Legend:

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

    r85470 r85867  
    216216        return sVBoxCfg;
    217217
    218     def _waitAdditionsIsRunning(self, oGuest):
     218    def _waitAdditionsIsRunning(self, oGuest, fWaitTrayControl):
    219219        """
    220220        Check is the additions running
     
    228228                eServiceStatus, _ = oGuest.getFacilityStatus(vboxcon.AdditionsFacilityType_VBoxService);
    229229                fRc = eServiceStatus == vboxcon.AdditionsFacilityStatus_Active;
     230                if fRc and not fWaitTrayControl:
     231                    break;
    230232                if fRc:
    231                     break;
     233                    eServiceStatus, _ = oGuest.getFacilityStatus(vboxcon.AdditionsFacilityType_VBoxTrayClient);
     234                    fRc = eServiceStatus == vboxcon.AdditionsFacilityStatus_Active;
     235                    if fRc:
     236                        break;
    232237
    233238            self.oTestDriver.sleep(10);
     
    499504        except:
    500505            if not fIgnoreErrors:
    501                 reporter.errorXcpt('Download file exception for sSrc="%s":' % (self.sGuestAdditionsIso,));
    502             else:
    503                 reporter.log('warning: Download file exception for sSrc="%s":' % (self.sGuestAdditionsIso,));
     506                reporter.errorXcpt('Download file exception for sSrc="%s":' % (sSrc,));
     507            else:
     508                reporter.log('warning: Download file exception for sSrc="%s":' % (sSrc,));
    504509            fRc = False;
    505510        else:
     
    560565            raise base.GenError("VirtualBox install package not found");
    561566
    562     def waitVMisReady(self, oSession):
     567    def waitVMisReady(self, oSession, fWaitTrayControl):
    563568        """
    564569        Waits the VM is ready after start or reboot.
    565570        Returns result (true or false) and guest session obtained
    566571        """
     572        _ = fWaitTrayControl;
    567573        # Give the VM a time to reboot
    568574        self.oTestDriver.sleep(30);
     
    571577        # To do it, one will try to open the guest session and start the guest process in loop
    572578
    573         if not self._waitAdditionsIsRunning(oSession.o.console.guest):
     579        if not self._waitAdditionsIsRunning(oSession.o.console.guest, False):
    574580            return (False, None);
    575581
     
    609615        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    610616        if fRc:
    611             (fRc, oGuestSession) = self.waitVMisReady(oSession);
     617            (fRc, oGuestSession) = self.waitVMisReady(oSession, False);
    612618
    613619        if not fRc:
     
    705711                fRc = self.closeSession(oGuestSession);
    706712                if fRc:
    707                     (fRc, oGuestSession) = self.waitVMisReady(oSession);
     713                    (fRc, oGuestSession) = self.waitVMisReady(oSession, False);
    708714
    709715                # Download log files.
     
    732738
    733739        reporter.testStart('Install Virtualbox into the guest VM');
     740        reporter.log("Virtualbox install file: %s" % os.path.basename(self.sTestBuild));
    734741
    735742        fRc = self.uploadFile(oGuestSession, self.sTestBuild,
     
    934941        return;
    935942
    936     def waitVMisReady(self, oSession):
     943    def waitVMisReady(self, oSession, fWaitTrayControl, fWaitFacility = True):
    937944        """
    938945        Waits the VM is ready after start or reboot.
     
    944951        # To do it, one will try to open the guest session and start the guest process in loop
    945952
    946         if not self._waitAdditionsIsRunning(oSession.o.console.guest):
     953        if fWaitFacility and not self._waitAdditionsIsRunning(oSession.o.console.guest, fWaitTrayControl):
    947954            return (False, None);
    948955
     
    959966                if fRc:
    960967                    break;
    961 
    962968                self.closeSession(oGuestSession, False);
    963969
     
    981987        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    982988        if fRc:
    983             (fRc, oGuestSession) = self.waitVMisReady(oSession);
     989            (fRc, oGuestSession) = self.waitVMisReady(oSession, True);
    984990        if not fRc:
    985991            reporter.error('VM is not ready after reboot');
     
    10151021        Installs the Windows guest additions using the test execution service.
    10161022        """
    1017         #
    1018         # Delete relevant log files.
    1019         #
    1020         # Note! On some guests the files in question still can be locked by the OS, so ignore
    1021         #       deletion errors from the guest side (e.g. sharing violations) and just continue.
    1022         #
    10231023        reporter.testStart('Install Guest Additions');
    10241024        asLogFiles = [];
    1025         fHaveSetupApiDevLog = False;
    1026         if oVM.OSTypeId in ('WindowsNT4',):
    1027             sWinDir = 'C:/WinNT/';
    1028         else:
    1029             sWinDir = 'C:/Windows/';
    1030             asLogFiles = [sWinDir + 'setupapi.log', sWinDir + 'setupact.log', sWinDir + 'setuperr.log'];
    1031 
    1032             # Apply The SetupAPI logging level so that we also get the (most verbose) setupapi.dev.log file.
    1033             ## @todo !!! HACK ALERT !!! Add the value directly into the testing source image. Later.
    1034             (fHaveSetupApiDevLog, _, _, _) = \
    1035                 self.guestProcessExecute(oGuestSession, 'Enabling setupapi.dev.log',
    1036                                          60 * 1000, 'c:\\Windows\\System32\\reg.exe',
    1037                                          ['c:\\Windows\\System32\\reg.exe', 'add',
    1038                                           '"HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup"',
    1039                                           '/v', 'LogLevel', '/t', 'REG_DWORD', '/d', '0xFF'],
    1040                                          False, True);
    1041         for sFile in asLogFiles:
    1042             try:    oGuestSession.fsObjRemove(sFile);
    1043             except: pass;
    10441025
    10451026        fRc = self.closeSession(oGuestSession, True); # pychecker hack.
    10461027
    10471028        try:
    1048             oCurProgress = oSession.o.console.guest.updateGuestAdditions(self.sGuestAdditionsIso, None, None);
     1029            oCurProgress = oSession.o.console.guest.updateGuestAdditions(self.sGuestAdditionsIso, ['/l',], None);
    10491030        except:
    10501031            reporter.maybeErrXcpt(True, 'Updating Guest Additions exception for sSrc="%s":'
     
    10621043                fRc = reporter.error('No progress object returned');
    10631044
    1064         if fRc:
    1065             fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
    1066                                             'vbox', 'password', 10 * 1000, True);
     1045        #---------------------------------------
     1046        #
     1047        ##
     1048        ## Install the public signing key.
     1049        ##
     1050        #
     1051        #self.oTestDriver.sleep(60 * 2);
     1052        #
     1053        #if oVM.OSTypeId not in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'):
     1054        #    (fRc, _, _, _) = \
     1055        #        self.guestProcessExecute(oGuestSession, 'Installing  SHA1 certificate',
     1056        #                                 60 * 1000, 'D:\\cert\\VBoxCertUtil.exe',
     1057        #                                 ['D:\\cert\\VBoxCertUtil.exe', 'add-trusted-publisher',
     1058        #                                  'D:\\cert\\vbox-sha1.cer'],
     1059        #                                 False, True);
     1060        #    if not fRc:
     1061        #        reporter.error('Error installing SHA1 certificate');
     1062        #    else:
     1063        #        (fRc, _, _, _) = \
     1064        #            self.guestProcessExecute(oGuestSession, 'Installing  SHA1 certificate',
     1065        #                                     60 * 1000, 'D:\\cert\\VBoxCertUtil.exe',
     1066        #                                     ['D:\\cert\\VBoxCertUtil.exe', 'add-trusted-publisher',
     1067        #                                      'D:\\cert\\vbox-sha256.cer'],
     1068        #                                     False, True);
     1069        #        if not fRc:
     1070        #            reporter.error('Error installing SHA256 certificate');
     1071        #
     1072        #(fRc, _, _, _) = \
     1073        #        self.guestProcessExecute(oGuestSession, 'Installing  GA',
     1074        #                                 60 * 1000, 'D:\\VBoxWindowsAdditions.exe',
     1075        #                                 ['D:\\VBoxWindowsAdditions.exe', '/S', '/l',
     1076        #                                  '/no_vboxservice_exit'],
     1077        #                                 False, True);
     1078        #
     1079        #if fRc:
     1080        #    # Due to the GA updates as separate process the above function returns before
     1081        #    # the actual installation finished. So just wait until the GA installed
     1082        #    fRc = self.closeSession(oGuestSession, True);
     1083        #    if fRc:
     1084        #        (fRc, oGuestSession) = self.waitVMisReady(oSession, False, False);
     1085        #---------------------------------------
     1086
     1087        # Store the result and try download logs anyway.
     1088        fGaRc = fRc;
     1089        fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
     1090                                        'vbox', 'password', 10 * 1000, True);
     1091        if fRc is True:
     1092            (fRc, oGuestSession) = self.rebootVMAndCheckReady(oSession, oGuestSession);
    10671093            if fRc is True:
    1068                 (fRc, oGuestSession) = self.rebootVMAndCheckReady(oSession, oGuestSession);
    1069                 if fRc is True:
    1070                     # Add the Windows Guest Additions installer files to the files we want to download
    1071                     # from the guest.
    1072                     sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
    1073                     asLogFiles.append(sGuestAddsDir + 'install.log');
    1074                     # Note: There won't be a install_ui.log because of the silent installation.
    1075                     asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
    1076                     asLogFiles.append('C:/Windows/setupapi.log');
    1077 
    1078                     # Note: setupapi.dev.log only is available since Windows 2000.
    1079                     if fHaveSetupApiDevLog:
    1080                         asLogFiles.append('C:/Windows/setupapi.dev.log');
    1081 
    1082                     #
    1083                     # Download log files.
    1084                     # Ignore errors as all files above might not be present (or in different locations)
    1085                     # on different Windows guests.
    1086                     #
    1087                     self.downloadFiles(oGuestSession, asLogFiles, fIgnoreErrors = True);
    1088                 else:
    1089                     reporter.error('Reboot after installing GuestAdditions failed');
    1090             else:
    1091                 reporter.error('Create session for user vbox after GA updating failed');
    1092         reporter.testDone();
    1093         return (fRc, oGuestSession);
     1094                # Add the Windows Guest Additions installer files to the files we want to download
     1095                # from the guest.
     1096                sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
     1097                asLogFiles.append(sGuestAddsDir + 'install.log');
     1098                # Note: There won't be a install_ui.log because of the silent installation.
     1099                asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
     1100
     1101                # Download log files.
     1102                # Ignore errors as all files above might not be present (or in different locations)
     1103                # on different Windows guests.
     1104                #
     1105                self.downloadFiles(oGuestSession, asLogFiles, fIgnoreErrors = True);
     1106            else:
     1107                reporter.error('Reboot after installing GuestAdditions failed');
     1108        else:
     1109            reporter.error('Create session for user vbox after GA updating failed');
     1110        reporter.testDone();
     1111        return (fRc and fGaRc, oGuestSession);
    10941112
    10951113    def installVirtualBox(self, oGuestSession):
     
    11011119            return False;
    11021120        reporter.testStart('Install Virtualbox into the guest VM');
     1121        reporter.log("Virtualbox install file: %s" % os.path.basename(self.sTestBuild));
    11031122        # Used windows image already contains the C:\Temp
    11041123        fRc = self.uploadFile(oGuestSession, self.sTestBuild,
     
    11081127        else:
    11091128            if self.sTestBuild.endswith('.msi'):
     1129                sLogFile = 'C:\\Temp\\VBoxInstallLog.txt';
    11101130                (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Installing VBox',
    11111131                                                        240 * 1000, 'C:\\Windows\\System32\\msiexec.exe',
    1112                                                         ['msiexec', '/quiet', '/i',
    1113                                                          'C:\\Temp\\' + os.path.basename(self.sTestBuild)],
     1132                                                        ['msiexec', '/quiet', '/norestart', '/i',
     1133                                                         'C:\\Temp\\' + os.path.basename(self.sTestBuild),
     1134                                                        '/lv', sLogFile],
    11141135                                                        False, True);
    11151136                if not fRc:
    11161137                    reporter.error('Installing the VBox from msi installer failed');
    11171138            else:
     1139                sLogFile = 'C:\\Temp\\Virtualbox\\VBoxInstallLog.txt';
    11181140                (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Installing VBox',
    11191141                                                        240 * 1000, 'C:\\Temp\\' + os.path.basename(self.sTestBuild),
    1120                                                         ['C:\\Temp\\' + os.path.basename(self.sTestBuild), '--silent'],
     1142                                                        ['C:\\Temp\\' + os.path.basename(self.sTestBuild), '-vvvv',
     1143                                                         '--silent', '--logging',
     1144                                                         '--msiparams', 'REBOOT=ReallySuppress'],
    11211145                                                        False, True);
    11221146                if not fRc:
    11231147                    reporter.error('Installing the VBox failed');
     1148                else:
     1149                    (_, _, _, aBuf) = self.guestProcessExecute(oGuestSession, 'Check installation',
     1150                                                               240 * 1000, 'C:\\Windows\\System32\\cmd.exe',
     1151                                                               ['c:\\Windows\\System32\\cmd.exe', '/c',
     1152                                                                'dir', 'C:\\Program Files\\Oracle\\VirtualBox\\*.*'],
     1153                                                               True, True);
     1154                    reporter.log('Content of  VirtualBxox folder:');
     1155                    reporter.log(str(aBuf));
     1156
     1157            asLogFiles = [sLogFile,];
     1158            self.downloadFiles(oGuestSession, asLogFiles, fIgnoreErrors = True);
     1159
    11241160        reporter.testDone();
    11251161        return fRc;
     
    13421378        reporter.log('      without any default value. The test raises an exception if the');
    13431379        reporter.log('      option is not specified. At least, one directory should be pointed.');
    1344         reporter.log('  --guest-additions-iso <path/to/iso>');
    1345         reporter.log('      The path to fresh VirtualBox Guest Additions iso. The option is');
    1346         reporter.log('      mandatory without any default value. The test raises an exception');
    1347         reporter.log('      if the option is not specified.');
    13481380        reporter.log('  --test-vms      <vm1[:vm2[:...]]>');
    13491381        reporter.log('      Test the specified VMs in the given order. Use this to change');
     
    13591391            if iArg >= len(asArgs): raise base.InvalidOption('The "--test-build-dirs" takes a paths argument');
    13601392            self.asTestBuildDirs = asArgs[iArg].split(',');
    1361         elif asArgs[iArg] == '--guest-additions-iso':
    1362             iArg += 1;
    1363             if iArg >= len(asArgs): raise base.InvalidOption('The "--guest-additions-iso" takes a path or url to iso argument');
    1364             self.sGuestAdditionsIso = asArgs[iArg];
    13651393        elif asArgs[iArg] == '--test-vms':
    13661394            iArg += 1;
     
    13861414        if self.asTestBuildDirs is None:
    13871415            raise base.InvalidOption('--test-build-dirs is not specified')
    1388         if self.sGuestAdditionsIso is None:
    1389             raise base.InvalidOption('--guest-additions-iso is not specified')
    1390 
    13911416        for sVM in self.asSkipVMs:
    13921417            try:    self.asTestVMs.remove(sVM);
     
    14141439        if not self.importVBoxApi():
    14151440            return False;
    1416 
    1417         # Download VBoxGuestAdditions.iso before work
    1418         sDestinationIso = os.path.join(self.sScratchPath, 'VBoxGuestAdditions.iso');
    1419         utils.noxcptDeleteFile(sDestinationIso);
    1420         if not downloadFile(self.sGuestAdditionsIso, sDestinationIso, '', reporter.log, reporter.error):
    1421             raise base.GenError("Could not download VBoxGuestAdditions.iso");
    1422         self.sGuestAdditionsIso = sDestinationIso;
    1423 
    14241441        #
    14251442        # Configure the VMs we're going to use.
     
    14341451                                    fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
    14351452                                    eNic0Type = vboxcon.NetworkAdapterType_Am79C973, cMbRam = 2048, \
    1436                                     cCpus = 2, sDvdImage = self.sGuestAdditionsIso);
     1453                                    cCpus = 2, sDvdImage = self.getGuestAdditionsIso());
    14371454            if oVM is None:
    14381455                return False;
     
    14441461                                    fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
    14451462                                    sHddControllerType = "SATA Controller", cMbRam = 2048, fPae = True, cCpus = 2, \
    1446                                     sDvdImage = self.sGuestAdditionsIso);
     1463                                    sDvdImage = self.getGuestAdditionsIso());
    14471464            if oVM is None:
    14481465                return False;
     
    14921509        if sVmName == self.ksOsLinux:
    14931510            oGuestOsHlp = tdAutostartOsLinux(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1494                                              self.sGuestAdditionsIso);
     1511                                             self.getGuestAdditionsIso());
    14951512        elif sVmName == self.ksOsSolaris:
    14961513            oGuestOsHlp = tdAutostartOsSolaris(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1497                                                self.sGuestAdditionsIso);
     1514                                               self.getGuestAdditionsIso());
    14981515        elif sVmName == self.ksOsDarwin:
    14991516            oGuestOsHlp = tdAutostartOsDarwin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1500                                               self.sGuestAdditionsIso);
     1517                                              self.getGuestAdditionsIso());
    15011518        elif sVmName == self.ksOsWindows:
    15021519            oGuestOsHlp = tdAutostartOsWin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type
    1503                                            self.sGuestAdditionsIso);
     1520                                           self.getGuestAdditionsIso());
    15041521
    15051522        sTestUserAllow = 'test1';
     
    15091526        if oGuestOsHlp is not None:
    15101527            #wait the VM is ready after starting
    1511             (fRc, oGuestSession) = oGuestOsHlp.waitVMisReady(oSession);
     1528            (fRc, oGuestSession) = oGuestOsHlp.waitVMisReady(oSession, True);
    15121529            #install fresh guest additions
    15131530            if fRc:
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette