Changeset 79156 in vbox
- Timestamp:
- Jun 15, 2019 2:35:24 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131325
- Location:
- trunk/src/VBox/ValidationKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/txsclient.py
r79092 r79156 1637 1637 The task returns True on success, False on failure (logged). 1638 1638 """ 1639 return self.startTask(cMsTimeout, fIgnoreErrors, "unpackFile", self.taskUnpackFile, \1639 return self.startTask(cMsTimeout, fIgnoreErrors, "unpackFile", self.taskUnpackFile, 1640 1640 (sRemoteFile, sRemoteDir)); 1641 1641 -
trunk/src/VBox/ValidationKit/testdriver/vboxtestvms.py
r79132 r79156 566 566 """ 567 567 return self.sKind; #self.aInfo[g_iGuestOsType]; 568 569 def getGuestArch(self): 570 """ Same as util.getHostArch. """ 571 return 'amd64' if self.sKind.find('_64') >= 0 else 'x86'; 572 573 def getGuestOs(self): 574 """ Same as util.getHostOs. """ 575 if self.isWindows(): return 'win'; 576 if self.isOS2(): return 'os2'; 577 if self.isLinux(): return 'linux'; 578 reporter.error('getGuestOs does not what to return!'); 579 raise Exception(); 580 581 def getGuestOsDotArch(self): 582 """ Same as util.getHostOsDotArch. """ 583 return self.getGuestOs() + '.' + self.getGuestArch(); 584 585 def getGuestExeSuff(self): 586 """ The executable image suffix for the guest. """ 587 if self.isWindows() or self.isOS2(): 588 return '.exe'; 589 return ''; 568 590 569 591 def isWindows(self): … … 1231 1253 return True; 1232 1254 1255 def getGuestArch(self): 1256 """ Same as util.getHostArch. """ 1257 return 'amd64' if self.sKind.find('_64') >= 0 else 'x86'; 1258 1259 def getGuestOs(self): 1260 """ Same as util.getHostOs. """ 1261 if self.isWindows(): return 'win'; 1262 if self.isOS2(): return 'os2'; 1263 if self.isLinux(): return 'linux'; 1264 reporter.error('getGuestOs does not what to return!'); 1265 raise Exception(); 1266 1267 def getGuestExeSuff(self): 1268 """ The executable image suffix for the guest. """ 1269 if self.isWindows() or self.isOS2(): 1270 return '.exe'; 1271 return ''; 1272 1273 def getGuestOsDotArch(self): 1274 """ Same as util.getHostOsDotArch.""" 1275 return self.getGuestOs() + '.' + self.getGuestArch(); 1276 1233 1277 def isWindows(self): 1234 1278 """ Checks if it's a Windows VM. """ -
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r79137 r79156 38 38 import struct 39 39 import sys 40 import tarfile; 40 41 import threading 41 42 import time … … 849 850 self.fRc = fRc; 850 851 852 class tdTestResultFailure(tdTestResult): 853 """ 854 Base class for test results. 855 """ 856 def __init__(self): 857 tdTestResult.__init__(self, fRc = False); 858 859 class tdTestResultSuccess(tdTestResult): 860 """ 861 Base class for test results. 862 """ 863 def __init__(self): 864 tdTestResult.__init__(self, fRc = True); 865 851 866 class tdTestResultDirRead(tdTestResult): 852 867 """ … … 908 923 self.cNumSessions = cNumSessions; 909 924 925 class GstFsObj(object): 926 """ A file system object we created in the guest for test purposes. """ 927 def __init__(self, oParent, sPath): 928 self.oParent = oParent # type: GstFsDir 929 self.sPath = sPath # type: str 930 self.sName = sPath # type: str 931 if oParent: 932 assert sPath.startswith(oParent.sPath); 933 self.sName = sPath[len(oParent.sPath) + 1:]; 934 # Add to parent. 935 oParent.aoChildren.append(self); 936 oParent.dChildrenUpper[self.sName.upper()] = self; 937 938 class GstFsFile(GstFsObj): 939 """ A file object in the guest. """ 940 def __init__(self, oParent, sPath, abContent): 941 GstFsObj.__init__(self, oParent, sPath); 942 self.abContent = abContent # type: bytearray 943 self.cbContent = len(abContent); 944 self.off = 0; 945 946 def read(self, cbToRead): 947 assert self.off <= self.cbContent; 948 cbLeft = self.cbContent - self.off; 949 if cbLeft < cbToRead: 950 cbToRead = cbLeft; 951 abRet = self.abContent[self.off:(self.off + cbToRead)]; 952 assert len(abRet) == cbToRead; 953 self.off += cbToRead; 954 return abRet; 955 956 class GstFsDir(GstFsObj): 957 """ A file object in the guest. """ 958 def __init__(self, oParent, sPath): 959 GstFsObj.__init__(self, oParent, sPath); 960 self.aoChildren = [] # type: list(GsFsObj) 961 self.dChildrenUpper = {} # type: dict(str,GsFsObj) 962 963 def contains(self, sName): 964 """ Checks if the directory contains the given name. """ 965 return sName.upper() in self.dChildrenUpper 966 967 910 968 class SubTstDrvAddGuestCtrl(base.SubTestDriverBase): 911 969 """ … … 926 984 'update_additions' 927 985 ]; 928 self.asTests = self.asTestsDef; 929 self.asRsrcs = ['5.3/guestctrl/50mb_rnd.dat', ]; 986 self.asTests = self.asTestsDef; 987 self.asRsrcs = ['5.3/guestctrl/50mb_rnd.dat', ]; 988 989 # Directories and files placed in the guest temp area by prepareGuestForTesting. 990 self.oTestRoot = None # type: GstFsDir; ##< The root directory. 991 self.oTestEmptyDir = None # type: GstFsDir; ##< Empty directory. 992 self.oTestManyDir = None # type: GstFsDir; ##< A directory with a few files in it (around 100) 993 self.oTestTreeDir = None # type: GstFsDir; ##< A directory with a mixed tree structure under it. 994 self.cTestTreeFiles = 0; ##< Number of files in oTestTreeDir. 995 self.cTestTreeDirs = 0; ##< Number of directories under oTestTreeDir. 996 997 self.aoTestDirs = [] # type: list(GstFsDir); 998 self.aoTestFiles = [] # type: list(GstFsFile); 999 self.dTestPaths = {} # type: dict(str, GstFsFile); 930 1000 931 1001 def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements … … 958 1028 reporter.log("Active tests: %s" % (self.asTests,)); 959 1029 1030 # The tests. Must-succeed tests should be first. 1031 atTests = [ 1032 ( True, self.prepareGuestForTesting, None, 'Preparations',), 1033 ( True, self.testGuestCtrlSession, 'session_basic', 'Session Basics',), 1034 ( True, self.testGuestCtrlExec, 'exec_basic', 'Execution',), 1035 ( False, self.testGuestCtrlExecTimeout, 'exec_timeout', 'Execution Timeouts',), 1036 ( False, self.testGuestCtrlSessionEnvironment, 'session_env', 'Session Environment',), 1037 ( False, self.testGuestCtrlSessionFileRefs, 'session_file_ref', 'Session File References',), 1038 #( False, self.testGuestCtrlSessionDirRefs, 'session_dir_ref', 'Session Directory References',), 1039 ( False, self.testGuestCtrlSessionProcRefs, 'session_proc_ref', 'Session Process References',), 1040 ( False, self.testGuestCtrlDirCreate, 'dir_create', 'Creating directories',), 1041 ( False, self.testGuestCtrlDirCreateTemp, 'dir_create_temp', 'Creating temporary directories',), 1042 ( False, self.testGuestCtrlDirRead, 'dir_read', 'Reading directories',), 1043 ( False, self.testGuestCtrlCopyTo, 'copy_to', 'Copy to guest',), 1044 ( False, self.testGuestCtrlCopyFrom, 'copy_from', 'Copy from guest',), 1045 ( False, self.testGuestCtrlFileStat, 'file_stat', 'Querying file information (stat)',), 1046 ( False, self.testGuestCtrlFileRead, 'file_read', 'File read',), 1047 ( False, self.testGuestCtrlFileWrite, 'file_write', 'File write',), 1048 ( False, self.testGuestCtrlFileRemove, 'file_remove', 'Removing files',), # Destroys prepped files. 1049 ( False, self.testGuestCtrlSessionReboot, 'session_reboot', 'Session w/ Guest Reboot',), # May zap /tmp. 1050 ( False, self.testGuestCtrlUpdateAdditions, 'update_additions', 'Updating Guest Additions',), 1051 ]; 1052 960 1053 fRc = True; 961 962 # Do the testing. 963 reporter.testStart('Session Basics'); 964 fSkip = 'session_basic' not in self.asTests; 965 if fSkip is False: 966 fRc, oTxsSession = self.testGuestCtrlSession(oSession, oTxsSession, oTestVm); 967 reporter.testDone(fSkip); 968 969 reporter.testStart('Session Environment'); 970 fSkip = 'session_env' not in self.asTests or fRc is False; 971 if fSkip is False: 972 fRc, oTxsSession = self.testGuestCtrlSessionEnvironment(oSession, oTxsSession, oTestVm); 973 reporter.testDone(fSkip); 974 975 reporter.testStart('Session File References'); 976 fSkip = 'session_file_ref' not in self.asTests; 977 if fSkip is False: 978 fRc, oTxsSession = self.testGuestCtrlSessionFileRefs(oSession, oTxsSession, oTestVm); 979 reporter.testDone(fSkip); 980 981 ## @todo Implement this. 982 #reporter.testStart('Session Directory References'); 983 #fSkip = 'session_dir_ref' not in self.asTests; 984 #if fSkip is False: 985 # fRc, oTxsSession = self.testGuestCtrlSessionDirRefs(oSession, oTxsSession, oTestVm); 986 #reporter.testDone(fSkip); 987 988 reporter.testStart('Session Process References'); 989 fSkip = 'session_proc_ref' not in self.asTests or fRc is False; 990 if fSkip is False: 991 fRc, oTxsSession = self.testGuestCtrlSessionProcRefs(oSession, oTxsSession, oTestVm); 992 reporter.testDone(fSkip); 993 994 reporter.testStart('Session w/ Guest Reboot'); 995 fSkip = 'session_reboot' not in self.asTests \ 996 or self.oTstDrv.fpApiVer <= 6.0; # Not backported yet. 997 if fSkip is False: 998 fRc, oTxsSession = self.testGuestCtrlSessionReboot(oSession, oTxsSession, oTestVm); 999 reporter.testDone(fSkip); 1000 1001 reporter.testStart('Execution'); 1002 fSkip = 'exec_basic' not in self.asTests or fRc is False; 1003 if fSkip is False: 1004 fRc, oTxsSession = self.testGuestCtrlExec(oSession, oTxsSession, oTestVm); 1005 reporter.testDone(fSkip); 1006 1007 reporter.testStart('Execution Timeouts'); 1008 fSkip = 'exec_timeout' not in self.asTests or fRc is False; 1009 if fSkip is False: 1010 fRc, oTxsSession = self.testGuestCtrlExecTimeout(oSession, oTxsSession, oTestVm); 1011 reporter.testDone(fSkip); 1012 1013 reporter.testStart('Creating directories'); 1014 fSkip = 'dir_create' not in self.asTests or fRc is False; 1015 if fSkip is False: 1016 fRc, oTxsSession = self.testGuestCtrlDirCreate(oSession, oTxsSession, oTestVm); 1017 reporter.testDone(fSkip); 1018 1019 reporter.testStart('Creating temporary directories'); 1020 fSkip = 'dir_create_temp' not in self.asTests or fRc is False; 1021 if fSkip is False: 1022 fRc, oTxsSession = self.testGuestCtrlDirCreateTemp(oSession, oTxsSession, oTestVm); 1023 reporter.testDone(fSkip); 1024 1025 reporter.testStart('Reading directories'); 1026 fSkip = 'dir_read' not in self.asTests or fRc is False; 1027 if fSkip is False: 1028 fRc, oTxsSession = self.testGuestCtrlDirRead(oSession, oTxsSession, oTestVm); 1029 reporter.testDone(fSkip); 1030 1031 reporter.testStart('Copy to guest'); 1032 fSkip = 'copy_to' not in self.asTests or fRc is False; 1033 if fSkip is False: 1034 fRc, oTxsSession = self.testGuestCtrlCopyTo(oSession, oTxsSession, oTestVm); 1035 reporter.testDone(fSkip); 1036 1037 reporter.testStart('Copy from guest'); 1038 fSkip = 'copy_from' not in self.asTests or fRc is False; 1039 if fSkip is False: 1040 fRc, oTxsSession = self.testGuestCtrlCopyFrom(oSession, oTxsSession, oTestVm); 1041 reporter.testDone(fSkip); 1042 1043 reporter.testStart('Removing files'); 1044 fSkip = 'file_remove' not in self.asTests or fRc is False; 1045 if fSkip is False: 1046 fRc, oTxsSession = self.testGuestCtrlFileRemove(oSession, oTxsSession, oTestVm); 1047 reporter.testDone(fSkip); 1048 1049 reporter.testStart('Querying file information (stat)'); 1050 fSkip = 'file_stat' not in self.asTests or fRc is False; 1051 if fSkip is False: 1052 fRc, oTxsSession = self.testGuestCtrlFileStat(oSession, oTxsSession, oTestVm); 1053 reporter.testDone(fSkip); 1054 1055 reporter.testStart('File read'); 1056 fSkip = 'file_read' not in self.asTests or fRc is False; 1057 if fSkip is False: 1058 fRc, oTxsSession = self.testGuestCtrlFileRead(oSession, oTxsSession, oTestVm); 1059 reporter.testDone(fSkip); 1060 1061 reporter.testStart('File write'); 1062 fSkip = 'file_write' not in self.asTests or fRc is False; 1063 if fSkip is False: 1064 fRc, oTxsSession = self.testGuestCtrlFileWrite(oSession, oTxsSession, oTestVm); 1065 reporter.testDone(fSkip); 1066 1067 reporter.testStart('Updating Guest Additions'); 1068 fSkip = 'update_additions' not in self.asTests or fRc is False; 1069 # Skip test for updating Guest Additions if we run on a too old (Windows) guest. 1070 fSkip = oTestVm.sKind in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'); 1071 if fSkip is False: 1072 fRc, oTxsSession = self.testGuestCtrlUpdateAdditions(oSession, oTxsSession, oTestVm); 1073 reporter.testDone(fSkip); 1054 for fMustSucceed, fnHandler, sShortNm, sTestNm in atTests: 1055 reporter.testStart(sTestNm); 1056 1057 if sShortNm is None or sShortNm in self.asTests: 1058 # Returns (fRc, oTxsSession, oSession) - but only the first one is mandatory. 1059 aoResult = fnHandler(oSession, oTxsSession, oTestVm); 1060 if aoResult is None or isinstance(aoResult, bool): 1061 fRcTest = aoResult; 1062 else: 1063 fRcTest = aoResult[0]; 1064 if len(aoResult) > 1: 1065 oTxsSession = aoResult[1]; 1066 if len(aoResult) > 2: 1067 oSession = aoResult[2]; 1068 assert len(aoResult) == 3; 1069 else: 1070 fRcTest = None; 1071 1072 if fRcTest is False and reporter.testErrorCount() != 0: 1073 fRcTest = reporter.error('Buggy test! Returned False w/o logging the error!'); 1074 if reporter.testDone(fRcTest is None)[1] != 0: 1075 fRcTest = False; 1076 fRc = False; 1077 1078 # Stop execution if this is a must-succeed test and it failed. 1079 if fRcTest is False and fMustSucceed is True: 1080 reporter.log('Skipping any remaining tests since the previous one failed.'); 1081 break; 1074 1082 1075 1083 return (fRc, oTxsSession); 1084 1085 # 1086 # Guest locations. 1087 # 1088 1089 @staticmethod 1090 def getGuestTempDir(oTestVm): 1091 """ 1092 Helper for finding a temporary directory in the test VM. 1093 1094 Note! It may be necessary to create it! 1095 """ 1096 if oTestVm.isWindows(): 1097 return "C:\\Temp"; 1098 if oTestVm.isOS2(): 1099 return "C:\\Temp"; 1100 return '/var/tmp'; 1076 1101 1077 1102 @staticmethod … … 1112 1137 return SubTstDrvAddGuestCtrl.getGuestSystemDir(oTestVm) + '\\DOSCALL1.DLL'; 1113 1138 return "/bin/sh"; 1139 1140 # 1141 # Guest test files. 1142 # 1143 1144 ## @todo separate this out into a separate class. This one is way to big and this may be handy for to reuse. 1145 1146 def __createTestDir(self, oParent, sDir): 1147 """ 1148 Creates a test directory. 1149 """ 1150 oDir = GstFsDir(oParent, sDir); 1151 self.aoTestDirs.append(oDir); 1152 self.dTestPaths[sDir] = oDir; 1153 return oDir; 1154 1155 def __createTestFile(self, oParent, sFile, oRandom, cbMaxContent): 1156 """ 1157 Creates a test file with random size up to cbMaxContent and random content. 1158 """ 1159 cbFile = oRandom.randrange(0, cbMaxContent); 1160 abContent = bytearray(oRandom.getrandbits(8) for _ in xrange(cbFile)); 1161 1162 oFile = GstFsFile(oParent, sFile, abContent); 1163 self.aoTestFiles.append(oFile); 1164 self.dTestPaths[sFile] = oFile; 1165 return oFile; 1166 1167 @staticmethod 1168 def __createFilename(oParent, oRandom, sCharset, sReservedTrailing): 1169 """ 1170 Creates a filename contains random characters from sCharset and together 1171 with oParent.sPath doesn't exceed 230 chars in length. 1172 """ 1173 while True: 1174 cchName = oRandom.randrange(1, 230 - len(oParent.sPath)); 1175 sName = ''.join(oRandom.choice(sCharset) for _ in xrange(cchName)); 1176 if oParent is None or not oParent.contains(sName): 1177 if sName[-1] not in sReservedTrailing: 1178 if sName not in ('.', '..',): 1179 return sName; 1180 1181 def __createTestStuff(self, oTestVm): 1182 """ 1183 Create a random file set that we can work on in the tests. 1184 Returns True/False. 1185 """ 1186 1187 # Zap anything left over from a previous run. 1188 for oFile in self.aoTestDirs: 1189 oFile.oParent = None; 1190 for oFile in self.aoTestFiles: 1191 oFile.oParent = None; 1192 oFile.abContent = None; 1193 self.oTestRoot = None; 1194 self.oTestEmptyDir = None; 1195 self.oTestManyDir = None; 1196 self.oTestTreeDir = None; 1197 self.cTestTreeFiles = 0; 1198 self.cTestTreeDirs = 0; 1199 self.aoTestDirs = []; 1200 self.aoTestFiles = []; 1201 self.dTestPaths = {}; 1202 1203 # See random. 1204 uSeed = utils.timestampMilli(); 1205 reporter.log('prepareGuestForTesting: random seed %s' % (uSeed,)); 1206 oRandom = random.Random(); 1207 oRandom.seed(uSeed); 1208 1209 # filename characters: 1210 ksReservedWinOS2 = '/\\"*:<>?|\t\v\n\r\f\a\b'; 1211 ksReservedUnix = '/'; 1212 ksReservedTrailingWinOS2 = ' .'; # The space is tar's fault. Must be first. 1213 ksReservedTrailingUnix = ' '; 1214 sFileCharset = string.printable; 1215 sFileCharsetCommon = string.printable; 1216 sReservedTrailingCommon = ksReservedTrailingWinOS2; 1217 1218 if oTestVm.isWindows() or oTestVm.isOS2(): 1219 sReservedTrailing = ksReservedTrailingWinOS2; 1220 for ch in ksReservedWinOS2: 1221 sFileCharset = sFileCharset.replace(ch, ''); 1222 else: 1223 sReservedTrailing = ksReservedTrailingUnix; 1224 for ch in ksReservedUnix: 1225 sFileCharset = sFileCharset.replace(ch, ''); 1226 sFileCharset += ' ...'; 1227 1228 for ch in ksReservedWinOS2: 1229 sFileCharsetCommon = sFileCharset.replace(ch, ''); 1230 sFileCharsetCommon += ' ...'; 1231 1232 # Create the root test dir. 1233 sRoot = oTestVm.pathJoinEx(self.getGuestTempDir(oTestVm), 'addgst-1'); 1234 self.oTestRoot = self.__createTestDir(None, sRoot); 1235 self.oTestEmptyDir = self.__createTestDir(self.oTestRoot, oTestVm.pathJoinEx(sRoot, 'empty')); 1236 1237 # Create a directory with about files in it using the guest specific charset: 1238 oDir = self.__createTestDir(self.oTestRoot, oTestVm.pathJoinEx(sRoot, 'many')); 1239 self.oTestManyDir = oDir; 1240 cManyFiles = oRandom.randrange(92, 128); 1241 for _ in xrange(cManyFiles): 1242 sName = self.__createFilename(oDir, oRandom, sFileCharset, sReservedTrailing); 1243 self.__createTestFile(oDir, oTestVm.pathJoinEx(oDir.sPath, sName), oRandom, 16384); 1244 1245 # Generate a tree of files and dirs. 2-16 levels deep. Portable character set. 1246 cMaxFiles = oRandom.randrange(128, 384); 1247 cMaxDirs = oRandom.randrange(92, 256); 1248 uMaxDepth = oRandom.randrange(2, 16); 1249 oDir = self.__createTestDir(self.oTestRoot, oTestVm.pathJoinEx(sRoot, 'tree')); 1250 self.oTestTreeDir = oDir; 1251 self.cTestTreeFiles = 0; 1252 self.cTestTreeDirs = 0; 1253 uDepth = 0; 1254 while self.cTestTreeFiles < cMaxFiles and self.cTestTreeDirs < cMaxDirs: 1255 iAction = oRandom.randrange(0, 2+1); 1256 # 0: Add a file: 1257 if iAction == 0 and self.cTestTreeFiles < cMaxFiles and len(oDir.sPath) < 230 - 2: 1258 sName = self.__createFilename(oDir, oRandom, sFileCharsetCommon, sReservedTrailingCommon[1:]); # trailing space ok 1259 self.__createTestFile(oDir, oTestVm.pathJoinEx(oDir.sPath, sName), oRandom, 16384); 1260 self.cTestTreeFiles += 1; 1261 # 1: Add a subdirector and descend into it: 1262 elif iAction == 1 and self.cTestTreeDirs < cMaxDirs and uDepth < uMaxDepth and len(oDir.sPath) < 220: 1263 sName = self.__createFilename(oDir, oRandom, sFileCharsetCommon, sReservedTrailingCommon); 1264 oDir = self.__createTestDir(oDir, oTestVm.pathJoinEx(oDir.sPath, sName)); 1265 self.cTestTreeDirs += 1; 1266 uDepth += 1; 1267 # 2: Ascend to parent dir: 1268 elif iAction == 2 and uDepth > 0: 1269 oDir = oDir.oParent; 1270 uDepth -= 1; 1271 1272 return True; 1273 1274 1275 def __uploadTestStuffsFallback(self, oTxsSession, oTestVm, sTarFileGst, sTempDirGst): 1276 """ 1277 Fallback upload method. 1278 """ 1279 1280 ## Directories: 1281 #for oDir in self.aoTestDirs: 1282 # if oTxsSession.syncMkDirPath(oDir.sPath, 0o777) is not True: 1283 # return reporter.error('Failed to create directory "%s"!' % (oDir.sPath,)); 1284 # 1285 ## Files: 1286 #for oFile in self.aoTestFiles: 1287 # if oTxsSession.syncUploadString(oFile.abContent, oFile.sPath) is not True: 1288 # return reporter.error('Failed to create file "%s" with %s content bytes!' % (oFile.sPath, oFile.cbContent)); 1289 1290 sVtsTarExe = 'vts_tar' + oTestVm.getGuestExeSuff(); 1291 sVtsTarHst = os.path.join(self.oTstDrv.sVBoxValidationKit, oTestVm.getGuestOs(), oTestVm.getGuestArch(), sVtsTarExe); 1292 sVtsTarGst = oTestVm.pathJoinEx(sTempDirGst, sVtsTarExe); 1293 1294 if oTxsSession.syncUploadFile(sVtsTarHst, sVtsTarGst) is not True: 1295 return reporter.error('Failed to upload "%s" to the guest as "%s"!' % (sVtsTarHst, sVtsTarGst,)); 1296 1297 fRc = oTxsSession.syncExec(sVtsTarGst, [sVtsTarGst, '-xzf', sTarFileGst, '-C', sTempDirGst,], fWithTestPipe = False); 1298 if fRc is not True: 1299 return reporter.error('vts_tar failed!'); 1300 return True; 1301 1302 def __uploadTestStuff(self, oTxsSession, oTestVm): 1303 """ 1304 Primary upload method. 1305 """ 1306 1307 # 1308 # Create a tarball. 1309 # 1310 sTempDirGst = self.getGuestTempDir(oTestVm); 1311 sTarFileHst = os.path.join(self.oTstDrv.sScratchPath, 'tdAddGuestCtrl-1-Stuff.tar.gz'); 1312 sTarFileGst = oTestVm.pathJoinEx(sTempDirGst, 'tdAddGuestCtrl-1-Stuff.tar.gz'); 1313 chOtherSlash = '\\' if oTestVm.isWindows() or oTestVm.isOS2() else '/'; 1314 cchSkip = len(sTempDirGst) + 1; 1315 1316 reporter.log('Creating tarball "%s" with test files for the guest...' % (sTarFileHst,)); 1317 1318 # Open the tarball: 1319 try: 1320 oTarFile = tarfile.open(sTarFileHst, 'w:gz'); 1321 except: 1322 return reporter.errorXcpt('Failed to open new tar file: %s' % (sTarFileHst,)); 1323 1324 # Directories: 1325 for oDir in self.aoTestDirs: 1326 oTarInfo = tarfile.TarInfo(oDir.sPath[cchSkip:].replace(chOtherSlash, '/') + '/'); 1327 oTarInfo.mode = 0o777; 1328 oTarInfo.type = tarfile.DIRTYPE; 1329 try: 1330 oTarFile.addfile(oTarInfo); 1331 except: 1332 return reporter.errorXcpt('Failed adding directory tarfile: %s' % (oDir.sPath,)); 1333 1334 # Files: 1335 for oFile in self.aoTestFiles: 1336 oTarInfo = tarfile.TarInfo(oFile.sPath[cchSkip:].replace(chOtherSlash, '/')); 1337 oTarInfo.size = len(oFile.abContent); 1338 oFile.off = 0; 1339 try: 1340 oTarFile.addfile(oTarInfo, oFile); 1341 except: 1342 return reporter.errorXcpt('Failed adding directory tarfile: %s' % (oFile.sPath,)); 1343 1344 # Complete the tarball. 1345 try: 1346 oTarFile.close(); 1347 except: 1348 return reporter.errorXcpt('Error closing new tar file: %s' % (sTarFileHst,)); 1349 1350 # 1351 # Upload it. 1352 # 1353 reporter.log('Uploading tarball "%s" to the guest as "%s"...' % (sTarFileHst, sTarFileGst)); 1354 if oTxsSession.syncUploadFile(sTarFileHst, sTarFileGst) is not True: 1355 return reporter.error('Failed upload tarball "%s" as "%s"!' % (sTarFileHst, sTarFileGst,)); 1356 1357 # 1358 # Try unpack it. 1359 # 1360 reporter.log('Unpacking "%s" into "%s"...' % (sTarFileGst, sTempDirGst)); 1361 if oTxsSession.syncUnpackFile(sTarFileGst, sTempDirGst, fIgnoreErrors = True) is not True: 1362 reporter.log('Failed to expand tarball "%s" into "%s", falling back on individual directory and file creation...' 1363 % (sTarFileGst, sTempDirGst,)); 1364 if self.__uploadTestStuffsFallback(oTxsSession, oTestVm, sTarFileGst, sTempDirGst) is not True: 1365 return False; 1366 reporter.log('Successfully placed test files and directories in the VM.'); 1367 return True; 1368 1369 def prepareGuestForTesting(self, oSession, oTxsSession, oTestVm): 1370 """ 1371 Prepares the VM for testing, uploading a bunch of files and stuff via TXS. 1372 Returns success indicator. 1373 """ 1374 _ = oSession; 1375 1376 #reporter.log('Take snapshot now!'); 1377 #self.oTstDrv.sleep(22); 1378 #return False; 1379 1380 # Make sure the temporary directory exists. 1381 for sDir in [self.getGuestTempDir(oTestVm), ]: 1382 if oTxsSession.syncMkDirPath(sDir, 0o777) is not True: 1383 return reporter.error('Failed to create directory "%s"!' % (sDir,)); 1384 1385 # Generate and upload some random files and dirs to the guest: 1386 if self.__createTestStuff(oTestVm) is not True: 1387 return False; 1388 return self.__uploadTestStuff(oTxsSession, oTestVm); 1389 1390 1391 # 1392 # gctrlXxxx stuff. 1393 # 1114 1394 1115 1395 def gctrlCopyFileFrom(self, oGuestSession, sSrc, sDst, fFlags, fExpected): … … 2279 2559 """ 2280 2560 2561 ## @todo backport fixes to 6.0 and maybe 5.2 2562 if self.oTstDrv.fpApiVer <= 6.0: 2563 reporter.log('Skipping: Required fixes not yet backported!'); 2564 return None; 2565 2281 2566 # Use credential defaults. 2282 2567 oCreds = tdCtxCreds(); … … 2500 2785 """ 2501 2786 2502 if oTestVm.isWindows(): 2503 sScratch = "C:\\Temp\\vboxtest\\testGuestCtrlDirCreate\\"; 2504 else: 2505 sScratch = "/tmp/testGuestCtrlDirCreate/"; 2506 2507 aaTests = []; 2508 aaTests.extend([ 2787 sScratch = oTestVm.pathJoinEx(self.getGuestTempDir(oTestVm), 'testGuestCtrlDirCreate'); 2788 2789 atTests = [ 2509 2790 # Invalid stuff. 2510 [ tdTestDirCreate(sDirectory = '' ), tdTestResult () ],2791 [ tdTestDirCreate(sDirectory = '' ), tdTestResultFailure() ], 2511 2792 # More unusual stuff. 2512 [ tdTestDirCreate(sDirectory = '..\\..\\' ), tdTestResult() ], 2513 [ tdTestDirCreate(sDirectory = '../../' ), tdTestResult() ], 2514 [ tdTestDirCreate(sDirectory = 'z:\\' ), tdTestResult() ], 2515 [ tdTestDirCreate(sDirectory = '\\\\uncrulez\\foo' ), tdTestResult() ], 2793 [ tdTestDirCreate(sDirectory = '../../' ), tdTestResultFailure() ], 2794 ]; 2795 if oTestVm.isWindows() or oTestVm.isOS2(): 2796 atTests.extend([ 2797 [ tdTestDirCreate(sDirectory = '..\\..\\' ), tdTestResultFailure() ], 2798 [ tdTestDirCreate(sDirectory = 'c:\\' ), tdTestResultFailure() ], 2799 [ tdTestDirCreate(sDirectory = 'z:\\' ), tdTestResultFailure() ], 2800 [ tdTestDirCreate(sDirectory = '\\\\uncrulez\\foo' ), tdTestResultFailure() ], 2801 ]); 2802 2803 atTests.extend([ 2516 2804 # Creating directories. 2517 [ tdTestDirCreate(sDirectory = sScratch ), tdTestResult () ],2805 [ tdTestDirCreate(sDirectory = sScratch ), tdTestResultFailure() ], 2518 2806 [ tdTestDirCreate(sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'), 2519 2807 fFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ), 2520 tdTestResult (fRc = True) ],2808 tdTestResultSuccess() ], 2521 2809 [ tdTestDirCreate(sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'), 2522 2810 fFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ), 2523 tdTestResult (fRc = True) ],2811 tdTestResultSuccess() ], 2524 2812 # Long (+ random) stuff. 2525 2813 [ tdTestDirCreate(sDirectory = os.path.join(sScratch, 2526 2814 "".join(random.choice(string.ascii_lowercase) for i in xrange(32))) ), 2527 tdTestResult (fRc = True) ],2815 tdTestResultSuccess() ], 2528 2816 [ tdTestDirCreate(sDirectory = os.path.join(sScratch, 2529 2817 "".join(random.choice(string.ascii_lowercase) for i in xrange(128))) ), 2530 tdTestResult (fRc = True) ],2818 tdTestResultSuccess() ], 2531 2819 # Following two should fail on Windows (paths too long). Both should timeout. 2532 2820 [ tdTestDirCreate(sDirectory = os.path.join(sScratch, … … 2539 2827 2540 2828 fRc = True; 2541 for (i, aTest) in enumerate(a aTests):2829 for (i, aTest) in enumerate(atTests): 2542 2830 oCurTest = aTest[0]; # tdTestExec, use an index, later. 2543 2831 oCurRes = aTest[1]; # tdTestResult … … 2562 2850 """ 2563 2851 2564 a aTests = [];2852 atTests = []; 2565 2853 if oTestVm.isWindows(): 2566 a aTests.extend([2854 atTests.extend([ 2567 2855 # Invalid stuff. 2568 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResult () ],2569 [ tdTestDirCreateTemp(sDirectory = 'C:\\Windows', fMode = 1234), tdTestResult () ],2570 [ tdTestDirCreateTemp(sTemplate = '', sDirectory = 'C:\\Windows', fMode = 1234), tdTestResult () ],2571 [ tdTestDirCreateTemp(sTemplate = 'xXx', sDirectory = 'C:\\Windows', fMode = 0o700), tdTestResult () ],2572 [ tdTestDirCreateTemp(sTemplate = 'xxx', sDirectory = 'C:\\Windows', fMode = 0o700), tdTestResult () ],2856 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResultFailure() ], 2857 [ tdTestDirCreateTemp(sDirectory = 'C:\\Windows', fMode = 1234), tdTestResultFailure() ], 2858 [ tdTestDirCreateTemp(sTemplate = '', sDirectory = 'C:\\Windows', fMode = 1234), tdTestResultFailure() ], 2859 [ tdTestDirCreateTemp(sTemplate = 'xXx', sDirectory = 'C:\\Windows', fMode = 0o700), tdTestResultFailure() ], 2860 [ tdTestDirCreateTemp(sTemplate = 'xxx', sDirectory = 'C:\\Windows', fMode = 0o700), tdTestResultFailure() ], 2573 2861 # More unusual stuff. 2574 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = 'z:\\'), tdTestResult () ],2575 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = '\\\\uncrulez\\foo'), tdTestResult () ],2862 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = 'z:\\'), tdTestResultFailure() ], 2863 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = '\\\\uncrulez\\foo'), tdTestResultFailure() ], 2576 2864 # Non-existing stuff. 2577 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = 'c:\\Apps\\nonexisting\\foo'), tdTestResult () ],2865 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = 'c:\\Apps\\nonexisting\\foo'), tdTestResultFailure() ], 2578 2866 # FIXME: Failing test. Non Windows path 2579 # [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/tmp/non/existing'), tdTestResult () ]2867 # [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/tmp/non/existing'), tdTestResultFailure() ] 2580 2868 ]); 2581 2869 elif oTestVm.isLinux(): 2582 a aTests.extend([2870 atTests.extend([ 2583 2871 # Invalid stuff. 2584 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResult () ],2872 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResultFailure() ], 2585 2873 [ tdTestDirCreateTemp(sDirectory = '/etc', fMode = 1234) ], 2586 [ tdTestDirCreateTemp(sTemplate = '', sDirectory = '/etc', fMode = 1234), tdTestResult () ],2587 [ tdTestDirCreateTemp(sTemplate = 'xXx', sDirectory = '/etc', fMode = 0o700), tdTestResult () ],2588 [ tdTestDirCreateTemp(sTemplate = 'xxx', sDirectory = '/etc', fMode = 0o700), tdTestResult () ],2874 [ tdTestDirCreateTemp(sTemplate = '', sDirectory = '/etc', fMode = 1234), tdTestResultFailure() ], 2875 [ tdTestDirCreateTemp(sTemplate = 'xXx', sDirectory = '/etc', fMode = 0o700), tdTestResultFailure() ], 2876 [ tdTestDirCreateTemp(sTemplate = 'xxx', sDirectory = '/etc', fMode = 0o700), tdTestResultFailure() ], 2589 2877 # More unusual stuff. 2590 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = 'z:\\'), tdTestResult () ],2591 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = '\\\\uncrulez\\foo'), tdTestResult () ],2878 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = 'z:\\'), tdTestResultFailure() ], 2879 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = '\\\\uncrulez\\foo'), tdTestResultFailure() ], 2592 2880 # Non-existing stuff. 2593 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/non/existing'), tdTestResult () ],2881 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/non/existing'), tdTestResultFailure() ], 2594 2882 ]); 2595 2883 2596 2884 # FIXME: Failing tests. 2597 # a aTests.extend([2885 # atTests.extend([ 2598 2886 # Non-secure variants. 2599 2887 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2600 2888 # sDirectory = sScratch), 2601 # tdTestResult (fRc = True) ],2889 # tdTestResultSuccess() ], 2602 2890 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2603 2891 # sDirectory = sScratch), 2604 # tdTestResult (fRc = True) ],2892 # tdTestResultSuccess() ], 2605 2893 # [ tdTestDirCreateTemp(sTemplate = 'X', 2606 2894 # sDirectory = sScratch), 2607 # tdTestResult (fRc = True) ],2895 # tdTestResultSuccess() ], 2608 2896 # [ tdTestDirCreateTemp(sTemplate = 'X', 2609 2897 # sDirectory = sScratch), 2610 # tdTestResult (fRc = True) ],2898 # tdTestResultSuccess() ], 2611 2899 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2612 2900 # sDirectory = sScratch, 2613 2901 # fMode = 0o700), 2614 # tdTestResult (fRc = True) ],2902 # tdTestResultSuccess() ], 2615 2903 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2616 2904 # sDirectory = sScratch, 2617 2905 # fMode = 0o700), 2618 # tdTestResult (fRc = True) ],2906 # tdTestResultSuccess() ], 2619 2907 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2620 2908 # sDirectory = sScratch, 2621 2909 # fMode = 0o755), 2622 # tdTestResult (fRc = True) ],2910 # tdTestResultSuccess() ], 2623 2911 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2624 2912 # sDirectory = sScratch, 2625 2913 # fMode = 0o755), 2626 # tdTestResult (fRc = True) ],2914 # tdTestResultSuccess() ], 2627 2915 # Secure variants. 2628 2916 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2629 2917 # sDirectory = sScratch, fSecure = True), 2630 # tdTestResult (fRc = True) ],2918 # tdTestResultSuccess() ], 2631 2919 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2632 2920 # sDirectory = sScratch, fSecure = True), 2633 # tdTestResult (fRc = True) ],2921 # tdTestResultSuccess() ], 2634 2922 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2635 2923 # sDirectory = sScratch, fSecure = True), 2636 # tdTestResult (fRc = True) ],2924 # tdTestResultSuccess() ], 2637 2925 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2638 2926 # sDirectory = sScratch, fSecure = True), 2639 # tdTestResult (fRc = True) ],2927 # tdTestResultSuccess() ], 2640 2928 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2641 2929 # sDirectory = sScratch, 2642 2930 # fSecure = True, fMode = 0o700), 2643 # tdTestResult (fRc = True) ],2931 # tdTestResultSuccess() ], 2644 2932 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2645 2933 # sDirectory = sScratch, 2646 2934 # fSecure = True, fMode = 0o700), 2647 # tdTestResult (fRc = True) ],2935 # tdTestResultSuccess() ], 2648 2936 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2649 2937 # sDirectory = sScratch, 2650 2938 # fSecure = True, fMode = 0o755), 2651 # tdTestResult (fRc = True) ],2939 # tdTestResultSuccess() ], 2652 2940 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2653 2941 # sDirectory = sScratch, 2654 2942 # fSecure = True, fMode = 0o755), 2655 # tdTestResult (fRc = True) ],2943 # tdTestResultSuccess() ], 2656 2944 # Random stuff. 2657 2945 # [ tdTestDirCreateTemp( … … 2659 2947 # sDirectory = sScratch, 2660 2948 # fSecure = True, fMode = 0o755), 2661 # tdTestResult (fRc = True) ],2949 # tdTestResultSuccess() ], 2662 2950 # [ tdTestDirCreateTemp(sTemplate = "".join('X' for i in xrange(32)), 2663 2951 # sDirectory = sScratch, 2664 2952 # fSecure = True, fMode = 0o755), 2665 # tdTestResult (fRc = True) ],2953 # tdTestResultSuccess() ], 2666 2954 # [ tdTestDirCreateTemp(sTemplate = "".join('X' for i in xrange(128)), 2667 2955 # sDirectory = sScratch, 2668 2956 # fSecure = True, fMode = 0o755), 2669 # tdTestResult (fRc = True) ]2957 # tdTestResultSuccess() ] 2670 2958 # ]); 2671 2959 2672 2960 fRc = True; 2673 for (i, aTest) in enumerate(a aTests):2961 for (i, aTest) in enumerate(atTests): 2674 2962 oCurTest = aTest[0]; # tdTestExec, use an index, later. 2675 2963 oCurRes = aTest[1]; # tdTestResult … … 2806 3094 sFileToDelete = "/home/vbox/.profile"; 2807 3095 2808 a aTests = [];3096 atTests = []; 2809 3097 if oTestVm.isWindows(): 2810 a aTests.extend([3098 atTests.extend([ 2811 3099 # Invalid stuff. 2812 [ tdTestFileRemove(sFile = ''), tdTestResult () ],2813 [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResult () ],3100 [ tdTestFileRemove(sFile = ''), tdTestResultFailure() ], 3101 [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResultFailure() ], 2814 3102 # More unusual stuff. 2815 [ tdTestFileRemove(sFile = 'z:\\'), tdTestResult () ],2816 [ tdTestFileRemove(sFile = '\\\\uncrulez\\foo'), tdTestResult () ],3103 [ tdTestFileRemove(sFile = 'z:\\'), tdTestResultFailure() ], 3104 [ tdTestFileRemove(sFile = '\\\\uncrulez\\foo'), tdTestResultFailure() ], 2817 3105 # Non-existing stuff. 2818 [ tdTestFileRemove(sFile = 'c:\\Apps\\nonexisting'), tdTestResult () ],3106 [ tdTestFileRemove(sFile = 'c:\\Apps\\nonexisting'), tdTestResultFailure() ], 2819 3107 # Try to delete system files. 2820 [ tdTestFileRemove(sFile = 'c:\\pagefile.sys'), tdTestResult () ],2821 [ tdTestFileRemove(sFile = 'c:\\Windows\\kernel32.sys'), tdTestResult () ] ## r=bird: it's in \system32\ ...3108 [ tdTestFileRemove(sFile = 'c:\\pagefile.sys'), tdTestResultFailure() ], 3109 [ tdTestFileRemove(sFile = 'c:\\Windows\\kernel32.sys'), tdTestResultFailure() ] ## r=bird: it's in \system32\ ... 2822 3110 ]); 2823 3111 2824 3112 if oTestVm.sKind == "WindowsXP": 2825 a aTests.extend([3113 atTests.extend([ 2826 3114 # Try delete some unimportant media stuff. 2827 [ tdTestFileRemove(sFile = 'c:\\Windows\\Media\\chimes.wav'), tdTestResult (fRc = True) ],3115 [ tdTestFileRemove(sFile = 'c:\\Windows\\Media\\chimes.wav'), tdTestResultSuccess() ], 2828 3116 # Second attempt should fail. 2829 [ tdTestFileRemove(sFile = 'c:\\Windows\\Media\\chimes.wav'), tdTestResult () ]3117 [ tdTestFileRemove(sFile = 'c:\\Windows\\Media\\chimes.wav'), tdTestResultFailure() ] 2830 3118 ]); 2831 3119 elif oTestVm.isLinux(): 2832 a aTests.extend([3120 atTests.extend([ 2833 3121 # Invalid stuff. 2834 [ tdTestFileRemove(sFile = ''), tdTestResult () ],2835 [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResult () ],3122 [ tdTestFileRemove(sFile = ''), tdTestResultFailure() ], 3123 [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResultFailure() ], 2836 3124 # More unusual stuff. 2837 [ tdTestFileRemove(sFile = 'z:/'), tdTestResult () ],2838 [ tdTestFileRemove(sFile = '//uncrulez/foo'), tdTestResult () ],3125 [ tdTestFileRemove(sFile = 'z:/'), tdTestResultFailure() ], 3126 [ tdTestFileRemove(sFile = '//uncrulez/foo'), tdTestResultFailure() ], 2839 3127 # Non-existing stuff. 2840 [ tdTestFileRemove(sFile = '/non/existing'), tdTestResult () ],3128 [ tdTestFileRemove(sFile = '/non/existing'), tdTestResultFailure() ], 2841 3129 # Try to delete system files. 2842 [ tdTestFileRemove(sFile = '/etc'), tdTestResult () ],2843 [ tdTestFileRemove(sFile = '/bin/sh'), tdTestResult () ]3130 [ tdTestFileRemove(sFile = '/etc'), tdTestResultFailure() ], 3131 [ tdTestFileRemove(sFile = '/bin/sh'), tdTestResultFailure() ] 2844 3132 ]); 2845 3133 2846 a aTests.extend([3134 atTests.extend([ 2847 3135 # Try delete some unimportant stuff. 2848 [ tdTestFileRemove(sFile = sFileToDelete), tdTestResult (fRc = True) ],3136 [ tdTestFileRemove(sFile = sFileToDelete), tdTestResultSuccess() ], 2849 3137 # Second attempt should fail. 2850 [ tdTestFileRemove(sFile = sFileToDelete), tdTestResult () ]3138 [ tdTestFileRemove(sFile = sFileToDelete), tdTestResultFailure() ] 2851 3139 ]); 2852 3140 2853 3141 fRc = True; 2854 for (i, aTest) in enumerate(a aTests):3142 for (i, aTest) in enumerate(atTests): 2855 3143 oCurTest = aTest[0]; # tdTestExec, use an index, later. 2856 3144 oCurRes = aTest[1]; # tdTestResult … … 2970 3258 return (False, oTxsSession); 2971 3259 2972 a aTests = [];2973 a aTests.extend([3260 atTests = []; 3261 atTests.extend([ 2974 3262 # Invalid stuff. 2975 3263 [ tdTestFileReadWrite(cbToReadWrite = 0), tdTestResultFileReadWrite() ], … … 3000 3288 3001 3289 if oTestVm.isWindows(): 3002 a aTests.extend([3290 atTests.extend([ 3003 3291 # Create a file which must not exist (but it hopefully does). 3004 3292 [ tdTestFileReadWrite(sFile = 'C:\\Windows\\System32\\calc.exe', sOpenMode = 'w', sDisposition = 'ce'), … … 3014 3302 # Note: tst-xppro has other contents in eula.txt. 3015 3303 if oTestVm.sVmName.startswith('tst-xpsp2'): 3016 a aTests.extend([3304 atTests.extend([ 3017 3305 # Reading from beginning. 3018 3306 [ tdTestFileReadWrite(sFile = 'C:\\Windows\\System32\\eula.txt', … … 3027 3315 ]); 3028 3316 elif oTestVm.isLinux(): 3029 a aTests.extend([3317 atTests.extend([ 3030 3318 # Create a file which must not exist (but it hopefully does). 3031 3319 [ tdTestFileReadWrite(sFile = '/etc/issue', sOpenMode = 'w', sDisposition = 'ce'), … … 3040 3328 3041 3329 fRc = True; 3042 for (i, aTest) in enumerate(a aTests):3330 for (i, aTest) in enumerate(atTests): 3043 3331 oCurTest = aTest[0]; # tdTestFileReadWrite, use an index, later. 3044 3332 oCurRes = aTest[1]; # tdTestResult … … 3128 3416 return (False, oTxsSession); 3129 3417 3130 a aTests = [];3418 atTests = []; 3131 3419 3132 3420 cbScratchBuf = random.randint(1, 4096); 3133 3421 abScratchBuf = os.urandom(cbScratchBuf); 3134 a aTests.extend([3422 atTests.extend([ 3135 3423 # Write to a non-existing file. 3136 3424 [ tdTestFileReadWrite(sFile = sScratch + 'testGuestCtrlFileWrite.txt', … … 3140 3428 3141 3429 aScratchBuf2 = os.urandom(cbScratchBuf); 3142 a aTests.extend([3430 atTests.extend([ 3143 3431 # Append the same amount of data to the just created file. 3144 3432 [ tdTestFileReadWrite(sFile = sScratch + 'testGuestCtrlFileWrite.txt', … … 3150 3438 3151 3439 fRc = True; 3152 for (i, aTest) in enumerate(a aTests):3440 for (i, aTest) in enumerate(atTests): 3153 3441 oCurTest = aTest[0]; # tdTestFileReadWrite, use an index, later. 3154 3442 oCurRes = aTest[1]; # tdTestResult … … 3289 3577 reporter.log('Warning: Test file for big copy not found -- some tests might fail'); 3290 3578 3291 a aTests = [];3292 a aTests.extend([3579 atTests = []; 3580 atTests.extend([ 3293 3581 # Destination missing. 3294 [ tdTestCopyTo(sSrc = ''), tdTestResult () ],3295 [ tdTestCopyTo(sSrc = '/placeholder', fFlags = [ 80 ] ), tdTestResult () ],3582 [ tdTestCopyTo(sSrc = ''), tdTestResultFailure() ], 3583 [ tdTestCopyTo(sSrc = '/placeholder', fFlags = [ 80 ] ), tdTestResultFailure() ], 3296 3584 # Source missing. 3297 [ tdTestCopyTo(sDst = ''), tdTestResult () ],3298 [ tdTestCopyTo(sDst = '/placeholder', fFlags = [ 80 ] ), tdTestResult () ],3585 [ tdTestCopyTo(sDst = ''), tdTestResultFailure() ], 3586 [ tdTestCopyTo(sDst = '/placeholder', fFlags = [ 80 ] ), tdTestResultFailure() ], 3299 3587 # Testing DirectoryCopyFlag flags. 3300 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResult () ],3588 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ], 3301 3589 # Testing FileCopyFlag flags. 3302 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResult () ],3590 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ], 3303 3591 # Nothing to copy (source and/or destination is empty). 3304 [ tdTestCopyTo(sSrc = 'z:\\'), tdTestResult () ],3305 [ tdTestCopyTo(sSrc = '\\\\uncrulez\\foo'), tdTestResult () ],3306 [ tdTestCopyTo(sSrc = 'non-exist', sDst = os.path.join(sScratchGst, 'non-exist.dll')), tdTestResult () ]3592 [ tdTestCopyTo(sSrc = 'z:\\'), tdTestResultFailure() ], 3593 [ tdTestCopyTo(sSrc = '\\\\uncrulez\\foo'), tdTestResultFailure() ], 3594 [ tdTestCopyTo(sSrc = 'non-exist', sDst = os.path.join(sScratchGst, 'non-exist.dll')), tdTestResultFailure() ] 3307 3595 ]); 3308 3596 … … 3311 3599 # 3312 3600 if self.oTstDrv.fpApiVer > 5.2: 3313 a aTests.extend([3314 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid), tdTestResult () ],3315 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstNotExist), tdTestResult () ],3316 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstNotExist), tdTestResult () ],3601 atTests.extend([ 3602 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid), tdTestResultFailure() ], 3603 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstNotExist), tdTestResultFailure() ], 3604 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstNotExist), tdTestResultFailure() ], 3317 3605 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGstNotExist, 'renamedfile.dll')), 3318 tdTestResult () ],3606 tdTestResultFailure() ], 3319 3607 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGst, 'HostGABig.dat')), 3320 tdTestResult (fRc = True) ],3608 tdTestResultSuccess() ], 3321 3609 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGst, 'HostGABig.dat')), 3322 tdTestResult (fRc = True) ],3610 tdTestResultSuccess() ], 3323 3611 # Note: Copying files into directories via Main is supported only in versions > 5.2. 3324 3612 # Destination is a directory. 3325 3613 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGst), 3326 tdTestResult (fRc = True) ],3614 tdTestResultSuccess() ], 3327 3615 # Copy over file again into same directory (overwrite). 3328 3616 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGst), 3329 tdTestResult (fRc = True) ]3617 tdTestResultSuccess() ] 3330 3618 ]); 3331 3619 3332 3620 if oTestVm.isWindows(): 3333 a aTests.extend([3621 atTests.extend([ 3334 3622 # Copy the same file over to the guest, but this time store the file into the former 3335 3623 # file's ADS (Alternate Data Stream). Only works on Windows, of course. 3336 3624 [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')), 3337 tdTestResult (fRc = True) ]3625 tdTestResultSuccess() ] 3338 3626 ]); 3339 3627 … … 3345 3633 if self.oTstDrv.sHost == "win": 3346 3634 sSystemRoot = os.getenv('SystemRoot', 'C:\\Windows') 3347 a aTests.extend([3635 atTests.extend([ 3348 3636 # Copying directories with contain files we don't have read access to. 3349 3637 ## @todo r=klaus disabled, because this can fill up the guest disk, making other tests fail, … … 3356 3644 [ tdTestCopyTo(sSrc = os.path.join(sSystemRoot, 'Help'), 3357 3645 sDst = sScratchGst, fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), 3358 tdTestResult (fRc = True) ]3646 tdTestResultSuccess() ] 3359 3647 ]); 3360 3648 3361 3649 fRc = True; 3362 for (i, aTest) in enumerate(a aTests):3650 for (i, aTest) in enumerate(atTests): 3363 3651 oCurTest = aTest[0]; # tdTestExec, use an index, later. 3364 3652 oCurRes = aTest[1]; # tdTestResult … … 3438 3726 reporter.log('Scratch path is: %s' % (sScratchHst,)); 3439 3727 3440 a aTests = [];3441 a aTests.extend([3728 atTests = []; 3729 atTests.extend([ 3442 3730 # Destination missing. 3443 [ tdTestCopyFrom(sSrc = ''), tdTestResult () ],3444 [ tdTestCopyFrom(sSrc = 'Something', fFlags = [ 80 ] ), tdTestResult () ],3731 [ tdTestCopyFrom(sSrc = ''), tdTestResultFailure() ], 3732 [ tdTestCopyFrom(sSrc = 'Something', fFlags = [ 80 ] ), tdTestResultFailure() ], 3445 3733 # Source missing. 3446 [ tdTestCopyFrom(sDst = ''), tdTestResult () ],3447 [ tdTestCopyFrom(sDst = 'Something', fFlags = [ 80 ] ), tdTestResult () ],3734 [ tdTestCopyFrom(sDst = ''), tdTestResultFailure() ], 3735 [ tdTestCopyFrom(sDst = 'Something', fFlags = [ 80 ] ), tdTestResultFailure() ], 3448 3736 # Testing DirectoryCopyFlag flags. 3449 [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResult () ],3737 [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ], 3450 3738 # Testing FileCopyFlag flags. 3451 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResult () ],3739 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ], 3452 3740 # Nothing to copy (sDst is empty / unreachable). 3453 [ tdTestCopyFrom(sSrc = 'z:\\'), tdTestResult () ],3454 [ tdTestCopyFrom(sSrc = '\\\\uncrulez\\foo'), tdTestResult () ],3455 [ tdTestCopyFrom(sSrc = 'non-exist', sDst = os.path.join(sScratchHst, 'non-exist')), tdTestResult () ]3741 [ tdTestCopyFrom(sSrc = 'z:\\'), tdTestResultFailure() ], 3742 [ tdTestCopyFrom(sSrc = '\\\\uncrulez\\foo'), tdTestResultFailure() ], 3743 [ tdTestCopyFrom(sSrc = 'non-exist', sDst = os.path.join(sScratchHst, 'non-exist')), tdTestResultFailure() ] 3456 3744 ]); 3457 3745 … … 3461 3749 if self.oTstDrv.fpApiVer > 5.2: 3462 3750 reporter.log(("Single file handling")); 3463 a aTests.extend([3751 atTests.extend([ 3464 3752 # Copying single files. 3465 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid), tdTestResult () ],3753 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid), tdTestResultFailure() ], 3466 3754 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = os.path.join(sScratchHstInvalid, 'tstCopyFrom-renamedfile')), 3467 tdTestResult () ],3755 tdTestResultFailure() ], 3468 3756 # Copy over file using a different destination name. 3469 3757 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = os.path.join(sScratchHst, 'tstCopyFrom-renamedfile')), 3470 tdTestResult (fRc = True) ],3758 tdTestResultSuccess() ], 3471 3759 # Copy over same file (and overwrite existing one). 3472 3760 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = os.path.join(sScratchHst, 'tstCopyFrom-renamedfile')), 3473 tdTestResult (fRc = True) ],3761 tdTestResultSuccess() ], 3474 3762 # Note: Copying files into directories via Main is supported only in versions > 5.2. 3475 3763 # Destination is a directory with a trailing slash (should work). 3476 3764 # See "cp" syntax. 3477 3765 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHst + "/"), 3478 tdTestResult (fRc = True) ],3766 tdTestResultSuccess() ], 3479 3767 # Destination is a directory (without a trailing slash, should also work). 3480 3768 # See "cp" syntax. 3481 3769 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHst), 3482 tdTestResult (fRc = True) ],3770 tdTestResultSuccess() ], 3483 3771 # Destination is a non-existing directory. 3484 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstNotExist), tdTestResult () ]3772 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstNotExist), tdTestResultFailure() ] 3485 3773 ]); 3486 3774 … … 3490 3778 if self.oTstDrv.fpApiVer > 5.2: # Copying directories via Main is supported only in versions > 5.2. 3491 3779 reporter.log(("Directory handling")); 3492 a aTests.extend([3780 atTests.extend([ 3493 3781 # Copying entire directories (destination is "<sScratchHst>\Web"). 3494 3782 [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst), 3495 tdTestResult (fRc = True) ],3783 tdTestResultSuccess() ], 3496 3784 # Repeat -- this time it should fail, as the destination directory already exists (and 3497 3785 # DirectoryCopyFlag_CopyIntoExisting is not specified). 3498 [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst), tdTestResult () ],3786 [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst), tdTestResultFailure() ], 3499 3787 # Next try with the DirectoryCopyFlag_CopyIntoExisting flag being set. 3500 3788 [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst, 3501 3789 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ] ), 3502 tdTestResult (fRc = True) ],3790 tdTestResultSuccess() ], 3503 3791 # Ditto, with trailing slash. 3504 3792 [ tdTestCopyFrom(sSrc = sSrcDirExisting, 3505 3793 sDst = sScratchHst + "/", fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), 3506 tdTestResult (fRc = True) ],3794 tdTestResultSuccess() ], 3507 3795 # Copying contents of directories into a non-existing directory chain on the host which fail. 3508 3796 [ tdTestCopyFrom(sSrc = sSrcDirExisting + sPathSep, sDst = sScratchHstNotExistChain, 3509 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), tdTestResult () ],3797 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), tdTestResultFailure() ], 3510 3798 # Copying contents of directories into a non-existing directory on the host, which should succeed. 3511 3799 [ tdTestCopyFrom(sSrc = sSrcDirExisting + sPathSep, sDst = sScratchHstNotExist, 3512 3800 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ] ), 3513 tdTestResult (fRc = True) ]3801 tdTestResultSuccess() ] 3514 3802 ]); 3515 3803 3516 3804 fRc = True; 3517 for (i, aTest) in enumerate(a aTests):3805 for (i, aTest) in enumerate(atTests): 3518 3806 oCurTest = aTest[0]; # tdTestExec, use an index, later. 3519 3807 oCurRes = aTest[1]; # tdTestResult … … 3558 3846 """ 3559 3847 Tests updating the Guest Additions inside the guest. 3560 """ 3848 3849 """ 3850 3851 # Skip test for updating Guest Additions if we run on a too old (Windows) guest. 3852 ## 3853 ## @todo make it work everywhere! 3854 ## 3855 if oTestVm.sKind in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'): 3856 reporter.log("Skipping updating GAs on old windows vm (sKind=%s)" % (oTestVm.sKind,)); 3857 return (None, oTxsSession); 3858 if oTestVm.isOS2(): 3859 reporter.log("Skipping updating GAs on OS/2 guest"); 3860 return (None, oTxsSession); 3561 3861 3562 3862 # Some stupid trickery to guess the location of the iso. … … 3589 3889 reporter.log('Scratch path is: %s' % (sScratch,)); 3590 3890 3591 a aTests = [];3891 atTests = []; 3592 3892 if oTestVm.isWindows(): 3593 a aTests.extend([3893 atTests.extend([ 3594 3894 # Source is missing. 3595 [ tdTestUpdateAdditions(sSrc = ''), tdTestResult () ],3895 [ tdTestUpdateAdditions(sSrc = ''), tdTestResultFailure() ], 3596 3896 3597 3897 # Wrong fFlags. 3598 3898 [ tdTestUpdateAdditions(sSrc = self.oTstDrv.getGuestAdditionsIso(), 3599 fFlags = [ 1234 ]), tdTestResult () ],3899 fFlags = [ 1234 ]), tdTestResultFailure() ], 3600 3900 3601 3901 # Non-existing .ISO. 3602 [ tdTestUpdateAdditions(sSrc = "non-existing.iso"), tdTestResult () ],3902 [ tdTestUpdateAdditions(sSrc = "non-existing.iso"), tdTestResultFailure() ], 3603 3903 3604 3904 # Wrong .ISO. 3605 [ tdTestUpdateAdditions(sSrc = sVBoxValidationKitISO), tdTestResult () ],3905 [ tdTestUpdateAdditions(sSrc = sVBoxValidationKitISO), tdTestResultFailure() ], 3606 3906 3607 3907 # The real thing. 3608 3908 [ tdTestUpdateAdditions(sSrc = self.oTstDrv.getGuestAdditionsIso()), 3609 tdTestResult (fRc = True) ],3909 tdTestResultSuccess() ], 3610 3910 # Test the (optional) installer arguments. This will extract the 3611 3911 # installer into our guest's scratch directory. 3612 3912 [ tdTestUpdateAdditions(sSrc = self.oTstDrv.getGuestAdditionsIso(), 3613 3913 asArgs = [ '/extract', '/D=' + sScratch ]), 3614 tdTestResult (fRc = True) ]3914 tdTestResultSuccess() ] 3615 3915 # Some debg ISO. Only enable locally. 3616 3916 #[ tdTestUpdateAdditions( 3617 3917 # sSrc = "V:\\Downloads\\VBoxGuestAdditions-r80354.iso"), 3618 # tdTestResult (fRc = True) ]3918 # tdTestResultSuccess() ] 3619 3919 ]); 3620 3920 else: … … 3622 3922 3623 3923 fRc = True; 3624 for (i, aTest) in enumerate(a aTests):3924 for (i, aTest) in enumerate(atTests): 3625 3925 oCurTest = aTest[0]; # tdTestExec, use an index, later. 3626 3926 oCurRes = aTest[1]; # tdTestResult
Note:
See TracChangeset
for help on using the changeset viewer.