Changeset 83734 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Apr 17, 2020 7:36:20 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137252
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddSharedFolders1.py
r82968 r83734 64 64 'E:/vboxvalidationkit/${OS/ARCH}/FsPerf${EXESUFF}', 65 65 ]; 66 self.sGuestSlash = ''; 66 67 67 68 def parseOption(self, asArgs, iArg): … … 94 95 return True; 95 96 97 def mountShareEx(self, oSession, oTxsSession, sShareName, sHostPath, sGuestMountPoint, fMustSucceed): 98 """ 99 Automount a shared folder in the guest, extended version. 100 101 Returns success status, based on fMustSucceed. 102 """ 103 reporter.testStart('Automounting "%s"' % (sShareName,)); 104 105 reporter.log2('Creating shared folder "%s" at "%s" ...' % (sShareName, sGuestMountPoint)); 106 try: 107 oConsole = oSession.o.console; 108 oConsole.createSharedFolder(sShareName, sHostPath, True, True, sGuestMountPoint); 109 except: 110 if fMustSucceed: 111 reporter.errorXcpt('createSharedFolder(%s,%s,True,True,%s)' % (sShareName, sHostPath, sGuestMountPoint)); 112 else: 113 reporter.log('createSharedFolder(%s,%s,True,True,%s) failed, good' % (sShareName, sHostPath, sGuestMountPoint)); 114 reporter.testDone(); 115 return False is fMustSucceed; 116 117 # Check whether we can see the shared folder now. Retry for 30 seconds. 118 msStart = base.timestampMilli(); 119 while True: 120 fRc = oTxsSession.syncIsDir(sGuestMountPoint + self.sGuestSlash + 'candle.dir'); 121 reporter.log2('candle.dir check -> %s' % (fRc,)); 122 if fRc is fMustSucceed: 123 break; 124 if base.timestampMilli() - msStart > 10 * 90000: 125 reporter.error('Shared folder mounting timed out!'); 126 break; 127 self.oTstDrv.sleep(1); 128 129 reporter.testDone(); 130 131 return fRc == fMustSucceed; 132 133 def mountShare(self, oSession, oTxsSession, sShareName, sHostPath, sGuestMountPoint): 134 """ 135 Automount a shared folder in the guest. 136 137 Returns success status. 138 """ 139 return self.mountShareEx(oSession, oTxsSession, sShareName, sHostPath, sGuestMountPoint, fMustSucceed = True); 140 141 def unmountShareEx(self, oSession, oTxsSession, sShareName, sGuestMountPoint, fMustSucceed): 142 """ 143 Unmounts a shared folder in the guest. 144 145 Returns success status, based on fMustSucceed. 146 """ 147 reporter.log2('Autounmount'); 148 try: 149 oConsole = oSession.o.console; 150 oConsole.removeSharedFolder(sShareName); 151 except: 152 if fMustSucceed: 153 reporter.errorXcpt('removeSharedFolder(%s)' % (sShareName,)); 154 else: 155 reporter.log('removeSharedFolder(%s)' % (sShareName,)); 156 reporter.testDone(); 157 return False is fMustSucceed; 158 159 # Check whether the shared folder is gone on the guest now. Retry for 30 seconds. 160 msStart = base.timestampMilli(); 161 while True: 162 fRc2 = oTxsSession.syncIsDir(sGuestMountPoint + self.sGuestSlash + 'candle.dir'); 163 reporter.log2('candle.dir check -> %s' % (fRc2,)); 164 if fRc2 is not fMustSucceed: 165 break; 166 if base.timestampMilli() - msStart > 10 * 90000: 167 reporter.error('Shared folder unmounting timed out!'); 168 fRc = False; 169 break; 170 self.oTstDrv.sleep(1); 171 172 reporter.testDone(); 173 174 return fRc is fMustSucceed; 175 176 def unmountShare(self, oSession, oTxsSession, sShareName, sGuestMountPoint): 177 """ 178 Unmounts a shared folder in the guest, extended version. 179 180 Returns success status, based on fMustSucceed. 181 """ 182 return self.unmountShareEx(oSession, oTxsSession, sShareName, sGuestMountPoint, fMustSucceed = True); 183 96 184 def testIt(self, oTestVm, oSession, oTxsSession): 97 185 """ … … 109 197 return (None, oTxsSession); 110 198 199 # Guess a free mount point inside the guest. 200 if oTestVm.isWindows() or oTestVm.isOS2(): 201 self.sGuestSlash = '\\'; 202 else: 203 self.sGuestSlash = '/'; 204 111 205 # 112 206 # Create the host directory to share. Empty except for a 'candle.dir' subdir 113 207 # that we use to check that it mounted correctly. 114 208 # 115 sSharedFolder1 = os.path.join(self.oTstDrv.sScratchPath, 'shfl1'); 116 reporter.log2('Creating shared host folder "%s"...' % (sSharedFolder1,)); 117 if os.path.exists(sSharedFolder1): 118 try: shutil.rmtree(sSharedFolder1); 119 except: return (reporter.errorXcpt('shutil.rmtree(%s)' % (sSharedFolder1,)), oTxsSession); 120 try: os.mkdir(sSharedFolder1); 121 except: return (reporter.errorXcpt('os.mkdir(%s)' % (sSharedFolder1,)), oTxsSession); 122 try: os.mkdir(os.path.join(sSharedFolder1, 'candle.dir')); 123 except: return (reporter.errorXcpt('os.mkdir(%s)' % (sSharedFolder1,)), oTxsSession); 209 sShareName1 = 'shfl1'; 210 sShareHostPath1 = os.path.join(self.oTstDrv.sScratchPath, sShareName1); 211 reporter.log2('Creating shared host folder "%s"...' % (sShareHostPath1,)); 212 if os.path.exists(sShareHostPath1): 213 try: shutil.rmtree(sShareHostPath1); 214 except: return (reporter.errorXcpt('shutil.rmtree(%s)' % (sShareHostPath1,)), oTxsSession); 215 try: os.mkdir(sShareHostPath1); 216 except: return (reporter.errorXcpt('os.mkdir(%s)' % (sShareHostPath1,)), oTxsSession); 217 try: os.mkdir(os.path.join(sShareHostPath1, 'candle.dir')); 218 except: return (reporter.errorXcpt('os.mkdir(%s)' % (sShareHostPath1,)), oTxsSession); 124 219 125 220 # Guess a free mount point inside the guest. 126 221 if oTestVm.isWindows() or oTestVm.isOS2(): 127 222 sMountPoint1 = 'V:'; 128 sGuestSlash = '\\';129 223 else: 130 sMountPoint1 = '/mnt/shfl1'; 131 sGuestSlash = '/'; 132 133 # 134 # Automount a shared folder in the guest. 135 # 136 reporter.testStart('Automount'); 137 138 reporter.log2('Creating shared folder shfl1...'); 139 try: 140 oConsole = oSession.o.console; 141 oConsole.createSharedFolder('shfl1', sSharedFolder1, True, True, sMountPoint1); 142 except: 143 reporter.errorXcpt('createSharedFolder(shfl1,%s,True,True,%s)' % (sSharedFolder1,sMountPoint1)); 144 reporter.testDone(); 145 return (False, oTxsSession); 146 147 # Check whether we can see the shared folder now. Retry for 30 seconds. 148 msStart = base.timestampMilli(); 149 while True: 150 fRc = oTxsSession.syncIsDir(sMountPoint1 + sGuestSlash + 'candle.dir'); 151 reporter.log2('candle.dir check -> %s' % (fRc,)); 152 if fRc is not False: 153 break; 154 if base.timestampMilli() - msStart > 30000: 155 reporter.error('Shared folder mounting timed out!'); 156 break; 157 self.oTstDrv.sleep(1); 158 159 reporter.testDone(); 224 sMountPoint1 = '/mnt/' + sShareName1; 225 226 fRc = self.mountShare(oSession, oTxsSession, sShareName1, sShareHostPath1, sMountPoint1); 160 227 if fRc is not True: 161 228 return (False, oTxsSession); # skip the remainder if we cannot auto mount the folder. … … 166 233 fSkip = 'fsperf' not in self.asTests; 167 234 if fSkip is False: 168 cMbFree = utils.getDiskUsage(sShare dFolder1);235 cMbFree = utils.getDiskUsage(sShareHostPath1); 169 236 if cMbFree >= 16: 170 237 reporter.log2('Free space: %u MBs' % (cMbFree,)); 171 238 else: 172 reporter.log('Skipping FsPerf because only %u MB free on %s' % (cMbFree, sShare dFolder1,));239 reporter.log('Skipping FsPerf because only %u MB free on %s' % (cMbFree, sShareHostPath1,)); 173 240 fSkip = True; 174 241 if fSkip is False: 175 242 # Common arguments: 176 asArgs = ['FsPerf', '-d', sMountPoint1 + s GuestSlash + 'fstestdir-1', '-s8'];243 asArgs = ['FsPerf', '-d', sMountPoint1 + self.sGuestSlash + 'fstestdir-1', '-s8']; 177 244 178 245 # Skip part of mmap on older windows systems without CcCoherencyFlushAndPurgeCache (>= w7). … … 217 284 reporter.log2('FsPerf -> %s' % (fRc,)); 218 285 219 sTestDir = os.path.join(sShare dFolder1, 'fstestdir-1');286 sTestDir = os.path.join(sShareHostPath1, 'fstestdir-1'); 220 287 if os.path.exists(sTestDir): 221 288 fRc = reporter.errorXcpt('test directory lingers: %s' % (sTestDir,)); … … 226 293 reporter.testDone(fSkip or fRc is None); 227 294 295 # 296 # Check if auto-unmounting works. 297 # 298 if fRc is True: 299 fRc = self.unmountShare(oSession, oTxsSession, sShareName1, sMountPoint1); 300 301 ## @todo Add tests for multiple automount shares, random unmounting, reboot test. 302 228 303 return (fRc, oTxsSession); 229 230 304 231 305 def _locateGstFsPerf(self, oTxsSession): … … 244 318 reporter.error('Cannot run standalone, use tdAddBasic1.py'); 245 319 sys.exit(1); 246
Note:
See TracChangeset
for help on using the changeset viewer.