From e2c6abcb6a8d4cb3bbcb07f431f42f213e16745d Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Wed, 7 Aug 2013 12:45:06 +0400 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 Acked-by: Andrew Vagin Signed-off-by: Pavel Emelyanov --- 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 49ed2e387..d8d039704 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; }