VirtualBox

Changeset 84597 in vbox


Ignore:
Timestamp:
May 28, 2020 4:03:23 PM (5 years ago)
Author:
vboxsync
Message:

ValKit/tdAddBasci1.py+vbox.py: Refactored txsDownloadFiles to get rid of path style issues and be a little more flexible wrt. filenames and stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/vbox.py

    r84581 r84597  
    34373437
    34383438        Returns False on error, logged.
    3439 
    34403439        Returns task result on success.
    34413440        """
     
    35433542                              (sRemoteFile, sLocalFile, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
    35443543
    3545     def txsDownloadFiles(self, oSession, oTxsSession, asFiles, fIgnoreErrors = False):
    3546         """
    3547         Convenience function to get files from the guest and stores it
    3548         into the scratch directory for later (manual) review.
     3544    def txsDownloadFiles(self, oSession, oTxsSession, aasFiles, fAddToLog = True, fIgnoreErrors = False):
     3545        """
     3546        Convenience function to get files from the guest, storing them in the
     3547        scratch and adding them to the test result set (optional, but default).
     3548
     3549        The aasFiles parameter contains an array of with guest-path + host-path
     3550        pairs, optionally a file 'kind', description and an alternative upload
     3551        filename can also be specified.
     3552
     3553        Host paths are relative to the scratch directory or they must be given
     3554        in absolute form.  The guest path should be using guest path style.
    35493555
    35503556        Returns True on success.
    3551 
    3552         Returns False on failure, logged.
    3553         """
    3554         fRc = True;
    3555         for sGstFile in asFiles:
    3556             sTmpFile = os.path.join(self.sScratchPath, 'tmp-' + os.path.basename(sGstFile));
    3557             reporter.log2('Downloading file "%s" to "%s" ...' % (sGstFile, sTmpFile));
    3558             # First try to remove (unlink) an existing temporary file, as we don't truncate the file.
    3559             try:    os.unlink(sTmpFile);
     3557        Returns False on failure (unless fIgnoreErrors is set), logged.
     3558        """
     3559        for asEntry in aasFiles:
     3560            # Unpack:
     3561            sGstFile     = asEntry[0];
     3562            sHstFile     = asEntry[1];
     3563            sKind        = asEntry[2] if len(asEntry) > 2 and asEntry[2] else 'misc/other';
     3564            sDescription = asEntry[3] if len(asEntry) > 3 and asEntry[3] else '';
     3565            sAltName     = asEntry[4] if len(asEntry) > 4 and asEntry[4] else None;
     3566            assert len(asEntry) <= 5 and sGstFile and sHstFile;
     3567            if not os.path.isabs(sHstFile):
     3568                sHstFile = os.path.join(self.sScratchPath, sHstFile);
     3569
     3570            reporter.log2('Downloading file "%s" to "%s" ...' % (sGstFile, sHstFile,));
     3571
     3572            try:    os.unlink(sHstFile); ## @todo txsDownloadFile doesn't truncate the output file.
    35603573            except: pass;
    3561             ## @todo Check for already existing files on the host and create a new
    3562             #        name for the current file to download.
    3563             fRc = self.txsDownloadFile(oSession, oTxsSession, sGstFile, sTmpFile, 30 * 1000, fIgnoreErrors);
     3574
     3575            fRc = self.txsDownloadFile(oSession, oTxsSession, sGstFile, sHstFile, 30 * 1000, fIgnoreErrors);
    35643576            if fRc:
    3565                 reporter.addLogFile(sTmpFile, 'misc/other', 'guest - ' + sGstFile);
     3577                if fAddToLog:
     3578                    reporter.addLogFile(sHstFile, sKind, sDescription, sAltName);
    35663579            else:
    35673580                if fIgnoreErrors is not True:
    3568                     reporter.error('error downloading file "%s" to "%s"' % (sGstFile, sTmpFile));
    3569                     return fRc;
     3581                    return reporter.error('error downloading file "%s" to "%s"' % (sGstFile, sHstFile));
    35703582                reporter.log('warning: file "%s" was not downloaded, ignoring.' % (sGstFile,));
    35713583        return True;
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddBasic1.py

    r84529 r84597  
    193193        the actual test result.
    194194        """
    195         fRc = False;
    196 
    197         if oTestVm.isWindows():
    198             self.sFileCdWait = 'VBoxWindowsAdditions.exe';
    199         elif oTestVm.isLinux():
    200             self.sFileCdWait = 'VBoxLinuxAdditions.run';
    201 
    202         self.logVmInfo(oVM);
    203 
     195        # HACK ALERT! HORRIBLE MESS THAT SHOULDN'T BE HERE!
     196        aasLogFiles = [ ];
    204197        if oTestVm.isLinux():
    205198            reporter.testStart('Enabling udev logging ...');
     
    207200            reporter.testDone();
    208201            if oTxsSession:
    209                 oTxsSession.syncExec("sed",
    210                                      ("sed", "-i", "'s/.*udev_log.*/udev_log=\"debug\"/'", "/etc/udev/udev.conf"),
     202                oTxsSession.syncExec("sed", ("sed", "-i", "'s/.*udev_log.*/udev_log=\"debug\"/'", "/etc/udev/udev.conf"),
    211203                                     fIgnoreErrors = True);
    212204
    213205                sUDevMonitorLog = '/tmp/udev_monitor.log';
     206                aasLogFiles.append((sUDevMonitorLog, 'guest-udev_monitor-%s.log' % (oTestVm.sVmName,),));
    214207
    215208                reporter.testStart('Enabling udev monitoring ...');
     
    228221                oTxsSession.syncUploadString(sUdevSvc.getvalue(), '/etc/systemd/system/systemd-udev-monitor.service', 0o644,
    229222                                             fIgnoreErrors = True);
    230                 oTxsSession.syncExec("systemctl", ("systemctl", "enable", "systemd-udev-monitor.service"),
    231                                      fIgnoreErrors = True);
     223                oTxsSession.syncExec("systemctl", ("systemctl", "enable", "systemd-udev-monitor.service"), fIgnoreErrors = True);
    232224                reporter.testDone();
     225        # HACK ALERT - END.
     226
     227        fRc = False;
     228
     229        self.logVmInfo(oVM);
     230
     231        if oTestVm.isWindows():
     232            self.sFileCdWait = 'VBoxWindowsAdditions.exe';
     233        elif oTestVm.isLinux():
     234            self.sFileCdWait = 'VBoxLinuxAdditions.run';
    233235
    234236        reporter.testStart('Waiting for TXS + CD (%s)' % (self.sFileCdWait,));
     
    243245        reporter.testDone();
    244246
    245         if oTestVm.isLinux():
    246             asLogFiles = [ sUDevMonitorLog ];
    247             self.txsDownloadFiles(oSession, oTxsSession, asLogFiles, fIgnoreErrors = True);
     247        # More HACK ALERT stuff.
     248        if aasLogFiles and oTxsSession:
     249            self.txsDownloadFiles(oSession, oTxsSession, aasLogFiles, fIgnoreErrors = True);
    248250
    249251        if oSession is not None:
     
    418420        #       deletion errors from the guest side (e.g. sharing violations) and just continue.
    419421        #
    420         asLogFiles = [];
    421         fHaveSetupApiDevLog = False;
    422422        sWinDir = self.getGuestWinDir(oTestVm);
    423         asLogFiles = [ oTestVm.pathJoin(sWinDir, 'setupapi.log'),
    424                        oTestVm.pathJoin(sWinDir, 'setupact.log'),
    425                        oTestVm.pathJoin(sWinDir, 'setuperr.log') ];
     423        aasLogFiles = [
     424            ( oTestVm.pathJoin(sWinDir, 'setupapi.log'), 'ga-setupapi-%s.log' % (oTestVm.sVmName,), ),
     425            ( oTestVm.pathJoin(sWinDir, 'setupact.log'), 'ga-setupact-%s.log' % (oTestVm.sVmName,), ),
     426            ( oTestVm.pathJoin(sWinDir, 'setuperr.log'), 'ga-setuperr-%s.log' % (oTestVm.sVmName,), ),
     427        ];
    426428
    427429        # Apply The SetupAPI logging level so that we also get the (most verbose) setupapi.dev.log file.
     
    435437                                               fCheckSessionStatus = True);
    436438
    437         for sFile in asLogFiles:
    438             self.txsRmFile(oSession, oTxsSession, sFile, 10 * 1000, fIgnoreErrors = True);
     439        for sGstFile, _ in aasLogFiles:
     440            self.txsRmFile(oSession, oTxsSession, sGstFile, 10 * 1000, fIgnoreErrors = True);
    439441
    440442        #
     
    447449
    448450        # Add the Windows Guest Additions installer files to the files we want to download
    449         # from the guest.
    450         sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
    451         asLogFiles.append(sGuestAddsDir + 'install.log');
    452         # Note: There won't be a install_ui.log because of the silent installation.
    453         asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
    454         asLogFiles.append('C:/Windows/setupapi.log');
     451        # from the guest. Note: There won't be a install_ui.log because of the silent installation.
     452        sGuestAddsDir = 'C:\\Program Files\\Oracle\\VirtualBox Guest Additions\\';
     453        aasLogFiles.append((sGuestAddsDir + 'install.log',           'ga-install-%s.log' % (oTestVm.sVmName,),));
     454        aasLogFiles.append((sGuestAddsDir + 'install_drivers.log',   'ga-install_drivers-%s.log' % (oTestVm.sVmName,),));
     455        aasLogFiles.append(('C:\\Windows\\setupapi.log',             'ga-setupapi-%s.log' % (oTestVm.sVmName,),));
    455456
    456457        # Note: setupapi.dev.log only is available since Windows 2000.
    457458        if fHaveSetupApiDevLog:
    458             asLogFiles.append('C:/Windows/setupapi.dev.log');
     459            aasLogFiles.append(('C:\\Windows\\setupapi.dev.log',     'ga-setupapi.dev-%s.log' % (oTestVm.sVmName,),));
    459460
    460461        #
     
    463464        # on different Windows guests.
    464465        #
    465         self.txsDownloadFiles(oSession, oTxsSession, asLogFiles, fIgnoreErrors = True);
     466        self.txsDownloadFiles(oSession, oTxsSession, aasLogFiles, fIgnoreErrors = True);
    466467
    467468        #
     
    494495
    495496    def testLinuxInstallAdditions(self, oSession, oTxsSession, oTestVm):
    496         _ = oSession;
    497         _ = oTestVm;
    498 
    499         fRc = False;
    500 
    501497        #
    502498        # The actual install.
     
    523519        # Ignore errors as all files above might not be present for whatever reason.
    524520        #
    525         asLogFile = [];
    526         asLogFile.append('/var/log/vboxadd-install.log');
    527         self.txsDownloadFiles(oSession, oTxsSession, asLogFile, fIgnoreErrors = True);
     521        self.txsDownloadFiles(oSession, oTxsSession,
     522                              [('/var/log/vboxadd-install.log', 'vboxadd-install-%s.log' % oTestVm.sName), ],
     523                              fIgnoreErrors = True);
    528524
    529525        # Do the final reboot to get the just installed Guest Additions up and running.
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