4.1 CLNT: Test Case for OPEN file with claim_type is CLAIM_FH
Subsystems (2)
PATCH 1/1 4.1 CLNT: Test Case for OPEN file with claim_type is CLAIM_FH
--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)
nfs4.1/server41tests/st_open.py +37 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op
@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid + res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH) + how = openflag4(OPEN4_NOCREATE) + oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res) + + stateid = res.resarray[-1].stateid + stateid.seqid = 0 + data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 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))
Signature · 1 line
1.7.7
Quoted 35 lines · Mi Jinlong
Signed-off-by Mi Jinlong <[email protected]>--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)nfs4.1/server41tests/st_open.py +14
-1@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 225
Quoted 10 lines
nfs4.1/server41tests/st_open.py +10
-0+ res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH) + how = openflag4(OPEN4_NOCREATE) + oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res)
You could just stop here. But I suppose I don't see a problem with doing some IO to the file too just to make sure the open is usable.
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 228
Quoted 3 lines
nfs4.1/server41tests/st_open.py +3
-0+ + stateid = res.resarray[-1].stateid + stateid.seqid = 0
Why are you modifying the seqid?
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 236
Quoted 8 lines
nfs4.1/server41tests/st_open.py +8
-0+ data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) + check(res) + if not res.resarray[-1].eof: + fail("EOF not set on read") + desired = "\0"*5 + data
Why the five nulls? I don't understand this code....
--b.
Quoted 6 lines
nfs4.1/server41tests/st_open.py +2
-0+ if res.resarray[-1].data != desired: + fail("Expected %r, got %r" % (desired, res.resarray[-1].data))Signature · 1 line
1.7.7
J. Bruce Fields:
Quoted 40 lines · Mi Jinlong
Quoted 39 lines
Signed-off-by Mi Jinlong <[email protected]>--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)nfs4.1/server41tests/st_open.py +19
-1@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid + res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH) + how = openflag4(OPEN4_NOCREATE)
Quoted 8 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 225
Quoted 5 lines
nfs4.1/server41tests/st_open.py +5
-0+ oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res)You could just stop here. But I suppose I don't see a problem with doing some IO to the file too just to make sure the open is usable.
Yes, that's right.
Quoted 16 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 228
Quoted 4 lines
nfs4.1/server41tests/st_open.py +3
-0+ + stateid = res.resarray[-1].stateid + stateid.seqid = 0Why are you modifying the seqid?
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 236
Quoted 8 lines
nfs4.1/server41tests/st_open.py +8
-0+ data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) + check(res) + if not res.resarray[-1].eof: + fail("EOF not set on read") + desired = "\0"*5 + data
Quoted 1 line
Why the five nulls? I don't understand this code....
I just do a simple READ and WRITE as OPEN30.
I will have a check about that.
Thanks for your comments.
Ps: Adding Fred.
thanks,
Mi Jinlong
Hi Bruce,
Sorry for so late replying you.
Mi Jinlong :
Quoted 50 lines
J. Bruce Fields:
Quoted 39 lines · Mi Jinlong
Quoted 38 lines
Signed-off-by Mi Jinlong <[email protected]>--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)nfs4.1/server41tests/st_open.py +18
-1@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid + res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH)Quoted 8 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 225
Quoted 6 lines
nfs4.1/server41tests/st_open.py +6
-0+ how = openflag4(OPEN4_NOCREATE) + oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res)You could just stop here. But I suppose I don't see a problem with doing some IO to the file too just to make sure the open is usable.
Quoted 6 lines
Yes, that's right.
Quoted 4 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 228
Quoted 3 lines
nfs4.1/server41tests/st_open.py +3
-0+ + stateid = res.resarray[-1].stateid + stateid.seqid = 0Why are you modifying the seqid?
At any date writing or reading, seqid should be zero. And, NFS client do as it. So, we set seqid = 0 here.
Quoted 10 lines
Quoted 10 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 236
Quoted 9 lines
nfs4.1/server41tests/st_open.py +8
-0+ data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) + check(res) + if not res.resarray[-1].eof: + fail("EOF not set on read") + desired = "\0"*5 + dataWhy the five nulls? I don't understand this code....
Because we write data at offset 5 above, so there are five nulls exist.
+ res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)])
thanks,
Mi Jinlong
Quoted 56 lines · Mi Jinlong
Hi Bruce,
Sorry for so late replying you.
Mi Jinlong :
Quoted 51 lines
J. Bruce Fields:
Quoted 39 lines · Mi Jinlong
Quoted 38 lines
Signed-off-by Mi Jinlong <[email protected]>--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)nfs4.1/server41tests/st_open.py +18
-1@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid + res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH)Quoted 8 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 225
Quoted 6 lines
nfs4.1/server41tests/st_open.py +6
-0+ how = openflag4(OPEN4_NOCREATE) + oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res)You could just stop here. But I suppose I don't see a problem with doing some IO to the file too just to make sure the open is usable.
Yes, that's right.
OK.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 228
Quoted 3 lines
nfs4.1/server41tests/st_open.py +3
-0+ + stateid = res.resarray[-1].stateid + stateid.seqid = 0Why are you modifying the seqid?
At any date writing or reading, seqid should be zero. And, NFS client do as it. So, we set seqid = 0 here.
Ugh, I guess. Seems a little ugly that every test-writer has to manually set seqid to 0 before doing IO, but OK.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
nfs4.1/server41tests/st_open.py +8
-0+ data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) + check(res) + if not res.resarray[-1].eof: + fail("EOF not set on read") + desired = "\0"*5 + data
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Why the five nulls? I don't understand this code....
Because we write data at offset 5 above, so there are five nulls exist.
+ res =
sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)])
Oops, I must be blind, thanks for setting me straight!
Could you resend this?
(Also, is there anything else you're waiting for me to do?)
--b.
J. Bruce Fields:
Quoted 76 lines · Mi Jinlong
Quoted 54 lines
Hi Bruce,
Sorry for so late replying you.
Mi Jinlong :
Quoted 49 lines
J. Bruce Fields:
Quoted 39 lines · Mi Jinlong
Quoted 38 lines
Signed-off-by Mi Jinlong <[email protected]>--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)nfs4.1/server41tests/st_open.py +18
-1@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid + res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH)Quoted 8 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 225
Quoted 6 lines
nfs4.1/server41tests/st_open.py +6
-0+ how = openflag4(OPEN4_NOCREATE) + oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res)You could just stop here. But I suppose I don't see a problem with doing some IO to the file too just to make sure the open is usable.
Yes, that's right.
OK.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
nfs4.1/server41tests/st_open.py def testEXCLUSIVE4AtNameAttribute(t, env): · line 228
Quoted 3 lines
nfs4.1/server41tests/st_open.py +3
-0+ + stateid = res.resarray[-1].stateid + stateid.seqid = 0Why are you modifying the seqid?
At any date writing or reading, seqid should be zero. And, NFS client do as it. So, we set seqid = 0 here.
Ugh, I guess. Seems a little ugly that every test-writer has to manually set seqid to 0 before doing IO, but OK.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
nfs4.1/server41tests/st_open.py +8
-0+ data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) + check(res) + if not res.resarray[-1].eof: + fail("EOF not set on read") + desired = "\0"*5 + data
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Why the five nulls? I don't understand this code....
Because we write data at offset 5 above, so there are five nulls exist.
+ res =
sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)])Oops, I must be blind, thanks for setting me straight!
Could you resend this?
OK, will resend.
Quoted 2 lines
(Also, is there anything else you're waiting for me to do?)
Thanks, no.
thanks,
Mi Jinlong
PATCH v2 1/1 4.1 CLNT: Test Case for OPEN file with claim_type is CLAIM_FH
In reply to Mi JinlongOpen NFS file with filehandle, write some data to the opened file, read and check it.
--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)
nfs4.1/server41tests/st_open.py +37 -1
@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op
@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid + res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH) + how = openflag4(OPEN4_NOCREATE) + oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res) + + stateid = res.resarray[-1].stateid + stateid.seqid = 0 + data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 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))
Signature · 1 line
1.7.7
Quoted 2 lines · Mi Jinlong
Open NFS file with filehandle, write some data to the opened file, read and check it.
OK, thanks, applied.--b.
Quoted 62 lines
Signed-off-by Mi Jinlong <[email protected]>--- nfs4.1/server41tests/st_open.py | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)nfs4.1/server41tests/st_open.py +37
-1@@ -1,6 +1,6 @@ from st_create_session import create_session from nfs4_const import * -from environment import check, checklist, fail, create_file, open_file +from environment import check, checklist, fail, create_file, open_file, close_file from nfs4_type import open_owner4, openflag4, createhow4, open_claim4 from nfs4_type import creatverfattr, fattr4 import nfs4_ops as op@@ -200,3 +200,39 @@ def testEXCLUSIVE4AtNameAttribute(t, env): res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) + +def testOPENClaimFH(t, env): + """OPEN file with claim_type is CLAIM_FH + + FLAGS: open all + CODE: OPEN7 + """ + sess1 = env.c1.new_client_session(env.testname(t)) + res = create_file(sess1, env.testname(t)) + check(res) + + fh = res.resarray[-1].object + stateid = res.resarray[-2].stateid + res = close_file(sess1, fh, stateid=stateid) + check(res) + + claim = open_claim4(CLAIM_FH) + how = openflag4(OPEN4_NOCREATE) + oowner = open_owner4(0, "My Open Owner 2") + open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, + oowner, how, claim) + res = sess1.compound([op.putfh(fh), open_op]) + check(res) + + stateid = res.resarray[-1].stateid + stateid.seqid = 0 + data = "write test data" + res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) + check(res) + res = sess1.compound([op.putfh(fh), op.read(stateid, 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))Signature · 1 line
1.7.7