* [LTP] [PATCH 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT()
2021-04-19 2:38 [LTP] [PATCH 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros ice_yangxiao
@ 2021-04-19 2:38 ` ice_yangxiao
2021-04-19 4:43 ` [LTP] [PATCH 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros Xiao Yang
1 sibling, 0 replies; 3+ messages in thread
From: ice_yangxiao @ 2021-04-19 2:38 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>
---
testcases/kernel/syscalls/wait4/wait401.c | 10 +++-------
testcases/kernel/syscalls/waitpid/waitpid01.c | 12 +++++-------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/syscalls/wait4/wait401.c b/testcases/kernel/syscalls/wait4/wait401.c
index 07fb864f3..405b0e133 100644
--- a/testcases/kernel/syscalls/wait4/wait401.c
+++ b/testcases/kernel/syscalls/wait4/wait401.c
@@ -29,17 +29,13 @@ static void run(void)
exit(0);
}
- TEST(wait4(pid, &status, 0, &rusage));
- if (TST_RET == -1) {
- tst_res(TFAIL | TTERRNO, "wait4() failed");
- return;
- }
+ TST_EXP_PID_SILENT(wait4(pid, &status, 0, &rusage), "wait4()");
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..0c5096f4e 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,11 @@ 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 (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] 3+ messages in thread
* [LTP] [PATCH 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros
2021-04-19 2:38 [LTP] [PATCH 1/2] include/tst_test_macros.h: Add TST_EXP_PID and TST_EXP_PID_SILENT macros ice_yangxiao
2021-04-19 2:38 ` [LTP] [PATCH 2/2] syscalls/{wait401.c, waitpid01.c}: Take use of TST_EXP_PID_SILENT() ice_yangxiao
@ 2021-04-19 4:43 ` Xiao Yang
1 sibling, 0 replies; 3+ messages in thread
From: Xiao Yang @ 2021-04-19 4:43 UTC (permalink / raw)
To: ltp
Hi
Please ignore the patchset and see the latest v2.
Thanks,
Xiao Yang
On 4/19/21 10:38 AM, ice_yangxiao@163.com wrote:
> 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); \
^ permalink raw reply [flat|nested] 3+ messages in thread