This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 433a78737 testing/ostest: Test mq_open() with an oversized message
size.
433a78737 is described below
commit 433a78737cb01ae564acf81280455495fae54460
Author: ganjing <[email protected]>
AuthorDate: Wed Nov 25 10:24:32 2026 +0800
testing/ostest: Test mq_open() with an oversized message size.
Check that mq_open() fails with EINVAL when mq_msgsize exceeds
CONFIG_MQ_MAXMSGSIZE. With CONFIG_DEBUG_ASSERTIONS the kernel asserted
on such an attribute before the fix in nuttx.
Signed-off-by: ganjing <[email protected]>
---
testing/ostest/mqueue.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/testing/ostest/mqueue.c b/testing/ostest/mqueue.c
index f31c0ecdc..77368b9fc 100644
--- a/testing/ostest/mqueue.c
+++ b/testing/ostest/mqueue.c
@@ -287,12 +287,33 @@ void mqueue_test(void)
int prio_max;
int prio_mid;
int status;
+ struct mq_attr mqattr;
+ mqd_t mqfd;
/* Reset globals for the beginning of the test */
g_send_mqfd = 0;
g_recv_mqfd = 0;
+ /* A message size above CONFIG_MQ_MAXMSGSIZE is an invalid argument */
+
+ printf("mqueue_test: Opening a queue with an oversized message size\n");
+ mqattr.mq_maxmsg = 2;
+ mqattr.mq_msgsize = CONFIG_MQ_MAXMSGSIZE + 1;
+ mqattr.mq_flags = 0;
+ mqfd = mq_open("mqueue_big", O_RDWR | O_CREAT, 0666, &mqattr);
+ if (mqfd != (mqd_t)-1 || errno != EINVAL)
+ {
+ printf("mqueue_test: ERROR mq_open returned %d, errno=%d, "
+ "expected -1 and EINVAL\n", (int)mqfd, errno);
+ ASSERT(false);
+ if (mqfd != (mqd_t)-1)
+ {
+ mq_close(mqfd);
+ mq_unlink("mqueue_big");
+ }
+ }
+
#ifdef CONFIG_ENABLE_ALL_SIGNALS
/* SIGUSR1 wakes up the receiver below. Catch it: its default action
* ends the process with CONFIG_SIG_SIGUSR1_ACTION, as POSIX wants.