VirtualBox

Ignore:
Timestamp:
Jun 17, 2019 5:41:18 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131366
Message:

vboxtestfileset.py: Validate the files copied to the host from the guest. bugref:9151 bugref:9320

File:
1 edited

Legend:

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

    r79185 r79193  
    8383            return bytes(abRet);
    8484        return abRet;
     85
     86    def equalFile(self, oFile):
     87        """ Compares the content of oFile with self.abContent. """
     88
     89        # Check the size first.
     90        try:
     91            cbFile = os.fstat(oFile.fileno()).st_size;
     92        except:
     93            return reporter.errorXcpt();
     94        if cbFile != self.cbContent:
     95            return reporter.error('file size differs: %s, cbContent=%s' % (cbFile, self.cbContent));
     96
     97        # Compare the bytes next.
     98        offFile = 0;
     99        try:
     100            oFile.seek(offFile);
     101        except:
     102            return reporter.error('seek error');
     103        while offFile < self.cbContent:
     104            cbToRead = self.cbContent - offFile;
     105            if cbToRead > 256*1024:
     106                cbToRead = 256*1024;
     107            try:
     108                abRead = oFile.read(cbToRead);
     109            except:
     110                return reporter.error('read error at offset %s' % (offFile,));
     111            cbRead = len(abRead);
     112            if cbRead == 0:
     113                return reporter.error('premature end of file at offset %s' % (offFile,));
     114            if not utils.areBytesEqual(abRead, self.abContent[offFile:(offFile + cbRead)]):
     115                return reporter.error('%s byte block at offset %s differs' % (cbRead, offFile,));
     116            # Advance:
     117            offFile += cbRead;
     118
     119        return True;
     120
    85121
    86122class TestDir(TestFsObj):
     
    440476                        return oDir;
    441477                    oParent = oParent.oParent;
     478        return None; # make pylint happy
    442479
    443480#
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