On Tue, 2014-03-11 at 16:43 +0100, [email protected] wrote:
> Hi!
> > open10 open10
> > open11 open11
> > +open12 open12 -F $LTPROOT/testcases/bin/test_cloexec
>
> This is not the way we treat subexecutables. See paragraph 2.1.3 in
> Test-Writing-Guidelines.
>
> https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines
>
OK. Thank you.
> > + fd = SAFE_OPEN(cleanup, TEST_FILE, O_WRONLY | O_CREAT, 0777);
> > + SAFE_WRITE(cleanup, 1, fd, TEST_FILE, sizeof(TEST_FILE));
> > + SAFE_CLOSE(cleanup, fd);
>
> What about SAFE_FILE_PRINTF(cleanup, TEST_FILE, TEST_FILE); ?
>
OK.
> > +}
> > + "or higher");
> > + return;
> > + }
>
> We should check here that test temp dir is mounted noatime, which would
> invalidate this test because all files are opened noatime.
>
OK.
> I've looked at a few systems and it seems that filesystems are mounted
> relatime these days, which sometimes updates the access time. Which
> makes this a bit more complicated.
>
Thank you.
> > + SAFE_STAT(cleanup, TEST_FILE, &orignal);
> > +
> > + fd = SAFE_OPEN(cleanup, TEST_FILE, O_RDONLY | O_NOATIME);
> > + sleep(1);
> > + SAFE_READ(cleanup, 1, fd, &read_buf, 1);
> > + SAFE_CLOSE(cleanup, fd);
> > + SAFE_STAT(cleanup, TEST_FILE, &flag);
>
> This order is a bit confusing. I would add the sleep() right after the
> first stat so that it's clear that we do stat() then wait, then read()
> then stat() again and that we expect these two values to be the same.
>
OK. Got it.
> > + fd = SAFE_OPEN(cleanup, TEST_FILE, O_RDONLY);
> > +
> > + pid = fork();
>
> Use tst_fork() please.
>
OK.
> > + if (pid < 0)
> > + tst_brkm(TBROK, cleanup, "fork() failed");
> > +
> > + if (pid == 0) {
> > + if (execl(test_app, "test", &fd2, "test O_CLOEXEC\n", NULL)) {
> ^
> This is completly wrong, you
> are passing pointer to fd2
> as a string to the execl()
> function
>
>
> What you should do instead is to snprintf() the value into a string
> buffer and pass that, then convert the value back to integer in the
> process atoi(argv[1]) should suffice.
>
OK.
> Also please pass something more usefull as the first arg. The whole name
> of the binary would be better.
>
How about open12_cloexec.
> > + printf("execl() error\n");
> > + exit(-2);
> > + }
> > + }
> > +
> > + SAFE_CLOSE(cleanup, fd2);
> > +
> > + if (wait(&status) != pid)
> > + tst_resm(TBROK | TERRNO, "wait() error");
> > +
> > + if (WIFEXITED(status) && (char)WEXITSTATUS(status) == -1)
> > + tst_resm(TPASS, "open(%s, O_CLOEXEC) test success", TEST_FILE);
> > + else
> > + tst_resm(TFAIL, "open(%s, O_CLOEXEC) test failed", TEST_FILE);
> > +}
> > +static void cleanup(void)
> > +{
> > + TEST_CLEANUP;
> > +
> > + tst_rmdir();
> > +}
> > +
> > +static void help(void)
> > +{
> > + printf(" -F <test file> : for example, 'open12 -F test'\n");
> > +}
> > diff --git a/testcases/kernel/syscalls/open/test_cloexec.c
> > b/testcases/kernel/syscalls/open/test_cloexec.c
> > new file mode 100644
> > index 0000000..c045cca
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/open/test_cloexec.c
> > @@ -0,0 +1,33 @@
> > +/*
> > + * Copyright (c) 2014 Fujitsu Ltd.
> > + * Author: Zeng Linggang <[email protected]>
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms of version 2 of the GNU General Public License as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it would be useful, but
> > + * WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> > + *
> > + * You should have received a copy of the GNU General Public License along
> > + * with this program.
> > + */
> > +
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <string.h>
> > +#include <errno.h>
> > +#include <unistd.h>
> > +
> > +int main(int argc, char **argv)
> > +{
> > + int ret;
> > +
> > + if (argc != 3)
> > + printf("Only three arguments: %s fd str", argv[0]);
> ^
> This should be two arguments
Got it.
> > + ret = write((int)(*argv[1]), argv[2], strlen(argv[2]));
> > +
> > + exit(ret);
> > +}
> > --
> > 1.8.4.2
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list