[LTP] [PATCH v3 1/4] openposix: mqueues: Use one thread by default

Anders Roxell anders.roxell@linaro.org
Wed Nov 25 22:09:30 CET 2026


multi_send_rev_1 and multi_send_rev_2 fail without the number of
threads as an argument. Only run-tests.sh passes it, from a .args file
that make install does not install.

Default to one thread like the .args files, and remove the unused
getopt.h include.

Suggested-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 .../stress/mqueues/multi_send_rev_1.c                     | 8 +++++---
 .../stress/mqueues/multi_send_rev_2.c                     | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_1.c b/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_1.c
index 5003681f7bb4..fed92ae755e6 100644
--- a/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_1.c
+++ b/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_1.c
@@ -18,7 +18,6 @@
 #include <sys/wait.h>
 #include <sys/mman.h>
 #include <string.h>
-#include <getopt.h>
 #include <pthread.h>
 #include <limits.h>
 #include <mqueue.h>
@@ -28,6 +27,7 @@
 #define MSG_SIZE	128
 #define MAX_MSG		3
 #define Max_Threads	10
+#define DEFAULT_THREADS	1
 #define Name_Size	20
 
 typedef struct {
@@ -96,8 +96,10 @@ int test_main(int argc, char **argv)
 	printf("_POSIX_MESSAGE_PASSING is not defined \n");
 	return PTS_UNRESOLVED;
 #endif */
-	if ((2 != argc) || ((num = atoi(argv[1])) <= 0)) {
-		fprintf(stderr, "Usage: %s number_of_threads\n", argv[0]);
+	if (argc < 2) {
+		num = DEFAULT_THREADS;
+	} else if ((num = atoi(argv[1])) <= 0) {
+		fprintf(stderr, "Usage: %s [number_of_threads]\n", argv[0]);
 		return PTS_FAIL;
 	}
 	if (num > Max_Threads) {
diff --git a/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_2.c b/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_2.c
index 9fe44113f704..989273b2da83 100644
--- a/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_2.c
+++ b/testcases/open_posix_testsuite/stress/mqueues/multi_send_rev_2.c
@@ -18,7 +18,6 @@
 #include <sys/wait.h>
 #include <sys/mman.h>
 #include <string.h>
-#include <getopt.h>
 #include <pthread.h>
 #include <limits.h>
 #include <mqueue.h>
@@ -29,6 +28,7 @@
 #define MSG_SIZE	128
 #define MAX_MSG		5
 #define Max_Threads	100
+#define DEFAULT_THREADS	1
 
 static const char *s_msg_ptr[] =
     { "send_1 1", "send_1 2", "send_1 3", "send_1 4", "send_1 5" };
@@ -85,8 +85,10 @@ int test_main(int argc, char **argv)
 	printf("_POSIX_MESSAGE_PASSING is not defined \n");
 	return PTS_UNRESOLVED;
 #endif */
-	if ((2 != argc) || ((num = atoi(argv[1])) <= 0)) {
-		fprintf(stderr, "Usage: %s number_of_threads\n", argv[0]);
+	if (argc < 2) {
+		num = DEFAULT_THREADS;
+	} else if ((num = atoi(argv[1])) <= 0) {
+		fprintf(stderr, "Usage: %s [number_of_threads]\n", argv[0]);
 		return PTS_FAIL;
 	}
 	if (num > Max_Threads) {
-- 
2.53.0



More information about the ltp mailing list