* [LTP] [PATCH] unshare01: add EINVAL check
@ 2025-03-12 9:28 lufei
2025-03-13 9:35 ` Petr Vorel
0 siblings, 1 reply; 2+ messages in thread
From: lufei @ 2025-03-12 9:28 UTC (permalink / raw)
To: ltp; +Cc: lufei
---
testcases/kernel/syscalls/unshare/unshare01.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/unshare/unshare01.c b/testcases/kernel/syscalls/unshare/unshare01.c
index 6e6315b11..ce1ed2e14 100644
--- a/testcases/kernel/syscalls/unshare/unshare01.c
+++ b/testcases/kernel/syscalls/unshare/unshare01.c
@@ -28,21 +28,30 @@
#include "config.h"
#ifdef HAVE_UNSHARE
+#define INV_FLAG 0x0123
+
static struct test_case_t {
int mode;
const char *desc;
+ const int eno;
} tc[] = {
- {CLONE_FILES, "CLONE_FILES"},
- {CLONE_FS, "CLONE_FS"},
- {CLONE_NEWNS, "CLONE_NEWNS"},
+ {CLONE_FILES, "CLONE_FILES", 0},
+ {CLONE_FS, "CLONE_FS", 0},
+ {CLONE_NEWNS, "CLONE_NEWNS", 0},
+ {INV_FLAG, "INV_FLAG", EINVAL},
};
static void run(unsigned int i)
{
pid_t pid = SAFE_FORK();
- if (pid == 0)
- TST_EXP_PASS(unshare(tc[i].mode), "unshare(%s)", tc[i].desc);
+
+ if (pid == 0) {
+ if (tc[i].eno)
+ TST_EXP_FAIL(unshare(tc[i].mode), tc[i].eno, "unshare(%s)", tc[i].desc);
+ else
+ TST_EXP_PASS(unshare(tc[i].mode), "unshare(%s)", tc[i].desc);
+ }
}
static struct tst_test test = {
--
2.39.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] unshare01: add EINVAL check
2025-03-12 9:28 [LTP] [PATCH] unshare01: add EINVAL check lufei
@ 2025-03-13 9:35 ` Petr Vorel
0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2025-03-13 9:35 UTC (permalink / raw)
To: lufei; +Cc: ltp
Hi lufei,
Please next time have a look on other tests, if the same thing is already
being tested or not. EINVAL is already tested in unshare02.c (as -1).
That's why is this patch not needed (if really high value should be tested,
which I don't think so, it should be in unshare02.c).
Also, we try to not mixing positive tests (e.g. CLONE_FILES) with negative ones
(e.g. EINVAL), we put negative to separate test.
> ---
> testcases/kernel/syscalls/unshare/unshare01.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
> diff --git a/testcases/kernel/syscalls/unshare/unshare01.c b/testcases/kernel/syscalls/unshare/unshare01.c
> index 6e6315b11..ce1ed2e14 100644
> --- a/testcases/kernel/syscalls/unshare/unshare01.c
> +++ b/testcases/kernel/syscalls/unshare/unshare01.c
> @@ -28,21 +28,30 @@
> #include "config.h"
> #ifdef HAVE_UNSHARE
> +#define INV_FLAG 0x0123
> +
> static struct test_case_t {
> int mode;
> const char *desc;
> + const int eno;
nit: "eno" is not much descriptive, we usually use exp_errno.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-13 9:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12 9:28 [LTP] [PATCH] unshare01: add EINVAL check lufei
2025-03-13 9:35 ` 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.