[CRIU] test/zdtm/cwd00: add error checking to cleanup code

Andrew Vagin avagin at parallels.com
Wed Aug 7 04:08:10 EDT 2013


Ack for the last five patches. Thanks.

Acked-by: Andrew Vagin <avagin at parallels.com>

On Tue, Aug 06, 2013 at 04:48:23PM -0700, Yicheng Qin wrote:
> From: Yicheng Qin <yichengq at google.com>
> Subject: [PATCH] test/zdtm/cwd00: add error checking to cleanup code
> 
> The checking helps debug unexpected failures.
> 
> The patch is useful to debug test failure. Chdir() may meet failure
> if the process does not have enough permissioin. Then, it cannot
> rename in-progress output file to output file. Finally, test script
> cannot catch 'PASS' flag from the output file and record it as
> failure. As the result, the test fails without any error message.
> 
> Signed-off-by: Yicheng Qin <yichengq at google.com>
> ---
>  test/zdtm/live/static/cwd00.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/test/zdtm/live/static/cwd00.c b/test/zdtm/live/static/cwd00.c
> index 49ed2e3..d8d0397 100644
> --- a/test/zdtm/live/static/cwd00.c
> +++ b/test/zdtm/live/static/cwd00.c
> @@ -51,7 +51,14 @@ int main(int argc, char **argv)
>         else
>                 pass();
>  cleanup:
> -       chdir(cwd0);    /* return to the initial dir before writing out results
> */
> -       rmdir(dirname);
> +       /* return to the initial dir before writing out results */
> +       if (chdir(cwd0)) {
> +               err("can't change directory to %s: %m\n", cwd0);
> +               exit(1);
> +       }
> +       if (rmdir(dirname)) {
> +               err("can't remove directory %s: %m\n", dirname);
> +               exit(1);
> +       }
>         return 0;
>  }
> -- 
> 1.8.3
> 

> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu



More information about the CRIU mailing list