From owner-svn-src-head@FreeBSD.ORG Tue Apr 28 10:53:07 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9A6E5554; Tue, 28 Apr 2015 10:53:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 7BD281AF7; Tue, 28 Apr 2015 10:53:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3SAr7IO004578; Tue, 28 Apr 2015 10:53:07 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3SAr7lr004573; Tue, 28 Apr 2015 10:53:07 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504281053.t3SAr7lr004573@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Tue, 28 Apr 2015 10:53:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282136 - head/tests/sys/aio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2015 10:53:07 -0000 Author: ngie Date: Tue Apr 28 10:53:06 2015 New Revision: 282136 URL: https://svnweb.freebsd.org/changeset/base/282136 Log: - Use ATF_REQUIRE_KERNEL_MDOULE to require aio(4) - Don't use /tmp as a basis for temporary files as it's outside of the ATF sandbox - Don't override MAX macro in sys/param.h MFC after: 6 days Modified: head/tests/sys/aio/aio_kqueue_test.c head/tests/sys/aio/lio_kqueue_test.c Modified: head/tests/sys/aio/aio_kqueue_test.c ============================================================================== --- head/tests/sys/aio/aio_kqueue_test.c Tue Apr 28 10:51:12 2015 (r282135) +++ head/tests/sys/aio/aio_kqueue_test.c Tue Apr 28 10:53:06 2015 (r282136) @@ -46,25 +46,29 @@ #include #include -#define PATH_TEMPLATE "/tmp/aio.XXXXXXXXXX" +#include "freebsd_test_suite/macros.h" -#define MAX 128 +#define PATH_TEMPLATE "aio.XXXXXXXXXX" + +#define MAX_IOCBS 128 #define MAX_RUNS 300 /* #define DEBUG */ int main (int argc, char *argv[]) { - int fd; - struct aiocb *iocb[MAX], *kq_iocb; - int i, result, run, error, j; - char buffer[32768]; - int kq = kqueue(); + struct aiocb *iocb[MAX_IOCBS], *kq_iocb; + char *file, pathname[sizeof(PATH_TEMPLATE)+1]; struct kevent ke, kq_returned; struct timespec ts; - int cancel, pending, tmp_file = 0, failed = 0; - char *file, pathname[sizeof(PATH_TEMPLATE)+1]; + char buffer[32768]; + int cancel, error, failed = 0, fd, kq, pending, result, run; + int tmp_file = 0; + unsigned i, j; + + PLAIN_REQUIRE_KERNEL_MODULE("aio", 0); + kq = kqueue(); if (kq < 0) { perror("No kqeueue\n"); exit(1); @@ -86,7 +90,7 @@ main (int argc, char *argv[]) #ifdef DEBUG printf("Run %d\n", run); #endif - for (i = 0; i < MAX; i++) { + for (i = 0; i < nitems(iocb); i++) { iocb[i] = (struct aiocb *)calloc(1, sizeof(struct aiocb)); if (iocb[i] == NULL) @@ -94,7 +98,7 @@ main (int argc, char *argv[]) } pending = 0; - for (i = 0; i < MAX; i++) { + for (i = 0; i < nitems(iocb); i++) { pending++; iocb[i]->aio_nbytes = sizeof(buffer); iocb[i]->aio_buf = buffer; @@ -129,8 +133,8 @@ main (int argc, char *argv[]) } } } - cancel = MAX - pending; - + cancel = nitems(iocb) - pending; + i = 0; while (pending) { @@ -159,11 +163,11 @@ main (int argc, char *argv[]) break; #ifdef DEBUG printf("Try again left %d out of %d %d\n", - pending, MAX, cancel); + pending, nitems(iocb), cancel); #endif } - for (j = 0; j < MAX && iocb[j] != kq_iocb; + for (j = 0; j < nitems(iocb) && iocb[j] != kq_iocb; j++) ; #ifdef DEBUG printf("kq_iocb %p\n", kq_iocb); @@ -190,7 +194,7 @@ main (int argc, char *argv[]) i++; } - for (i = 0; i < MAX; i++) + for (i = 0; i < nitems(iocb); i++) free(iocb[i]); } Modified: head/tests/sys/aio/lio_kqueue_test.c ============================================================================== --- head/tests/sys/aio/lio_kqueue_test.c Tue Apr 28 10:51:12 2015 (r282135) +++ head/tests/sys/aio/lio_kqueue_test.c Tue Apr 28 10:53:06 2015 (r282136) @@ -48,16 +48,18 @@ #include #include -#define PATH_TEMPLATE "/tmp/aio.XXXXXXXXXX" +#include "freebsd_test_suite/macros.h" + +#define PATH_TEMPLATE "aio.XXXXXXXXXX" #define LIO_MAX 5 -#define MAX LIO_MAX * 16 +#define MAX_IOCBS LIO_MAX * 16 #define MAX_RUNS 300 int main(int argc, char *argv[]){ int fd; - struct aiocb *iocb[MAX]; + struct aiocb *iocb[MAX_IOCBS]; struct aiocb **lio[LIO_MAX], **lio_element, **kq_lio; int i, result, run, error, j, k; char buffer[32768]; @@ -69,6 +71,8 @@ main(int argc, char *argv[]){ char *file, pathname[sizeof(PATH_TEMPLATE)-1]; int tmp_file = 0, failed = 0; + PLAIN_REQUIRE_KERNEL_MODULE("aio", 0); + if (kq < 0) { perror("No kqeueue\n"); exit(1); @@ -99,9 +103,9 @@ main(int argc, char *argv[]){ #endif for (j = 0; j < LIO_MAX; j++) { lio[j] = (struct aiocb **) - malloc(sizeof(struct aiocb *) * MAX/LIO_MAX); - for(i = 0; i < MAX / LIO_MAX; i++) { - k = (MAX / LIO_MAX * j) + i; + malloc(sizeof(struct aiocb *) * MAX_IOCBS/LIO_MAX); + for(i = 0; i < MAX_IOCBS / LIO_MAX; i++) { + k = (MAX_IOCBS / LIO_MAX * j) + i; lio_element = lio[j]; lio[j][i] = iocb[k] = (struct aiocb *) malloc(sizeof(struct aiocb)); @@ -123,7 +127,7 @@ main(int argc, char *argv[]){ sig.sigev_notify = SIGEV_KEVENT; time(&time1); result = lio_listio(LIO_NOWAIT, lio[j], - MAX / LIO_MAX, &sig); + MAX_IOCBS / LIO_MAX, &sig); error = errno; time(&time2); #ifdef DEBUG @@ -203,7 +207,7 @@ main(int argc, char *argv[]){ } else { printf("PASS: run %d, operation %d result %d \n", run, LIO_MAX - i -1, result); } - for(k = 0; k < MAX / LIO_MAX; k++){ + for(k = 0; k < MAX_IOCBS / LIO_MAX; k++){ result = aio_return(kq_lio[k]); #ifdef DEBUG printf("Return Resulto for %d %d is %d\n", j, k, result); @@ -220,7 +224,7 @@ main(int argc, char *argv[]){ printf("\n"); #endif - for(k = 0; k < MAX / LIO_MAX; k++) { + for(k = 0; k < MAX_IOCBS / LIO_MAX; k++) { free(lio[j][k]); } free(lio[j]);