test: add delay time in test alarm
PATCH 1/1 test: add delay time in test alarm
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.
--- test/test/test_alarm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
test/test/test_alarm.c +4 -2
@@ -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 ){
Signature · 1 line
1.8.3.1
PATCH v2 1/1 test: add delay time in test alarm
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.
---
v2 changes:
* fixed coding style problems
---
--- test/test/test_alarm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
test/test/test_alarm.c +6 -2
@@ -96,6 +96,7 @@ static inttest_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 ){
Signature · 1 line
2.7.4
Hi,
Quoted 26 lines
test/test/test_alarm.c index renamed from test/test/test_alarm.c +0
-0ecb2f6d..cbae1a0 100644
test/test/test_alarm.c +1
-0@@ -96,6 +96,7 @@ static inttest_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");test/test/test_alarm.c +4
-1return -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 );
test/test/test_alarm.c test_alarm(void) · line 221
Quoted 7 lines
test/test/test_alarm.c +1
-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 );
What's the criteria to delay 20* RTE_TEST_CHECK_PERIOD ms? Add more comments?
Quoted 3 lines
test/test/test_alarm.c +0
-1if (flag ==0 ){ --2.7.4
Overall comment is to replace numeric with macro.
Hi,
Quoted 20 lines
-----Original Message-----
From: Chen, Jing D
Sent: Friday, May 5, 2017 2:29 PM
To: Yang, Qiming <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>
Subject: RE: [PATCH v2] test: add delay time in test alarmHi,
Quoted 11 lines
test/test/test_alarm.c index renamed from test/test/test_alarm.c +0
-0ecb2f6d..cbae1a0 100644
test/test/test_alarm.c +1
-0@@ -96,6 +96,7 @@ static inttest_multi_alarms (void) {int rm_count =0 ; +int count =0 ; cb_count.cnt =0 ;
Quoted 10 lines
test/test/test_alarm.c test_multi_alarms(void) · line 175
Quoted 10 lines
test/test/test_alarm.c +0
-0printf("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");test/test/test_alarm.c +3
-1return -1 ; } -rte_delay_ms (10 ); + +while (flag !=2 && count++ <6 ) +rte_delay_ms (10 );
The count can be replaced with macro, but the delay 10 ms is based on the alarm time set before. rte_eal_alarm_set(10 * US_PER_MS, test_remove_in_callback, (void *)1);
Quoted 22 lines
test/test/test_alarm.c test_multi_alarms(void) · line 179
Quoted 4 lines
test/test/test_alarm.c +1
-0+if (flag !=2 ) {printf ("Error - expected callback not called\n" );rte_eal_alarm_cancel (test_remove_in_callback, (void *)-1 );@@
test/test/test_alarm.c test_alarm(void) · line 220
Quoted 8 lines
-212,7 +216,7 @@
test_alarm(void)test/test/test_alarm.c +1
-1printf ("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 );What's the criteria to delay 20*
RTE_TEST_CHECK_PERIODms? Add more comments?Quoted 3 lines
if (flag == 0){
--
2.7.4Overall comment is to replace numeric with macro.
PATCH v3 1/1 test: add delay time in test alarm
In reply to Qiming YangBecause 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.
---
v2 changes:
* fixed coding style problems
v3 changes:
* replaced the numeric by macro
---
--- test/test/test_alarm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
test/test/test_alarm.c +7 -2
@@ -47,6 +47,7 @@#define RTE_TEST_ALARM_TIMEOUT 10/* ms */ #define RTE_TEST_CHECK_PERIOD 3/* ms */ +#define RTE_TEST_MAX_REPEAT 20static volatile int flag;
@@ -96,6 +97,7 @@ static inttest_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 ){
Signature · 1 line
2.7.4
+ while (flag != 2 && count++ < RTE_TEST_MAX_REPEAT)
+ rte_delay_ms(10);
Why you don't replace "2" and "10" with macro?
-----Original Message-----
From: Yang, Qiming
Sent: Tuesday, June 20, 2017 11:24 AM
To: [email protected]
Cc: Chen, Jing D <[email protected]>; Wu, Jingjing <[email protected]>; Yang, Qiming <[email protected]>
Subject: [PATCH v3] test: add delay time in test alarm
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.
---
v2 changes:
* fixed coding style problems
v3 changes:
* replaced the numeric by macro
---
--- test/test/test_alarm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
test/test/test_alarm.c +2 -0
@@ -47,6 +47,7 @@#define RTE_TEST_ALARM_TIMEOUT 10/* ms */ #define RTE_TEST_CHECK_PERIOD 3/* ms */ +#define RTE_TEST_MAX_REPEAT 20static volatile int flag;
@@ -96,6 +97,7 @@ static inttest_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){
--
2.7.4
Hi, Mark
"2" and "10" is the special number in this test case, not a general number.
/* Test that we cannot cancel an alarm from within the callback itself
* Also test that we can cancel head-of-line callbacks ok.*/
flag = 0;
recursive_error = 0;
rte_eal_alarm_set(10 * US_PER_MS, test_remove_in_callback, (void *)1);
rte_eal_alarm_set(20 * US_PER_MS, test_remove_in_callback, (void *)2);Quoted 82 lines
-----Original Message-----
From: Chen, Jing D
Sent: Thursday, July 6, 2017 4:29 PM
To: Yang, Qiming <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>
Subject: RE: [PATCH v3] test: add delay time in test alarm(quoted diff) +2
-0+ while (flag != 2 && count++ < RTE_TEST_MAX_REPEAT) + rte_delay_ms(10);Why you don't replace "2" and "10" with macro?
-----Original Message-----
From: Yang, Qiming
Sent: Tuesday, June 20, 2017 11:24 AM
To: [email protected]
Cc: Chen, Jing D <[email protected]>; Wu, Jingjing <[email protected]>; Yang, Qiming <[email protected]>
Subject: [PATCH v3] test: add delay time in test alarmBecause 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 <[email protected]>---
v2 changes:
* fixed coding style problems
v3 changes:
* replaced the numeric by macro
------ test/test/test_alarm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)test/test/test_alarm.c index renamed from test/test/test_alarm.c +0
-0ecb2f6d..40f55b5 100644
test/test/test_alarm.c +2
-0@@ -47,6 +47,7 @@#define RTE_TEST_ALARM_TIMEOUT 10/* ms */ #define RTE_TEST_CHECK_PERIOD 3/* ms */ +#define RTE_TEST_MAX_REPEAT 20static volatile int flag;@@ -96,6 +97,7 @@ static inttest_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");test/test/test_alarm.c +5
-3return -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 ){ --2.7.4
Chen, Jing D
Acked-byQuoted 69 lines
Quoted 50 lines
-----Original Message-----
From: Yang, Qiming
Sent: Tuesday, June 20, 2017 11:24 AM
To: [email protected]
Cc: Chen, Jing D <[email protected]>; Wu, Jingjing <[email protected]>; Yang, Qiming <[email protected]>
Subject: [PATCH v3] test: add delay time in test alarmBecause 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 <[email protected]>---
v2 changes:
* fixed coding style problems
v3 changes:
* replaced the numeric by macro
------ test/test/test_alarm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)test/test/test_alarm.c index renamed from test/test/test_alarm.c +0
-0ecb2f6d..40f55b5 100644
test/test/test_alarm.c +2
-0@@ -47,6 +47,7 @@#define RTE_TEST_ALARM_TIMEOUT 10/* ms */ #define RTE_TEST_CHECK_PERIOD 3/* ms */ +#define RTE_TEST_MAX_REPEAT 20static volatile int flag;@@ -96,6 +97,7 @@ static inttest_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");test/test/test_alarm.c
Quoted 10 lines
test/test/test_alarm.c +4
-1return -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 );@@
Quoted 8 lines
-212,7 +217,7 @@
test_alarm(void)test/test/test_alarm.c +1
-1printf ("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 );
Quoted 3 lines
Quoted 3 lines
if (flag == 0){
--
2.7.4
PATCH v3 1/1 test: add delay time in test alarm
Hi, Thomas
Can this patch be applied?
Qiming
Quoted 81 lines
-----Original Message-----
From: Chen, Jing D
Sent: Wednesday, July 12, 2017 9:31 AM
To: Yang, Qiming <[email protected]>; [email protected]
Cc: Wu, Jingjing <[email protected]>
Subject: RE: [PATCH v3] test: add delay time in test alarmQuoted 68 lines
Quoted 49 lines
-----Original Message-----
From: Yang, Qiming
Sent: Tuesday, June 20, 2017 11:24 AM
To: [email protected]
Cc: Chen, Jing D <[email protected]>; Wu, Jingjing <[email protected]>; Yang, Qiming <[email protected]>
Subject: [PATCH v3] test: add delay time in test alarmBecause 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 <[email protected]>---
v2 changes:
* fixed coding style problems
v3 changes:
* replaced the numeric by macro
------ test/test/test_alarm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)test/test/test_alarm.c index renamed from test/test/test_alarm.c +0
-0ecb2f6d..40f55b5 100644
test/test/test_alarm.c +2
-0@@ -47,6 +47,7 @@#define RTE_TEST_ALARM_TIMEOUT 10/* ms */ #define RTE_TEST_CHECK_PERIOD 3/* ms */ +#define RTE_TEST_MAX_REPEAT 20static volatile int flag;@@ -96,6 +97,7 @@ static inttest_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");test/test/test_alarm.c
Quoted 10 lines
test/test/test_alarm.c +4
-1return -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 );@@
Quoted 8 lines
-212,7 +217,7 @@
test_alarm(void)test/test/test_alarm.c +1
-1printf ("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 );Quoted 3 lines
Quoted 3 lines
if (flag == 0){
--
2.7.4Acked-by Jing Chen <[email protected]>
Thomas Monjalon
AppliedQuoted 9 lines
Quoted 7 lines
Quoted 7 lines
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 <[email protected]>Acked-by Jing Chen <[email protected]>
Applied, thanks