Test that reading /dev/random returns within a reasonable time.

This commit is contained in:
pooka 2016-05-12 11:41:43 +00:00
parent 74f1f7b042
commit 2d2ae8f1cf
1 changed files with 21 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_rnd.c,v 1.6 2015/04/13 22:24:34 riastradh Exp $ */
/* $NetBSD: t_rnd.c,v 1.7 2016/05/12 11:41:43 pooka Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_rnd.c,v 1.6 2015/04/13 22:24:34 riastradh Exp $");
__RCSID("$NetBSD: t_rnd.c,v 1.7 2016/05/12 11:41:43 pooka Exp $");
#include <sys/types.h>
#include <sys/fcntl.h>
@ -86,10 +86,29 @@ ATF_TC_BODY(RNDADDDATA2, tc)
ATF_REQUIRE_ERRNO(EINVAL, rump_sys_ioctl(fd, RNDADDDATA, &rd) == -1);
}
ATF_TC(read_random);
ATF_TC_HEAD(read_random, tc)
{
atf_tc_set_md_var(tc, "descr", "does reading /dev/random return "
"within reasonable time");
atf_tc_set_md_var(tc, "timeout", "10");
}
ATF_TC_BODY(read_random, tc)
{
char buf[128];
int fd;
rump_init();
RL(fd = rump_sys_open("/dev/random", O_RDONLY));
RL(rump_sys_read(fd, buf, sizeof(buf)));
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, RNDADDDATA);
ATF_TP_ADD_TC(tp, RNDADDDATA2);
ATF_TP_ADD_TC(tp, read_random);
return atf_no_error();
}