All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH LTP] open_posix: fix send_rev_2.c testcase
@ 2025-06-02  1:37 yang.zhang
  2025-06-04 13:41 ` Jan Stancek via ltp
  0 siblings, 1 reply; 3+ messages in thread
From: yang.zhang @ 2025-06-02  1:37 UTC (permalink / raw)
  To: ltp; +Cc: yang.zhang

From: "yang.zhang" <zhangyang01@kylinos.cn>

1. After fork, using correct switch branch for parent and child.
2. Fix array out-of-bounds issue when calling mq_send.

Signed-off-by: yang.zhang <zhangyang01@kylinos.cn>
---
 .../functional/mqueues/send_rev_1.c           | 35 +++++++++----------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c b/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c
index 46eef837a..7c7d2f761 100644
--- a/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c
+++ b/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c
@@ -57,23 +57,6 @@ int main(void)
 		ret_code = PTS_UNRESOLVED;
 		break;
 	case 0:
-		mq_getattr(mq, &attr);
-		for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) {
-			printf("[%d] s_msg_ptr is '%s' \n", i + 1,
-			       s_msg_ptr[i]);
-			printf("Prepare to send message...\n");
-			if (-1 == mq_send(mq, s_msg_ptr[i], attr.mq_msgsize, 1)) {
-				perror("mq_send doesn't return success \n");
-				ret_code = PTS_UNRESOLVED;
-			} else {
-				printf("Process %ld send message '%s' to "
-				       "process %ld \n",
-				       (long)getpid(), s_msg_ptr[i], (long)pid);
-			}
-		}
-		(void)wait(NULL);
-		break;
-	default:
 		printf("Enter into child process...\n");
 		mq_getattr(mq, &attr);
 		for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) {
@@ -91,7 +74,23 @@ int main(void)
 			}
 		}
 		exit(ret_code);
-
+		break;
+	default:
+		mq_getattr(mq, &attr);
+		for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) {
+			printf("[%d] s_msg_ptr is '%s' \n", i + 1,
+			       s_msg_ptr[i]);
+			printf("Prepare to send message...\n");
+			if (-1 == mq_send(mq, s_msg_ptr[i], strlen(s_msg_ptr[i]) + 1, 1)) {
+				perror("mq_send doesn't return success \n");
+				ret_code = PTS_UNRESOLVED;
+			} else {
+				printf("Process %ld send message '%s' to "
+				       "process %ld \n",
+				       (long)getpid(), s_msg_ptr[i], (long)pid);
+			}
+		}
+		(void)wait(NULL);
 		break;
 	}
 
-- 
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH LTP] open_posix: fix send_rev_2.c testcase
  2025-06-02  1:37 [LTP] [PATCH LTP] open_posix: fix send_rev_2.c testcase yang.zhang
@ 2025-06-04 13:41 ` Jan Stancek via ltp
  2025-06-09 13:16   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek via ltp @ 2025-06-04 13:41 UTC (permalink / raw)
  To: yang.zhang; +Cc: yang.zhang, ltp

On Mon, Jun 2, 2025 at 5:22 PM yang.zhang <gaoshanliukou@163.com> wrote:
>
> From: "yang.zhang" <zhangyang01@kylinos.cn>
>
> 1. After fork, using correct switch branch for parent and child.
> 2. Fix array out-of-bounds issue when calling mq_send.
>
> Signed-off-by: yang.zhang <zhangyang01@kylinos.cn>

Subject says "send_rev_2.c", but patch is for send_rev_1.c,
so that's something to fix during commit.

Reviewed-by: Jan Stancek <jstancek@redhat.com>


> ---
>  .../functional/mqueues/send_rev_1.c           | 35 +++++++++----------
>  1 file changed, 17 insertions(+), 18 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c b/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c
> index 46eef837a..7c7d2f761 100644
> --- a/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c
> +++ b/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c
> @@ -57,23 +57,6 @@ int main(void)
>                 ret_code = PTS_UNRESOLVED;
>                 break;
>         case 0:
> -               mq_getattr(mq, &attr);
> -               for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) {
> -                       printf("[%d] s_msg_ptr is '%s' \n", i + 1,
> -                              s_msg_ptr[i]);
> -                       printf("Prepare to send message...\n");
> -                       if (-1 == mq_send(mq, s_msg_ptr[i], attr.mq_msgsize, 1)) {
> -                               perror("mq_send doesn't return success \n");
> -                               ret_code = PTS_UNRESOLVED;
> -                       } else {
> -                               printf("Process %ld send message '%s' to "
> -                                      "process %ld \n",
> -                                      (long)getpid(), s_msg_ptr[i], (long)pid);
> -                       }
> -               }
> -               (void)wait(NULL);
> -               break;
> -       default:
>                 printf("Enter into child process...\n");
>                 mq_getattr(mq, &attr);
>                 for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) {
> @@ -91,7 +74,23 @@ int main(void)
>                         }
>                 }
>                 exit(ret_code);
> -
> +               break;
> +       default:
> +               mq_getattr(mq, &attr);
> +               for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) {
> +                       printf("[%d] s_msg_ptr is '%s' \n", i + 1,
> +                              s_msg_ptr[i]);
> +                       printf("Prepare to send message...\n");
> +                       if (-1 == mq_send(mq, s_msg_ptr[i], strlen(s_msg_ptr[i]) + 1, 1)) {
> +                               perror("mq_send doesn't return success \n");
> +                               ret_code = PTS_UNRESOLVED;
> +                       } else {
> +                               printf("Process %ld send message '%s' to "
> +                                      "process %ld \n",
> +                                      (long)getpid(), s_msg_ptr[i], (long)pid);
> +                       }
> +               }
> +               (void)wait(NULL);
>                 break;
>         }
>
> --
> 2.34.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH LTP] open_posix: fix send_rev_2.c testcase
  2025-06-04 13:41 ` Jan Stancek via ltp
@ 2025-06-09 13:16   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2025-06-09 13:16 UTC (permalink / raw)
  To: Jan Stancek; +Cc: yang.zhang, ltp, yang.zhang

Hi yang.zhang, Jan,

> Subject says "send_rev_2.c", but patch is for send_rev_1.c,
> so that's something to fix during commit.

Good point, fixed and merged.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-09 13:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-02  1:37 [LTP] [PATCH LTP] open_posix: fix send_rev_2.c testcase yang.zhang
2025-06-04 13:41 ` Jan Stancek via ltp
2025-06-09 13:16   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.