Module Name: src Committed By: pooka Date: Thu May 12 11:41:43 UTC 2016
Modified Files: src/tests/kernel: t_rnd.c Log Message: Test that reading /dev/random returns within a reasonable time. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/kernel/t_rnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/kernel/t_rnd.c diff -u src/tests/kernel/t_rnd.c:1.6 src/tests/kernel/t_rnd.c:1.7 --- src/tests/kernel/t_rnd.c:1.6 Mon Apr 13 22:24:34 2015 +++ src/tests/kernel/t_rnd.c Thu May 12 11:41:43 2016 @@ -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(); }