Changeset 79159 in vbox for trunk/src/VBox/ValidationKit/testdriver
- Timestamp:
- Jun 16, 2019 3:27:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/vboxtestfileset.py
r79158 r79159 47 47 48 48 49 50 class GstFsObj(object): 51 """ A file system object we created in the guest for test purposes. """ 52 def __init__(self, oParent, sPath): 53 self.oParent = oParent # type: GstDir 54 self.sPath = sPath # type: str 55 self.sName = sPath # type: str 56 if oParent: 57 assert sPath.startswith(oParent.sPath); 58 self.sName = sPath[len(oParent.sPath) + 1:]; 59 # Add to parent. 60 oParent.aoChildren.append(self); 61 oParent.dChildrenUpper[self.sName.upper()] = self; 62 63 class GstFile(GstFsObj): 64 """ A file object in the guest. """ 65 def __init__(self, oParent, sPath, abContent): 66 GstFsObj.__init__(self, oParent, sPath); 67 self.abContent = abContent # type: bytearray 68 self.cbContent = len(abContent); 69 self.off = 0; 70 71 def read(self, cbToRead): 72 assert self.off <= self.cbContent; 73 cbLeft = self.cbContent - self.off; 74 if cbLeft < cbToRead: 75 cbToRead = cbLeft; 76 abRet = self.abContent[self.off:(self.off + cbToRead)]; 77 assert len(abRet) == cbToRead; 78 self.off += cbToRead; 79 return abRet; 80 81 class GstDir(GstFsObj): 82 """ A file object in the guest. """ 83 def __init__(self, oParent, sPath): 84 GstFsObj.__init__(self, oParent, sPath); 85 self.aoChildren = [] # type: list(GsFsObj) 86 self.dChildrenUpper = {} # type: dict(str,GsFsObj) 87 88 def contains(self, sName): 89 """ Checks if the directory contains the given name. """ 90 return sName.upper() in self.dChildrenUpper 91 92 49 93 class TestFileSet(object): 50 94 """ … … 54 98 utility from the validation kit. 55 99 """ 56 57 class GstFsObj(object):58 """ A file system object we created in the guest for test purposes. """59 def __init__(self, oParent, sPath):60 self.oParent = oParent # type: GstDir61 self.sPath = sPath # type: str62 self.sName = sPath # type: str63 if oParent:64 assert sPath.startswith(oParent.sPath);65 self.sName = sPath[len(oParent.sPath) + 1:];66 # Add to parent.67 oParent.aoChildren.append(self);68 oParent.dChildrenUpper[self.sName.upper()] = self;69 70 class GstFile(GstFsObj):71 """ A file object in the guest. """72 def __init__(self, oParent, sPath, abContent):73 TestFileSet.GstFsObj.__init__(self, oParent, sPath);74 self.abContent = abContent # type: bytearray75 self.cbContent = len(abContent);76 self.off = 0;77 78 def read(self, cbToRead):79 assert self.off <= self.cbContent;80 cbLeft = self.cbContent - self.off;81 if cbLeft < cbToRead:82 cbToRead = cbLeft;83 abRet = self.abContent[self.off:(self.off + cbToRead)];84 assert len(abRet) == cbToRead;85 self.off += cbToRead;86 return abRet;87 88 class GstDir(GstFsObj):89 """ A file object in the guest. """90 def __init__(self, oParent, sPath):91 TestFileSet.GstFsObj.__init__(self, oParent, sPath);92 self.aoChildren = [] # type: list(GsFsObj)93 self.dChildrenUpper = {} # type: dict(str,GsFsObj)94 95 def contains(self, sName):96 """ Checks if the directory contains the given name. """97 return sName.upper() in self.dChildrenUpper98 99 100 100 101 ksReservedWinOS2 = '/\\"*:<>?|\t\v\n\r\f\a\b'; … … 164 165 ## Number of directories under oTreeDir. 165 166 self.cTreeDirs = 0; 167 ## Number of other file types under oTreeDir. 168 self.cTreeOthers = 0; 166 169 167 170 ## All directories in creation order. … … 242 245 Creates a test directory. 243 246 """ 244 oDir = TestFileSet.GstDir(oParent, sDir);247 oDir = GstDir(oParent, sDir); 245 248 self.aoDirs.append(oDir); 246 249 self.dPaths[sDir] = oDir; … … 254 257 abContent = bytearray(self.oRandom.getrandbits(8) for _ in xrange(cbFile)); 255 258 256 oFile = TestFileSet.GstFile(oParent, sFile, abContent);259 oFile = GstFile(oParent, sFile, abContent); 257 260 self.aoFiles.append(oFile); 258 261 self.dPaths[sFile] = oFile; … … 418 421 return True; 419 422 420
Note:
See TracChangeset
for help on using the changeset viewer.