mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
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@google.com> Acked-by: Andrew Vagin <avagin@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
fdfaf0a769
commit
e2c6abcb6a
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user