Skip to contentSkip to conversation

test: add delay time in test alarm

PATCH Superseded Qiming Yang 3 participants 10 messages Mar 21, 2017 – Jul 14, 2017

lore
Share & tools
lore
#0 lore raw

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
index ecb2f6d..ad4e908 100644
@@ -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
#1 lore raw

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
index ecb2f6d..cbae1a0 100644
@@ -96,6 +96,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 +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
#2 lore raw

Hi,

Quoted 26 lines
test/test/test_alarm.c index renamed from test/test/test_alarm.c +0 -0

ecb2f6d..cbae1a0 100644

test/test/test_alarm.c +1 -0
@@ -96,6 +96,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 +170,10 @@

test_multi_alarms(void)
printf("Error, cancelling head-of-list leads to premature
callback\n");

test/test/test_alarm.c +4 -1
 		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);

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 -1
 	if (flag == 0){
--

2.7.4

Overall comment is to replace numeric with macro.

#3 lore raw

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 alarm

Hi,

Quoted 11 lines
test/test/test_alarm.c index renamed from test/test/test_alarm.c +0 -0

ecb2f6d..cbae1a0 100644

test/test/test_alarm.c +1 -0
@@ -96,6 +96,7 @@ static int
 test_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 -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 +3 -1
 		return -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 -1
 		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

if (flag == 0){
--
2.7.4

Overall comment is to replace numeric with macro.

#4 lore raw

PATCH v3 1/1 test: add delay time in test alarm

In reply to Qiming Yang

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 +7 -2
index ecb2f6d..40f55b5 100644
@@ -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){
Signature · 1 line
2.7.4
#5 lore raw

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

#6 lore raw

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 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 index renamed from test/test/test_alarm.c +0 -0

ecb2f6d..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    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");

test/test/test_alarm.c +5 -3
 		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

Acked-by
#7 lore raw
Quoted 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 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 index renamed from test/test/test_alarm.c +0 -0

ecb2f6d..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    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");

test/test/test_alarm.c

Quoted 10 lines
test/test/test_alarm.c +4 -1
 		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);

@@

Quoted 8 lines

-212,7 +217,7 @@ test_alarm(void)

test/test/test_alarm.c +1 -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);
Quoted 3 lines
Quoted 3 lines

if (flag == 0){
--
2.7.4

#8 lore raw

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 alarm

Quoted 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 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 index renamed from test/test/test_alarm.c +0 -0

ecb2f6d..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    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");

test/test/test_alarm.c

Quoted 10 lines
test/test/test_alarm.c +4 -1
 		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);

@@

Quoted 8 lines

-212,7 +217,7 @@ test_alarm(void)

test/test/test_alarm.c +1 -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);
Quoted 3 lines
Quoted 3 lines

if (flag == 0){
--
2.7.4

#9 lore raw
In reply to Chen, Jing D
Quoted 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.

Applied, thanks