Date: Wed, 7 Dec 2016 00:57:16 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r309662 - stable/10/tests/sys/kern/pipe Message-ID: <201612070057.uB70vG0A070113@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Wed Dec 7 00:57:15 2016 New Revision: 309662 URL: https://svnweb.freebsd.org/changeset/base/309662 Log: MFstable/11 r309661: MFC r306962: r306962 (by br): Ensure data in pipe is available to read. Useful for latest (5th, direct mode) test only. Modified: stable/10/tests/sys/kern/pipe/pipe_fstat_bug_test.c Directory Properties: stable/10/ (props changed) Modified: stable/10/tests/sys/kern/pipe/pipe_fstat_bug_test.c ============================================================================== --- stable/10/tests/sys/kern/pipe/pipe_fstat_bug_test.c Wed Dec 7 00:55:36 2016 (r309661) +++ stable/10/tests/sys/kern/pipe/pipe_fstat_bug_test.c Wed Dec 7 00:57:15 2016 (r309662) @@ -26,6 +26,7 @@ SUCH DAMAGE. #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> +#include <sys/event.h> #include <assert.h> #include <err.h> #include <errno.h> @@ -49,10 +50,12 @@ main(void) { char buffer[32768], buffer2[32768], go[] = "go", go2[] = "go2"; int desc[2], ipc_coord[2]; + struct kevent event, ke; ssize_t error; int successes = 0; struct stat status; pid_t new_pid; + int kq; error = pipe(desc); if (error == -1) @@ -118,9 +121,24 @@ main(void) _exit(0); } + kq = kqueue(); + if (kq == -1) + _exit(1); + + EV_SET(&ke, desc[0], EVFILT_READ, EV_ADD, 0, 0, NULL); + + /* Attach event to the kqueue. */ + if (kevent(kq, &ke, 1, NULL, 0, NULL) != 0) + _exit(2); + while (successes < 5) { SYNC_W(1, go); SYNC_R(1, go2); + + /* Ensure data is available to read */ + if (kevent(kq, NULL, 0, &event, 1, NULL) != 1) + _exit(3); + fstat(desc[0], &status); error = read(desc[0], &buffer2, sizeof(buffer2));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612070057.uB70vG0A070113>