Changeset 84322 in vbox
- Timestamp:
- May 15, 2020 5:29:46 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py
r83972 r84322 175 175 self.sGuestAdditionsIso = sGuestAdditionsIso; 176 176 177 def _findFile(self, sRegExp, sTestBuildDir):178 """ 179 Returns a filepath based on the given regex and path to look into177 def _findFile(self, sRegExp, asTestBuildDirs): 178 """ 179 Returns a filepath based on the given regex and paths to look into 180 180 or None if no matching file is found. 181 181 """ 182 182 183 183 oRegExp = re.compile(sRegExp); 184 185 #return most recent file if there are several ones matching the pattern 186 asFiles = [s for s in os.listdir(sTestBuildDir) 187 if os.path.isfile(os.path.join(sTestBuildDir, s))]; 188 asFiles = (s for s in asFiles 189 if oRegExp.match(os.path.basename(s)) 190 and os.path.exists(sTestBuildDir + '/' + s)); 191 asFiles = sorted(asFiles, reverse = True, key = lambda s: os.path.getmtime(os.path.join(sTestBuildDir, s))); 192 if asFiles: 193 return sTestBuildDir + '/' + asFiles[0]; 184 for sTestBuildDir in asTestBuildDirs: 185 try: 186 #return most recent file if there are several ones matching the pattern 187 asFiles = [s for s in os.listdir(sTestBuildDir) 188 if os.path.isfile(os.path.join(sTestBuildDir, s))]; 189 asFiles = (s for s in asFiles 190 if oRegExp.match(os.path.basename(s)) 191 and os.path.exists(sTestBuildDir + '/' + s)); 192 asFiles = sorted(asFiles, reverse = True, key = lambda s: os.path.getmtime(os.path.join(sTestBuildDir, s))); 193 if asFiles: 194 return sTestBuildDir + '/' + asFiles[0]; 195 except: 196 pass; 194 197 195 198 reporter.error('Failed to find a file matching "%s" in %s.' % (sRegExp, sTestBuildDir)); … … 547 550 """ 548 551 549 def __init__(self, oTestDriver, sTestBuildDir, fpApiVer, sGuestAdditionsIso):552 def __init__(self, oTestDriver, asTestBuildDirs, fpApiVer, sGuestAdditionsIso): 550 553 tdAutostartOs.__init__(self, oTestDriver, fpApiVer, sGuestAdditionsIso); 551 self.sTestBuild = self._findFile('^VirtualBox-.*\\.run$', sTestBuildDir);554 self.sTestBuild = self._findFile('^VirtualBox-.*\\.run$', asTestBuildDirs); 552 555 if not self.sTestBuild: 553 556 raise base.GenError("VirtualBox install package not found"); … … 865 868 """ 866 869 867 def __init__(self, oTestDriver, sTestBuildDir, fpApiVer, sGuestAdditionsIso):870 def __init__(self, oTestDriver, asTestBuildDirs, fpApiVer, sGuestAdditionsIso): 868 871 tdAutostartOs.__init__(self, oTestDriver, fpApiVer, sGuestAdditionsIso); 869 self.sTestBuild = self._findFile('^VirtualBox-.*\\.(exe|msi)$', sTestBuildDir);872 self.sTestBuild = self._findFile('^VirtualBox-.*\\.(exe|msi)$', asTestBuildDirs); 870 873 if not self.sTestBuild: 871 874 raise base.GenError("VirtualBox install package not found"); … … 1205 1208 self.asTestVMs = self.asTestVMsDef; 1206 1209 self.asSkipVMs = []; 1207 self. sTestBuildDir= None; #'D:/AlexD/TestBox/TestAdditionalFiles';1210 self.asTestBuildDirs = None; #'D:/AlexD/TestBox/TestAdditionalFiles'; 1208 1211 self.sGuestAdditionsIso = None; #'D:/AlexD/TestBox/TestAdditionalFiles/VBoxGuestAdditions_6.1.2.iso'; 1209 1212 … … 1215 1218 reporter.log(''); 1216 1219 reporter.log('tdAutostart Options:'); 1217 reporter.log(' --test-build-dir <path>');1218 reporter.log(' The directorywith VirtualBox distros. The option is mandatory');1220 reporter.log(' --test-build-dirs <path1[,path2[,...]]>'); 1221 reporter.log(' The list of directories with VirtualBox distros. The option is mandatory'); 1219 1222 reporter.log(' without any default value. The test raises an exception if the'); 1220 reporter.log(' option is not specified. ');1223 reporter.log(' option is not specified. At least, one directory should be pointed.'); 1221 1224 reporter.log(' --guest-additions-iso <path/to/iso>'); 1222 1225 reporter.log(' The path to fresh VirtualBox Guest Additions iso. The option is'); … … 1232 1235 1233 1236 def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements 1234 if asArgs[iArg] == '--test-build-dir ':1237 if asArgs[iArg] == '--test-build-dirs': 1235 1238 iArg += 1; 1236 if iArg >= len(asArgs): raise base.InvalidOption('The "--test-build-dir " takes a pathargument');1237 self. sTestBuildDir = asArgs[iArg];1239 if iArg >= len(asArgs): raise base.InvalidOption('The "--test-build-dirs" takes a paths argument'); 1240 self.asTestBuildDirs = asArgs[iArg].split(','); 1238 1241 elif asArgs[iArg] == '--guest-additions-iso': 1239 1242 iArg += 1; … … 1261 1264 def completeOptions(self): 1262 1265 # Remove skipped VMs from the test list. 1263 if self. sTestBuildDiris None:1264 raise base.InvalidOption('--test-build-dir is not specified')1266 if self.asTestBuildDirs is None: 1267 raise base.InvalidOption('--test-build-dirs is not specified') 1265 1268 if self.sGuestAdditionsIso is None: 1266 1269 raise base.InvalidOption('--guest-additions-iso is not specified') … … 1367 1370 oGuestOsHlp = None # type: tdAutostartOs 1368 1371 if sVmName == self.ksOsLinux: 1369 oGuestOsHlp = tdAutostartOsLinux(self, self. sTestBuildDir, self.fpApiVer, # pylint: disable=redefined-variable-type1372 oGuestOsHlp = tdAutostartOsLinux(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1370 1373 self.sGuestAdditionsIso); 1371 1374 elif sVmName == self.ksOsSolaris: 1372 oGuestOsHlp = tdAutostartOsSolaris(self, self. sTestBuildDir, self.fpApiVer, # pylint: disable=redefined-variable-type1375 oGuestOsHlp = tdAutostartOsSolaris(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1373 1376 self.sGuestAdditionsIso); 1374 1377 elif sVmName == self.ksOsDarwin: 1375 oGuestOsHlp = tdAutostartOsDarwin(self, self. sTestBuildDir, self.fpApiVer, # pylint: disable=redefined-variable-type1378 oGuestOsHlp = tdAutostartOsDarwin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1376 1379 self.sGuestAdditionsIso); 1377 1380 elif sVmName == self.ksOsWindows: 1378 oGuestOsHlp = tdAutostartOsWin(self, self. sTestBuildDir, self.fpApiVer, # pylint: disable=redefined-variable-type1381 oGuestOsHlp = tdAutostartOsWin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1379 1382 self.sGuestAdditionsIso); 1380 1383
Note:
See TracChangeset
for help on using the changeset viewer.