Changeset 84563 in vbox
- Timestamp:
- May 27, 2020 2:06:44 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r84544 r84563 60 60 xrange = range; # pylint: disable=redefined-builtin,invalid-name 61 61 62 def limitString(sString, cLimit = 32): 63 """ 64 Returns a string with ellipsis ("...") when exceeding the specified limit. 65 Useful for toning down logging. By default strings will be shortened at 32 characters. 66 """ 67 if not isinstance(sString, str): 68 return ""; 69 cLen = len(sString); 70 return (sString[:cLimit] + '...[%d more]' % (cLen - cLimit)) if cLen > cLimit else sString; 62 71 63 72 class GuestStream(bytearray): … … 386 395 387 396 def execute(self, oSubTstDrv): 388 reporter.log2('Deleting file "%s" ...' % ( self.sPath,));397 reporter.log2('Deleting file "%s" ...' % (limitString(self.sPath),)); 389 398 try: 390 399 if oSubTstDrv.oTstDrv.fpApiVer >= 5.0: … … 409 418 def execute(self, oSubTstDrv): 410 419 _ = oSubTstDrv; 411 reporter.log2('Deleting directory "%s" ...' % ( self.sPath,));420 reporter.log2('Deleting directory "%s" ...' % (limitString(self.sPath),)); 412 421 try: 413 422 self.oGuestSession.directoryRemove(self.sPath); … … 430 439 431 440 def execute(self, oSubTstDrv): 432 reporter.log2('Deleting tree "%s" ...' % ( self.sPath,));441 reporter.log2('Deleting tree "%s" ...' % (limitString(self.sPath),)); 433 442 try: 434 443 oProgress = self.oGuestSession.directoryRemoveRecursive(self.sPath, self.afFlags); … … 1121 1130 """ 1122 1131 reporter.log2('tdStepStat: sPath=%s enmType=%s hrcExpected=%s fFound=%s fFollowLinks=%s' 1123 % ( self.sPath, self.enmType, self.hrcExpected, self.fFound, self.fFollowLinks,));1132 % (limitString(self.sPath), self.enmType, self.hrcExpected, self.fFound, self.fFollowLinks,)); 1124 1133 1125 1134 # Don't execute non-file tests on older VBox version. … … 1671 1680 # Do the copying. 1672 1681 # 1673 reporter.log2('Copying guest file "%s" to host "%s"' % ( oTest.sSrc, oTest.sDst));1682 reporter.log2('Copying guest file "%s" to host "%s"' % (limitString(oTest.sSrc), limitString(oTest.sDst))); 1674 1683 try: 1675 1684 if self.oTstDrv.fpApiVer >= 5.0: … … 1767 1776 # Do the copying. 1768 1777 # 1769 reporter.log2('Copying guest dir "%s" to host "%s"' % ( oTest.sSrc, oTest.sDst));1778 reporter.log2('Copying guest dir "%s" to host "%s"' % (limitString(oTest.sSrc), limitString(oTest.sDst))); 1770 1779 try: 1771 1780 oCurProgress = oGuestSession.directoryCopyFromGuest(oTest.sSrc, oTest.sDst, oTest.afFlags); … … 1800 1809 Helper function to copy a single file from the host to the guest. 1801 1810 """ 1802 reporter.log2('Copying host file "%s" to guest "%s" (flags %s)' % ( sSrc, sDst, afFlags));1811 reporter.log2('Copying host file "%s" to guest "%s" (flags %s)' % (limitString(sSrc), limitString(sDst), afFlags)); 1803 1812 try: 1804 1813 if self.oTstDrv.fpApiVer >= 5.0: … … 1828 1837 Helper function to copy a directory tree from the host to the guest. 1829 1838 """ 1830 reporter.log2('Copying host directory "%s" to guest "%s" (flags %s)' % ( sSrc, sDst, afFlags));1839 reporter.log2('Copying host directory "%s" to guest "%s" (flags %s)' % (limitString(sSrc), limitString(sDst), afFlags)); 1831 1840 try: 1832 1841 oCurProgress = oGuestSession.directoryCopyToGuest(sSrc, sDst, afFlags); … … 1853 1862 Helper function to create a guest directory specified in the current test. 1854 1863 """ 1855 reporter.log2('Creating directory "%s"' % ( oTest.sDirectory,));1864 reporter.log2('Creating directory "%s"' % (limitString(oTest.sDirectory),)); 1856 1865 try: 1857 1866 oGuestSession.directoryCreate(oTest.sDirectory, oTest.fMode, oTest.afFlags); … … 1892 1901 1893 1902 # Open the directory: 1894 reporter.log2('Directory="%s", filter="%s", afFlags="%s"' % ( sCurDir, sFilter, afFlags));1903 reporter.log2('Directory="%s", filter="%s", afFlags="%s"' % (limitString(sCurDir), sFilter, afFlags)); 1895 1904 try: 1896 1905 oCurDir = oGuestSession.directoryOpen(sCurDir, sFilter, afFlags); … … 1912 1921 fRc = False; 1913 1922 else: 1914 reporter.log2('\tNo more directory entries for "%s"' % ( sCurDir,));1923 reporter.log2('\tNo more directory entries for "%s"' % (limitString(sCurDir),)); 1915 1924 break; 1916 1925 … … 1927 1936 % (sName, eType, vboxcon.FsObjType_Directory)); 1928 1937 elif eType == vboxcon.FsObjType_Directory: 1929 reporter.log2(' Directory "%s"' % oFsObjInfo.name);1938 reporter.log2(' Directory "%s"' % limitString(oFsObjInfo.name)); 1930 1939 aSubResult = self.gctrlReadDirTree(oTest, oGuestSession, fIsError, 1931 1940 oTestVm.pathJoin(sSubDir, sName) if sSubDir else sName); … … 2125 2134 # Start the process: 2126 2135 # 2127 reporter.log2('Executing sCmd=%s, afFlags=%s, timeoutMS=%d, asEnv=%s' 2128 % (oTest.sCmd, oTest.afFlags, oTest.timeoutMS, oTest.aEnv,)); 2129 2130 # Don't be too noisy by default when testing reeeeeeally long arguments. 2131 if len(oTest.asArgs) <= 64: 2132 reporter.log2('asArgs=%s' % (oTest.asArgs,)); 2133 else: 2134 reporter.log4('asArgs=%s' % (oTest.asArgs,)); 2135 2136 reporter.log2('Executing sCmd=%s, afFlags=%s, timeoutMS=%d, asArgs=%s, asEnv=%s' 2137 % (oTest.sCmd, oTest.afFlags, oTest.timeoutMS, limitString(oTest.asArgs), limitString(oTest.aEnv),)); 2136 2138 try: 2137 2139 oProcess = oGuestSession.processCreate(oTest.sCmd, … … 3450 3452 reporter.logXcpt('Creating temp directory "%s" failed expectedly, skipping:' % (oCurTest.sDirectory,)); 3451 3453 else: 3452 reporter.log2('Temporary directory is: "%s"' % ( sDirTemp,));3454 reporter.log2('Temporary directory is: "%s"' % (limitString(sDirTemp),)); 3453 3455 if not sDirTemp: 3454 3456 fRc = reporter.error('Resulting directory is empty!'); … … 3472 3474 fRc = reporter.errorXcpt('sDirTemp="%s"' % (sDirTemp,)); 3473 3475 else: 3474 reporter.log2('%s: eType=%s (dir=%d)' % ( sDirTemp, eType, vboxcon.FsObjType_Directory,));3476 reporter.log2('%s: eType=%s (dir=%d)' % (limitString(sDirTemp), eType, vboxcon.FsObjType_Directory,)); 3475 3477 if eType != vboxcon.FsObjType_Directory: 3476 3478 fRc = reporter.error('Temporary directory "%s" not created as a directory: eType=%d' … … 3681 3683 reporter.log('Deleting the file in "%s" ...' % (self.oTestFiles.oManyDir.sPath,)); 3682 3684 for oFile in self.oTestFiles.oManyDir.aoChildren: 3683 reporter.log2('"%s"' % ( oFile.sPath,));3685 reporter.log2('"%s"' % (limitString(oFile.sPath),)); 3684 3686 try: 3685 3687 if self.oTstDrv.fpApiVer >= 5.0: … … 3795 3797 oFsObj = self.oTestFiles.dPaths[sPath]; 3796 3798 reporter.log2('testGuestCtrlFileStat: %s sPath=%s' 3797 % ('file' if isinstance(oFsObj, testfileset.TestFile) else 'dir ', oFsObj.sPath,));3799 % ('file' if isinstance(oFsObj, testfileset.TestFile) else 'dir ', limitString(oFsObj.sPath),)); 3798 3800 3799 3801 # Query the information: … … 4100 4102 # 4101 4103 for oTestFile in aoExtraFiles + self.oTestFiles.aoFiles: # type: testfileset.TestFile 4102 reporter.log2('Test file: %s bytes, "%s" ...' % (oTestFile.cbContent, oTestFile.sPath,));4104 reporter.log2('Test file: %s bytes, "%s" ...' % (oTestFile.cbContent, limitString(oTestFile.sPath),)); 4103 4105 4104 4106 # … … 4656 4658 oCurTest = tTest[0]; # tdTestCopyTo 4657 4659 oCurRes = tTest[1]; # tdTestResult 4658 reporter.log('Testing #%d, sSrc=%s, sDst=%s, afFlags=%s ...' % (i, oCurTest.sSrc, oCurTest.sDst, oCurTest.afFlags)); 4660 reporter.log('Testing #%d, sSrc=%s, sDst=%s, afFlags=%s ...' 4661 % (i, limitString(oCurTest.sSrc), limitString(oCurTest.sDst), oCurTest.afFlags)); 4659 4662 4660 4663 oCurTest.setEnvironment(oSession, oTxsSession, oTestVm); … … 4831 4834 reporter.log('Testing #%d, %s: sSrc="%s", sDst="%s", afFlags="%s" ...' 4832 4835 % (i, "directory" if isinstance(oCurTest, tdTestCopyFromDir) else "file", 4833 oCurTest.sSrc, oCurTest.sDst, oCurTest.afFlags,));4836 limitString(oCurTest.sSrc), limitString(oCurTest.sDst), oCurTest.afFlags,)); 4834 4837 else: 4835 4838 reporter.log('Testing #%d, tdTestRemoveHostDir "%s" ...' % (i, oCurTest.sDir,));
Note:
See TracChangeset
for help on using the changeset viewer.

