changeset 19319:ec17ddecdf64 stable

test-pathencode: randomize length of each path component This makes it possible for long and short components to exist in the same path. This also makes shorter path components more likely. For randint(1, randint(1, n)), the likelihood that one sees a number k (1 <= k <= n) is 1/n * (\sum_{k=i}^n 1/i). This decreases with k, much like in the real world where shorter paths are more common than longer ones. The previous fix and this one together cause issue3958 to be detected by this test with reasonable frequency. When this test was run 100 times in a loop, the issue was detected 30 of those times.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 19 Jun 2013 23:05:40 -0700
parents 9778c77f05d6
children cf1b0a58a0de e71667a085f5 0af993732f66
files tests/test-pathencode.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-pathencode.py	Wed Jun 19 23:01:22 2013 -0700
+++ b/tests/test-pathencode.py	Wed Jun 19 23:05:40 2013 -0700
@@ -125,7 +125,8 @@
     p = pickfrom(rng, firsttable)(rng)
     l = len(p)
     ps = [p]
-    while l < k:
+    maxl = rng.randint(1, k)
+    while l < maxl:
         p = pickfrom(rng, resttable)(rng)
         l += len(p)
         ps.append(p)