From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 5C2C7101B for ; Tue, 21 Mar 2017 07:12:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490076743; x=1521612743; h=from:to:cc:subject:date:message-id; bh=zsj3069Nu+HaySaA4yoOo633qy8p4gB8AmAqF2B0Ano=; b=HgxvzunM1SBxj8nPHiBC+40DWvBCUGojlLsYq66ig1p062nVK4MaA8Yi cWRoUXnX5qBXUY7XdZsPqtSYn6c5hg==; Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2017 23:12:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,198,1486454400"; d="scan'208";a="836904622" Received: from dpdk7.bj.intel.com ([172.16.182.73]) by FMSMGA003.fm.intel.com with ESMTP; 20 Mar 2017 23:12:21 -0700 From: Qiming Yang To: dev@dpdk.org Cc: Qiming Yang Date: Tue, 21 Mar 2017 14:03:44 +0800 Message-Id: <1490076224-26964-1-git-send-email-qiming.yang@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] 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: Tue, 21 Mar 2017 06:12:23 -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 --- test/test/test_alarm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test/test_alarm.c b/test/test/test_alarm.c index ecb2f6d..ad4e908 100644 --- a/test/test/test_alarm.c +++ b/test/test/test_alarm.c @@ -169,7 +169,9 @@ printf("Error, cancelling head-of-list leads to premature callback\n"); return -1; } - rte_delay_ms(10); + int count = 0; + 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 +214,7 @@ 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){ -- 1.8.3.1