<div dir="ltr"><div>From: Yicheng Qin <<a href="mailto:yichengq@google.com">yichengq@google.com</a>></div><div>Subject: [PATCH] test/zdtm/cwd00: add error checking to cleanup code</div><div><br></div><div>The checking helps debug unexpected failures.</div>
<div><br></div><div>The patch is useful to debug test failure. Chdir() may meet failure</div><div>if the process does not have enough permissioin. Then, it cannot</div><div>rename in-progress output file to output file. Finally, test script</div>
<div>cannot catch 'PASS' flag from the output file and record it as</div><div>failure. As the result, the test fails without any error message.</div><div><br></div><div>Signed-off-by: Yicheng Qin <<a href="mailto:yichengq@google.com">yichengq@google.com</a>></div>
<div>---</div><div> test/zdtm/live/static/cwd00.c | 11 +++++++++--</div><div> 1 file changed, 9 insertions(+), 2 deletions(-)</div><div><br></div><div>diff --git a/test/zdtm/live/static/cwd00.c b/test/zdtm/live/static/cwd00.c</div>
<div>index 49ed2e3..d8d0397 100644</div><div>--- a/test/zdtm/live/static/cwd00.c</div><div>+++ b/test/zdtm/live/static/cwd00.c</div><div>@@ -51,7 +51,14 @@ int main(int argc, char **argv)</div><div> else</div><div>
pass();</div><div> cleanup:</div><div>- chdir(cwd0); /* return to the initial dir before writing out results */</div><div>- rmdir(dirname);</div><div>+ /* return to the initial dir before writing out results */</div>
<div>+ if (chdir(cwd0)) {</div><div>+ err("can't change directory to %s: %m\n", cwd0);</div><div>+ exit(1);</div><div>+ }</div><div>+ if (rmdir(dirname)) {</div>
<div>+ err("can't remove directory %s: %m\n", dirname);</div><div>+ exit(1);</div><div>+ }</div><div> return 0;</div><div> }</div><div>-- </div><div>1.8.3</div><div><br>
</div></div>