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>
#define RTE_TEST_ALARM_TIMEOUT 10 /* ms */
#define RTE_TEST_CHECK_PERIOD 3 /* ms */
#define RTE_TEST_ALARM_TIMEOUT 10 /* ms */
#define RTE_TEST_CHECK_PERIOD 3 /* ms */
+#define RTE_TEST_MAX_REPEAT 20
static volatile int flag;
static volatile int flag;
test_multi_alarms(void)
{
int rm_count = 0;
test_multi_alarms(void)
{
int rm_count = 0;
cb_count.cnt = 0;
printf("Expect 6 callbacks in order...\n");
cb_count.cnt = 0;
printf("Expect 6 callbacks in order...\n");
printf("Error, cancelling head-of-list leads to premature callback\n");
return -1;
}
printf("Error, cancelling head-of-list leads to premature callback\n");
return -1;
}
+
+ 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);
if (flag != 2) {
printf("Error - expected callback not called\n");
rte_eal_alarm_cancel(test_remove_in_callback, (void *)-1);
printf("fail to set alarm callback\n");
return -1;
}
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){
rte_delay_ms(RTE_TEST_CHECK_PERIOD);
if (flag == 0){