* [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros
@ 2021-04-19 4:41 ice_yangxiao
2021-04-19 4:41 ` [LTP] [PATCH v2 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT() ice_yangxiao
2021-04-19 8:49 ` [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros Cyril Hrubis
0 siblings, 2 replies; 5+ messages in thread
From: ice_yangxiao @ 2021-04-19 4:41 UTC (permalink / raw)
To: ltp
From: Xiao Yang <yangx.jy@fujitsu.com>
Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
include/tst_test_macros.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 189891507..101ac2c87 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -77,6 +77,17 @@ extern void *TST_RET_PTR;
#SCALL, ##__VA_ARGS__); \
} while (0)
+#define TST_EXP_PID_SILENT(SCALL, ...) TST_EXP_FD_SILENT(SCALL, __VA_ARGS__)
+
+#define TST_EXP_PID(SCALL, ...) \
+ do { \
+ TST_EXP_PID_SILENT(SCALL, __VA_ARGS__); \
+ \
+ if (TST_PASS) \
+ TST_MSGP_(TPASS, " returned pid %ld", TST_RET, \
+ #SCALL, ##__VA_ARGS__); \
+ } while (0)
+
#define TST_EXP_PASS_SILENT(SCALL, ...) \
do { \
TEST(SCALL); \
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH v2 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT()
2021-04-19 4:41 [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros ice_yangxiao
@ 2021-04-19 4:41 ` ice_yangxiao
2021-04-19 8:55 ` Cyril Hrubis
2021-04-19 8:49 ` [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros Cyril Hrubis
1 sibling, 1 reply; 5+ messages in thread
From: ice_yangxiao @ 2021-04-19 4:41 UTC (permalink / raw)
To: ltp
From: Xiao Yang <yangx.jy@fujitsu.com>
Also correct the name(waitpid=>wait4) in the output of wait401.
Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
V1->V2:
Return immediately if TST_PASS == 0
testcases/kernel/syscalls/wait4/wait401.c | 10 ++++------
testcases/kernel/syscalls/waitpid/waitpid01.c | 14 +++++++-------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/testcases/kernel/syscalls/wait4/wait401.c b/testcases/kernel/syscalls/wait4/wait401.c
index 07fb864f3..ab99891be 100644
--- a/testcases/kernel/syscalls/wait4/wait401.c
+++ b/testcases/kernel/syscalls/wait4/wait401.c
@@ -29,17 +29,15 @@ static void run(void)
exit(0);
}
- TEST(wait4(pid, &status, 0, &rusage));
- if (TST_RET == -1) {
- tst_res(TFAIL | TTERRNO, "wait4() failed");
+ TST_EXP_PID_SILENT(wait4(pid, &status, 0, &rusage), "wait4()");
+ if (!TST_PASS)
return;
- }
if (TST_RET != pid) {
- tst_res(TFAIL, "waitpid() returned wrong pid %li, expected %i",
+ tst_res(TFAIL, "wait4() returned wrong pid %li, expected %i",
TST_RET, pid);
} else {
- tst_res(TPASS, "waitpid() returned correct pid %i", pid);
+ tst_res(TPASS, "wait4() returned correct pid %i", pid);
}
if (!WIFEXITED(status)) {
diff --git a/testcases/kernel/syscalls/waitpid/waitpid01.c b/testcases/kernel/syscalls/waitpid/waitpid01.c
index 6e03acef6..5a39a1107 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid01.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid01.c
@@ -18,7 +18,7 @@
static void run(void)
{
- pid_t pid, rpid;
+ pid_t pid;
int status;
pid = SAFE_FORK();
@@ -27,13 +27,13 @@ static void run(void)
exit(0);
}
- rpid = waitpid(pid, &status, 0);
- if (rpid < 0)
- tst_brk(TBROK | TERRNO, "waitpid() failed");
+ TST_EXP_PID_SILENT(waitpid(pid, &status, 0));
+ if (!TST_PASS)
+ return;
- if (rpid != pid) {
- tst_res(TFAIL, "waitpid() returned wrong pid %i, expected %i",
- rpid, pid);
+ if (TST_RET != pid) {
+ tst_res(TFAIL, "waitpid() returned wrong pid %li, expected %i",
+ TST_RET, pid);
} else {
tst_res(TPASS, "waitpid() returned correct pid %i", pid);
}
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros
2021-04-19 4:41 [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros ice_yangxiao
2021-04-19 4:41 ` [LTP] [PATCH v2 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT() ice_yangxiao
@ 2021-04-19 8:49 ` Cyril Hrubis
2021-04-19 10:17 ` Xiao Yang
1 sibling, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2021-04-19 8:49 UTC (permalink / raw)
To: ltp
Hi!
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---
> include/tst_test_macros.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index 189891507..101ac2c87 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -77,6 +77,17 @@ extern void *TST_RET_PTR;
> #SCALL, ##__VA_ARGS__); \
> } while (0)
>
> +#define TST_EXP_PID_SILENT(SCALL, ...) TST_EXP_FD_SILENT(SCALL, __VA_ARGS__)
Maybe we should rename the TST_EXP_FD_SILENT() to TST_EXP_POSITIVE() and
then define both TST_EXP_PID_SILENT() and TST_EXP_FD_SILENT() based on
TST_EXP_POSITIVE(), but that's very minor.
Looks good to me:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> +#define TST_EXP_PID(SCALL, ...) \
> + do { \
> + TST_EXP_PID_SILENT(SCALL, __VA_ARGS__); \
> + \
> + if (TST_PASS) \
> + TST_MSGP_(TPASS, " returned pid %ld", TST_RET, \
> + #SCALL, ##__VA_ARGS__); \
> + } while (0)
> +
> #define TST_EXP_PASS_SILENT(SCALL, ...) \
> do { \
> TEST(SCALL); \
> --
> 2.26.2
>
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH v2 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT()
2021-04-19 4:41 ` [LTP] [PATCH v2 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT() ice_yangxiao
@ 2021-04-19 8:55 ` Cyril Hrubis
0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2021-04-19 8:55 UTC (permalink / raw)
To: ltp
Hi!
Reviwed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros
2021-04-19 8:49 ` [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros Cyril Hrubis
@ 2021-04-19 10:17 ` Xiao Yang
0 siblings, 0 replies; 5+ messages in thread
From: Xiao Yang @ 2021-04-19 10:17 UTC (permalink / raw)
To: ltp
Hi Cyril,
Thanks, pushed with your suggestion(use TST_EXP_POSITIVE).
Best Regards,
Xiao Yang
On 4/19/21 4:49 PM, Cyril Hrubis wrote:
> Maybe we should rename the TST_EXP_FD_SILENT() to TST_EXP_POSITIVE() and
> then define both TST_EXP_PID_SILENT() and TST_EXP_FD_SILENT() based on
> TST_EXP_POSITIVE(), but that's very minor.
>
> Looks good to me:
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-19 10:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-19 4:41 [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros ice_yangxiao
2021-04-19 4:41 ` [LTP] [PATCH v2 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT() ice_yangxiao
2021-04-19 8:55 ` Cyril Hrubis
2021-04-19 8:49 ` [LTP] [PATCH v2 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros Cyril Hrubis
2021-04-19 10:17 ` Xiao Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox