summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorQiming Yang <qiming.yang@intel.com>2017-06-20 11:24:11 +0800
committerThomas Monjalon <thomas@monjalon.net>2017-07-14 11:57:54 +0200
commit82d708384ff0bfeaa282b338f5e9dcd7e3fa41ed (patch)
treeb8812bcc8fe39bec27026b29549a8db73732ca89 /test
parent7ee3e9446290ba3f618d8cb93374e76994057057 (diff)
downloaddpdk-82d708384ff0bfeaa282b338f5e9dcd7e3fa41ed.zip
dpdk-82d708384ff0bfeaa282b338f5e9dcd7e3fa41ed.tar.gz
dpdk-82d708384ff0bfeaa282b338f5e9dcd7e3fa41ed.tar.xz
test/alarm: add delay tolerance
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> Acked-by: Jing Chen <jing.d.chen@intel.com>
Diffstat (limited to 'test')
-rw-r--r--test/test/test_alarm.c9
1 files 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 @@
#define RTE_TEST_ALARM_TIMEOUT 10 /* ms */
#define RTE_TEST_CHECK_PERIOD 3 /* ms */
+#define RTE_TEST_MAX_REPEAT 20
static volatile int flag;
@@ -96,6 +97,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 +171,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++ < RTE_TEST_MAX_REPEAT)
+ 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 +217,7 @@ test_alarm(void)
printf("fail to set alarm callback\n");
return -1;
}
- while (flag == 0 && count ++ < 6)
+ while (flag == 0 && count++ < RTE_TEST_MAX_REPEAT)
rte_delay_ms(RTE_TEST_CHECK_PERIOD);
if (flag == 0){