[LTP] [PATCH v2] getrandom02: relax check for returned data
Jan Stancek
jstancek@redhat.com
Wed Feb 8 15:04:40 CET 2017
"nb * 0.1" can easily fail for nb < 20, since all we need
are 2 identical bytes. Worst case (nb == 19) is almost
identical to "birthday problem", but with smaller pool.
Chance of hitting 2 identical bytes in pool of 19
is close to 50%.
Adjust formula to allow small repetitions in small pools.
Chance we fail now should be pretty unlikely, ~10^-16.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/syscalls/getrandom/getrandom02.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/getrandom/getrandom02.c b/testcases/kernel/syscalls/getrandom/getrandom02.c
index 0ac8bd28aed0..ec19f0fb32c5 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom02.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom02.c
@@ -83,7 +83,7 @@ static int check_content(int nb)
memset(table, 0, sizeof(table));
- max = nb * 0.10;
+ max = 6 + nb * 0.2;
for (i = 0; i < nb; i++) {
index = buf[i];
--
1.8.3.1
More information about the ltp
mailing list