From owner-svn-src-all@freebsd.org Fri Aug 25 14:37:24 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 954F5DD9CC2; Fri, 25 Aug 2017 14:37:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 71B9A3869; Fri, 25 Aug 2017 14:37:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PEbNQH014980; Fri, 25 Aug 2017 14:37:23 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PEbNQ3014978; Fri, 25 Aug 2017 14:37:23 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201708251437.v7PEbNQ3014978@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 25 Aug 2017 14:37:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322891 - stable/11/tests/sys/aio X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/tests/sys/aio X-SVN-Commit-Revision: 322891 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 14:37:24 -0000 Author: asomers Date: Fri Aug 25 14:37:23 2017 New Revision: 322891 URL: https://svnweb.freebsd.org/changeset/base/322891 Log: MFC r321082: Add regression tests for bugs 220459 and 220398 Bug 220398 - lio_listio(2) never sends asynchronous notification if nent==0 Bug 220459 - lio_listio(2) doesn't support SIGEV_THREAD PR: 220459 PR: 220398 Reviewed by: cem, jhb Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11470 Added: stable/11/tests/sys/aio/lio_test.c - copied unchanged from r321082, head/tests/sys/aio/lio_test.c Modified: stable/11/tests/sys/aio/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/aio/Makefile ============================================================================== --- stable/11/tests/sys/aio/Makefile Fri Aug 25 14:32:03 2017 (r322890) +++ stable/11/tests/sys/aio/Makefile Fri Aug 25 14:37:23 2017 (r322891) @@ -3,12 +3,15 @@ TESTSDIR= ${TESTSBASE}/sys/aio ATF_TESTS_C+= aio_test +ATF_TESTS_C+= lio_test TEST_METADATA.aio_test+= timeout="30" +TEST_METADATA.lio_test+= timeout="10" PLAIN_TESTS_C+= aio_kqueue_test PLAIN_TESTS_C+= lio_kqueue_test LIBADD.aio_test+= util rt +LIBADD.lio_test+= rt CFLAGS+= -I${.CURDIR:H:H} Copied: stable/11/tests/sys/aio/lio_test.c (from r321082, head/tests/sys/aio/lio_test.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tests/sys/aio/lio_test.c Fri Aug 25 14:37:23 2017 (r322891, copy of r321082, head/tests/sys/aio/lio_test.c) @@ -0,0 +1,145 @@ +/*- + * Copyright (c) 2017 Spectra Logic Corp + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +#include +#include + +#include + +#include "freebsd_test_suite/macros.h" + +static sem_t completions; + + +static void +handler(int sig __unused) +{ + ATF_REQUIRE_EQ(0, sem_post(&completions)); +} + +static void +thr_handler(union sigval sv __unused) +{ + ATF_REQUIRE_EQ(0, sem_post(&completions)); +} + +/* With LIO_WAIT, an empty lio_listio should return immediately */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_wait); +ATF_TC_BODY(lio_listio_empty_wait, tc) +{ + struct aiocb *list = NULL; + + ATF_REQUIRE_EQ(0, lio_listio(LIO_WAIT, &list, 0, NULL)); +} + +/* + * With LIO_NOWAIT, an empty lio_listio should send completion notification + * immediately + */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_nowait_kevent); +ATF_TC_BODY(lio_listio_empty_nowait_kevent, tc) +{ + struct aiocb *list = NULL; + struct sigevent sev; + struct kevent kq_returned; + int kq, result; + void *udata = (void*)0xdeadbeefdeadbeef; + + atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends" + " asynchronous notification if nent==0"); + kq = kqueue(); + ATF_REQUIRE(kq > 0); + sev.sigev_notify = SIGEV_KEVENT; + sev.sigev_notify_kqueue = kq; + sev.sigev_value.sival_ptr = udata; + ATF_REQUIRE_EQ(0, lio_listio(LIO_NOWAIT, &list, 0, &sev)); + result = kevent(kq, NULL, 0, &kq_returned, 1, NULL); + ATF_REQUIRE_MSG(result == 1, "Never got completion notification"); + ATF_REQUIRE_EQ((uintptr_t)list, kq_returned.ident); + ATF_REQUIRE_EQ(EVFILT_LIO, kq_returned.filter); + ATF_REQUIRE_EQ(udata, kq_returned.udata); +} + +/* + * With LIO_NOWAIT, an empty lio_listio should send completion notification + * immediately + */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_nowait_signal); +ATF_TC_BODY(lio_listio_empty_nowait_signal, tc) +{ + struct aiocb *list = NULL; + struct sigevent sev; + + atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends" + "asynchronous notification if nent==0"); + ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGUSR1; + ATF_REQUIRE(SIG_ERR != signal(SIGUSR1, handler)); + ATF_REQUIRE_EQ(0, lio_listio(LIO_NOWAIT, &list, 0, &sev)); + ATF_REQUIRE_EQ(0, sem_wait(&completions)); + ATF_REQUIRE_EQ(0, sem_destroy(&completions)); +} + +/* + * With LIO_NOWAIT, an empty lio_listio should send completion notification + * immediately + */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_nowait_thread); +ATF_TC_BODY(lio_listio_empty_nowait_thread, tc) +{ + struct aiocb *list = NULL; + struct sigevent sev; + + atf_tc_expect_fail("Bug 220459 - lio_listio(2) doesn't support" + " SIGEV_THREAD"); + ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); + bzero(&sev, sizeof(sev)); + sev.sigev_notify = SIGEV_THREAD; + sev.sigev_notify_function = thr_handler; + sev.sigev_notify_attributes = NULL; + ATF_REQUIRE_MSG(0 == lio_listio(LIO_NOWAIT, &list, 0, &sev), + "lio_listio: %s", strerror(errno)); + ATF_REQUIRE_EQ(0, sem_wait(&completions)); + ATF_REQUIRE_EQ(0, sem_destroy(&completions)); +} + + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_kevent); + ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_signal); + ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_thread); + ATF_TP_ADD_TC(tp, lio_listio_empty_wait); + + return (atf_no_error()); +}