mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 09:39:13 +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:
parent
fdfaf0a769
commit
e2c6abcb6a
1 changed files with 9 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue