test: add variable delta for poll.c test

Submitted by Vitaly Ostrosablin on Jan. 9, 2017, 8:39 a.m.

Details

Message ID 20170109083928.27738-1-vostrosablin@virtuozzo.com
State Superseded
Series "test: add variable delta for poll.c test"
Headers show

Commit Message

Vitaly Ostrosablin Jan. 9, 2017, 8:39 a.m.
For ZDTM purposes, poll.c uses delta of 5 seconds, which is fine, since
tests don't take a very long time to pass. However, in vzt-cpt, we start
a batch with multitude of tests and starting them all could take over an
hour. Hence, the test is bound to fail. An easy solution would be to
introduce an environment variable, which would allow to specify the
delta - ZDTM_DELTA. If it's unset (which is default behaviour in ZDTM) -
it would default to 5 seconds. However, if it's set (what we can do from
vzt-cpt) - then it will use delta which is set by our test.

Signed-off-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
---
 test/zdtm/static/poll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/poll.c b/test/zdtm/static/poll.c
index c0f75745..2368d079 100644
--- a/test/zdtm/static/poll.c
+++ b/test/zdtm/static/poll.c
@@ -80,7 +80,9 @@  int main(int argc, char *argv[])
 		show_timestamp("Start", time1.tv_sec, time1.tv_usec);
 
 		task_waiter_complete(&t, 1);
-		delta = 5;
+		char *deltaenv = getenv("ZDTM_DELTA")
+		if (deltaenv) delta = atoi(deltaenv);
+		else delta = 5;
 		while (test_go()) {
 			ret = poll(ufds, 2, delta * 1000);
 			show_pollfd(ufds, 2);

Comments

Cyrill Gorcunov Jan. 9, 2017, 9:01 a.m.
On Mon, Jan 09, 2017 at 11:39:28AM +0300, Vitaly Ostrosablin wrote:
> 
> diff --git a/test/zdtm/static/poll.c b/test/zdtm/static/poll.c
> index c0f75745..2368d079 100644
> --- a/test/zdtm/static/poll.c
> +++ b/test/zdtm/static/poll.c
> @@ -80,7 +80,9 @@ int main(int argc, char *argv[])
>  		show_timestamp("Start", time1.tv_sec, time1.tv_usec);
>  
>  		task_waiter_complete(&t, 1);
> -		delta = 5;
> +		char *deltaenv = getenv("ZDTM_DELTA")
> +		if (deltaenv) delta = atoi(deltaenv);
> +		else delta = 5;

Fix the style please

		deltaenv = getenv("ZDTM_DELTA");
		if (deltaenv)
			delta = atoi(deltaenv);
		else
			delta = 5;

Since you've missed semicolon as well I suspect you didn't
even compiled the test

>  		while (test_go()) {
>  			ret = poll(ufds, 2, delta * 1000);
>  			show_pollfd(ufds, 2);
> -- 
> 2.11.0
> 

	Cyrill
Pavel Emelianov Jan. 9, 2017, 11:18 a.m.
On 01/09/2017 11:39 AM, Vitaly Ostrosablin wrote:
> For ZDTM purposes, poll.c uses delta of 5 seconds, which is fine, since
> tests don't take a very long time to pass. However, in vzt-cpt, we start
> a batch with multitude of tests and starting them all could take over an
> hour. Hence, the test is bound to fail. An easy solution would be to
> introduce an environment variable, which would allow to specify the
> delta - ZDTM_DELTA. If it's unset (which is default behaviour in ZDTM) -
> it would default to 5 seconds. However, if it's set (what we can do from
> vzt-cpt) - then it will use delta which is set by our test.
> 
> Signed-off-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
> ---
>  test/zdtm/static/poll.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/test/zdtm/static/poll.c b/test/zdtm/static/poll.c
> index c0f75745..2368d079 100644
> --- a/test/zdtm/static/poll.c
> +++ b/test/zdtm/static/poll.c
> @@ -80,7 +80,9 @@ int main(int argc, char *argv[])
>  		show_timestamp("Start", time1.tv_sec, time1.tv_usec);
>  
>  		task_waiter_complete(&t, 1);
> -		delta = 5;
> +		char *deltaenv = getenv("ZDTM_DELTA")

Declaring variables in the middle of the code is not welcome.
Non-compiling patches are even less welcome.

-- Pavel

> +		if (deltaenv) delta = atoi(deltaenv);
> +		else delta = 5;
>  		while (test_go()) {
>  			ret = poll(ufds, 2, delta * 1000);
>  			show_pollfd(ufds, 2);
>