[LTP] [PATCH 1/2] fchdir/fchdir01: Convert to new API
Li Wang
liwang@redhat.com
Mon Nov 8 08:18:13 CET 2021
> -void check_functionality(void)
> +static void verify_fchdir(void)
> {
> - char *buf = NULL;
> - char *dir;
> + if ((fd = open(TEST_DIR, O_RDONLY)) == -1)
>
If making use of SAFE_OPEN, then we can save time for the error
checking over and over again.
And better move this into setup() to make "-i x" happy.
Btw, plz remember to close the fd in cleanup().
I made some improvement work as below and pushed:
--- a/testcases/kernel/syscalls/fchdir/fchdir01.c
+++ b/testcases/kernel/syscalls/fchdir/fchdir01.c
@@ -17,19 +17,23 @@ static const char *TEST_DIR = "alpha";
static void verify_fchdir(void)
{
- if ((fd = open(TEST_DIR, O_RDONLY)) == -1)
- tst_brk(TBROK, "open of directory failed");
-
TST_EXP_PASS(fchdir(fd));
}
static void setup(void)
{
SAFE_MKDIR(TEST_DIR, MODES);
+ fd = SAFE_OPEN(TEST_DIR, O_RDONLY);
+}
+
+static void cleanup(void)
+{
+ SAFE_CLOSE(fd);
}
static struct tst_test test = {
.test_all = verify_fchdir,
.setup = setup,
+ .cleanup = cleanup,
.needs_tmpdir = 1,
};
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20211108/8351eb8f/attachment.htm>
More information about the ltp
mailing list