* [LTP] [PATCH] syscalls/fstatfs:using temporary file description to test the system call
@ 2014-04-24 10:15 shuang.qiu
2014-04-25 10:55 ` Stanislav Kholmanskikh
0 siblings, 1 reply; 2+ messages in thread
From: shuang.qiu @ 2014-04-24 10:15 UTC (permalink / raw)
To: ltp-list
From: Shuang Qiu <shuang.qiu@oracle.com>
It does not make sense to use stdout as the file description to test the
system call fstatfs().We may get unexpected result(i.e. erron38:Function
not implemented) if redirect stdout when running ltp.
Using ltp temporary file instead.
Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com>
---
testcases/kernel/syscalls/fstatfs/fstatfs02.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/testcases/kernel/syscalls/fstatfs/fstatfs02.c b/testcases/kernel/syscalls/fstatfs/fstatfs02.c
index cee234f..652624b 100644
--- a/testcases/kernel/syscalls/fstatfs/fstatfs02.c
+++ b/testcases/kernel/syscalls/fstatfs/fstatfs02.c
@@ -47,6 +47,7 @@
#include <sys/vfs.h>
#include <sys/types.h>
+#include <sys/fcntl.h>
#include <sys/statfs.h>
#include <errno.h>
#include "test.h"
@@ -59,6 +60,8 @@ char *TCID = "fstatfs02";
int exp_enos[] = { EBADF, EFAULT, 0 };
+char fname[255];
+int fd;
struct statfs buf;
struct test_case_t {
@@ -91,6 +94,10 @@ int main(int ac, char **av)
setup();
+#ifndef UCLINUX
+ TC[1].fd = fd;
+#endif
+
/* set up the expected errnos */
TEST_EXP_ENOS(exp_enos);
@@ -138,6 +145,10 @@ void setup(void)
/* make a temporary directory and cd to it */
tst_tmpdir();
+
+ sprintf(fname, "tfile_%d", getpid());
+ if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1)
+ tst_brkm(TBROK | TERRNO, cleanup, "open failed");
}
/*
@@ -152,6 +163,9 @@ void cleanup(void)
*/
TEST_CLEANUP;
+ if (close(fd) == -1)
+ tst_resm(TWARN | TERRNO, "close failed");
+
/* delete the test directory created in setup() */
tst_rmdir();
--
1.7.7
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] syscalls/fstatfs:using temporary file description to test the system call
2014-04-24 10:15 [LTP] [PATCH] syscalls/fstatfs:using temporary file description to test the system call shuang.qiu
@ 2014-04-25 10:55 ` Stanislav Kholmanskikh
0 siblings, 0 replies; 2+ messages in thread
From: Stanislav Kholmanskikh @ 2014-04-25 10:55 UTC (permalink / raw)
To: shuang.qiu, ltp-list
Hi!
It would be nice to have a cleanup patch beforehand (static vars,
useless comments and etc).
I think It would be better to mark somehow inside definition of struct
test_case_t TC, that for the second test case we don't use '1' as the
file descriptor but use one opened on later.
And one small comment below.
On 04/24/2014 02:15 PM, shuang.qiu@oracle.com wrote:
> From: Shuang Qiu <shuang.qiu@oracle.com>
>
> It does not make sense to use stdout as the file description to test the
> system call fstatfs().We may get unexpected result(i.e. erron38:Function
> not implemented) if redirect stdout when running ltp.
> Using ltp temporary file instead.
>
> Signed-off-by: Shuang Qiu <shuang.qiu@oracle.com>
> ---
> testcases/kernel/syscalls/fstatfs/fstatfs02.c | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fstatfs/fstatfs02.c b/testcases/kernel/syscalls/fstatfs/fstatfs02.c
> index cee234f..652624b 100644
> --- a/testcases/kernel/syscalls/fstatfs/fstatfs02.c
> +++ b/testcases/kernel/syscalls/fstatfs/fstatfs02.c
> @@ -47,6 +47,7 @@
>
> #include <sys/vfs.h>
> #include <sys/types.h>
> +#include <sys/fcntl.h>
> #include <sys/statfs.h>
> #include <errno.h>
> #include "test.h"
> @@ -59,6 +60,8 @@ char *TCID = "fstatfs02";
>
> int exp_enos[] = { EBADF, EFAULT, 0 };
>
> +char fname[255];
> +int fd;
> struct statfs buf;
>
> struct test_case_t {
> @@ -91,6 +94,10 @@ int main(int ac, char **av)
>
> setup();
>
> +#ifndef UCLINUX
> + TC[1].fd = fd;
> +#endif
> +
Maybe move it inside setup()?
> /* set up the expected errnos */
> TEST_EXP_ENOS(exp_enos);
>
> @@ -138,6 +145,10 @@ void setup(void)
>
> /* make a temporary directory and cd to it */
> tst_tmpdir();
> +
> + sprintf(fname, "tfile_%d", getpid());
> + if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1)
> + tst_brkm(TBROK | TERRNO, cleanup, "open failed");
> }
>
> /*
> @@ -152,6 +163,9 @@ void cleanup(void)
> */
> TEST_CLEANUP;
>
> + if (close(fd) == -1)
> + tst_resm(TWARN | TERRNO, "close failed");
> +
> /* delete the test directory created in setup() */
> tst_rmdir();
>
>
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-25 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-24 10:15 [LTP] [PATCH] syscalls/fstatfs:using temporary file description to test the system call shuang.qiu
2014-04-25 10:55 ` Stanislav Kholmanskikh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox