From: Shuang Qiu <[email protected]>

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 <[email protected]>
---
 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to