[CRIU] test/zdtm/cwd00: add error checking to cleanup code
Yicheng Qin
yichengq at google.com
Tue Aug 6 19:48:23 EDT 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20130806/4d1213b7/attachment.html>
More information about the CRIU
mailing list