[LTP] [PATCH v6 1/6] Refactor mqns_01 using new LTP API

Andrea Cervesato andrea.cervesato@suse.com
Wed May 10 11:56:02 CEST 2023


Hi!

On 3/23/23 12:17, Petr Vorel wrote:
> Hi Andrea,
>
>> +++ b/runtest/containers
>> @@ -16,7 +16,8 @@ pidns31 pidns31
>>   pidns32 pidns32
>>   mqns_01 mqns_01
> Also, if anybody run this tests without params, it's actually not testing
> unshade as it was before (i.e. the default case is doing something different,
> than the main purpose of the test).
It's now testing also the plain process test case. All namespaces tests 
which have this testcase, "unshare" variant is set via option. If no 
options are given, then plain process is created.
>
>> -mqns_01_clone mqns_01 -clone
>> +mqns_01_clone mqns_01 -m clone
>> +mqns_01_unshare mqns_01 -m unshare
> BTW I'm verbose on changes during rewrite, I'd notice the fact that one extra
> run, which tests just fork (i.e. case where pass - the opposite is expected).
>
>
>> +++ b/testcases/kernel/containers/mqns/mqns_01.c
>> +/*\
>> + * [Description]
>> + *
>> + * Create a mqueue inside the parent and check if it can be accessed from
>> + * the child namespace.
> Actually my previous note "verify if cannot" is invalid, when -m is not set
> (fork call).  Again, I'd mention it here.
>
> ...
>> +		if (!SAFE_CLONE(&clone_args)) {
>> +			TST_EXP_FAIL(mq_open(MQNAME, O_RDONLY), ENOENT);
>> +			return;
>> +		}
>> +	} else if (str_op && !strcmp(str_op, "unshare")) {
>> +		tst_res(TINFO, "Spawning unshared process");
>> +
>> +		if (!SAFE_FORK()) {
>> +			SAFE_UNSHARE(CLONE_NEWIPC);
>> +			TST_EXP_FAIL(mq_open(MQNAME, O_RDONLY), ENOENT);
>> +			return;
>>   		}
>>   	} else {
>> -		if (write(p2[1], "exists", strlen("exists") + 1) < 0) {
>> -			perror("write(p2[1], \"exists\", 7) failed");
>> -			exit(1);
>> -		} else if (mq_close(mqd) < 0) {
>> -			perror("mq_close(mqd) failed");
>> -			exit(1);
>> +		tst_res(TINFO, "Spawning plain process");
>> +
>> +		if (!SAFE_FORK()) {
>> +			TST_EXP_POSITIVE(mq_open(MQNAME, O_RDONLY));
> nit: shouldn't this be TST_EXP_FD() (no real change, just extra "fd" being printed.

mq_open doesn't create a FD, but a queue identifier.


> Kind regards,
> Petr

Andrea



More information about the ltp mailing list