[PATCH 1/2] nfs41: add some READ/WRITE tests for special stateids

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jeff Layton <jeff.layton@xxxxxxxxxxxxxxx>
---
 nfs4.1/server41tests/st_open.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/nfs4.1/server41tests/st_open.py b/nfs4.1/server41tests/st_open.py
index 24f051e75e8f..235212cccaed 100644
--- a/nfs4.1/server41tests/st_open.py
+++ b/nfs4.1/server41tests/st_open.py
@@ -9,6 +9,7 @@ from xdrdef.nfs4_type import open_to_lock_owner4
 import nfs_ops
 op = nfs_ops.NFS4ops()
 import threading
+import nfs4lib
 
 def expect(res, seqid):
     """Verify that open result has expected stateid.seqid"""
@@ -77,6 +78,31 @@ def testReadWrite(t, env):
     if res.resarray[-1].data != desired:
         fail("Expected %r, got %r" % (desired, res.resarray[-1].data))
 
+def testAnonReadWrite(t, env):
+    """Do a simple READ and WRITE using anonymous stateid
+
+    FLAGS: open all
+    CODE: OPEN31
+    """
+    sess1 = env.c1.new_client_session(env.testname(t))
+    owner = open_owner4(0, "My Open Owner")
+    res = create_file(sess1, env.testname(t))
+    check(res)
+    expect(res, seqid=1)
+    fh = res.resarray[-1].object
+    data = "write test data"
+    stateid = res.resarray[-2].stateid
+    res = close_file(sess1, fh, stateid=stateid)
+    res = sess1.compound([op.putfh(fh), op.write(nfs4lib.state00, 5, FILE_SYNC4, data)])
+    check(res)
+    res = sess1.compound([op.putfh(fh), op.read(nfs4lib.state00, 0, 1000)])
+    check(res)
+    if not res.resarray[-1].eof:
+        fail("EOF not set on read")
+    desired = "\0"*5 + data
+    if res.resarray[-1].data != desired:
+        fail("Expected %r, got %r" % (desired, res.resarray[-1].data))
+
 def testEXCLUSIVE4AtNameAttribute(t, env):
     """If the file does exist,but the stored verifier does not match,
        then an error of NFS4ERR_EXIST is returned from server.
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux