[2/2] zdtm: Pre-check flock before daemonize in file_locks04 test

Submitted by Kirill Tkhai on June 28, 2016, 5:49 p.m.

Details

Message ID 146713615389.18194.8686195323807378037.stgit@pro
State Rejected
Series "Series without cover letter"
Headers show

Commit Message

Kirill Tkhai June 28, 2016, 5:49 p.m.
On some kernel (on travis.org, for example) either child
or parent fdinfo do not contain flock information, on the
configuration the test setups.

Pre-check if lock contains in child's fdinfo before the
daemonization, and simply pass if not so.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 test/zdtm/static/file_locks04.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/file_locks04.c b/test/zdtm/static/file_locks04.c
index dfb7c53..6feb27b 100644
--- a/test/zdtm/static/file_locks04.c
+++ b/test/zdtm/static/file_locks04.c
@@ -105,6 +105,20 @@  int main(int argc, char **argv)
 		return -1;
 	}
 
+	ret = check_file_locks(pid, fd, child_fd);
+	if (ret < 0) {
+		fail("Pre-check failed\n");
+		goto out_kill;
+	} else if (ret == 0) {
+		test_msg("Old kernel?\n");
+		test_daemon();
+		test_waitsig();
+		pass();
+		goto out_kill;
+	}
+
+	test_msg("Daemonize\n");
+
 	test_daemon();
 	test_waitsig();
 

Comments

Andrey Vagin June 28, 2016, 6:16 p.m.
On Tue, Jun 28, 2016 at 08:49:53PM +0300, Kirill Tkhai wrote:
> On some kernel (on travis.org, for example) either child
> or parent fdinfo do not contain flock information, on the
> configuration the test setups.
> 
> Pre-check if lock contains in child's fdinfo before the
> daemonization, and simply pass if not so.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  test/zdtm/static/file_locks04.c |   14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/test/zdtm/static/file_locks04.c b/test/zdtm/static/file_locks04.c
> index dfb7c53..6feb27b 100644
> --- a/test/zdtm/static/file_locks04.c
> +++ b/test/zdtm/static/file_locks04.c
> @@ -105,6 +105,20 @@ int main(int argc, char **argv)
>  		return -1;
>  	}
>  
> +	ret = check_file_locks(pid, fd, child_fd);
> +	if (ret < 0) {
> +		fail("Pre-check failed\n");
> +		goto out_kill;
> +	} else if (ret == 0) {
> +		test_msg("Old kernel?\n");
> +		test_daemon();
> +		test_waitsig();

you can add "'feature': 'fdinfo_lock'" to file_locks04.desc instead of
this code

> +		pass();
> +		goto out_kill;
> +	}
> +
> +	test_msg("Daemonize\n");
> +
>  	test_daemon();
>  	test_waitsig();
>  
>
Kirill Tkhai June 28, 2016, 6:19 p.m.
On 28.06.2016 21:16, Andrew Vagin wrote:
> On Tue, Jun 28, 2016 at 08:49:53PM +0300, Kirill Tkhai wrote:
>> On some kernel (on travis.org, for example) either child
>> or parent fdinfo do not contain flock information, on the
>> configuration the test setups.
>>
>> Pre-check if lock contains in child's fdinfo before the
>> daemonization, and simply pass if not so.
>>
>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>> ---
>>  test/zdtm/static/file_locks04.c |   14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/test/zdtm/static/file_locks04.c b/test/zdtm/static/file_locks04.c
>> index dfb7c53..6feb27b 100644
>> --- a/test/zdtm/static/file_locks04.c
>> +++ b/test/zdtm/static/file_locks04.c
>> @@ -105,6 +105,20 @@ int main(int argc, char **argv)
>>  		return -1;
>>  	}
>>  
>> +	ret = check_file_locks(pid, fd, child_fd);
>> +	if (ret < 0) {
>> +		fail("Pre-check failed\n");
>> +		goto out_kill;
>> +	} else if (ret == 0) {
>> +		test_msg("Old kernel?\n");
>> +		test_daemon();
>> +		test_waitsig();
> 
> you can add "'feature': 'fdinfo_lock'" to file_locks04.desc instead of
> this code

Ok, thanks

> 
>> +		pass();
>> +		goto out_kill;
>> +	}
>> +
>> +	test_msg("Daemonize\n");
>> +
>>  	test_daemon();
>>  	test_waitsig();
>>  
>>