All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] diotest4/fcntl16: Skip some dio/fcntl cases on NFS
       [not found] <2123230838.18328229.1407740231363.JavaMail.zimbra@redhat.com>
@ 2014-08-11  6:57 ` Xiong Zhou
  2014-08-11 15:08   ` Stanislav Kholmanskikh
  0 siblings, 1 reply; 2+ messages in thread
From: Xiong Zhou @ 2014-08-11  6:57 UTC (permalink / raw)
  To: ltp-list

According to description of NFS and directIO in open(2), especially
"The Linux NFS client places no alignment restrictions on
O_DIRECT I/O", ignore some FAILs in diotest4.

According to nfs(5), NLM supports advisory file locks only. So skip
fcntl16 test if NFS.

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
---
 testcases/kernel/io/direct_io/diotest4.c  | 14 ++++++++++----
 testcases/kernel/syscalls/fcntl/fcntl16.c |  8 ++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/io/direct_io/diotest4.c b/testcases/kernel/io/direct_io/diotest4.c
index 10281bf..506e34c 100644
--- a/testcases/kernel/io/direct_io/diotest4.c
+++ b/testcases/kernel/io/direct_io/diotest4.c
@@ -71,9 +71,11 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "tst_fs_type.h"
 
 char *TCID = "diotest4";	/* Test program identifier.    */
 int TST_TOTAL = 17;		/* Total number of test conditions */
+int NO_NFS = 1;			/* Test on NFS or not */
 
 #ifdef O_DIRECT
 
@@ -106,7 +108,7 @@ runtest_f(int fd, char *buf, int offset, int count, int errnum, int testnum,
 		}
 	} else {
 		ret = read(fd, buf, count);
-		if (ret >= 0 || errno != errnum) {
+		if ((ret >= 0 || errno != errnum) && NO_NFS) {
 			tst_resm(TFAIL, "read allows %s. returns %d: %s",
 				 msg, ret, strerror(errno));
 			l_fail = TRUE;
@@ -120,7 +122,7 @@ runtest_f(int fd, char *buf, int offset, int count, int errnum, int testnum,
 		}
 	} else {
 		ret = write(fd, buf, count);
-		if (ret >= 0 || errno != errnum) {
+		if ((ret >= 0 || errno != errnum) && NO_NFS) {
 			tst_resm(TFAIL, "write allows %s.returns %d: %s",
 				 msg, ret, strerror(errno));
 			l_fail = TRUE;
@@ -206,6 +208,10 @@ int main(int argc, char *argv[])
 
 	setup();
 
+	/* On NFS or not */
+	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC)
+		NO_NFS = 0;
+
 	/* Open file and fill, allocate for buffer */
 	if ((fd = open(filename, O_DIRECT | O_RDWR | O_CREAT, 0666)) < 0) {
 		tst_brkm(TBROK, cleanup, "open failed for %s: %s",
@@ -459,7 +465,7 @@ int main(int argc, char *argv[])
 			 strerror(errno));
 		l_fail = TRUE;
 	} else {
-		if ((ret = read(fd, buf2 + 1, count)) != -1) {
+		if (((ret = read(fd, buf2 + 1, count)) != -1) && NO_NFS) {
 			tst_resm(TFAIL,
 				 "allows read nonaligned buf. returns %d: %s",
 				 ret, strerror(errno));
@@ -471,7 +477,7 @@ int main(int argc, char *argv[])
 			 strerror(errno));
 		l_fail = TRUE;
 	} else {
-		if ((ret = write(fd, buf2 + 1, count)) != -1) {
+		if (((ret = write(fd, buf2 + 1, count)) != -1) && NO_NFS) {
 			tst_resm(TFAIL,
 				 "allows write nonaligned buf. returns %d: %s",
 				 ret, strerror(errno));
diff --git a/testcases/kernel/syscalls/fcntl/fcntl16.c b/testcases/kernel/syscalls/fcntl/fcntl16.c
index 44b6a80..7dba6ea 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl16.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl16.c
@@ -51,6 +51,8 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "tst_fs_type.h"
+
 #define SKIPVAL 0x0f00
 //#define       SKIP    SKIPVAL, 0, 0L, 0L, IGNORED
 #define SKIP 0,0,0L,0L,0
@@ -412,6 +414,12 @@ void setup(void)
 
 	tst_tmpdir();
 
+	/* On NFS or not */
+	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC) {
+		tst_brkm(TCONF, cleanup, "Cannot test madatory locking "
+			"on a file located on an NFS filesystem");
+	}
+
 	/* set up temp filename */
 	sprintf(tmpname, "fcntl4.%d", parent);
 
-- 
1.8.3.1

------------------------------------------------------------------------------
_______________________________________________
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] diotest4/fcntl16: Skip some dio/fcntl cases on NFS
  2014-08-11  6:57 ` [LTP] [PATCH] diotest4/fcntl16: Skip some dio/fcntl cases on NFS Xiong Zhou
@ 2014-08-11 15:08   ` Stanislav Kholmanskikh
  0 siblings, 0 replies; 2+ messages in thread
From: Stanislav Kholmanskikh @ 2014-08-11 15:08 UTC (permalink / raw)
  To: ltp-list

Hi!

On 08/11/2014 10:57 AM, Xiong Zhou wrote:
> According to description of NFS and directIO in open(2), especially
> "The Linux NFS client places no alignment restrictions on
> O_DIRECT I/O", ignore some FAILs in diotest4.
>
> According to nfs(5), NLM supports advisory file locks only. So skip
> fcntl16 test if NFS.
>
> Signed-off-by: Xiong Zhou <xzhou@redhat.com>
> ---
>   testcases/kernel/io/direct_io/diotest4.c  | 14 ++++++++++----
>   testcases/kernel/syscalls/fcntl/fcntl16.c |  8 ++++++++
>   2 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/io/direct_io/diotest4.c b/testcases/kernel/io/direct_io/diotest4.c
> index 10281bf..506e34c 100644
> --- a/testcases/kernel/io/direct_io/diotest4.c
> +++ b/testcases/kernel/io/direct_io/diotest4.c
> @@ -71,9 +71,11 @@
>
>   #include "test.h"
>   #include "usctest.h"
> +#include "tst_fs_type.h"
>
>   char *TCID = "diotest4";	/* Test program identifier.    */
>   int TST_TOTAL = 17;		/* Total number of test conditions */
> +int NO_NFS = 1;			/* Test on NFS or not */
>
>   #ifdef O_DIRECT
>
> @@ -106,7 +108,7 @@ runtest_f(int fd, char *buf, int offset, int count, int errnum, int testnum,
>   		}
>   	} else {
>   		ret = read(fd, buf, count);
> -		if (ret >= 0 || errno != errnum) {
> +		if ((ret >= 0 || errno != errnum) && NO_NFS) {
>   			tst_resm(TFAIL, "read allows %s. returns %d: %s",
>   				 msg, ret, strerror(errno));
>   			l_fail = TRUE;
> @@ -120,7 +122,7 @@ runtest_f(int fd, char *buf, int offset, int count, int errnum, int testnum,
>   		}
>   	} else {
>   		ret = write(fd, buf, count);
> -		if (ret >= 0 || errno != errnum) {
> +		if ((ret >= 0 || errno != errnum) && NO_NFS) {
>   			tst_resm(TFAIL, "write allows %s.returns %d: %s",
>   				 msg, ret, strerror(errno));
>   			l_fail = TRUE;

You are modifying runtest_f() which is invoked in multiple test scenarios.
I suppose that not all the test cases should be excluded from the 
execution on NFS. For example, "negative fd".

I think we should disable only ones which don't work with NFS.

> @@ -206,6 +208,10 @@ int main(int argc, char *argv[])
>
>   	setup();
>
> +	/* On NFS or not */
> +	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC)
> +		NO_NFS = 0;
> +
>   	/* Open file and fill, allocate for buffer */
>   	if ((fd = open(filename, O_DIRECT | O_RDWR | O_CREAT, 0666)) < 0) {
>   		tst_brkm(TBROK, cleanup, "open failed for %s: %s",
> @@ -459,7 +465,7 @@ int main(int argc, char *argv[])
>   			 strerror(errno));
>   		l_fail = TRUE;
>   	} else {
> -		if ((ret = read(fd, buf2 + 1, count)) != -1) {
> +		if (((ret = read(fd, buf2 + 1, count)) != -1) && NO_NFS) {
>   			tst_resm(TFAIL,
>   				 "allows read nonaligned buf. returns %d: %s",
>   				 ret, strerror(errno));
> @@ -471,7 +477,7 @@ int main(int argc, char *argv[])
>   			 strerror(errno));
>   		l_fail = TRUE;
>   	} else {
> -		if ((ret = write(fd, buf2 + 1, count)) != -1) {
> +		if (((ret = write(fd, buf2 + 1, count)) != -1) && NO_NFS) {
>   			tst_resm(TFAIL,
>   				 "allows write nonaligned buf. returns %d: %s",
>   				 ret, strerror(errno));


Hmm. diotest4.c has many duplicated parts of code like 'open(O_DIRECT)' 
and tests like 'if (l_fail)' and 'if (ret != 0)'.

What do you think about cleaning these things up before doing functional 
changes? :)

Thanks.


> diff --git a/testcases/kernel/syscalls/fcntl/fcntl16.c b/testcases/kernel/syscalls/fcntl/fcntl16.c
> index 44b6a80..7dba6ea 100644
> --- a/testcases/kernel/syscalls/fcntl/fcntl16.c
> +++ b/testcases/kernel/syscalls/fcntl/fcntl16.c
> @@ -51,6 +51,8 @@
>   #include <sys/types.h>
>   #include <sys/wait.h>
>
> +#include "tst_fs_type.h"
> +
>   #define SKIPVAL 0x0f00
>   //#define       SKIP    SKIPVAL, 0, 0L, 0L, IGNORED
>   #define SKIP 0,0,0L,0L,0
> @@ -412,6 +414,12 @@ void setup(void)
>
>   	tst_tmpdir();
>
> +	/* On NFS or not */
> +	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC) {
> +		tst_brkm(TCONF, cleanup, "Cannot test madatory locking "
> +			"on a file located on an NFS filesystem");
> +	}
> +
>   	/* set up temp filename */
>   	sprintf(tmpname, "fcntl4.%d", parent);
>
>

------------------------------------------------------------------------------
_______________________________________________
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-08-11 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <2123230838.18328229.1407740231363.JavaMail.zimbra@redhat.com>
2014-08-11  6:57 ` [LTP] [PATCH] diotest4/fcntl16: Skip some dio/fcntl cases on NFS Xiong Zhou
2014-08-11 15:08   ` Stanislav Kholmanskikh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.