public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 2/2-updated] syscalls/fstatfs02: Using temporary file description to test the syscall
@ 2014-04-30 10:57 shuang.qiu
  2014-05-06 11:00 ` Stanislav Kholmanskikh
  0 siblings, 1 reply; 4+ messages in thread
From: shuang.qiu @ 2014-04-30 10:57 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.
errno=38: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 b243af3..88376a1 100644
--- a/testcases/kernel/syscalls/fstatfs/fstatfs02.c
+++ b/testcases/kernel/syscalls/fstatfs/fstatfs02.c
@@ -23,6 +23,7 @@
 
 #include <sys/vfs.h>
 #include <sys/types.h>
+#include <sys/fcntl.h>
 #include <sys/statfs.h>
 #include <errno.h>
 #include "test.h"
@@ -35,6 +36,7 @@ char *TCID = "fstatfs02";
 
 static int exp_enos[] = { EBADF, EFAULT, 0 };
 
+static char fname[255];
 static struct statfs buf;
 
 static struct test_case_t {
@@ -48,6 +50,7 @@ static struct test_case_t {
 #ifndef UCLINUX
 	    /* Skip since uClinux does not implement memory protection */
 	    /* EFAULT - address for buf is invalid */
+	    /* Use the init "1" as fd may cause unexpected ENOSYS error,will assign a tmp file later */
 	{
 	1, (void *)-1, EFAULT}
 #endif
@@ -109,11 +112,22 @@ static void setup(void)
 	TEST_PAUSE;
 
 	tst_tmpdir();
+
+#ifndef UCLINUX
+	sprintf(fname, "tfile_%d", getpid());
+	if ((TC[1].fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1)
+		tst_brkm(TBROK | TERRNO, cleanup, "open failed");
+#endif
 }
 
 static void cleanup(void)
 {
 	TEST_CLEANUP;
 
+#ifndef UCLINUX
+	if (close(TC[1].fd) == -1)
+		tst_resm(TWARN | TERRNO, "close failed");
+#endif
+
 	tst_rmdir();
 }
-- 
1.7.7


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-29 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30 10:57 [LTP] [PATCH 2/2-updated] syscalls/fstatfs02: Using temporary file description to test the syscall shuang.qiu
2014-05-06 11:00 ` Stanislav Kholmanskikh
2014-05-06 11:10   ` Stanislav Kholmanskikh
2014-05-29 11:56   ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox