VirtualBox

Changeset 79156 in vbox


Ignore:
Timestamp:
Jun 15, 2019 2:35:24 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131325
Message:

tdAddGuestCtrl.py: More cleanups. bugref:9151 bugref:9320

Location:
trunk/src/VBox/ValidationKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/txsclient.py

    r79092 r79156  
    16371637        The task returns True on success, False on failure (logged).
    16381638        """
    1639         return self.startTask(cMsTimeout, fIgnoreErrors, "unpackFile", self.taskUnpackFile, \
     1639        return self.startTask(cMsTimeout, fIgnoreErrors, "unpackFile", self.taskUnpackFile,
    16401640                              (sRemoteFile, sRemoteDir));
    16411641
  • trunk/src/VBox/ValidationKit/testdriver/vboxtestvms.py

    r79132 r79156  
    566566        """
    567567        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 '';
    568590
    569591    def isWindows(self):
     
    12311253        return True;
    12321254
     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
    12331277    def isWindows(self):
    12341278        """ Checks if it's a Windows VM. """
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r79137 r79156  
    3838import struct
    3939import sys
     40import tarfile;
    4041import threading
    4142import time
     
    849850        self.fRc = fRc;
    850851
     852class tdTestResultFailure(tdTestResult):
     853    """
     854    Base class for test results.
     855    """
     856    def __init__(self):
     857        tdTestResult.__init__(self, fRc = False);
     858
     859class tdTestResultSuccess(tdTestResult):
     860    """
     861    Base class for test results.
     862    """
     863    def __init__(self):
     864        tdTestResult.__init__(self, fRc = True);
     865
    851866class tdTestResultDirRead(tdTestResult):
    852867    """
     
    908923        self.cNumSessions = cNumSessions;
    909924
     925class 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
     938class 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
     956class 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
    910968class SubTstDrvAddGuestCtrl(base.SubTestDriverBase):
    911969    """
     
    926984            'update_additions'
    927985        ];
    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);
    9301000
    9311001    def parseOption(self, asArgs, iArg):                                        # pylint: disable=too-many-branches,too-many-statements
     
    9581028        reporter.log("Active tests: %s" % (self.asTests,));
    9591029
     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
    9601053        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;
    10741082
    10751083        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';
    10761101
    10771102    @staticmethod
     
    11121137            return SubTstDrvAddGuestCtrl.getGuestSystemDir(oTestVm) + '\\DOSCALL1.DLL';
    11131138        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    #
    11141394
    11151395    def gctrlCopyFileFrom(self, oGuestSession, sSrc, sDst, fFlags, fExpected):
     
    22792559        """
    22802560
     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
    22812566        # Use credential defaults.
    22822567        oCreds = tdCtxCreds();
     
    25002785        """
    25012786
    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 = [
    25092790            # Invalid stuff.
    2510             [ tdTestDirCreate(sDirectory = '' ), tdTestResult() ],
     2791            [ tdTestDirCreate(sDirectory = '' ), tdTestResultFailure() ],
    25112792            # 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([
    25162804            # Creating directories.
    2517             [ tdTestDirCreate(sDirectory = sScratch ), tdTestResult() ],
     2805            [ tdTestDirCreate(sDirectory = sScratch ), tdTestResultFailure() ],
    25182806            [ tdTestDirCreate(sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'),
    25192807                              fFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ),
    2520               tdTestResult(fRc = True) ],
     2808              tdTestResultSuccess() ],
    25212809            [ tdTestDirCreate(sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'),
    25222810                              fFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ),
    2523               tdTestResult(fRc = True) ],
     2811              tdTestResultSuccess() ],
    25242812            # Long (+ random) stuff.
    25252813            [ tdTestDirCreate(sDirectory = os.path.join(sScratch,
    25262814                                                        "".join(random.choice(string.ascii_lowercase) for i in xrange(32))) ),
    2527               tdTestResult(fRc = True) ],
     2815              tdTestResultSuccess() ],
    25282816            [ tdTestDirCreate(sDirectory = os.path.join(sScratch,
    25292817                                                        "".join(random.choice(string.ascii_lowercase) for i in xrange(128))) ),
    2530               tdTestResult(fRc = True) ],
     2818              tdTestResultSuccess() ],
    25312819            # Following two should fail on Windows (paths too long). Both should timeout.
    25322820            [ tdTestDirCreate(sDirectory = os.path.join(sScratch,
     
    25392827
    25402828        fRc = True;
    2541         for (i, aTest) in enumerate(aaTests):
     2829        for (i, aTest) in enumerate(atTests):
    25422830            oCurTest = aTest[0]; # tdTestExec, use an index, later.
    25432831            oCurRes  = aTest[1]; # tdTestResult
     
    25622850        """
    25632851
    2564         aaTests = [];
     2852        atTests = [];
    25652853        if oTestVm.isWindows():
    2566             aaTests.extend([
     2854            atTests.extend([
    25672855                # 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() ],
    25732861                # 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() ],
    25762864                # Non-existing stuff.
    2577                 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = 'c:\\Apps\\nonexisting\\foo'), tdTestResult() ],
     2865                [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = 'c:\\Apps\\nonexisting\\foo'), tdTestResultFailure() ],
    25782866                # FIXME: Failing test. Non Windows path
    2579                 # [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/tmp/non/existing'), tdTestResult() ]
     2867                # [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/tmp/non/existing'), tdTestResultFailure() ]
    25802868            ]);
    25812869        elif oTestVm.isLinux():
    2582             aaTests.extend([
     2870            atTests.extend([
    25832871                # Invalid stuff.
    2584                 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResult() ],
     2872                [ tdTestDirCreateTemp(sDirectory = ''), tdTestResultFailure() ],
    25852873                [ 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() ],
    25892877                # 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() ],
    25922880                # Non-existing stuff.
    2593                 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/non/existing'), tdTestResult() ],
     2881                [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/non/existing'), tdTestResultFailure() ],
    25942882            ]);
    25952883
    25962884            # FIXME: Failing tests.
    2597             # aaTests.extend([
     2885            # atTests.extend([
    25982886                # Non-secure variants.
    25992887                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26002888                #                       sDirectory = sScratch),
    2601                 #   tdTestResult(fRc = True) ],
     2889                #   tdTestResultSuccess() ],
    26022890                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26032891                #                       sDirectory = sScratch),
    2604                 #   tdTestResult(fRc = True) ],
     2892                #   tdTestResultSuccess() ],
    26052893                # [ tdTestDirCreateTemp(sTemplate = 'X',
    26062894                #                       sDirectory = sScratch),
    2607                 #   tdTestResult(fRc = True) ],
     2895                #   tdTestResultSuccess() ],
    26082896                # [ tdTestDirCreateTemp(sTemplate = 'X',
    26092897                #                       sDirectory = sScratch),
    2610                 #   tdTestResult(fRc = True) ],
     2898                #   tdTestResultSuccess() ],
    26112899                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26122900                #                       sDirectory = sScratch,
    26132901                #                       fMode = 0o700),
    2614                 #   tdTestResult(fRc = True) ],
     2902                #   tdTestResultSuccess() ],
    26152903                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26162904                #                     sDirectory = sScratch,
    26172905                #                     fMode = 0o700),
    2618                 #   tdTestResult(fRc = True) ],
     2906                #   tdTestResultSuccess() ],
    26192907                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26202908                #                       sDirectory = sScratch,
    26212909                #                       fMode = 0o755),
    2622                 #   tdTestResult(fRc = True) ],
     2910                #   tdTestResultSuccess() ],
    26232911                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26242912                #                       sDirectory = sScratch,
    26252913                #                       fMode = 0o755),
    2626                 #   tdTestResult(fRc = True) ],
     2914                #   tdTestResultSuccess() ],
    26272915                # Secure variants.
    26282916                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26292917                #                       sDirectory = sScratch, fSecure = True),
    2630                 #   tdTestResult(fRc = True) ],
     2918                #   tdTestResultSuccess() ],
    26312919                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26322920                #                       sDirectory = sScratch, fSecure = True),
    2633                 #   tdTestResult(fRc = True) ],
     2921                #   tdTestResultSuccess() ],
    26342922                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26352923                #                       sDirectory = sScratch, fSecure = True),
    2636                 #   tdTestResult(fRc = True) ],
     2924                #   tdTestResultSuccess() ],
    26372925                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26382926                #                       sDirectory = sScratch, fSecure = True),
    2639                 #   tdTestResult(fRc = True) ],
     2927                #   tdTestResultSuccess() ],
    26402928                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26412929                #                       sDirectory = sScratch,
    26422930                #                       fSecure = True, fMode = 0o700),
    2643                 #   tdTestResult(fRc = True) ],
     2931                #   tdTestResultSuccess() ],
    26442932                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26452933                #                       sDirectory = sScratch,
    26462934                #                       fSecure = True, fMode = 0o700),
    2647                 #   tdTestResult(fRc = True) ],
     2935                #   tdTestResultSuccess() ],
    26482936                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26492937                #                       sDirectory = sScratch,
    26502938                #                       fSecure = True, fMode = 0o755),
    2651                 #   tdTestResult(fRc = True) ],
     2939                #   tdTestResultSuccess() ],
    26522940                # [ tdTestDirCreateTemp(sTemplate = 'XXX',
    26532941                #                       sDirectory = sScratch,
    26542942                #                       fSecure = True, fMode = 0o755),
    2655                 #   tdTestResult(fRc = True) ],
     2943                #   tdTestResultSuccess() ],
    26562944                # Random stuff.
    26572945                # [ tdTestDirCreateTemp(
     
    26592947                #                       sDirectory = sScratch,
    26602948                #                       fSecure = True, fMode = 0o755),
    2661                 #   tdTestResult(fRc = True) ],
     2949                #   tdTestResultSuccess() ],
    26622950                # [ tdTestDirCreateTemp(sTemplate = "".join('X' for i in xrange(32)),
    26632951                #                       sDirectory = sScratch,
    26642952                #                       fSecure = True, fMode = 0o755),
    2665                 #   tdTestResult(fRc = True) ],
     2953                #   tdTestResultSuccess() ],
    26662954                # [ tdTestDirCreateTemp(sTemplate = "".join('X' for i in xrange(128)),
    26672955                #                       sDirectory = sScratch,
    26682956                #                       fSecure = True, fMode = 0o755),
    2669                 #   tdTestResult(fRc = True) ]
     2957                #   tdTestResultSuccess() ]
    26702958            # ]);
    26712959
    26722960        fRc = True;
    2673         for (i, aTest) in enumerate(aaTests):
     2961        for (i, aTest) in enumerate(atTests):
    26742962            oCurTest = aTest[0]; # tdTestExec, use an index, later.
    26752963            oCurRes  = aTest[1]; # tdTestResult
     
    28063094            sFileToDelete = "/home/vbox/.profile";
    28073095
    2808         aaTests = [];
     3096        atTests = [];
    28093097        if oTestVm.isWindows():
    2810             aaTests.extend([
     3098            atTests.extend([
    28113099                # Invalid stuff.
    2812                 [ tdTestFileRemove(sFile = ''), tdTestResult() ],
    2813                 [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResult() ],
     3100                [ tdTestFileRemove(sFile = ''), tdTestResultFailure() ],
     3101                [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResultFailure() ],
    28143102                # 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() ],
    28173105                # Non-existing stuff.
    2818                 [ tdTestFileRemove(sFile = 'c:\\Apps\\nonexisting'), tdTestResult() ],
     3106                [ tdTestFileRemove(sFile = 'c:\\Apps\\nonexisting'), tdTestResultFailure() ],
    28193107                # 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\ ...
    28223110            ]);
    28233111
    28243112            if oTestVm.sKind == "WindowsXP":
    2825                 aaTests.extend([
     3113                atTests.extend([
    28263114                    # 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() ],
    28283116                    # Second attempt should fail.
    2829                     [ tdTestFileRemove(sFile = 'c:\\Windows\\Media\\chimes.wav'), tdTestResult() ]
     3117                    [ tdTestFileRemove(sFile = 'c:\\Windows\\Media\\chimes.wav'), tdTestResultFailure() ]
    28303118                ]);
    28313119        elif oTestVm.isLinux():
    2832             aaTests.extend([
     3120            atTests.extend([
    28333121                # Invalid stuff.
    2834                 [ tdTestFileRemove(sFile = ''), tdTestResult() ],
    2835                 [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResult() ],
     3122                [ tdTestFileRemove(sFile = ''), tdTestResultFailure() ],
     3123                [ tdTestFileRemove(sFile = 'C:\\Windows'), tdTestResultFailure() ],
    28363124                # 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() ],
    28393127                # Non-existing stuff.
    2840                 [ tdTestFileRemove(sFile = '/non/existing'), tdTestResult() ],
     3128                [ tdTestFileRemove(sFile = '/non/existing'), tdTestResultFailure() ],
    28413129                # 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() ]
    28443132            ]);
    28453133
    2846         aaTests.extend([
     3134        atTests.extend([
    28473135            # Try delete some unimportant stuff.
    2848             [ tdTestFileRemove(sFile = sFileToDelete), tdTestResult(fRc = True) ],
     3136            [ tdTestFileRemove(sFile = sFileToDelete), tdTestResultSuccess() ],
    28493137            # Second attempt should fail.
    2850             [ tdTestFileRemove(sFile = sFileToDelete), tdTestResult() ]
     3138            [ tdTestFileRemove(sFile = sFileToDelete), tdTestResultFailure() ]
    28513139        ]);
    28523140
    28533141        fRc = True;
    2854         for (i, aTest) in enumerate(aaTests):
     3142        for (i, aTest) in enumerate(atTests):
    28553143            oCurTest = aTest[0]; # tdTestExec, use an index, later.
    28563144            oCurRes  = aTest[1]; # tdTestResult
     
    29703258            return (False, oTxsSession);
    29713259
    2972         aaTests = [];
    2973         aaTests.extend([
     3260        atTests = [];
     3261        atTests.extend([
    29743262            # Invalid stuff.
    29753263            [ tdTestFileReadWrite(cbToReadWrite = 0), tdTestResultFileReadWrite() ],
     
    30003288
    30013289        if oTestVm.isWindows():
    3002             aaTests.extend([
     3290            atTests.extend([
    30033291                # Create a file which must not exist (but it hopefully does).
    30043292                [ tdTestFileReadWrite(sFile = 'C:\\Windows\\System32\\calc.exe', sOpenMode = 'w', sDisposition = 'ce'),
     
    30143302            # Note: tst-xppro has other contents in eula.txt.
    30153303            if oTestVm.sVmName.startswith('tst-xpsp2'):
    3016                 aaTests.extend([
     3304                atTests.extend([
    30173305                    # Reading from beginning.
    30183306                    [ tdTestFileReadWrite(sFile = 'C:\\Windows\\System32\\eula.txt',
     
    30273315                ]);
    30283316        elif oTestVm.isLinux():
    3029             aaTests.extend([
     3317            atTests.extend([
    30303318                # Create a file which must not exist (but it hopefully does).
    30313319                [ tdTestFileReadWrite(sFile = '/etc/issue', sOpenMode = 'w', sDisposition = 'ce'),
     
    30403328
    30413329        fRc = True;
    3042         for (i, aTest) in enumerate(aaTests):
     3330        for (i, aTest) in enumerate(atTests):
    30433331            oCurTest = aTest[0]; # tdTestFileReadWrite, use an index, later.
    30443332            oCurRes  = aTest[1]; # tdTestResult
     
    31283416            return (False, oTxsSession);
    31293417
    3130         aaTests = [];
     3418        atTests = [];
    31313419
    31323420        cbScratchBuf = random.randint(1, 4096);
    31333421        abScratchBuf = os.urandom(cbScratchBuf);
    3134         aaTests.extend([
     3422        atTests.extend([
    31353423            # Write to a non-existing file.
    31363424            [ tdTestFileReadWrite(sFile = sScratch + 'testGuestCtrlFileWrite.txt',
     
    31403428
    31413429        aScratchBuf2 = os.urandom(cbScratchBuf);
    3142         aaTests.extend([
     3430        atTests.extend([
    31433431            # Append the same amount of data to the just created file.
    31443432            [ tdTestFileReadWrite(sFile = sScratch + 'testGuestCtrlFileWrite.txt',
     
    31503438
    31513439        fRc = True;
    3152         for (i, aTest) in enumerate(aaTests):
     3440        for (i, aTest) in enumerate(atTests):
    31533441            oCurTest = aTest[0]; # tdTestFileReadWrite, use an index, later.
    31543442            oCurRes  = aTest[1]; # tdTestResult
     
    32893577            reporter.log('Warning: Test file for big copy not found -- some tests might fail');
    32903578
    3291         aaTests = [];
    3292         aaTests.extend([
     3579        atTests = [];
     3580        atTests.extend([
    32933581            # Destination missing.
    3294             [ tdTestCopyTo(sSrc = ''), tdTestResult() ],
    3295             [ tdTestCopyTo(sSrc = '/placeholder', fFlags = [ 80 ] ), tdTestResult() ],
     3582            [ tdTestCopyTo(sSrc = ''), tdTestResultFailure() ],
     3583            [ tdTestCopyTo(sSrc = '/placeholder', fFlags = [ 80 ] ), tdTestResultFailure() ],
    32963584            # Source missing.
    3297             [ tdTestCopyTo(sDst = ''), tdTestResult() ],
    3298             [ tdTestCopyTo(sDst = '/placeholder', fFlags = [ 80 ] ), tdTestResult() ],
     3585            [ tdTestCopyTo(sDst = ''), tdTestResultFailure() ],
     3586            [ tdTestCopyTo(sDst = '/placeholder', fFlags = [ 80 ] ), tdTestResultFailure() ],
    32993587            # Testing DirectoryCopyFlag flags.
    3300             [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResult() ],
     3588            [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ],
    33013589            # Testing FileCopyFlag flags.
    3302             [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResult() ],
     3590            [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ],
    33033591            # 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() ]
    33073595        ]);
    33083596
     
    33113599        #
    33123600        if self.oTstDrv.fpApiVer > 5.2:
    3313             aaTests.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() ],
    33173605                [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGstNotExist, 'renamedfile.dll')),
    3318                   tdTestResult() ],
     3606                  tdTestResultFailure() ],
    33193607                [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGst, 'HostGABig.dat')),
    3320                   tdTestResult(fRc = True) ],
     3608                  tdTestResultSuccess() ],
    33213609                [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGst, 'HostGABig.dat')),
    3322                   tdTestResult(fRc = True) ],
     3610                  tdTestResultSuccess() ],
    33233611                # Note: Copying files into directories via Main is supported only in versions > 5.2.
    33243612                # Destination is a directory.
    33253613                [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGst),
    3326                   tdTestResult(fRc = True) ],
     3614                  tdTestResultSuccess() ],
    33273615                # Copy over file again into same directory (overwrite).
    33283616                [ tdTestCopyTo(sSrc = sTestFileBig, sDst = sScratchGst),
    3329                   tdTestResult(fRc = True) ]
     3617                  tdTestResultSuccess() ]
    33303618            ]);
    33313619
    33323620            if oTestVm.isWindows():
    3333                 aaTests.extend([
     3621                atTests.extend([
    33343622                    # Copy the same file over to the guest, but this time store the file into the former
    33353623                    # file's ADS (Alternate Data Stream). Only works on Windows, of course.
    33363624                    [ tdTestCopyTo(sSrc = sTestFileBig, sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')),
    3337                       tdTestResult(fRc = True) ]
     3625                      tdTestResultSuccess() ]
    33383626                ]);
    33393627
     
    33453633                if self.oTstDrv.sHost == "win":
    33463634                    sSystemRoot = os.getenv('SystemRoot', 'C:\\Windows')
    3347                     aaTests.extend([
     3635                    atTests.extend([
    33483636                        # Copying directories with contain files we don't have read access to.
    33493637                        ## @todo r=klaus disabled, because this can fill up the guest disk, making other tests fail,
     
    33563644                        [ tdTestCopyTo(sSrc = os.path.join(sSystemRoot, 'Help'),
    33573645                                       sDst = sScratchGst, fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]),
    3358                           tdTestResult(fRc = True) ]
     3646                          tdTestResultSuccess() ]
    33593647                        ]);
    33603648
    33613649        fRc = True;
    3362         for (i, aTest) in enumerate(aaTests):
     3650        for (i, aTest) in enumerate(atTests):
    33633651            oCurTest = aTest[0]; # tdTestExec, use an index, later.
    33643652            oCurRes  = aTest[1]; # tdTestResult
     
    34383726        reporter.log('Scratch path is: %s' % (sScratchHst,));
    34393727
    3440         aaTests = [];
    3441         aaTests.extend([
     3728        atTests = [];
     3729        atTests.extend([
    34423730            # Destination missing.
    3443             [ tdTestCopyFrom(sSrc = ''), tdTestResult() ],
    3444             [ tdTestCopyFrom(sSrc = 'Something', fFlags = [ 80 ] ), tdTestResult() ],
     3731            [ tdTestCopyFrom(sSrc = ''), tdTestResultFailure() ],
     3732            [ tdTestCopyFrom(sSrc = 'Something', fFlags = [ 80 ] ), tdTestResultFailure() ],
    34453733            # Source missing.
    3446             [ tdTestCopyFrom(sDst = ''), tdTestResult() ],
    3447             [ tdTestCopyFrom(sDst = 'Something', fFlags = [ 80 ] ), tdTestResult() ],
     3734            [ tdTestCopyFrom(sDst = ''), tdTestResultFailure() ],
     3735            [ tdTestCopyFrom(sDst = 'Something', fFlags = [ 80 ] ), tdTestResultFailure() ],
    34483736            # Testing DirectoryCopyFlag flags.
    3449             [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResult() ],
     3737            [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ],
    34503738            # Testing FileCopyFlag flags.
    3451             [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResult() ],
     3739            [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid, fFlags = [ 80 ] ), tdTestResultFailure() ],
    34523740            # 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() ]
    34563744        ]);
    34573745
     
    34613749        if self.oTstDrv.fpApiVer > 5.2:
    34623750            reporter.log(("Single file handling"));
    3463             aaTests.extend([
     3751            atTests.extend([
    34643752                # Copying single files.
    3465                 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid), tdTestResult() ],
     3753                [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstInvalid), tdTestResultFailure() ],
    34663754                [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = os.path.join(sScratchHstInvalid, 'tstCopyFrom-renamedfile')),
    3467                   tdTestResult() ],
     3755                  tdTestResultFailure() ],
    34683756                # Copy over file using a different destination name.
    34693757                [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = os.path.join(sScratchHst, 'tstCopyFrom-renamedfile')),
    3470                   tdTestResult(fRc = True) ],
     3758                  tdTestResultSuccess() ],
    34713759                # Copy over same file (and overwrite existing one).
    34723760                [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = os.path.join(sScratchHst, 'tstCopyFrom-renamedfile')),
    3473                   tdTestResult(fRc = True) ],
     3761                  tdTestResultSuccess() ],
    34743762                # Note: Copying files into directories via Main is supported only in versions > 5.2.
    34753763                # Destination is a directory with a trailing slash (should work).
    34763764                # See "cp" syntax.
    34773765                [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHst + "/"),
    3478                   tdTestResult(fRc = True) ],
     3766                  tdTestResultSuccess() ],
    34793767                # Destination is a directory (without a trailing slash, should also work).
    34803768                # See "cp" syntax.
    34813769                [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHst),
    3482                   tdTestResult(fRc = True) ],
     3770                  tdTestResultSuccess() ],
    34833771                # Destination is a non-existing directory.
    3484                 [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstNotExist), tdTestResult() ]
     3772                [ tdTestCopyFrom(sSrc = sSrcFileExisting, sDst = sScratchHstNotExist), tdTestResultFailure() ]
    34853773            ]);
    34863774
     
    34903778            if self.oTstDrv.fpApiVer > 5.2: # Copying directories via Main is supported only in versions > 5.2.
    34913779                reporter.log(("Directory handling"));
    3492                 aaTests.extend([
     3780                atTests.extend([
    34933781                    # Copying entire directories (destination is "<sScratchHst>\Web").
    34943782                    [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst),
    3495                       tdTestResult(fRc = True) ],
     3783                      tdTestResultSuccess() ],
    34963784                    # Repeat -- this time it should fail, as the destination directory already exists (and
    34973785                    # DirectoryCopyFlag_CopyIntoExisting is not specified).
    3498                     [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst), tdTestResult() ],
     3786                    [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst), tdTestResultFailure() ],
    34993787                    # Next try with the DirectoryCopyFlag_CopyIntoExisting flag being set.
    35003788                    [ tdTestCopyFrom(sSrc = sSrcDirExisting, sDst = sScratchHst,
    35013789                                     fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ] ),
    3502                       tdTestResult(fRc = True) ],
     3790                      tdTestResultSuccess() ],
    35033791                    # Ditto, with trailing slash.
    35043792                    [ tdTestCopyFrom(sSrc = sSrcDirExisting,
    35053793                                     sDst = sScratchHst + "/", fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]),
    3506                       tdTestResult(fRc = True) ],
     3794                      tdTestResultSuccess() ],
    35073795                    # Copying contents of directories into a non-existing directory chain on the host which fail.
    35083796                    [ tdTestCopyFrom(sSrc = sSrcDirExisting + sPathSep, sDst = sScratchHstNotExistChain,
    3509                                      fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), tdTestResult() ],
     3797                                     fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), tdTestResultFailure() ],
    35103798                    # Copying contents of directories into a non-existing directory on the host, which should succeed.
    35113799                    [ tdTestCopyFrom(sSrc = sSrcDirExisting + sPathSep, sDst = sScratchHstNotExist,
    35123800                                     fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ] ),
    3513                       tdTestResult(fRc = True) ]
     3801                      tdTestResultSuccess() ]
    35143802                ]);
    35153803
    35163804        fRc = True;
    3517         for (i, aTest) in enumerate(aaTests):
     3805        for (i, aTest) in enumerate(atTests):
    35183806            oCurTest = aTest[0]; # tdTestExec, use an index, later.
    35193807            oCurRes  = aTest[1]; # tdTestResult
     
    35583846        """
    35593847        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);
    35613861
    35623862        # Some stupid trickery to guess the location of the iso.
     
    35893889        reporter.log('Scratch path is: %s' % (sScratch,));
    35903890
    3591         aaTests = [];
     3891        atTests = [];
    35923892        if oTestVm.isWindows():
    3593             aaTests.extend([
     3893            atTests.extend([
    35943894                # Source is missing.
    3595                 [ tdTestUpdateAdditions(sSrc = ''), tdTestResult() ],
     3895                [ tdTestUpdateAdditions(sSrc = ''), tdTestResultFailure() ],
    35963896
    35973897                # Wrong fFlags.
    35983898                [ tdTestUpdateAdditions(sSrc = self.oTstDrv.getGuestAdditionsIso(),
    3599                                         fFlags = [ 1234 ]), tdTestResult() ],
     3899                                        fFlags = [ 1234 ]), tdTestResultFailure() ],
    36003900
    36013901                # Non-existing .ISO.
    3602                 [ tdTestUpdateAdditions(sSrc = "non-existing.iso"), tdTestResult() ],
     3902                [ tdTestUpdateAdditions(sSrc = "non-existing.iso"), tdTestResultFailure() ],
    36033903
    36043904                # Wrong .ISO.
    3605                 [ tdTestUpdateAdditions(sSrc = sVBoxValidationKitISO), tdTestResult() ],
     3905                [ tdTestUpdateAdditions(sSrc = sVBoxValidationKitISO), tdTestResultFailure() ],
    36063906
    36073907                # The real thing.
    36083908                [ tdTestUpdateAdditions(sSrc = self.oTstDrv.getGuestAdditionsIso()),
    3609                   tdTestResult(fRc = True) ],
     3909                  tdTestResultSuccess() ],
    36103910                # Test the (optional) installer arguments. This will extract the
    36113911                # installer into our guest's scratch directory.
    36123912                [ tdTestUpdateAdditions(sSrc = self.oTstDrv.getGuestAdditionsIso(),
    36133913                                        asArgs = [ '/extract', '/D=' + sScratch ]),
    3614                   tdTestResult(fRc = True) ]
     3914                  tdTestResultSuccess() ]
    36153915                # Some debg ISO. Only enable locally.
    36163916                #[ tdTestUpdateAdditions(
    36173917                #                      sSrc = "V:\\Downloads\\VBoxGuestAdditions-r80354.iso"),
    3618                 #  tdTestResult(fRc = True) ]
     3918                #  tdTestResultSuccess() ]
    36193919            ]);
    36203920        else:
     
    36223922
    36233923        fRc = True;
    3624         for (i, aTest) in enumerate(aaTests):
     3924        for (i, aTest) in enumerate(atTests):
    36253925            oCurTest = aTest[0]; # tdTestExec, use an index, later.
    36263926            oCurRes  = aTest[1]; # tdTestResult
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette