* [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS()
@ 2024-11-12 23:35 Petr Vorel
2024-11-12 23:35 ` [LTP] [PATCH 2/2] kcmp02: Use TST_EXP_FAIL + print more info Petr Vorel
2024-12-03 13:00 ` [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS() Cyril Hrubis
0 siblings, 2 replies; 5+ messages in thread
From: Petr Vorel @ 2024-11-12 23:35 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/syscalls/kcmp/kcmp03.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
index 4ae6e02953..37d5118d55 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp03.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
@@ -30,14 +30,16 @@ static int pid1;
static int pid2;
static void *stack;
+#define ARGS(x, y) .clone_type = x, .kcmp_type = y, .desc = #x ", " #y
static struct tcase {
int clone_type;
int kcmp_type;
+ char *desc;
} tcases[] = {
- {CLONE_VM, KCMP_VM},
- {CLONE_FS, KCMP_FS},
- {CLONE_IO, KCMP_IO},
- {CLONE_SYSVSEM, KCMP_SYSVSEM}
+ {ARGS(CLONE_VM, KCMP_VM)},
+ {ARGS(CLONE_FS, KCMP_FS)},
+ {ARGS(CLONE_IO, KCMP_IO)},
+ {ARGS(CLONE_SYSVSEM, KCMP_SYSVSEM)}
};
static void setup(void)
@@ -53,28 +55,17 @@ static void cleanup(void)
static int do_child(void *arg)
{
pid2 = getpid();
-
- TEST(kcmp(pid1, pid2, *(int *)arg, 0, 0));
- if (TST_RET == -1) {
- tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
- return 0;
- }
-
- if (TST_RET == 0)
- tst_res(TPASS, "kcmp() returned the expected value");
- else
- tst_res(TFAIL, "kcmp() returned the unexpected value");
-
+ TST_EXP_PASS(kcmp(pid1, pid2, *(int *)arg, 0, 0));
return 0;
}
static void verify_kcmp(unsigned int n)
{
int res;
-
struct tcase *tc = &tcases[n];
pid1 = getpid();
+ tst_res(TINFO, "Testing %s", tc->desc);
res = ltp_clone(tc->clone_type | SIGCHLD, do_child, &tc->kcmp_type,
STACK_SIZE, stack);
--
2.45.2
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 2/2] kcmp02: Use TST_EXP_FAIL + print more info
2024-11-12 23:35 [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS() Petr Vorel
@ 2024-11-12 23:35 ` Petr Vorel
2024-12-03 13:07 ` Cyril Hrubis
2024-12-03 13:00 ` [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS() Cyril Hrubis
1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2024-11-12 23:35 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/syscalls/kcmp/kcmp02.c | 35 +++++++++----------------
1 file changed, 12 insertions(+), 23 deletions(-)
diff --git a/testcases/kernel/syscalls/kcmp/kcmp02.c b/testcases/kernel/syscalls/kcmp/kcmp02.c
index c9481206b4..d5696b70c3 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp02.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp02.c
@@ -37,20 +37,22 @@ static int fd_fake = -1;
#include <sys/wait.h>
#include <limits.h>
+#define TYPE_DESC(x) .type = x, .desc = #x
static struct test_case {
int *pid1;
int *pid2;
int type;
+ char *desc;
int *fd1;
int *fd2;
int exp_errno;
} test_cases[] = {
- {&pid1, &pid_unused, KCMP_FILE, &fd1, &fd2, ESRCH},
- {&pid1, &pid1, KCMP_TYPES + 1, &fd1, &fd2, EINVAL},
- {&pid1, &pid1, -1, &fd1, &fd2, EINVAL},
- {&pid1, &pid1, INT_MIN, &fd1, &fd2, EINVAL},
- {&pid1, &pid1, INT_MAX, &fd1, &fd2, EINVAL},
- {&pid1, &pid1, KCMP_FILE, &fd1, &fd_fake, EBADF}
+ {&pid1, &pid_unused, TYPE_DESC(KCMP_FILE), &fd1, &fd2, ESRCH},
+ {&pid1, &pid1, TYPE_DESC(KCMP_TYPES + 1), &fd1, &fd2, EINVAL},
+ {&pid1, &pid1, TYPE_DESC(-1), &fd1, &fd2, EINVAL},
+ {&pid1, &pid1, TYPE_DESC(INT_MIN), &fd1, &fd2, EINVAL},
+ {&pid1, &pid1, TYPE_DESC(INT_MAX), &fd1, &fd2, EINVAL},
+ {&pid1, &pid1, TYPE_DESC(KCMP_FILE), &fd1, &fd_fake, EBADF}
};
static void setup(void)
@@ -73,24 +75,11 @@ static void cleanup(void)
static void verify_kcmp(unsigned int n)
{
- struct test_case *test = &test_cases[n];
+ struct test_case *tc = &test_cases[n];
- TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
- *(test->fd1), *(test->fd2)));
-
- if (TST_RET != -1) {
- tst_res(TFAIL, "kcmp() succeeded unexpectedly");
- return;
- }
-
- if (test->exp_errno == TST_ERR) {
- tst_res(TPASS | TTERRNO, "kcmp() returned the expected value");
- return;
- }
-
- tst_res(TFAIL | TTERRNO,
- "kcmp() got unexpected return value: expected: %d - %s",
- test->exp_errno, tst_strerrno(test->exp_errno));
+ TST_EXP_FAIL(kcmp(*(tc->pid1), *(tc->pid2), tc->type,
+ *(tc->fd1), *(tc->fd2)), tc->exp_errno, "kcmp(%d,%d,%s,%d,%d)",
+ *tc->pid1, *tc->pid2, tc->desc, *tc->fd1, *tc->fd2);
}
static struct tst_test test = {
--
2.45.2
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS()
2024-11-12 23:35 [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS() Petr Vorel
2024-11-12 23:35 ` [LTP] [PATCH 2/2] kcmp02: Use TST_EXP_FAIL + print more info Petr Vorel
@ 2024-12-03 13:00 ` Cyril Hrubis
1 sibling, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2024-12-03 13:00 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 2/2] kcmp02: Use TST_EXP_FAIL + print more info
2024-11-12 23:35 ` [LTP] [PATCH 2/2] kcmp02: Use TST_EXP_FAIL + print more info Petr Vorel
@ 2024-12-03 13:07 ` Cyril Hrubis
2024-12-03 13:42 ` Petr Vorel
0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2024-12-03 13:07 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 2/2] kcmp02: Use TST_EXP_FAIL + print more info
2024-12-03 13:07 ` Cyril Hrubis
@ 2024-12-03 13:42 ` Petr Vorel
0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2024-12-03 13:42 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
merged. Thanks for your review!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-03 13:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12 23:35 [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS() Petr Vorel
2024-11-12 23:35 ` [LTP] [PATCH 2/2] kcmp02: Use TST_EXP_FAIL + print more info Petr Vorel
2024-12-03 13:07 ` Cyril Hrubis
2024-12-03 13:42 ` Petr Vorel
2024-12-03 13:00 ` [LTP] [PATCH 1/2] kcmp03: Use TST_EXP_PASS() Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox