public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [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

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