From owner-svn-src-all@freebsd.org Tue May 30 03:05:23 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 89FC5AF88F3; Tue, 30 May 2017 03:05:23 +0000 (UTC) (envelope-from ngie@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 632EA734BB; Tue, 30 May 2017 03:05:23 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4U35MFN053032; Tue, 30 May 2017 03:05:22 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4U35MhE053031; Tue, 30 May 2017 03:05:22 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201705300305.v4U35MhE053031@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 30 May 2017 03:05:22 +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: r319172 - stable/11/tests/sys/aio X-SVN-Group: stable-11 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: Tue, 30 May 2017 03:05:23 -0000 Author: ngie Date: Tue May 30 03:05:22 2017 New Revision: 319172 URL: https://svnweb.freebsd.org/changeset/base/319172 Log: MFC r318094,r318098,r318099: r318094: style(9): clean up trailing whitespace r318098: Refactor ATF_REQUIRE_UNSAFE_AIO and PLAIN_REQUIRE_UNSAFE_AIO This is being done to reduce duplication between the two macros. r318099: Print out when unsafe AIO is enabled to debugging purposes Modified: stable/11/tests/sys/aio/local.h Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/aio/local.h ============================================================================== --- stable/11/tests/sys/aio/local.h Tue May 30 03:02:07 2017 (r319171) +++ stable/11/tests/sys/aio/local.h Tue May 30 03:05:22 2017 (r319172) @@ -39,36 +39,51 @@ #include -#define ATF_REQUIRE_UNSAFE_AIO() do { \ - size_t _len; \ - int _unsafe; \ - \ - _len = sizeof(_unsafe); \ - if (sysctlbyname("vfs.aio.enable_unsafe", &_unsafe, &_len, NULL,\ - 0) < 0) { \ - if (errno != ENOENT) \ - atf_libc_error(errno, \ - "Failed to read vfs.aio.enable_unsafe"); \ - } else if (_unsafe == 0) \ - atf_tc_skip("Unsafe AIO is disabled"); \ +static const char *sysctl_oid_name = "vfs.aio.enable_unsafe"; + +static int +is_unsafe_aio_enabled(void) +{ + size_t len; + int unsafe; + + len = sizeof(unsafe); + if (sysctlbyname(sysctl_oid_name, &unsafe, &len, NULL, 0) < 0) { + if (errno == ENOENT) + return (-1); + return (0); + } + return (unsafe == 0 ? 0 : 1); +} + +#define ATF_REQUIRE_UNSAFE_AIO() do { \ + switch (is_unsafe_aio_enabled()) { \ + case -1: \ + atf_libc_error(errno, "Failed to read %s", sysctl_oid_name); \ + break; \ + case 0: \ + atf_tc_skip("Unsafe AIO is disabled"); \ + break; \ + default: \ + printf("Unsafe AIO is enabled\n"); \ + break; \ + } \ } while (0) - -#define PLAIN_REQUIRE_UNSAFE_AIO(_exit_code) do { \ - size_t _len; \ - int _unsafe; \ - \ - _len = sizeof(_unsafe); \ - if (sysctlbyname("vfs.aio.enable_unsafe", &_unsafe, &_len, NULL,\ - 0) < 0) { \ - if (errno != ENOENT) { \ - printf("Failed to read vfs.aio.enable_unsafe: %s\n",\ - strerror(errno)); \ - _exit(1); \ - } \ - } else if (_unsafe == 0) { \ - printf("Unsafe AIO is disabled"); \ - _exit(_exit_code); \ - } \ + +#define PLAIN_REQUIRE_UNSAFE_AIO(_exit_code) do { \ + switch (is_unsafe_aio_enabled()) { \ + case -1: \ + printf("Failed to read %s", sysctl_oid_name); \ + _exit(_exit_code); \ + break; \ + case 0: \ + printf("Unsafe AIO is disabled\n"); \ + _exit(_exit_code); \ + break; \ + default: \ + printf("Unsafe AIO is enabled\n"); \ + break; \ + } \ } while (0) #endif /* !_AIO_TEST_LOCAL_H_ */