<div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
-void check_functionality(void)<br>
+static void verify_fchdir(void)<br>
{<br>
- char *buf = NULL;<br>
- char *dir;<br>
+ if ((fd = open(TEST_DIR, O_RDONLY)) == -1)<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">If making use of SAFE_OPEN, then we can save time for the error</div><div class="gmail_default">checking over and over again. </div><div class="gmail_default"><br></div><div class="gmail_default">And better move this into setup() to make "-i x" happy.</div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small">Btw, plz remember to close the fd in cleanup().</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I made some improvement work as below and pushed:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--- a/testcases/kernel/syscalls/fchdir/fchdir01.c<br>+++ b/testcases/kernel/syscalls/fchdir/fchdir01.c<br>@@ -17,19 +17,23 @@ static const char *TEST_DIR = "alpha";<br> <br> static void verify_fchdir(void)<br> {<br>- if ((fd = open(TEST_DIR, O_RDONLY)) == -1)<br>- tst_brk(TBROK, "open of directory failed");<br>-<br> TST_EXP_PASS(fchdir(fd));<br> }<br> <br> static void setup(void)<br> {<br> SAFE_MKDIR(TEST_DIR, MODES);<br>+ fd = SAFE_OPEN(TEST_DIR, O_RDONLY);<br>+}<br>+<br>+static void cleanup(void)<br>+{<br>+ SAFE_CLOSE(fd);<br> }<br> <br> static struct tst_test test = {<br> .test_all = verify_fchdir,<br> .setup = setup,<br>+ .cleanup = cleanup,<br> .needs_tmpdir = 1,<br> };<br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>