diff options
| author | Enji Cooper <ngie@FreeBSD.org> | 2016-08-12 01:05:07 +0000 |
|---|---|---|
| committer | Enji Cooper <ngie@FreeBSD.org> | 2016-08-12 01:05:07 +0000 |
| commit | 014db25b98371942a535a35783bbaf8b571a6bee (patch) | |
| tree | 2a53a31277b7fd32b957a50009847705b13b68cf /kernel | |
| parent | 478290db20b28ab28ce7e08cf33f1b44d82e4cb3 (diff) | |
Notes
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/Makefile | 9 | ||||
| -rw-r--r-- | kernel/kqueue/Makefile | 6 | ||||
| -rw-r--r-- | kernel/kqueue/t_ioctl.c | 7 | ||||
| -rw-r--r-- | kernel/kqueue/t_proc1.c | 9 | ||||
| -rw-r--r-- | kernel/kqueue/t_proc2.c | 7 | ||||
| -rw-r--r-- | kernel/kqueue/t_proc3.c | 6 | ||||
| -rw-r--r-- | kernel/kqueue/t_vnode.c | 533 | ||||
| -rw-r--r-- | kernel/t_rnd.c | 25 | ||||
| -rw-r--r-- | kernel/tty/Makefile | 3 |
9 files changed, 582 insertions, 23 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 6a2bb907a915..5df392d9e499 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.36 2014/08/10 16:44:37 tls Exp $ +# $NetBSD: Makefile,v 1.39 2016/02/15 14:59:38 christos Exp $ NOMAN= # defined @@ -27,7 +27,7 @@ PROGS+= h_ps_strings2 LDADD.t_mqueue+= -lrt -.if (${MKRUMP} != "no") +.if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE) TESTS_SUBDIRS+= tty TESTS_C+= t_extattrctl @@ -38,6 +38,7 @@ LDADD.t_extattrctl+= -lrump -lpthread LDADD.t_filedesc+= ${LDADD.t_rnd} LDADD.t_rnd+= -lrumpvfs -lrumpdev_rnd -lrumpdev -lrump -lrumpuser LDADD.t_rnd+= -lrump -lpthread +CPPFLAGS+= -D_KERNTYPES .endif @@ -45,8 +46,8 @@ LDADD.t_rnd+= -lrump -lpthread .PATH: ${NETBSDSRCDIR}/sys/kern TESTS_C+= t_extent SRCS.t_extent= t_extent.c subr_extent.c -CPPFLAGS.t_extent.c= -D_EXTENT_TESTING -D__POOL_EXPOSE -CPPFLAGS.subr_extent.c= -D_EXTENT_TESTING -D__POOL_EXPOSE +CPPFLAGS.t_extent.c= -D_EXTENT_TESTING -D__POOL_EXPOSE -D_KERNTYPES +CPPFLAGS.subr_extent.c= -D_EXTENT_TESTING -D__POOL_EXPOSE -D_KERNTYPES t_subr_prf.c: gen_t_subr_prf ${NETBSDSRCDIR}/sys/kern/subr_prf.c ${HOST_SH} ${.ALLSRC} ${.TARGET} diff --git a/kernel/kqueue/Makefile b/kernel/kqueue/Makefile index f35d2b9076cd..a6e8b2d23ac9 100644 --- a/kernel/kqueue/Makefile +++ b/kernel/kqueue/Makefile @@ -1,12 +1,13 @@ -# $NetBSD: Makefile,v 1.3 2012/11/17 21:55:24 joerg Exp $ +# $NetBSD: Makefile,v 1.5 2016/04/29 07:12:34 ryoon Exp $ +WARNS?=6 NOMAN= # defined .include <bsd.own.mk> TESTSDIR= ${TESTSBASE}/kernel/kqueue -TESTS_SUBDIRS= read +TESTS_SUBDIRS= read TESTS_SUBDIRS+= write TESTS_C= t_ioctl @@ -14,5 +15,6 @@ TESTS_C+= t_proc1 TESTS_C+= t_proc2 TESTS_C+= t_proc3 TESTS_C+= t_sig +TESTS_C+= t_vnode .include <bsd.test.mk> diff --git a/kernel/kqueue/t_ioctl.c b/kernel/kqueue/t_ioctl.c index 8ed5a79c222d..d996fdfbd575 100644 --- a/kernel/kqueue/t_ioctl.c +++ b/kernel/kqueue/t_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_ioctl.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ +/* $NetBSD: t_ioctl.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_ioctl.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); +__RCSID("$NetBSD: t_ioctl.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); #include <sys/event.h> #include <sys/ioctl.h> @@ -53,7 +53,8 @@ ATF_TC_BODY(kfilter_byfilter, tc) { char buf[32]; struct kfilter_mapping km; - int i, kq; + int kq; + uint32_t i; RL(kq = kqueue()); diff --git a/kernel/kqueue/t_proc1.c b/kernel/kqueue/t_proc1.c index e7553095faf5..07d5a3c0279d 100644 --- a/kernel/kqueue/t_proc1.c +++ b/kernel/kqueue/t_proc1.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_proc1.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ +/* $NetBSD: t_proc1.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_proc1.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); +__RCSID("$NetBSD: t_proc1.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); /* * this also used to trigger problem fixed in @@ -99,7 +99,8 @@ ATF_TC_BODY(proc1, tc) { struct kevent event[1]; pid_t pid; - int kq, want, status; + int kq, status; + u_int want; RL(kq = kqueue()); @@ -112,7 +113,7 @@ ATF_TC_BODY(proc1, tc) (void)sleep(1); /* give child some time to come up */ - event[0].ident = pid; + event[0].ident = (uintptr_t)pid; event[0].filter = EVFILT_PROC; event[0].flags = EV_ADD | EV_ENABLE; event[0].fflags = NOTE_EXIT | NOTE_FORK | NOTE_EXEC; /* | NOTE_TRACK;*/ diff --git a/kernel/kqueue/t_proc2.c b/kernel/kqueue/t_proc2.c index 54769d6e8791..e70fcb279d1a 100644 --- a/kernel/kqueue/t_proc2.c +++ b/kernel/kqueue/t_proc2.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_proc2.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ +/* $NetBSD: t_proc2.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_proc2.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); +__RCSID("$NetBSD: t_proc2.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); #include <sys/event.h> #include <sys/time.h> @@ -106,7 +106,8 @@ ATF_TC_BODY(proc2, tc) /* NOTREACHED */ } - EV_SET(&ke, pid, EVFILT_PROC, EV_ADD, NOTE_FORK|NOTE_TRACK, 0, 0); + EV_SET(&ke, (uintptr_t)pid, EVFILT_PROC, EV_ADD, NOTE_FORK|NOTE_TRACK, + 0, 0); RL(kevent(kq, &ke, 1, NULL, 0, &timeout)); diff --git a/kernel/kqueue/t_proc3.c b/kernel/kqueue/t_proc3.c index 3cb9ae565cbb..b77510becec7 100644 --- a/kernel/kqueue/t_proc3.c +++ b/kernel/kqueue/t_proc3.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_proc3.c,v 1.1 2012/11/17 21:55:24 joerg Exp $ */ +/* $NetBSD: t_proc3.c,v 1.2 2015/01/14 22:22:32 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_proc3.c,v 1.1 2012/11/17 21:55:24 joerg Exp $"); +__RCSID("$NetBSD: t_proc3.c,v 1.2 2015/01/14 22:22:32 christos Exp $"); #include <sys/event.h> #include <sys/time.h> @@ -63,7 +63,7 @@ ATF_TC_BODY(proc3, tc) RL(kq = kqueue()); - EV_SET(&ke, getpid(), EVFILT_PROC, EV_ADD, NOTE_TRACK, 0, 0); + EV_SET(&ke, (uintptr_t)getpid(), EVFILT_PROC, EV_ADD, NOTE_TRACK, 0, 0); RL(kevent(kq, &ke, 1, NULL, 0, NULL)); diff --git a/kernel/kqueue/t_vnode.c b/kernel/kqueue/t_vnode.c new file mode 100644 index 000000000000..e87c2b2c2d6f --- /dev/null +++ b/kernel/kqueue/t_vnode.c @@ -0,0 +1,533 @@ +#include <sys/event.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> + +#include <atf-c.h> + +/* + * Test cases for events triggered by manipulating a target directory + * content. Using EVFILT_VNODE filter on the target directory descriptor. + * + */ + +static const char *dir_target = "foo"; +static const char *dir_inside1 = "foo/bar1"; +static const char *dir_inside2 = "foo/bar2"; +static const char *dir_outside = "bar"; +static const char *file_inside1 = "foo/baz1"; +static const char *file_inside2 = "foo/baz2"; +static const char *file_outside = "qux"; +static const struct timespec ts = {0, 0}; +static int kq = -1; +static int target = -1; + +int init_target(void); +int init_kqueue(void); +int create_file(const char *); +void cleanup(void); + +int +init_target(void) +{ + if (mkdir(dir_target, S_IRWXU) < 0) { + return -1; + } + target = open(dir_target, O_RDONLY, 0); + return target; +} + +int +init_kqueue(void) +{ + struct kevent eventlist[1]; + + kq = kqueue(); + if (kq < 0) { + return -1; + } + EV_SET(&eventlist[0], (uintptr_t)target, EVFILT_VNODE, + EV_ADD | EV_ONESHOT, NOTE_DELETE | + NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | + NOTE_LINK | NOTE_RENAME | NOTE_REVOKE, 0, 0); + return kevent(kq, eventlist, 1, NULL, 0, NULL); +} + +int +create_file(const char *file) +{ + int fd; + + fd = open(file, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); + if (fd < 0) { + return -1; + } + return close(fd); +} + +void +cleanup(void) +{ + (void)unlink(file_inside1); + (void)unlink(file_inside2); + (void)unlink(file_outside); + (void)rmdir(dir_inside1); + (void)rmdir(dir_inside2); + (void)rmdir(dir_outside); + (void)rmdir(dir_target); + (void)close(kq); + (void)close(target); +} + +ATF_TC_WITH_CLEANUP(dir_no_note_link_create_file_in); +ATF_TC_HEAD(dir_no_note_link_create_file_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) does not return NOTE_LINK for the directory " + "'foo' if a file 'foo/baz' is created."); +} +ATF_TC_BODY(dir_no_note_link_create_file_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(create_file(file_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); +} +ATF_TC_CLEANUP(dir_no_note_link_create_file_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_no_note_link_delete_file_in); +ATF_TC_HEAD(dir_no_note_link_delete_file_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) does not return NOTE_LINK for the directory " + "'foo' if a file 'foo/baz' is deleted."); +} +ATF_TC_BODY(dir_no_note_link_delete_file_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(create_file(file_inside1) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(unlink(file_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); +} +ATF_TC_CLEANUP(dir_no_note_link_delete_file_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_no_note_link_mv_dir_within); +ATF_TC_HEAD(dir_no_note_link_mv_dir_within, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) does not return NOTE_LINK for the directory " + "'foo' if a directory 'foo/bar' is renamed to 'foo/baz'."); +} +ATF_TC_BODY(dir_no_note_link_mv_dir_within, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(dir_inside1, dir_inside2) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); +} +ATF_TC_CLEANUP(dir_no_note_link_mv_dir_within, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_no_note_link_mv_file_within); +ATF_TC_HEAD(dir_no_note_link_mv_file_within, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) does not return NOTE_LINK for the directory " + "'foo' if a file 'foo/baz' is renamed to 'foo/qux'."); +} +ATF_TC_BODY(dir_no_note_link_mv_file_within, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(create_file(file_inside1) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(file_inside1, file_inside2) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, 0); +} +ATF_TC_CLEANUP(dir_no_note_link_mv_file_within, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_link_create_dir_in); +ATF_TC_HEAD(dir_note_link_create_dir_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_LINK for the directory " + "'foo' if a directory 'foo/bar' is created."); +} +ATF_TC_BODY(dir_note_link_create_dir_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); +} +ATF_TC_CLEANUP(dir_note_link_create_dir_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_link_delete_dir_in); +ATF_TC_HEAD(dir_note_link_delete_dir_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_LINK for the directory " + "'foo' if a directory 'foo/bar' is deleted."); +} +ATF_TC_BODY(dir_note_link_delete_dir_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rmdir(dir_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); +} +ATF_TC_CLEANUP(dir_note_link_delete_dir_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_link_mv_dir_in); +ATF_TC_HEAD(dir_note_link_mv_dir_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_LINK for the directory " + "'foo' if a directory 'bar' is renamed to 'foo/bar'."); +} +ATF_TC_BODY(dir_note_link_mv_dir_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_outside, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(dir_outside, dir_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); +} +ATF_TC_CLEANUP(dir_note_link_mv_dir_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_link_mv_dir_out); +ATF_TC_HEAD(dir_note_link_mv_dir_out, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_LINK for the directory " + "'foo' if a directory 'foo/bar' is renamed to 'bar'."); +} +ATF_TC_BODY(dir_note_link_mv_dir_out, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(dir_inside1, dir_outside) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_LINK, NOTE_LINK); +} +ATF_TC_CLEANUP(dir_note_link_mv_dir_out, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_create_dir_in); +ATF_TC_HEAD(dir_note_write_create_dir_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a directory 'foo/bar' is created."); +} +ATF_TC_BODY(dir_note_write_create_dir_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_create_dir_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_create_file_in); +ATF_TC_HEAD(dir_note_write_create_file_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a file 'foo/baz' is created."); +} +ATF_TC_BODY(dir_note_write_create_file_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(create_file(file_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_create_file_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_delete_dir_in); +ATF_TC_HEAD(dir_note_write_delete_dir_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a directory 'foo/bar' is deleted."); +} +ATF_TC_BODY(dir_note_write_delete_dir_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rmdir(dir_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_delete_dir_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_delete_file_in); +ATF_TC_HEAD(dir_note_write_delete_file_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a file 'foo/baz' is deleted."); +} +ATF_TC_BODY(dir_note_write_delete_file_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(create_file(file_inside1) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(unlink(file_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_delete_file_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_mv_dir_in); +ATF_TC_HEAD(dir_note_write_mv_dir_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a directory 'bar' is renamed to 'foo/bar'."); +} +ATF_TC_BODY(dir_note_write_mv_dir_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_outside, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(dir_outside, dir_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_mv_dir_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_mv_dir_out); +ATF_TC_HEAD(dir_note_write_mv_dir_out, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a directory 'foo/bar' is renamed to 'bar'."); +} +ATF_TC_BODY(dir_note_write_mv_dir_out, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(dir_inside1, dir_outside) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_mv_dir_out, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_mv_dir_within); +ATF_TC_HEAD(dir_note_write_mv_dir_within, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a directory 'foo/bar' is renamed to 'foo/baz'."); +} +ATF_TC_BODY(dir_note_write_mv_dir_within, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(mkdir(dir_inside1, S_IRWXU) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(dir_inside1, dir_inside2) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_mv_dir_within, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_mv_file_in); +ATF_TC_HEAD(dir_note_write_mv_file_in, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a file 'qux' is renamed to 'foo/baz'."); +} +ATF_TC_BODY(dir_note_write_mv_file_in, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(create_file(file_outside) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(file_outside, file_inside1) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_mv_file_in, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_mv_file_out); +ATF_TC_HEAD(dir_note_write_mv_file_out, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a file 'foo/baz' is renamed to 'qux'."); +} +ATF_TC_BODY(dir_note_write_mv_file_out, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(create_file(file_inside1) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(file_inside1, file_outside) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_mv_file_out, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(dir_note_write_mv_file_within); +ATF_TC_HEAD(dir_note_write_mv_file_within, tc) +{ + atf_tc_set_md_var(tc, "descr", "This test case ensures " + "that kevent(2) returns NOTE_WRITE for the directory " + "'foo' if a file 'foo/baz' is renamed to 'foo/qux'."); +} +ATF_TC_BODY(dir_note_write_mv_file_within, tc) +{ + struct kevent changelist[1]; + + ATF_REQUIRE(init_target() != -1); + ATF_REQUIRE(create_file(file_inside1) != -1); + ATF_REQUIRE(init_kqueue() != -1); + + ATF_REQUIRE(rename(file_inside1, file_inside2) != -1); + ATF_REQUIRE(kevent(kq, NULL, 0, changelist, 1, &ts) != -1); + ATF_CHECK_EQ(changelist[0].fflags & NOTE_WRITE, NOTE_WRITE); +} +ATF_TC_CLEANUP(dir_note_write_mv_file_within, tc) +{ + cleanup(); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, dir_no_note_link_create_file_in); + ATF_TP_ADD_TC(tp, dir_no_note_link_delete_file_in); + ATF_TP_ADD_TC(tp, dir_no_note_link_mv_dir_within); + ATF_TP_ADD_TC(tp, dir_no_note_link_mv_file_within); + ATF_TP_ADD_TC(tp, dir_note_link_create_dir_in); + ATF_TP_ADD_TC(tp, dir_note_link_delete_dir_in); + ATF_TP_ADD_TC(tp, dir_note_link_mv_dir_in); + ATF_TP_ADD_TC(tp, dir_note_link_mv_dir_out); + ATF_TP_ADD_TC(tp, dir_note_write_create_dir_in); + ATF_TP_ADD_TC(tp, dir_note_write_create_file_in); + ATF_TP_ADD_TC(tp, dir_note_write_delete_dir_in); + ATF_TP_ADD_TC(tp, dir_note_write_delete_file_in); + ATF_TP_ADD_TC(tp, dir_note_write_mv_dir_in); + ATF_TP_ADD_TC(tp, dir_note_write_mv_dir_out); + ATF_TP_ADD_TC(tp, dir_note_write_mv_dir_within); + ATF_TP_ADD_TC(tp, dir_note_write_mv_file_in); + ATF_TP_ADD_TC(tp, dir_note_write_mv_file_out); + ATF_TP_ADD_TC(tp, dir_note_write_mv_file_within); + return atf_no_error(); +} diff --git a/kernel/t_rnd.c b/kernel/t_rnd.c index 7f1f28844b7e..86461308daa4 100644 --- a/kernel/t_rnd.c +++ b/kernel/t_rnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_rnd.c,v 1.5 2012/03/18 09:46:50 jruoho Exp $ */ +/* $NetBSD: t_rnd.c,v 1.9 2016/05/22 04:34:44 riastradh Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -27,12 +27,12 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_rnd.c,v 1.5 2012/03/18 09:46:50 jruoho Exp $"); +__RCSID("$NetBSD: t_rnd.c,v 1.9 2016/05/22 04:34:44 riastradh Exp $"); #include <sys/types.h> #include <sys/fcntl.h> #include <sys/ioctl.h> -#include <sys/rnd.h> +#include <sys/rndio.h> #include <atf-c.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(); } diff --git a/kernel/tty/Makefile b/kernel/tty/Makefile index 696141bb82d6..ac37dec1e9ff 100644 --- a/kernel/tty/Makefile +++ b/kernel/tty/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2014/06/10 04:28:39 he Exp $ +# $NetBSD: Makefile,v 1.3 2016/01/23 21:22:49 christos Exp $ .include <bsd.own.mk> @@ -6,6 +6,7 @@ TESTSDIR= ${TESTSBASE}/kernel/tty TESTS_C= t_pr +CPPFLAGS+= -D_KERNTYPES LDADD+= -lrumpkern_tty -lrumpvfs -lrump -lrumpuser LDADD+= -lrump LDADD+= -lpthread |
