* [LTP] [PATCH] execve: Add negative test for execve
@ 2024-04-16 8:01 Yang Xu via ltp
2024-08-21 10:30 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Yang Xu via ltp @ 2024-04-16 8:01 UTC (permalink / raw)
To: ltp
Add negative case for execve, when errno is ELOOP
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/execve/.gitignore | 1 +
testcases/kernel/syscalls/execve/execve07.c | 51 +++++++++++++++++++++
3 files changed, 53 insertions(+)
create mode 100644 testcases/kernel/syscalls/execve/execve07.c
diff --git a/runtest/syscalls b/runtest/syscalls
index cb2c001a0..9578e991a 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -210,6 +210,7 @@ execve03 execve03
execve04 execve04
execve05 execve05 -i 5 -n 32
execve06 execve06
+execve07 execve07
execvp01 execvp01
execveat01 execveat01
execveat02 execveat02
diff --git a/testcases/kernel/syscalls/execve/.gitignore b/testcases/kernel/syscalls/execve/.gitignore
index fee81faf7..881f75486 100644
--- a/testcases/kernel/syscalls/execve/.gitignore
+++ b/testcases/kernel/syscalls/execve/.gitignore
@@ -7,3 +7,4 @@
/execve06
/execve06_child
/execve_child
+/execve07
diff --git a/testcases/kernel/syscalls/execve/execve07.c b/testcases/kernel/syscalls/execve/execve07.c
new file mode 100644
index 000000000..6571846b9
--- /dev/null
+++ b/testcases/kernel/syscalls/execve/execve07.c
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that execve(2) fails with
+ *
+ * - ELOOP when too many symbolic links are encountered in filename
+ */
+
+#include "tst_test.h"
+
+#define TEST_ELOOP "test_eloop"
+#define TEST_ELOOP2 "test_eloop2"
+
+static struct test_case_t {
+ char *filename;
+ int expected_errno;
+ int user;
+ char *desc;
+} tcases[] = {
+ {TEST_ELOOP, ELOOP, 0,
+ "too many symbolic links are encountered in filename"},
+};
+
+static void setup(void)
+{
+ SAFE_SYMLINK(TEST_ELOOP, TEST_ELOOP2);
+ SAFE_SYMLINK(TEST_ELOOP2, TEST_ELOOP);
+}
+
+static void verify_execve(unsigned int i)
+{
+ struct test_case_t *tc = &tcases[i];
+ char *argv[2] = {tc->filename, NULL};
+
+ TST_EXP_FAIL(execve(tc->filename, argv, NULL), tc->expected_errno,
+ "%s", tc->desc);
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .tcnt = ARRAY_SIZE(tcases),
+ .test = verify_execve,
+ .needs_tmpdir = 1,
+ .needs_root = 1,
+};
--
2.39.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH] execve: Add negative test for execve
2024-04-16 8:01 [LTP] [PATCH] execve: Add negative test for execve Yang Xu via ltp
@ 2024-08-21 10:30 ` Cyril Hrubis
2024-10-21 12:52 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2024-08-21 10:30 UTC (permalink / raw)
To: Yang Xu; +Cc: ltp
Hi!
> +/*\
> + * [Description]
> + *
> + * Verify that execve(2) fails with
> + *
> + * - ELOOP when too many symbolic links are encountered in filename
> + */
> +
> +#include "tst_test.h"
> +
> +#define TEST_ELOOP "test_eloop"
> +#define TEST_ELOOP2 "test_eloop2"
> +
> +static struct test_case_t {
> + char *filename;
> + int expected_errno;
> + int user;
> + char *desc;
> +} tcases[] = {
> + {TEST_ELOOP, ELOOP, 0,
> + "too many symbolic links are encountered in filename"},
> +};
> +
> +static void setup(void)
> +{
> + SAFE_SYMLINK(TEST_ELOOP, TEST_ELOOP2);
> + SAFE_SYMLINK(TEST_ELOOP2, TEST_ELOOP);
> +}
> +
> +static void verify_execve(unsigned int i)
> +{
> + struct test_case_t *tc = &tcases[i];
> + char *argv[2] = {tc->filename, NULL};
> +
> + TST_EXP_FAIL(execve(tc->filename, argv, NULL), tc->expected_errno,
> + "%s", tc->desc);
> +}
> +
> +static struct tst_test test = {
> + .setup = setup,
> + .tcnt = ARRAY_SIZE(tcases),
> + .test = verify_execve,
> + .needs_tmpdir = 1,
> + .needs_root = 1,
> +};
Any reason why this isn't added to execve03.c instead?
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-21 12:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16 8:01 [LTP] [PATCH] execve: Add negative test for execve Yang Xu via ltp
2024-08-21 10:30 ` Cyril Hrubis
2024-10-21 12:52 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox