From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 323F6374F for ; Fri, 5 May 2017 04:28:00 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2017 19:27:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,290,1491289200"; d="scan'208";a="964643840" Received: from dpdk7.bj.intel.com ([172.16.182.73]) by orsmga003.jf.intel.com with ESMTP; 04 May 2017 19:27:57 -0700 From: Qiming Yang To: dev@dpdk.org Cc: jing.d.chen@intel.com, jingjing.wu@intel.com, Qiming Yang Date: Fri, 5 May 2017 10:17:53 +0800 Message-Id: <1493950673-15953-1-git-send-email-qiming.yang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490076224-26964-1-git-send-email-qiming.yang@intel.com> References: <1490076224-26964-1-git-send-email-qiming.yang@intel.com> Subject: [dpdk-dev] [PATCH v2] 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: Fri, 05 May 2017 02:28:01 -0000 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 order 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 --- --- test/test/test_alarm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/test/test_alarm.c b/test/test/test_alarm.c index ecb2f6d..cbae1a0 100644 --- a/test/test/test_alarm.c +++ b/test/test/test_alarm.c @@ -96,6 +96,7 @@ static int test_multi_alarms(void) { int rm_count = 0; + int count = 0; cb_count.cnt = 0; printf("Expect 6 callbacks in order...\n"); @@ -169,7 +170,10 @@ test_multi_alarms(void) printf("Error, cancelling head-of-list leads to premature callback\n"); return -1; } - rte_delay_ms(10); + + while (flag != 2 && count++ < 6) + rte_delay_ms(10); + if (flag != 2) { printf("Error - expected callback not called\n"); rte_eal_alarm_cancel(test_remove_in_callback, (void *)-1); @@ -212,7 +216,7 @@ test_alarm(void) printf("fail to set alarm callback\n"); return -1; } - while (flag == 0 && count ++ < 6) + while (flag == 0 && count++ < 20) rte_delay_ms(RTE_TEST_CHECK_PERIOD); if (flag == 0){ -- 2.7.4