[LTP] [PATCH 02/12] posix/mq_(timed)send/5-1: Fix error reporting

Joerg Vehlow lkml@jv-coder.de
Fri Nov 19 08:45:52 CET 2021


From: Joerg Vehlow <joerg.vehlow@aox-tech.de>

In case mq_receive failed, the whole test could still return PASS/FAIL

Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>
---
 .../conformance/interfaces/mq_send/5-1.c                    | 3 +--
 .../conformance/interfaces/mq_timedsend/5-1.c               | 6 ++++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_send/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_send/5-1.c
index a2b3025d4..174e4f69e 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/mq_send/5-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_send/5-1.c
@@ -68,7 +68,6 @@ int main(void)
 	char msgrcd[BUFFER];
 	const char *msgptr = MSGSTR;
 	struct mq_attr attr;
-	int unresolved = 0;
 	unsigned pri;
 
 	sprintf(gqname, "/mq_send_5-1_%d", getpid());
@@ -128,7 +127,7 @@ int main(void)
 		/* receive one message and allow child's mq_send to complete */
 		if (mq_receive(gqueue, msgrcd, BUFFER, &pri) == -1) {
 			perror("mq_receive() did not return success");
-			unresolved = 1;
+			return cleanup_for_exit(gqueue, gqname, PTS_UNRESOLVED);
 		}
 
 		/* child has 5 seconds to call mq_send() again and notify us */
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
index fb4a81fef..371cdbcd4 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
@@ -58,7 +58,6 @@ int main(void)
 	char msgrcd[BUFFER];
 	const char *msgptr = MSGSTR;
 	struct mq_attr attr;
-	int unresolved = 0;
 	unsigned pri;
 
 	sprintf(gqname, "/mq_timedsend_5-1_%d", getpid());
@@ -119,7 +118,10 @@ int main(void)
 		/* receive message and allow blocked send to complete */
 		if (mq_receive(gqueue, msgrcd, BUFFER, &pri) == -1) {
 			perror("mq_receive() did not return success");
-			unresolved = 1;
+			kill(pid, SIGKILL);	//kill child
+			mq_close(gqueue);
+			mq_unlink(gqname);
+			return PTS_UNRESOLVED;
 		}
 
 		if (sleep(3) == 0) {
-- 
2.25.1



More information about the ltp mailing list