[PATCH libinput v3] test: check getcwd() and system() return values in litest
Peter Hutterer
peter.hutterer at who-t.net
Mon Jun 1 18:53:43 PDT 2015
On Mon, Jun 01, 2015 at 06:04:59PM -0700, Jon A. Cruz wrote:
> Added code to check for errors in getcwd() and system() that
> were previously ignored and silently dropped.
>
> Signed-off-by: Jon A. Cruz <jonc at osg.samsung.com>
> ---
pushed, thanks. for next time, please add a section here with
Changes to v1:
- added blah
- fixed foo
etc. it'll get stripped out during git-am but focuses reviewer efforts
better.
thanks
Cheers,
Peter
> test/litest.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/test/litest.c b/test/litest.c
> index 30d3056..d457a27 100644
> --- a/test/litest.c
> +++ b/test/litest.c
> @@ -84,8 +84,10 @@ litest_backtrace_get_lineno(const char *executable,
> char *s;
> unsigned int i;
>
> - if (!cwd[0])
> - getcwd(cwd, sizeof(cwd));
> + if (!cwd[0]) {
> + if (getcwd(cwd, sizeof(cwd)) == NULL)
> + cwd[0] = 0; /* contents otherwise undefined. */
> + }
>
> sprintf (buffer,
> ADDR2LINE " -C -e %s -i %lx",
> @@ -375,7 +377,17 @@ static struct list all_tests;
> static void
> litest_reload_udev_rules(void)
> {
> - system("udevadm control --reload-rules");
> + int ret = system("udevadm control --reload-rules");
> + if (ret == -1) {
> + litest_abort_msg("Failed to execute: udevadm");
> + } else if (WIFEXITED(ret)) {
> + if (WEXITSTATUS(ret))
> + litest_abort_msg("udevadm failed with %d",
> + WEXITSTATUS(ret));
> + } else if (WIFSIGNALED(ret)) {
> + litest_abort_msg("udevadm terminated with signal %d",
> + WTERMSIG(ret));
> + }
> }
>
> static int
> --
> 2.1.0
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list