From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id E6A822C8 for ; Thu, 6 Jul 2017 10:28:37 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP; 06 Jul 2017 01:28:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,316,1496127600"; d="scan'208";a="989335305" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 06 Jul 2017 01:28:36 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 6 Jul 2017 01:28:36 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.197]) with mapi id 14.03.0319.002; Thu, 6 Jul 2017 16:28:34 +0800 From: "Chen, Jing D" To: "Yang, Qiming" , "dev@dpdk.org" CC: "Wu, Jingjing" Thread-Topic: [PATCH v3] test: add delay time in test alarm Thread-Index: AQHS6XZB5VyNMZNY10yK/6LvQhL/QKJGkKog Date: Thu, 6 Jul 2017 08:28:33 +0000 Message-ID: <4341B239C0EFF9468EE453F9E9F4604D3C678919@shsmsx102.ccr.corp.intel.com> References: <1493950673-15953-1-git-send-email-qiming.yang@intel.com> <1497929051-48912-1-git-send-email-qiming.yang@intel.com> In-Reply-To: <1497929051-48912-1-git-send-email-qiming.yang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] test: add delay time in test alarm X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jul 2017 08:28:38 -0000 + while (flag !=3D 2 && count++ < RTE_TEST_MAX_REPEAT) + rte_delay_ms(10); Why you don't replace "2" and "10" with macro? -----Original Message----- From: Yang, Qiming=20 Sent: Tuesday, June 20, 2017 11:24 AM To: dev@dpdk.org Cc: Chen, Jing D ; Wu, Jingjing ; Yang, Qiming Subject: [PATCH v3] test: add delay time in test alarm Because accuracy of timing to the microsecond is not guaranteed in rte_eal_= alarm_set, this function will not be called before the requested time, but = may be called a period of time afterwards which can not be calculated. In o= rder to ensure test alarm running success, this patch added the delay time = before check the flag. Signed-off-by: Qiming Yang --- v2 changes: * fixed coding style problems v3 changes: * replaced the numeric by macro --- --- test/test/test_alarm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/test/test_alarm.c b/test/test/test_alarm.c index ecb2f6d.= .40f55b5 100644 --- a/test/test/test_alarm.c +++ b/test/test/test_alarm.c @@ -47,6 +47,7 @@ =20 #define RTE_TEST_ALARM_TIMEOUT 10 /* ms */ #define RTE_TEST_CHECK_PERIOD 3 /* ms */ +#define RTE_TEST_MAX_REPEAT 20 =20 static volatile int flag; =20 @@ -96,6 +97,7 @@ static int test_multi_alarms(void) { int rm_count =3D 0; + int count =3D 0; cb_count.cnt =3D 0; =20 printf("Expect 6 callbacks in order...\n"); @@ -169,7 +171,10 @@ test_mul= ti_alarms(void) printf("Error, cancelling head-of-list leads to premature callback\n"); return -1; } - rte_delay_ms(10); + + while (flag !=3D 2 && count++ < RTE_TEST_MAX_REPEAT) + rte_delay_ms(10); + if (flag !=3D 2) { printf("Error - expected callback not called\n"); rte_eal_alarm_cancel(test_remove_in_callback, (void *)-1); @@ -212,7 +21= 7,7 @@ test_alarm(void) printf("fail to set alarm callback\n"); return -1; } - while (flag =3D=3D 0 && count ++ < 6) + while (flag =3D=3D 0 && count++ < RTE_TEST_MAX_REPEAT) rte_delay_ms(RTE_TEST_CHECK_PERIOD); =20 if (flag =3D=3D 0){ -- 2.7.4