* [LTP] [PATCH v2] getrandom02: relax check for returned data
@ 2017-02-08 14:04 Jan Stancek
2017-02-08 14:12 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2017-02-08 14:04 UTC (permalink / raw)
To: ltp
"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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH v2] getrandom02: relax check for returned data
2017-02-08 14:04 [LTP] [PATCH v2] getrandom02: relax check for returned data Jan Stancek
@ 2017-02-08 14:12 ` Cyril Hrubis
2017-02-08 14:18 ` Jan Stancek
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2017-02-08 14:12 UTC (permalink / raw)
To: ltp
Hi!
> "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>
Acked.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH v2] getrandom02: relax check for returned data
2017-02-08 14:12 ` Cyril Hrubis
@ 2017-02-08 14:18 ` Jan Stancek
0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2017-02-08 14:18 UTC (permalink / raw)
To: ltp
----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Wednesday, 8 February, 2017 3:12:51 PM
> Subject: Re: [PATCH v2] getrandom02: relax check for returned data
>
> Hi!
> > "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>
>
> Acked.
Pushed.
Regards,
Jan
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-08 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-08 14:04 [LTP] [PATCH v2] getrandom02: relax check for returned data Jan Stancek
2017-02-08 14:12 ` Cyril Hrubis
2017-02-08 14:18 ` Jan Stancek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox