Commit e2c6abcb authored by Yicheng Qin's avatar Yicheng Qin Committed by Pavel Emelyanov

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: 's avatarYicheng Qin <yichengq@google.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent fdfaf0a7
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment