Skip to contentSkip to conversation

mq_timedreceive_5-3: Initialize maxmsg properly

PATCH New Cyril Hrubis 2 participants 4 messages Feb 12, 2021 – Feb 15, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mq_timedreceive_5-3: Initialize maxmsg properly

The test can be actually executed as non-root user but the maxmsg must be set to a value that is less by user limit for messages and since we do not send any messages we can safely initialize it to 1.

---
 .../conformance/interfaces/mq_timedreceive/5-3.c               | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-3.c +2 -1
index cc592f5a7..87f3365d5 100644
@@ -55,7 +55,8 @@ int main(void)
 	sprintf(mqname, "/" FUNCTION "_" TEST "_%d", getpid());
 
 	attr.mq_msgsize = BUFFER;
-	attr.mq_maxmsg = BUFFER;
+	attr.mq_maxmsg = 1;
+
 	mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
 	if (mqdes == (mqd_t) - 1) {
 		perror(ERROR_PREFIX "mq_open");
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 mq_timedreceive_5-3: Initialize maxmsg properly

Hi Cyril,

Quoted 3 lines · Cyril Hrubis

The test can be actually executed as non-root user but the maxmsg must be set to a value that is less by user limit for messages and since we do not send any messages we can safely initialize it to 1.

This is applies to more than only this test. I also recognized this when fixing the time issue, but decided not to change it, because it is not the only affected test.
The max message size could be up to /proc/sys/fs/mqueue/msg_max. This is usually 10.

J?rg

#2 lore raw

PATCH 1/1 mq_timedreceive_5-3: Initialize maxmsg properly

Hi!

Quoted 6 lines
Quoted 3 lines

The test can be actually executed as non-root user but the maxmsg must be set to a value that is less by user limit for messages and since we do not send any messages we can safely initialize it to 1.

This is applies to more than only this test. I also recognized this when fixing the time issue, but decided not to change it, because it is not the only affected test.

Feel free to send a patch for the rest :-).

Setting the mq_maxmsg to BUFFER which is supposed to be constant for the mq_msgsize is quite confusing and also prevents these tests from being executed as ordinary user so I think that it's worth fixing.

Quoted 2 lines

The max message size could be up to /proc/sys/fs/mqueue/msg_max. This is usually 10.

Looking at the rest of the tests I guess the original author either did not care that much or was clueless since it does not really make sense to set mq_maxmsg to the same number as mq_msgsize in tests that send just one or two message.

So we should either set it to 2 in all tests, or set it to 1 or 2 depending on how many messages test sends.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 1/1 mq_timedreceive_5-3: Initialize maxmsg properly

Hi,

Quoted 1 line · Cyril Hrubis

Feel free to send a patch for the rest :-).

Don't want to many open patches at the same time ;)

Quoted 7 lines

Looking at the rest of the tests I guess the original author either did not care that much or was clueless since it does not really make sense to set mq_maxmsg to the same number as mq_msgsize in tests that send just one or two message.

So we should either set it to 2 in all tests, or set it to 1 or 2 depending on how many messages test sends.

Couldn't agree more

J?rg