Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 99276 invoked from network); 9 Nov 2009 16:16:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Nov 2009 16:16:50 -0000 Received: (qmail 94067 invoked by uid 500); 9 Nov 2009 16:16:50 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 94021 invoked by uid 500); 9 Nov 2009 16:16:50 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 94012 invoked by uid 99); 9 Nov 2009 16:16:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2009 16:16:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2009 16:16:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 02BF52388893; Mon, 9 Nov 2009 16:16:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r834130 - /apr/apr/trunk/test/testpoll.c Date: Mon, 09 Nov 2009 16:16:10 -0000 To: commits@apr.apache.org From: trawick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091109161618.02BF52388893@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: trawick Date: Mon Nov 9 16:16:06 2009 New Revision: 834130 URL: http://svn.apache.org/viewvc?rev=834130&view=rev Log: fix incorrect assumptions in pollset/pollcb tests: - polling won't necessary detect the status change immediately after an I/O operation - a single poll call won't necessarily return multiple status changes after multiple I/O operations Submitted by: Neil Conway Reviewed by: trawick Modified: apr/apr/trunk/test/testpoll.c Modified: apr/apr/trunk/test/testpoll.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testpoll.c?rev=834130&r1=834129&r2=834130&view=diff ============================================================================== --- apr/apr/trunk/test/testpoll.c (original) +++ apr/apr/trunk/test/testpoll.c Mon Nov 9 16:16:06 2009 @@ -308,12 +308,14 @@ send_msg(s, sa, 0, tc); - rv = apr_pollset_poll(pollset, 0, &lrv, &descs); - ABTS_INT_EQUAL(tc, 0, APR_STATUS_IS_TIMEUP(rv)); + rv = apr_pollset_poll(pollset, -1, &lrv, &descs); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); if (lrv == 1) { + int ev = descs[0].rtnevents; ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s); - ABTS_INT_EQUAL(tc, APR_POLLIN | APR_POLLOUT, descs[0].rtnevents); ABTS_PTR_EQUAL(tc, s[0], descs[0].client_data); + ABTS_ASSERT(tc, "either or both of APR_POLLIN, APR_POLLOUT returned", + ((ev & APR_POLLIN) != 0) || ((ev & APR_POLLOUT) != 0)); } else if (lrv == 2) { ABTS_PTR_EQUAL(tc, s[0], descs[0].desc.s); @@ -381,7 +383,7 @@ int num; send_msg(s, sa, 0, tc); - rv = apr_pollset_poll(pollset, 0, &num, &descs); + rv = apr_pollset_poll(pollset, -1, &num, &descs); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, num); ABTS_PTR_NOTNULL(tc, descs); @@ -411,14 +413,19 @@ send_msg(s, sa, 2, tc); send_msg(s, sa, 5, tc); - rv = apr_pollset_poll(pollset, 0, &num, &descs); + rv = apr_pollset_poll(pollset, -1, &num, &descs); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - ABTS_INT_EQUAL(tc, 2, num); ABTS_PTR_NOTNULL(tc, descs); + ABTS_ASSERT(tc, "either one or two events returned", + num == 1 || num == 2); - ABTS_ASSERT(tc, "Incorrect socket in result set", - ((descs[0].desc.s == s[2]) && (descs[1].desc.s == s[5])) || - ((descs[0].desc.s == s[5]) && (descs[1].desc.s == s[2]))); + /* The poll might only see the first sent message, in which + * case we just don't bother checking this assertion */ + if (num == 2) { + ABTS_ASSERT(tc, "Incorrect socket in result set", + ((descs[0].desc.s == s[2]) && (descs[1].desc.s == s[5])) || + ((descs[0].desc.s == s[5]) && (descs[1].desc.s == s[2]))); + } } static void clear_middle_pollset(abts_case *tc, void *data) @@ -443,7 +450,7 @@ int num; send_msg(s, sa, LARGE_NUM_SOCKETS - 1, tc); - rv = apr_pollset_poll(pollset, 0, &num, &descs); + rv = apr_pollset_poll(pollset, -1, &num, &descs); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, num); ABTS_PTR_NOTNULL(tc, descs); @@ -607,8 +614,8 @@ send_msg(s, sa, 0, tc); pcb.tc = tc; pcb.count = 0; - rv = apr_pollcb_poll(pollcb, 0, trigger_pollcb_cb, &pcb); - ABTS_INT_EQUAL(tc, 0, APR_STATUS_IS_TIMEUP(rv)); + rv = apr_pollcb_poll(pollcb, -1, trigger_pollcb_cb, &pcb); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); ABTS_INT_EQUAL(tc, 1, pcb.count); rv = apr_pollcb_remove(pollcb, &socket_pollfd);