[PATCH] tests: fix execve test
Dmitry V. Levin
ldv at altlinux.org
Tue Nov 10 16:52:01 UTC 2020
On Tue, Nov 10, 2020 at 07:38:34AM +0100, Sven Schnelle wrote:
> execve error code checking has changed which makes some of the
> assumption done in the test fail. Use the errno2name() helper
> to show the correct error code name.
Thanks, applied with the following change:
> Signed-off-by: Sven Schnelle <svens at stackframe.org>
> ---
> tests/execve.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/tests/execve.c b/tests/execve.c
> index db7206d8..4073af5f 100644
> --- a/tests/execve.c
> +++ b/tests/execve.c
> @@ -45,7 +45,7 @@ main(void)
> #else
> ", %p /* 5 vars, unterminated */"
> #endif
> - ") = -1 ENOENT (%m)\n",
> + ") = -1 %s (%m)\n",
> Q_FILENAME, q_argv[0], q_argv[1], q_argv[2],
> argv[3], argv[4], argv[5], (char *) tail_argv + sizeof(argv)
> #if VERBOSE
> @@ -54,7 +54,7 @@ main(void)
> #else
> , tail_envp
> #endif
> - );
> + , errno2name());
>
> tail_argv[ARRAY_SIZE(q_argv)] = NULL;
> tail_envp[ARRAY_SIZE(q_envp)] = NULL;
> @@ -67,14 +67,14 @@ main(void)
> #else
> ", %p /* 2 vars */"
> #endif
> - ") = -1 ENOENT (%m)\n",
> + ") = -1 %s (%m)\n",
> Q_FILENAME, q_argv[0], q_argv[1], q_argv[2]
> #if VERBOSE
> , q_envp[0], q_envp[1]
> #else
> , tail_envp
> #endif
> - );
> + , errno2name());
>
> execve(FILENAME, tail_argv + 2, tail_envp + 1);
> printf("execve(\"%s\", [\"%s\"]"
> @@ -83,14 +83,14 @@ main(void)
> #else
> ", %p /* 1 var */"
> #endif
> - ") = -1 ENOENT (%m)\n",
> + ") = -1 %s (%m)\n",
> Q_FILENAME, q_argv[2]
> #if VERBOSE
> , q_envp[1]
> #else
> , tail_envp + 1
> #endif
> - );
> + , errno2name());
>
> TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty);
> char **const efault = empty + 1;
> @@ -103,11 +103,11 @@ main(void)
> #else
> ", %p /* 0 vars */"
> #endif
> - ") = -1 ENOENT (%m)\n", Q_FILENAME
> + ") = -1 %s (%m)\n", Q_FILENAME
> #if !VERBOSE
> , empty
> #endif
> - );
> + , errno2name());
>
> char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
> fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
> @@ -143,7 +143,7 @@ main(void)
> #else
> printf("], %p /* %u vars */", b, DEFAULT_STRLEN + 1);
> #endif
> - printf(") = -1 ENOENT (%m)\n");
> + printf(") = -1 %s (%m)\n", errno2name());
>
> execve(FILENAME, a + 1, b + 1);
> printf("execve(\"%s\", [\"%s\"", Q_FILENAME, a[1]);
> @@ -157,15 +157,15 @@ main(void)
> #else
> printf("], %p /* %d vars */", b + 1, DEFAULT_STRLEN);
> #endif
> - printf(") = -1 ENOENT (%m)\n");
> + printf(") = -1 %s (%m)\n", errno2name());
>
> execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
> - printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n",
> - Q_FILENAME, efault);
> + printf("execve(\"%s\", NULL, %p) = -1 %s (%m)\n",
> + Q_FILENAME, efault, errno2name());
>
> execve(FILENAME, efault, NULL);
> - printf("execve(\"%s\", %p, NULL) = -1 ENOENT (%m)\n",
> - Q_FILENAME, efault);
> + printf("execve(\"%s\", %p, NULL) = -1 %s (%m)\n",
> + Q_FILENAME, efault, errno2name());
>
> return 0;
> }
In those cases where the expected output is printed using several printf
statements, the first of them may clobber errno.
I've introduced a wrapper around execve that saves the error string using
sprintrc(), and the saved string is used later in printf statements.
--
ldv
More information about the Strace-devel
mailing list