[dpdk-dev] test: add delay time in test alarm

Message ID 1490076224-26964-1-git-send-email-qiming.yang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Qiming Yang March 21, 2017, 6:03 a.m. UTC
  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 <qiming.yang@intel.com>
---
 test/test/test_alarm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

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){