diff mbox

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

Message ID 4341B239C0EFF9468EE453F9E9F4604D3C678919@shsmsx102.ccr.corp.intel.com (mailing list archive)
State Not Applicable, archived
Delegated to: Thomas Monjalon
Headers show

Checks

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

Commit Message

Chen, Jing D July 6, 2017, 8:28 a.m. UTC
+	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: dev@dpdk.org
Cc: Chen, Jing D <jing.d.chen@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Yang, Qiming <qiming.yang@intel.com>
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.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
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(-)

 		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

Comments

Qiming Yang July 7, 2017, 4:35 a.m. UTC | #1
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);


> -----Original Message-----
> From: Chen, Jing D
> Sent: Thursday, July 6, 2017 4:29 PM
> To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
> Cc: Wu, Jingjing <jingjing.wu@intel.com>
> Subject: RE: [PATCH v3] test: add delay time in test alarm
> 
> 
> +	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: dev@dpdk.org
> Cc: Chen, Jing D <jing.d.chen@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>;
> Yang, Qiming <qiming.yang@intel.com>
> 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.
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
> 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(-)
> 
> 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){
> --
> 2.7.4
Chen, Jing D July 12, 2017, 1:31 a.m. UTC | #2
> >
> > -----Original Message-----
> > From: Yang, Qiming
> > Sent: Tuesday, June 20, 2017 11:24 AM
> > To: dev@dpdk.org
> > Cc: Chen, Jing D <jing.d.chen@intel.com>; Wu, Jingjing
> > <jingjing.wu@intel.com>; Yang, Qiming <qiming.yang@intel.com>
> > 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.
> >
> > Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> > ---
> > 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(-)
> >
> > 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){
> > --
> > 2.7.4

Acked-by : Jing Chen <jing.d.chen@intel.com>
Qiming Yang July 14, 2017, 5:51 a.m. UTC | #3
Hi, Thomas

Can this patch be applied?

Qiming
> -----Original Message-----
> From: Chen, Jing D
> Sent: Wednesday, July 12, 2017 9:31 AM
> To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
> Cc: Wu, Jingjing <jingjing.wu@intel.com>
> Subject: RE: [PATCH v3] test: add delay time in test alarm
> 
> 
> > >
> > > -----Original Message-----
> > > From: Yang, Qiming
> > > Sent: Tuesday, June 20, 2017 11:24 AM
> > > To: dev@dpdk.org
> > > Cc: Chen, Jing D <jing.d.chen@intel.com>; Wu, Jingjing
> > > <jingjing.wu@intel.com>; Yang, Qiming <qiming.yang@intel.com>
> > > 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.
> > >
> > > Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> > > ---
> > > 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(-)
> > >
> > > 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){
> > > --
> > > 2.7.4
> 
> Acked-by : Jing Chen <jing.d.chen@intel.com>
Thomas Monjalon July 14, 2017, 9:36 a.m. UTC | #4
> > > 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>

Applied, thanks
diff mbox

Patch

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)