Changeset 71519 in vbox for trunk/src/VBox/ValidationKit/tests/additions
- Timestamp:
- Mar 26, 2018 4:20:22 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r70660 r71519 1030 1030 reporter.testDone(fSkip); 1031 1031 1032 # FIXME: Failing test. 1033 # reporter.testStart('Copy to guest'); 1034 # fSkip = 'copy_to' not in self.asTests or fRc is False; 1035 # if fSkip is False: 1036 # fRc, oTxsSession = self.testGuestCtrlCopyTo(oSession, oTxsSession, oTestVm); 1037 # reporter.testDone(fSkip); 1032 reporter.testStart('Copy to guest'); 1033 fSkip = 'copy_to' not in self.asTests or fRc is False; 1034 if fSkip is False: 1035 fRc, oTxsSession = self.testGuestCtrlCopyTo(oSession, oTxsSession, oTestVm); 1036 reporter.testDone(fSkip); 1038 1037 1039 1038 reporter.testStart('Copy from guest'); … … 1090 1089 curProgress = oGuestSession.copyFrom(sSrc, sDst, aFlags); 1091 1090 if curProgress is not None: 1092 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self , "gctrlCopyFrm");1091 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self.oTstDrv, "gctrlFileCopyFrom"); 1093 1092 try: 1094 iRc = oProgress.waitForOperation(0, fIgnoreErrors = True);1095 if iRc != 0:1096 reporter.log('Waiting for copyFrom failed');1093 oProgress.wait(); 1094 if not oProgress.isSuccess(): 1095 oProgress.logResult(fIgnoreErrors = True); 1097 1096 fRc = False; 1098 1097 except: 1099 reporter.logXcpt('Copy from waiting exception for sSrc="%s", sDst="%s":' \ 1100 % (sSrc, sDst)); 1101 fRc = False; 1098 reporter.logXcpt('Waiting exception for sSrc="%s", sDst="%s":' % (sSrc, sDst)); 1099 fRc = False; 1100 else: 1101 reporter.error('No progress object returned'); 1102 fRc = False; 1102 1103 except: 1103 1104 # Just log, don't assume an error here (will be done in the main loop then). 1104 reporter.logXcpt('Copy from exception for sSrc="%s", sDst="%s":' \ 1105 % (sSrc, sDst)); 1105 reporter.logXcpt('Copy from exception for sSrc="%s", sDst="%s":' % (sSrc, sDst)); 1106 1106 fRc = False; 1107 1107 … … 1120 1120 curProgress = oGuestSession.copyTo(sSrc, sDst, aFlags); 1121 1121 if curProgress is not None: 1122 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self , "gctrlCopyTo");1122 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self.oTstDrv, "gctrlCopyFileTo"); 1123 1123 try: 1124 iRc = oProgress.waitForOperation(0, fIgnoreErrors = True);1125 if iRc != 0:1126 reporter.log('Waiting for copyTo failed');1124 oProgress.wait(); 1125 if not oProgress.isSuccess(): 1126 oProgress.logResult(fIgnoreErrors = True); 1127 1127 fRc = False; 1128 1128 except: 1129 reporter.logXcpt('Copy to waiting exception for sSrc="%s", sDst="%s":' \ 1130 % (sSrc, sDst)); 1129 reporter.logXcpt('Wait exception for sSrc="%s", sDst="%s":' % (sSrc, sDst)); 1131 1130 fRc = False; 1132 1131 else: 1133 1132 reporter.error('No progress object returned'); 1133 fRc = False; 1134 1134 except: 1135 1135 # Just log, don't assume an error here (will be done in the main loop then). 1136 reporter.logXcpt('Copy to exception for sSrc="%s", sDst="%s":' \ 1137 % (sSrc, sDst)); 1136 reporter.logXcpt('Copy to exception for sSrc="%s", sDst="%s":' % (sSrc, sDst)); 1138 1137 fRc = False; 1139 1140 return fRc;1141 1142 def gctrlCopyFrom(self, oTest, oRes, oGuestSession, subDir = ''): # pylint: disable=R09141143 """1144 Copies files / directories to the host.1145 Source always contains the absolute path, subDir all paths1146 below it.1147 """1148 ## @todo r=bird: The use subDir and sSubDir in this method is extremely confusing!!1149 # Just follow the coding guidelines and ALWAYS use prefixes, please!1150 fRc = True; # Be optimistic.1151 1152 sSrc = oTest.sSrc;1153 sDst = oTest.sDst;1154 aFlags = oTest.aFlags;1155 1156 if sSrc == "" \1157 or os.path.isfile(sSrc):1158 return self.gctrlCopyFileFrom(oGuestSession, \1159 sSrc, sDst, aFlags);1160 sSrcAbs = sSrc;1161 if subDir != "":1162 sSrcAbs = os.path.join(sSrc, subDir);1163 sFilter = ""; # No filter.1164 1165 sDstAbs = os.path.join(sDst, subDir);1166 reporter.log2('Copying guest directory "%s" to host "%s"' % (sSrcAbs, sDstAbs));1167 1168 try:1169 #reporter.log2('Directory="%s", filter="%s", aFlags="%s"' % (sCurDir, sFilter, aFlags));1170 oCurDir = oGuestSession.directoryOpen(sSrcAbs, sFilter, aFlags);1171 while fRc:1172 try:1173 oFsObjInfo = oCurDir.read();1174 if oFsObjInfo.name == "." \1175 or oFsObjInfo.name == "..":1176 #reporter.log2('\tSkipping "%s"' % (oFsObjInfo.name,));1177 continue; # Skip "." and ".." entries.1178 if oFsObjInfo.type is vboxcon.FsObjType_Directory:1179 #reporter.log2('\tDirectory "%s"' % (oFsObjInfo.name,));1180 sDirCreate = sDst;1181 if subDir != "":1182 sDirCreate = os.path.join(sDirCreate, subDir);1183 sDirCreate = os.path.join(sDirCreate, oFsObjInfo.name);1184 try:1185 reporter.log2('\tCreating directory "%s"' % (sDirCreate,));1186 os.makedirs(sDirCreate);1187 sSubDir = oFsObjInfo.name;1188 if subDir != "":1189 sSubDir = os.path.join(subDir, oFsObjInfo.name);1190 self.gctrlCopyFrom(oTest, oRes, oGuestSession, sSubDir);1191 except (OSError) as e:1192 if e.errno == errno.EEXIST:1193 pass;1194 else:1195 # Just log, don't assume an error here (will be done in the main loop then).1196 reporter.logXcpt('\tDirectory creation exception for directory="%s":' % (sSubDir,));1197 raise;1198 elif oFsObjInfo.type is vboxcon.FsObjType_File:1199 #reporter.log2('\tFile "%s"' % (oFsObjInfo.name,));1200 sSourceFile = os.path.join(sSrcAbs, oFsObjInfo.name);1201 sDestFile = os.path.join(sDstAbs, oFsObjInfo.name);1202 self.gctrlCopyFileFrom(oGuestSession, sSourceFile, sDestFile, aFlags);1203 elif oFsObjInfo.type is vboxcon.FsObjType_Symlink:1204 #reporter.log2('\tSymlink "%s" -- not tested yet' % oFsObjInfo.name);1205 pass;1206 else:1207 reporter.error('\tDirectory "%s" contains invalid directory entry "%s" (%d)' \1208 % (sSubDir, oFsObjInfo.name, oFsObjInfo.type));1209 fRc = False;1210 except Exception as oXcpt:1211 # No necessarily an error -- could be VBOX_E_OBJECT_NOT_FOUND. See reference.1212 if vbox.ComError.equal(oXcpt, vbox.ComError.VBOX_E_OBJECT_NOT_FOUND):1213 #reporter.log2('\tNo more directory entries for "%s"' % (sCurDir,));1214 break1215 # Just log, don't assume an error here (will be done in the main loop then).1216 reporter.logXcpt('\tDirectory read exception for directory="%s":' % (sSrcAbs,));1217 fRc = False;1218 break;1219 oCurDir.close();1220 except:1221 # Just log, don't assume an error here (will be done in the main loop then).1222 reporter.logXcpt('\tDirectory open exception for directory="%s":' % (sSrcAbs,));1223 fRc = False;1224 1225 return fRc;1226 1227 def gctrlCopyTo(self, oTest, oGuestSession, subDir = ''): # pylint: disable=R09141228 """1229 Copies files / directories to the guest.1230 Source always contains the absolute path,1231 subDir all paths below it.1232 """1233 fRc = True; # Be optimistic.1234 1235 sSrc = oTest.sSrc;1236 sDst = oTest.sDst;1237 aFlags = oTest.aFlags;1238 1239 reporter.log2('sSrc=%s, sDst=%s, aFlags=%s' % (sSrc, sDst, aFlags));1240 1241 sSrcAbs = sSrc;1242 if subDir != "":1243 sSrcAbs = os.path.join(sSrc, subDir);1244 1245 # Note: Current test might want to test copying empty sources1246 if not os.path.exists(sSrcAbs) \1247 or os.path.isfile(sSrcAbs):1248 return self.gctrlCopyFileTo(oGuestSession, \1249 sSrcAbs, sDst, aFlags);1250 1251 sDstAbs = os.path.join(sDst, subDir);1252 reporter.log2('Copying host directory "%s" to guest "%s"' % (sSrcAbs, sDstAbs));1253 1254 try:1255 # Note: Symlinks intentionally not considered here.1256 for (sDirCurrent, oDirs, oFiles) in os.walk(sSrcAbs, topdown=True):1257 for sFile in oFiles:1258 sCurFile = os.path.join(sDirCurrent, sFile);1259 reporter.log2('Processing host file "%s"' % (sCurFile,));1260 sFileDest = os.path.join(sDstAbs, os.path.relpath(sCurFile, sSrcAbs));1261 reporter.log2('Copying file to "%s"' % (sFileDest,));1262 fRc = self.gctrlCopyFileTo(oGuestSession, \1263 sCurFile, sFileDest, aFlags);1264 if fRc is False:1265 break;1266 1267 if fRc is False:1268 break;1269 1270 for sSubDir in oDirs:1271 sCurDir = os.path.join(sDirCurrent, sSubDir);1272 reporter.log2('Processing host dir "%s"' % (sCurDir,));1273 sDirDest = os.path.join(sDstAbs, os.path.relpath(sCurDir, sSrcAbs));1274 reporter.log2('Creating guest dir "%s"' % (sDirDest,));1275 oGuestSession.directoryCreate(sDirDest, \1276 700, [ vboxcon.DirectoryCreateFlag_Parents ]);1277 if fRc is False:1278 break;1279 1280 if fRc is False:1281 break;1282 except:1283 # Just log, don't assume an error here (will be done in the main loop then).1284 reporter.logXcpt('Copy to exception for sSrc="%s", sDst="%s":' \1285 % (sSrcAbs, sDst));1286 return False;1287 1138 1288 1139 return fRc; … … 3366 3217 reporter.error('Test #%d failed: Could not create session' % (i,)); 3367 3218 break; 3368 fRc2 = self.gctrlCopyTo(curTest, curGuestSession); 3219 3220 fRc2 = False; 3221 if os.path.isdir(curTest.sSrc): 3222 try: 3223 curProgress = curGuestSession.directoryCopyToGuest(curTest.sSrc, curTest.sDst, curTest.aFlags); 3224 if curProgress is not None: 3225 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self.oTstDrv, "gctrlDirCopyTo"); 3226 try: 3227 oProgress.wait(); 3228 if not oProgress.isSuccess(): 3229 oProgress.logResult(fIgnoreErrors = True); 3230 fRc = False; 3231 except: 3232 reporter.logXcpt('Waiting exception for sSrc="%s", sDst="%s":' % (curTest.sSrc, curTest.sDst)); 3233 fRc2 = False; 3234 else: 3235 reporter.error('No progress object returned'); 3236 fRc2 = False; 3237 except: 3238 fRc2 = False; 3239 else: 3240 fRc2 = self.gctrlCopyFileTo(curGuestSession, curTest.sSrc, curTest.sDst, curTest.aFlags); 3241 3369 3242 curTest.closeSession(); 3243 3370 3244 if fRc2 is curRes.fRc: 3371 3245 ## @todo Verify the copied results (size, checksum?). … … 3463 3337 reporter.error('Test #%d failed: Could not create session' % (i,)); 3464 3338 break; 3465 fRc2 = self.gctrlCopyFrom(curTest, curRes, curGuestSession); 3339 3340 try: 3341 if self.oTstDrv.fpApiVer >= 5.0: 3342 oFsInfo = curGuestSession.fsObjQueryInfo(curTest.sSrc, True); # fFollowSymlinks 3343 else: 3344 oFsInfo = curGuestSession.fileQueryInfo(curTest.sSrc); 3345 3346 if oFsInfo.type is vboxcon.FsObjType_Directory: 3347 curProgress = curGuestSession.directoryCopyFrom(curTest.sSrc, curTest.sDst, curTest.aFlags); 3348 if curProgress is not None: 3349 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self.oTstDrv, "gctrlDirCopyFrom"); 3350 try: 3351 oProgress.wait(); 3352 if not oProgress.isSuccess(): 3353 oProgress.logResult(fIgnoreErrors = True); 3354 fRc2 = False; 3355 except: 3356 reporter.logXcpt('Waiting exception for sSrc="%s", sDst="%s":' % (curTest.sSrc, curTest.sDst)); 3357 fRc2 = False; 3358 else: 3359 reporter.error('No progress object returned'); 3360 fRc2 = False; 3361 elif oFsInfo.type is vboxcon.FsObjType_File: 3362 fRc2 = self.gctrlCopyFileFrom(curGuestSession, curTest.sSrc, curTest.sDst, curTest.aFlags); 3363 else: 3364 reporter.log2('Element "%s" not handled (yet), skipping' % oFsInfo.name); 3365 pass; 3366 3367 except: 3368 reporter.logXcpt('Query information exception for sSrc="%s", sDst="%s":' % (curTest.sSrc, curTest.sDst)); 3369 fRc2 = False; 3370 3466 3371 curTest.closeSession(); 3467 3372 if fRc2 is curRes.fRc: … … 3561 3466 curProgress = curTest.oTest.oGuest.updateGuestAdditions(curTest.sSrc, curTest.aArgs, curTest.aFlags); 3562 3467 if curProgress is not None: 3563 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self , "gctrlUpGA");3468 oProgress = vboxwrappers.ProgressWrapper(curProgress, self.oTstDrv.oVBoxMgr, self.oTstDrv, "gctrlUpGA"); 3564 3469 try: 3565 iRc = oProgress.waitForOperation(0, fIgnoreErrors = True);3566 if iRc != 0:3567 reporter.log('Waiting for updating Guest Additions failed');3470 oProgress.wait(); 3471 if not oProgress.isSuccess(): 3472 oProgress.logResult(fIgnoreErrors = True); 3568 3473 fRc = False; 3569 3474 except: 3570 reporter.logXcpt('Updating Guest Additions waiting exception for sSrc="%s", aFlags="%s":' \ 3571 % (curTest.sSrc, curTest.aFlags)); 3475 reporter.logXcpt('Waiting exception for updating Guest Additions:'); 3572 3476 fRc = False; 3477 else: 3478 reporter.error('No progress object returned'); 3479 fRc = False; 3573 3480 except: 3574 3481 # Just log, don't assume an error here (will be done in the main loop then). … … 3738 3645 if __name__ == '__main__': 3739 3646 sys.exit(tdAddGuestCtrl().main(sys.argv)); 3740
Note:
See TracChangeset
for help on using the changeset viewer.