All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC] syscalls/ipc: Make use of TST_EXP_FAIL macro
@ 2021-06-22 10:12 Yang Xu
  2021-06-22 10:58 ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Yang Xu @ 2021-06-22 10:12 UTC (permalink / raw)
  To: ltp

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
Since TST_EXP_FAIL macro only recognizes sycalls succeeded when syscalls return 0,
Can we use this macro directly for the these syscalls's error test? It may result in
invalid retval value and print errno when syscall succeeded. I think it
is a nit and it can improve this api usage range. Is it right?

 testcases/kernel/syscalls/ipc/msgget/msgget02.c | 15 ++-------------
 testcases/kernel/syscalls/ipc/msgget/msgget03.c | 12 ++----------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c | 14 ++------------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c | 17 ++---------------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c | 12 ++----------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c | 11 ++---------
 testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c | 14 ++------------
 testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c | 14 ++------------
 testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c | 14 ++------------
 9 files changed, 18 insertions(+), 105 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget02.c b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
index a8fac930b..de139790b 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget02.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
@@ -46,19 +46,8 @@ static struct tcase {
 
 static void verify_msgget(struct tcase *tc)
 {
-	TEST(msgget(*tc->key, tc->flags));
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgget() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgget() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgget() failed unexpectedly,"
-			" expected %s", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL(msgget(*tc->key, tc->flags), tc->exp_err, "msgget(%i, %i)",
+		*tc->key, tc->flags);
 }
 
 static void do_test(unsigned int n)
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget03.c b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
index 8fa620855..e1f36b3ae 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget03.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
@@ -26,16 +26,8 @@ static key_t msgkey;
 
 static void verify_msgget(void)
 {
-	TEST(msgget(msgkey + maxmsgs, IPC_CREAT | IPC_EXCL));
-	if (TST_RET != -1)
-		tst_res(TFAIL, "msgget() succeeded unexpectedly");
-
-	if (TST_ERR == ENOSPC) {
-		tst_res(TPASS | TTERRNO, "msgget() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgget() failed unexpectedly,"
-			" expected ENOSPC");
-	}
+	TST_EXP_FAIL(msgget(msgkey + maxmsgs, IPC_CREAT | IPC_EXCL), ENOSPC,
+		"msgget(%i, %i)", msgkey + maxmsgs, IPC_CREAT | IPC_EXCL);
 }
 
 static void setup(void)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
index 8dd28116a..d8df401e7 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
@@ -59,18 +59,8 @@ static struct tcase {
 
 static void verify_msgrcv(struct tcase *tc)
 {
-	TEST(msgrcv(*tc->id, tc->buffer, tc->msgsz, tc->msgtyp, tc->msgflag));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "smgrcv() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgrcv() failed unexpectedly,"
-			" expected %s but got", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL(msgrcv(*tc->id, tc->buffer, tc->msgsz, tc->msgtyp, tc->msgflag), tc->exp_err,
+		"msgrcv(%i, %p, %i, %ld, %i)", *tc->id, tc->buffer, tc->msgsz, tc->msgtyp, tc->msgflag);
 }
 
 static void do_test(unsigned int n)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c
index b578e2810..8f4b3fa52 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c
@@ -59,21 +59,8 @@ static void verify_msgrcv(unsigned int n)
 
 	tst_res(TINFO, "%s", tc->message);
 
-	TEST(msgrcv(queue_id, &rcv_buf, MSGSIZE, tc->msg_type, MSG_COPY | tc->msg_flag));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgrcv() succeeded unexpectedly");
-		SAFE_MSGSND(queue_id, &snd_buf, MSGSIZE, 0);
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-		return;
-	}
-
-	tst_res(TFAIL | TTERRNO,
-		"msgrcv() failed unexpectedly, expected %s got",
-		tst_strerrno(tc->exp_err));
+	TST_EXP_FAIL(msgrcv(queue_id, &rcv_buf, MSGSIZE, tc->msg_type, MSG_COPY | tc->msg_flag), tc->exp_err,
+		"msgrcv(%i, %p, %i, %i, %i)", queue_id, &rcv_buf, MSGSIZE, tc->msg_type, MSG_COPY | tc->msg_flag);
 }
 
 static void setup(void)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
index 43581896a..6bc908aa5 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
@@ -30,16 +30,8 @@ static void sighandler(int sig)
 
 static void verify_msgrcv(void)
 {
-	TEST(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0));
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgrcv() succeeded unexpectedly");
-		return;
-	}
-	if (TST_ERR == EINTR)
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-	else
-		tst_res(TFAIL | TTERRNO, "msgrcv() failed expected EINTR but got");
+	TST_EXP_FAIL(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0), EINTR,
+		"msgrcv(%i, %p, %d, 1, 0)", queue_id, &rcv_buf, MSGSIZE);
 }
 
 static void do_test(void)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
index 283b4af1d..7fec0b6ad 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
@@ -24,15 +24,8 @@ static struct buf {
 
 static void verify_msgrcv(void)
 {
-	TEST(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgrcv() succeeded unexpectedly");
-		return;
-	}
-	if (TST_ERR == EIDRM)
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-	else
-		tst_res(TFAIL | TTERRNO, "msgrcv() failed expected EIDRM but got");
+	TST_EXP_FAIL(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0), EIDRM,
+		"msgrcv(%i, %p, %d, 1, 0)", queue_id, &rcv_buf, MSGSIZE);
 }
 
 static void do_test(void)
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
index 24ef6c562..eca660605 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
@@ -61,18 +61,8 @@ static struct tcase {
 
 static void verify_msgsnd(struct tcase *tc)
 {
-	TEST(msgsnd(*tc->id, tc->buffer, tc->msgsz, 0));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "smgsnd() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgsnd() failed unexpectedly,"
-			" expected %s", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL(msgsnd(*tc->id, tc->buffer, tc->msgsz, 0), tc->exp_err,
+		"msgsnd(%i, %p, %i, 0)", *tc->id, tc->buffer, tc->msgsz);
 }
 
 static void do_test(unsigned int n)
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
index ace32cdaa..f048fa698 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
@@ -41,18 +41,8 @@ static struct tcase {
 
 static void verify_msgsnd(struct tcase *tc)
 {
-	TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, tc->flag));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgsnd() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgsnd() failed unexpectedly,"
-			" expected %s", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL(msgsnd(queue_id, &snd_buf, MSGSIZE, tc->flag), tc->exp_err,
+		"msgsnd(%i, %p, %i, %i)", queue_id, &snd_buf, MSGSIZE, tc->flag);
 }
 
 static void sighandler(int sig)
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
index 9f462b672..8fc665e68 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
@@ -28,18 +28,8 @@ static struct buf {
 
 static void verify_msgsnd(void)
 {
-	TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, 0));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgsnd() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == EIDRM) {
-		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO,
-			"msgsnd() failed unexpectedly, expected EIDRM");
-	}
+	TST_EXP_FAIL(msgsnd(queue_id, &snd_buf, MSGSIZE, 0), EIDRM,
+		"msgsnd(%i, %p, %i, 0)", queue_id, &snd_buf, MSGSIZE);
 }
 
 static void do_test(void)
-- 
2.23.0


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

* [LTP] [RFC] syscalls/ipc: Make use of TST_EXP_FAIL macro
  2021-06-22 10:12 [LTP] [RFC] syscalls/ipc: Make use of TST_EXP_FAIL macro Yang Xu
@ 2021-06-22 10:58 ` Cyril Hrubis
  2021-06-24  4:41   ` xuyang2018.jy
  2021-06-29 10:44   ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro Yang Xu
  0 siblings, 2 replies; 9+ messages in thread
From: Cyril Hrubis @ 2021-06-22 10:58 UTC (permalink / raw)
  To: ltp

Hi!
> Since TST_EXP_FAIL macro only recognizes sycalls succeeded when syscalls return 0,
> Can we use this macro directly for the these syscalls's error test? It may result in
> invalid retval value and print errno when syscall succeeded. I think it
> is a nit and it can improve this api usage range. Is it right?

I guess that it would be slightly cleaner to add more generic macro that
allows us to pass the condition for succeess and build TST_EXP_FAIL() on
the top of that. Maybe something as:

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 89dfe5a31..4d41741a4 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -120,13 +120,13 @@ extern void *TST_RET_PTR;
                        TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \
        } while (0)                                                            \

-#define TST_EXP_FAIL(SCALL, ERRNO, ...)                                        \
+#define TST_EXP_FAIL_(PASS_COND, SCALL, ERRNO, ...)                            \
        do {                                                                   \
                TEST(SCALL);                                                   \
                                                                               \
                TST_PASS = 0;                                                  \
                                                                               \
-               if (TST_RET == 0) {                                            \
+               if (PASS_COND) {                                               \
                        TST_MSG_(TFAIL, " succeeded", #SCALL, ##__VA_ARGS__);  \
                        break;                                                 \
                }                                                              \
@@ -150,4 +150,8 @@ extern void *TST_RET_PTR;
                }                                                              \
        } while (0)

+#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET == 0, SCALL, ERRNO)
+
+#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET >= 0, SCALL, ERRNO)
+
 #endif /* TST_TEST_MACROS_H__ */

The only hard thing is to find a good name for TST_EXP_FAIL2(), I'm out
of ideas here...

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [RFC] syscalls/ipc: Make use of TST_EXP_FAIL macro
  2021-06-22 10:58 ` Cyril Hrubis
@ 2021-06-24  4:41   ` xuyang2018.jy
  2021-06-29 10:44   ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro Yang Xu
  1 sibling, 0 replies; 9+ messages in thread
From: xuyang2018.jy @ 2021-06-24  4:41 UTC (permalink / raw)
  To: ltp

Hi Cyril
> Hi!
>> Since TST_EXP_FAIL macro only recognizes sycalls succeeded when syscalls return 0,
>> Can we use this macro directly for the these syscalls's error test? It may result in
>> invalid retval value and print errno when syscall succeeded. I think it
>> is a nit and it can improve this api usage range. Is it right?
>
> I guess that it would be slightly cleaner to add more generic macro that
> allows us to pass the condition for succeess and build TST_EXP_FAIL() on
> the top of that. Maybe something as:
>
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index 89dfe5a31..4d41741a4 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -120,13 +120,13 @@ extern void *TST_RET_PTR;
>                          TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \
>          } while (0)                                                            \
>
> -#define TST_EXP_FAIL(SCALL, ERRNO, ...)                                        \
> +#define TST_EXP_FAIL_(PASS_COND, SCALL, ERRNO, ...)                            \
>          do {                                                                   \
>                  TEST(SCALL);                                                   \
>                                                                                 \
>                  TST_PASS = 0;                                                  \
>                                                                                 \
> -               if (TST_RET == 0) {                                            \
> +               if (PASS_COND) {                                               \
>                          TST_MSG_(TFAIL, " succeeded", #SCALL, ##__VA_ARGS__);  \
>                          break;                                                 \
>                  }                                                              \
> @@ -150,4 +150,8 @@ extern void *TST_RET_PTR;
>                  }                                                              \
>          } while (0)
>
> +#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET == 0, SCALL, ERRNO)
> +
> +#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET>= 0, SCALL, ERRNO)
> +
>   #endif /* TST_TEST_MACROS_H__ */
>
> The only hard thing is to find a good name for TST_EXP_FAIL2(), I'm out
> of ideas here...
I think using TST_EXP_FAIL2 directly is simple and clear.

Best Regards
Yang Xu
>

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

* [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro
  2021-06-22 10:58 ` Cyril Hrubis
  2021-06-24  4:41   ` xuyang2018.jy
@ 2021-06-29 10:44   ` Yang Xu
  2021-06-29 10:44     ` [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or " Yang Xu
  2021-06-29 11:16     ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate " xuyang2018.jy
  1 sibling, 2 replies; 9+ messages in thread
From: Yang Xu @ 2021-06-29 10:44 UTC (permalink / raw)
  To: ltp

For these modified files, the return value is expected to be non-negative integer
if call passes. So they should use TST_EXP_FAIL2 macro.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/syscalls/accept/accept01.c             | 2 +-
 testcases/kernel/syscalls/adjtimex/adjtimex02.c         | 2 +-
 testcases/kernel/syscalls/io_getevents/io_getevents01.c | 3 ++-
 testcases/kernel/syscalls/io_submit/io_submit03.c       | 2 +-
 testcases/kernel/syscalls/open/open02.c                 | 2 +-
 testcases/kernel/syscalls/open/open11.c                 | 2 +-
 testcases/kernel/syscalls/recvmmsg/recvmmsg01.c         | 2 +-
 testcases/kernel/syscalls/sendfile/sendfile03.c         | 2 +-
 testcases/kernel/syscalls/sendfile/sendfile04.c         | 2 +-
 9 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/accept/accept01.c b/testcases/kernel/syscalls/accept/accept01.c
index 52234b792..85af0f8af 100644
--- a/testcases/kernel/syscalls/accept/accept01.c
+++ b/testcases/kernel/syscalls/accept/accept01.c
@@ -97,7 +97,7 @@ void verify_accept(unsigned int nr)
 {
 	struct test_case *tcase = &tcases[nr];
 
-	TST_EXP_FAIL(accept(*tcase->fd, tcase->sockaddr, &tcase->salen),
+	TST_EXP_FAIL2(accept(*tcase->fd, tcase->sockaddr, &tcase->salen),
 	             tcase->experrno, "%s", tcase->desc);
 }
 
diff --git a/testcases/kernel/syscalls/adjtimex/adjtimex02.c b/testcases/kernel/syscalls/adjtimex/adjtimex02.c
index 5d8d7019b..747d83254 100644
--- a/testcases/kernel/syscalls/adjtimex/adjtimex02.c
+++ b/testcases/kernel/syscalls/adjtimex/adjtimex02.c
@@ -110,7 +110,7 @@ static void verify_adjtimex(unsigned int i)
 		}
 	}
 
-	TST_EXP_FAIL(tv->adjtimex(bufp), tc[i].exp_err, "adjtimex() error");
+	TST_EXP_FAIL2(tv->adjtimex(bufp), tc[i].exp_err, "adjtimex() error");
 
 	if (tc[i].exp_err == EPERM)
 		SAFE_SETEUID(0);
diff --git a/testcases/kernel/syscalls/io_getevents/io_getevents01.c b/testcases/kernel/syscalls/io_getevents/io_getevents01.c
index 9dba4addf..e8a426ab6 100644
--- a/testcases/kernel/syscalls/io_getevents/io_getevents01.c
+++ b/testcases/kernel/syscalls/io_getevents/io_getevents01.c
@@ -23,7 +23,8 @@ static void run(void)
 	aio_context_t ctx;
 
 	memset(&ctx, 0, sizeof(ctx));
-	TST_EXP_FAIL(tst_syscall(__NR_io_getevents, ctx, 0, 0, NULL, NULL), EINVAL);
+	TST_EXP_FAIL2(tst_syscall(__NR_io_getevents, ctx, 0, 0, NULL, NULL), EINVAL,
+		"io_getevents syscall with invalid ctx");
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/io_submit/io_submit03.c b/testcases/kernel/syscalls/io_submit/io_submit03.c
index 052b0c8cc..90780c0e4 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit03.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit03.c
@@ -103,7 +103,7 @@ static void cleanup(void)
 
 static void run(unsigned int i)
 {
-	TST_EXP_FAIL(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs),
+	TST_EXP_FAIL2(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs),
 		     tc[i].exp_errno, "io_submit() with %s", tc[i].desc);
 }
 
diff --git a/testcases/kernel/syscalls/open/open02.c b/testcases/kernel/syscalls/open/open02.c
index ca9839c2d..67bf423ae 100644
--- a/testcases/kernel/syscalls/open/open02.c
+++ b/testcases/kernel/syscalls/open/open02.c
@@ -49,7 +49,7 @@ static void verify_open(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
 
-	TST_EXP_FAIL(open(tc->filename, tc->flag, 0444),
+	TST_EXP_FAIL2(open(tc->filename, tc->flag, 0444),
 	             tc->exp_errno, "open() %s", tc->desc);
 }
 
diff --git a/testcases/kernel/syscalls/open/open11.c b/testcases/kernel/syscalls/open/open11.c
index ded384fa8..3c3c11b84 100644
--- a/testcases/kernel/syscalls/open/open11.c
+++ b/testcases/kernel/syscalls/open/open11.c
@@ -278,7 +278,7 @@ static struct test_case {
 static void verify_open(unsigned int n)
 {
 	if (tc[n].err > 0) {
-		TST_EXP_FAIL(open(tc[n].path, tc[n].flags, tc[n].mode),
+		TST_EXP_FAIL2(open(tc[n].path, tc[n].flags, tc[n].mode),
 		             tc[n].err, "%s", tc[n].desc);
 	} else if (tc[n].err == 0) {
 		TST_EXP_FD(open(tc[n].path, tc[n].flags, tc[n].mode),
diff --git a/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c b/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
index 10eaa3dcd..fb21ea1e7 100644
--- a/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
+++ b/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
@@ -89,7 +89,7 @@ static void do_test(unsigned int i)
 	else
 		timeout = tst_ts_get(&ts);
 
-	TST_EXP_FAIL(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
+	TST_EXP_FAIL2(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
 	             tc->exp_errno, "recvmmsg() %s", tc->desc);
 }
 
diff --git a/testcases/kernel/syscalls/sendfile/sendfile03.c b/testcases/kernel/syscalls/sendfile/sendfile03.c
index dda651703..85a3b0f35 100644
--- a/testcases/kernel/syscalls/sendfile/sendfile03.c
+++ b/testcases/kernel/syscalls/sendfile/sendfile03.c
@@ -50,7 +50,7 @@ static void cleanup(void)
 
 static void run(unsigned int i)
 {
-	TST_EXP_FAIL(sendfile(*(tc[i].out_fd), *(tc[i].in_fd), NULL, 1),
+	TST_EXP_FAIL2(sendfile(*(tc[i].out_fd), *(tc[i].in_fd), NULL, 1),
 		     EBADF, "sendfile(..) with %s", tc[i].desc);
 }
 
diff --git a/testcases/kernel/syscalls/sendfile/sendfile04.c b/testcases/kernel/syscalls/sendfile/sendfile04.c
index 8ebeb3c10..9a8ec08b9 100644
--- a/testcases/kernel/syscalls/sendfile/sendfile04.c
+++ b/testcases/kernel/syscalls/sendfile/sendfile04.c
@@ -58,7 +58,7 @@ static void run(unsigned int i)
 	if (tc[i].pass_unmapped_buffer)
 		SAFE_MUNMAP(protected_buffer, sizeof(*protected_buffer));
 
-	TST_EXP_FAIL(sendfile(out_fd, in_fd, protected_buffer, 1),
+	TST_EXP_FAIL2(sendfile(out_fd, in_fd, protected_buffer, 1),
 		     EFAULT, "sendfile(..) with %s, protection=%d",
 		     tc[i].desc, tc[i].protection);
 
-- 
2.23.0


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

* [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or TST_EXP_FAIL2 macro
  2021-06-29 10:44   ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro Yang Xu
@ 2021-06-29 10:44     ` Yang Xu
  2021-06-30 14:27       ` Cyril Hrubis
  2021-06-29 11:16     ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate " xuyang2018.jy
  1 sibling, 1 reply; 9+ messages in thread
From: Yang Xu @ 2021-06-29 10:44 UTC (permalink / raw)
  To: ltp

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/syscalls/ipc/msgget/msgget02.c | 15 ++-------------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c | 14 ++------------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c | 17 ++---------------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c | 12 ++----------
 testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c | 11 ++---------
 testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c | 14 ++------------
 testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c | 14 ++------------
 testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c | 14 ++------------
 8 files changed, 16 insertions(+), 95 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget02.c b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
index a8fac930b..de139790b 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget02.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
@@ -46,19 +46,8 @@ static struct tcase {
 
 static void verify_msgget(struct tcase *tc)
 {
-	TEST(msgget(*tc->key, tc->flags));
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgget() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgget() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgget() failed unexpectedly,"
-			" expected %s", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL(msgget(*tc->key, tc->flags), tc->exp_err, "msgget(%i, %i)",
+		*tc->key, tc->flags);
 }
 
 static void do_test(unsigned int n)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
index 8dd28116a..cfb7d7446 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
@@ -59,18 +59,8 @@ static struct tcase {
 
 static void verify_msgrcv(struct tcase *tc)
 {
-	TEST(msgrcv(*tc->id, tc->buffer, tc->msgsz, tc->msgtyp, tc->msgflag));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "smgrcv() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgrcv() failed unexpectedly,"
-			" expected %s but got", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL2(msgrcv(*tc->id, tc->buffer, tc->msgsz, tc->msgtyp, tc->msgflag), tc->exp_err,
+		"msgrcv(%i, %p, %i, %ld, %i)", *tc->id, tc->buffer, tc->msgsz, tc->msgtyp, tc->msgflag);
 }
 
 static void do_test(unsigned int n)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c
index b578e2810..ebc583b3e 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c
@@ -59,21 +59,8 @@ static void verify_msgrcv(unsigned int n)
 
 	tst_res(TINFO, "%s", tc->message);
 
-	TEST(msgrcv(queue_id, &rcv_buf, MSGSIZE, tc->msg_type, MSG_COPY | tc->msg_flag));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgrcv() succeeded unexpectedly");
-		SAFE_MSGSND(queue_id, &snd_buf, MSGSIZE, 0);
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-		return;
-	}
-
-	tst_res(TFAIL | TTERRNO,
-		"msgrcv() failed unexpectedly, expected %s got",
-		tst_strerrno(tc->exp_err));
+	TST_EXP_FAIL2(msgrcv(queue_id, &rcv_buf, MSGSIZE, tc->msg_type, MSG_COPY | tc->msg_flag), tc->exp_err,
+		"msgrcv(%i, %p, %i, %i, %i)", queue_id, &rcv_buf, MSGSIZE, tc->msg_type, MSG_COPY | tc->msg_flag);
 }
 
 static void setup(void)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
index 43581896a..cc385ee6e 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
@@ -30,16 +30,8 @@ static void sighandler(int sig)
 
 static void verify_msgrcv(void)
 {
-	TEST(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0));
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgrcv() succeeded unexpectedly");
-		return;
-	}
-	if (TST_ERR == EINTR)
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-	else
-		tst_res(TFAIL | TTERRNO, "msgrcv() failed expected EINTR but got");
+	TST_EXP_FAIL2(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0), EINTR,
+		"msgrcv(%i, %p, %d, 1, 0)", queue_id, &rcv_buf, MSGSIZE);
 }
 
 static void do_test(void)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
index 283b4af1d..f14526df9 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
@@ -24,15 +24,8 @@ static struct buf {
 
 static void verify_msgrcv(void)
 {
-	TEST(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgrcv() succeeded unexpectedly");
-		return;
-	}
-	if (TST_ERR == EIDRM)
-		tst_res(TPASS | TTERRNO, "msgrcv() failed as expected");
-	else
-		tst_res(TFAIL | TTERRNO, "msgrcv() failed expected EIDRM but got");
+	TST_EXP_FAIL2(msgrcv(queue_id, &rcv_buf, MSGSIZE, 1, 0), EIDRM,
+		"msgrcv(%i, %p, %d, 1, 0)", queue_id, &rcv_buf, MSGSIZE);
 }
 
 static void do_test(void)
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
index 24ef6c562..eca660605 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
@@ -61,18 +61,8 @@ static struct tcase {
 
 static void verify_msgsnd(struct tcase *tc)
 {
-	TEST(msgsnd(*tc->id, tc->buffer, tc->msgsz, 0));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "smgsnd() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgsnd() failed unexpectedly,"
-			" expected %s", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL(msgsnd(*tc->id, tc->buffer, tc->msgsz, 0), tc->exp_err,
+		"msgsnd(%i, %p, %i, 0)", *tc->id, tc->buffer, tc->msgsz);
 }
 
 static void do_test(unsigned int n)
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
index ace32cdaa..f048fa698 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
@@ -41,18 +41,8 @@ static struct tcase {
 
 static void verify_msgsnd(struct tcase *tc)
 {
-	TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, tc->flag));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgsnd() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_err) {
-		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO, "msgsnd() failed unexpectedly,"
-			" expected %s", tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL(msgsnd(queue_id, &snd_buf, MSGSIZE, tc->flag), tc->exp_err,
+		"msgsnd(%i, %p, %i, %i)", queue_id, &snd_buf, MSGSIZE, tc->flag);
 }
 
 static void sighandler(int sig)
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
index 9f462b672..8fc665e68 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
@@ -28,18 +28,8 @@ static struct buf {
 
 static void verify_msgsnd(void)
 {
-	TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, 0));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "msgsnd() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR == EIDRM) {
-		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO,
-			"msgsnd() failed unexpectedly, expected EIDRM");
-	}
+	TST_EXP_FAIL(msgsnd(queue_id, &snd_buf, MSGSIZE, 0), EIDRM,
+		"msgsnd(%i, %p, %i, 0)", queue_id, &snd_buf, MSGSIZE);
 }
 
 static void do_test(void)
-- 
2.23.0


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

* [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro
  2021-06-29 10:44   ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro Yang Xu
  2021-06-29 10:44     ` [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or " Yang Xu
@ 2021-06-29 11:16     ` xuyang2018.jy
  2021-06-30 13:24       ` Cyril Hrubis
  1 sibling, 1 reply; 9+ messages in thread
From: xuyang2018.jy @ 2021-06-29 11:16 UTC (permalink / raw)
  To: ltp

Hi Cyril

When I do this patch, I found a tst_res usage problem in sendfile06.c.

see https://github.com/linux-test-project/ltp/runs/2933366481#step:10:3797

Best Regards
Yang Xu
> For these modified files, the return value is expected to be non-negative integer
> if call passes. So they should use TST_EXP_FAIL2 macro.
> 
> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
> ---
>   testcases/kernel/syscalls/accept/accept01.c             | 2 +-
>   testcases/kernel/syscalls/adjtimex/adjtimex02.c         | 2 +-
>   testcases/kernel/syscalls/io_getevents/io_getevents01.c | 3 ++-
>   testcases/kernel/syscalls/io_submit/io_submit03.c       | 2 +-
>   testcases/kernel/syscalls/open/open02.c                 | 2 +-
>   testcases/kernel/syscalls/open/open11.c                 | 2 +-
>   testcases/kernel/syscalls/recvmmsg/recvmmsg01.c         | 2 +-
>   testcases/kernel/syscalls/sendfile/sendfile03.c         | 2 +-
>   testcases/kernel/syscalls/sendfile/sendfile04.c         | 2 +-
>   9 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/accept/accept01.c b/testcases/kernel/syscalls/accept/accept01.c
> index 52234b792..85af0f8af 100644
> --- a/testcases/kernel/syscalls/accept/accept01.c
> +++ b/testcases/kernel/syscalls/accept/accept01.c
> @@ -97,7 +97,7 @@ void verify_accept(unsigned int nr)
>   {
>   	struct test_case *tcase =&tcases[nr];
> 
> -	TST_EXP_FAIL(accept(*tcase->fd, tcase->sockaddr,&tcase->salen),
> +	TST_EXP_FAIL2(accept(*tcase->fd, tcase->sockaddr,&tcase->salen),
>   	             tcase->experrno, "%s", tcase->desc);
>   }
> 
> diff --git a/testcases/kernel/syscalls/adjtimex/adjtimex02.c b/testcases/kernel/syscalls/adjtimex/adjtimex02.c
> index 5d8d7019b..747d83254 100644
> --- a/testcases/kernel/syscalls/adjtimex/adjtimex02.c
> +++ b/testcases/kernel/syscalls/adjtimex/adjtimex02.c
> @@ -110,7 +110,7 @@ static void verify_adjtimex(unsigned int i)
>   		}
>   	}
> 
> -	TST_EXP_FAIL(tv->adjtimex(bufp), tc[i].exp_err, "adjtimex() error");
> +	TST_EXP_FAIL2(tv->adjtimex(bufp), tc[i].exp_err, "adjtimex() error");
> 
>   	if (tc[i].exp_err == EPERM)
>   		SAFE_SETEUID(0);
> diff --git a/testcases/kernel/syscalls/io_getevents/io_getevents01.c b/testcases/kernel/syscalls/io_getevents/io_getevents01.c
> index 9dba4addf..e8a426ab6 100644
> --- a/testcases/kernel/syscalls/io_getevents/io_getevents01.c
> +++ b/testcases/kernel/syscalls/io_getevents/io_getevents01.c
> @@ -23,7 +23,8 @@ static void run(void)
>   	aio_context_t ctx;
> 
>   	memset(&ctx, 0, sizeof(ctx));
> -	TST_EXP_FAIL(tst_syscall(__NR_io_getevents, ctx, 0, 0, NULL, NULL), EINVAL);
> +	TST_EXP_FAIL2(tst_syscall(__NR_io_getevents, ctx, 0, 0, NULL, NULL), EINVAL,
> +		"io_getevents syscall with invalid ctx");
>   }
> 
>   static struct tst_test test = {
> diff --git a/testcases/kernel/syscalls/io_submit/io_submit03.c b/testcases/kernel/syscalls/io_submit/io_submit03.c
> index 052b0c8cc..90780c0e4 100644
> --- a/testcases/kernel/syscalls/io_submit/io_submit03.c
> +++ b/testcases/kernel/syscalls/io_submit/io_submit03.c
> @@ -103,7 +103,7 @@ static void cleanup(void)
> 
>   static void run(unsigned int i)
>   {
> -	TST_EXP_FAIL(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs),
> +	TST_EXP_FAIL2(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs),
>   		     tc[i].exp_errno, "io_submit() with %s", tc[i].desc);
>   }
> 
> diff --git a/testcases/kernel/syscalls/open/open02.c b/testcases/kernel/syscalls/open/open02.c
> index ca9839c2d..67bf423ae 100644
> --- a/testcases/kernel/syscalls/open/open02.c
> +++ b/testcases/kernel/syscalls/open/open02.c
> @@ -49,7 +49,7 @@ static void verify_open(unsigned int n)
>   {
>   	struct tcase *tc =&tcases[n];
> 
> -	TST_EXP_FAIL(open(tc->filename, tc->flag, 0444),
> +	TST_EXP_FAIL2(open(tc->filename, tc->flag, 0444),
>   	             tc->exp_errno, "open() %s", tc->desc);
>   }
> 
> diff --git a/testcases/kernel/syscalls/open/open11.c b/testcases/kernel/syscalls/open/open11.c
> index ded384fa8..3c3c11b84 100644
> --- a/testcases/kernel/syscalls/open/open11.c
> +++ b/testcases/kernel/syscalls/open/open11.c
> @@ -278,7 +278,7 @@ static struct test_case {
>   static void verify_open(unsigned int n)
>   {
>   	if (tc[n].err>  0) {
> -		TST_EXP_FAIL(open(tc[n].path, tc[n].flags, tc[n].mode),
> +		TST_EXP_FAIL2(open(tc[n].path, tc[n].flags, tc[n].mode),
>   		             tc[n].err, "%s", tc[n].desc);
>   	} else if (tc[n].err == 0) {
>   		TST_EXP_FD(open(tc[n].path, tc[n].flags, tc[n].mode),
> diff --git a/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c b/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
> index 10eaa3dcd..fb21ea1e7 100644
> --- a/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
> +++ b/testcases/kernel/syscalls/recvmmsg/recvmmsg01.c
> @@ -89,7 +89,7 @@ static void do_test(unsigned int i)
>   	else
>   		timeout = tst_ts_get(&ts);
> 
> -	TST_EXP_FAIL(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
> +	TST_EXP_FAIL2(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
>   	             tc->exp_errno, "recvmmsg() %s", tc->desc);
>   }
> 
> diff --git a/testcases/kernel/syscalls/sendfile/sendfile03.c b/testcases/kernel/syscalls/sendfile/sendfile03.c
> index dda651703..85a3b0f35 100644
> --- a/testcases/kernel/syscalls/sendfile/sendfile03.c
> +++ b/testcases/kernel/syscalls/sendfile/sendfile03.c
> @@ -50,7 +50,7 @@ static void cleanup(void)
> 
>   static void run(unsigned int i)
>   {
> -	TST_EXP_FAIL(sendfile(*(tc[i].out_fd), *(tc[i].in_fd), NULL, 1),
> +	TST_EXP_FAIL2(sendfile(*(tc[i].out_fd), *(tc[i].in_fd), NULL, 1),
>   		     EBADF, "sendfile(..) with %s", tc[i].desc);
>   }
> 
> diff --git a/testcases/kernel/syscalls/sendfile/sendfile04.c b/testcases/kernel/syscalls/sendfile/sendfile04.c
> index 8ebeb3c10..9a8ec08b9 100644
> --- a/testcases/kernel/syscalls/sendfile/sendfile04.c
> +++ b/testcases/kernel/syscalls/sendfile/sendfile04.c
> @@ -58,7 +58,7 @@ static void run(unsigned int i)
>   	if (tc[i].pass_unmapped_buffer)
>   		SAFE_MUNMAP(protected_buffer, sizeof(*protected_buffer));
> 
> -	TST_EXP_FAIL(sendfile(out_fd, in_fd, protected_buffer, 1),
> +	TST_EXP_FAIL2(sendfile(out_fd, in_fd, protected_buffer, 1),
>   		     EFAULT, "sendfile(..) with %s, protection=%d",
>   		     tc[i].desc, tc[i].protection);
> 

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

* [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro
  2021-06-29 11:16     ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate " xuyang2018.jy
@ 2021-06-30 13:24       ` Cyril Hrubis
  0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2021-06-30 13:24 UTC (permalink / raw)
  To: ltp

Hi!
> When I do this patch, I found a tst_res usage problem in sendfile06.c.
> 
> see https://github.com/linux-test-project/ltp/runs/2933366481#step:10:3797

Someone has put comma between % and the PRId64 which is obviously wrong.

Fixed in: 0880bf5aa757 (syscalls/sendfile06: Fix format string)

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or TST_EXP_FAIL2 macro
  2021-06-29 10:44     ` [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or " Yang Xu
@ 2021-06-30 14:27       ` Cyril Hrubis
  2021-07-01  1:28         ` xuyang2018.jy
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2021-06-30 14:27 UTC (permalink / raw)
  To: ltp

Hi!
> +	TST_EXP_FAIL(msgget(*tc->key, tc->flags), tc->exp_err, "msgget(%i, %i)",
> +		*tc->key, tc->flags);
>  }

I've changed this one to TST_EXP_FAIL2() since msgget() returns
non-negative integer on success and pushed the patchset, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or TST_EXP_FAIL2 macro
  2021-06-30 14:27       ` Cyril Hrubis
@ 2021-07-01  1:28         ` xuyang2018.jy
  0 siblings, 0 replies; 9+ messages in thread
From: xuyang2018.jy @ 2021-07-01  1:28 UTC (permalink / raw)
  To: ltp

Hi Cyril
> Hi!
>> +	TST_EXP_FAIL(msgget(*tc->key, tc->flags), tc->exp_err, "msgget(%i, %i)",
>> +		*tc->key, tc->flags);
>>   }
>
> I've changed this one to TST_EXP_FAIL2() since msgget() returns
> non-negative integer on success and pushed the patchset, thanks.
Oh, yes! I pasted from v1. Sorry for not changing this.

Best Regards
Yang Xu
>

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

end of thread, other threads:[~2021-07-01  1:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 10:12 [LTP] [RFC] syscalls/ipc: Make use of TST_EXP_FAIL macro Yang Xu
2021-06-22 10:58 ` Cyril Hrubis
2021-06-24  4:41   ` xuyang2018.jy
2021-06-29 10:44   ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate TST_EXP_FAIL2 macro Yang Xu
2021-06-29 10:44     ` [LTP] [PATCH v2 2/2] syscalls/ipc: Make use of TST_EXP_FAIL or " Yang Xu
2021-06-30 14:27       ` Cyril Hrubis
2021-07-01  1:28         ` xuyang2018.jy
2021-06-29 11:16     ` [LTP] [PATCH v2 1/2] syscalls: Use more accurate " xuyang2018.jy
2021-06-30 13:24       ` Cyril Hrubis

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.