VirtualBox

Ignore:
Timestamp:
Jun 22, 2020 11:06:48 AM (5 years ago)
Author:
vboxsync
Message:

Validation Kit/testfileset: Limit iterations of chooseRandomDirFromTree() to avoid potential endless loops.

File:
1 edited

Legend:

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

    r83623 r84893  
    618618        return self.aoFiles[self.oRandom.choice(xrange(len(self.aoFiles)))];
    619619
    620     def chooseRandomDirFromTree(self, fLeaf = False, fNonEmpty = False):
     620    def chooseRandomDirFromTree(self, fLeaf = False, fNonEmpty = False, cMaxRetries = 1024):
    621621        """
    622622        Returns a random directory from the tree (self.oTreeDir).
    623623        """
    624         while True:
     624        cRetries = 0;
     625        while cRetries < cMaxRetries:
    625626            oDir = self.aoDirs[self.oRandom.choice(xrange(len(self.aoDirs)))];
    626627            # Check fNonEmpty requirement:
     
    638639                        return oDir;
    639640                    oParent = oParent.oParent;
     641            cRetries++;
     642
     643        reporter.errorXcpt('chooseRandomDirFromTree() failed; cMaxRetries=%d' % (cMaxRetries));
    640644        return None; # make pylint happy
    641645
Note: See TracChangeset for help on using the changeset viewer.

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