<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 5, 2020 at 9:57 PM Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 5, 2020 at 5:19 PM Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Some PPC KVM guests accumulate about 1 bit of entropy per second while idle<br>
and running getrandom02. Which isn't enough and test sporadically fails on<br>
timeout.<br>
<br>
Adjust the buffer size by looking at entropy_avail. We want to run the test,<br>
even if all entropy is exhausted, but with smaller buffer we don't set<br>
as high expectations on how much entropy is generated within default test time.<br>
<br>
Signed-off-by: Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>><br>
---<br>
testcases/kernel/syscalls/getrandom/getrandom02.c | 12 ++++++++++--<br>
1 file changed, 10 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/testcases/kernel/syscalls/getrandom/getrandom02.c b/testcases/kernel/syscalls/getrandom/getrandom02.c<br>
index ee0193df9897..1384fc5f32c0 100644<br>
--- a/testcases/kernel/syscalls/getrandom/getrandom02.c<br>
+++ b/testcases/kernel/syscalls/getrandom/getrandom02.c<br>
@@ -10,6 +10,8 @@<br>
#include "lapi/syscalls.h"<br>
#include "tst_test.h"<br>
<br>
+#define PROC_ENTROPY_AVAIL "/proc/sys/kernel/random/entropy_avail"<br>
+<br>
static int modes[] = { 0, GRND_RANDOM, GRND_NONBLOCK,<br>
GRND_RANDOM | GRND_NONBLOCK };<br>
<br>
@@ -37,11 +39,17 @@ static int check_content(unsigned char *buf, int nb)<br>
static void verify_getrandom(unsigned int n)<br>
{<br>
unsigned char buf[256];<br>
+ int bufsize = 64, entropy_avail;<br></blockquote><div><br></div><div><div style="font-size:small">I'm not sure why here initialize bufsize as 64? can you explain more?</div></div></div></div></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Ah I see, it just picks a smaller size to obtain littler random bytes to decrease the failure probability. But not has special meaning for 64, right?</div><div class="gmail_default" style="font-size:small"><br></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>