[PATCH 1/2] pynfs: courtesy: use a helper function to prepare the lock op args

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

 



Cleanup.

Future tests to be added will use the same sequence to prepare the args
for the lock op, so use a helper function for that.

Signed-off-by: Calum Mackay <calum.mackay@xxxxxxxxxx>
---
 nfs4.1/server41tests/st_courtesy.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/nfs4.1/server41tests/st_courtesy.py b/nfs4.1/server41tests/st_courtesy.py
index 5e13dad44a01..e74d9afbca60 100644
--- a/nfs4.1/server41tests/st_courtesy.py
+++ b/nfs4.1/server41tests/st_courtesy.py
@@ -15,6 +15,12 @@ def _getleasetime(sess):
     res = sess.compound([op.putrootfh(), op.getattr(1 << FATTR4_LEASE_TIME)])
     return res.resarray[-1].obj_attributes[FATTR4_LEASE_TIME]
 
+def cour_lockargs(fh, stateid):
+    open_to_lock_owner = open_to_lock_owner4( 0, stateid, 0, lock_owner4(0, b"lock1"))
+    lock_owner = locker4(open_owner=open_to_lock_owner, new_lock_owner=True)
+    lock_ops = [ op.lock(WRITE_LT, False, 0, NFS4_UINT64_MAX, lock_owner) ]
+    return [op.putfh(fh)] + lock_ops
+
 def testLockSleepLockU(t, env):
     """test server courtesy by having LOCK and LOCKU
        in separate compounds, separated by a sleep of twice the lease period
@@ -29,10 +35,7 @@ def testLockSleepLockU(t, env):
 
     fh = res.resarray[-1].object
     stateid = res.resarray[-2].stateid
-    open_to_lock_owner = open_to_lock_owner4( 0, stateid, 0, lock_owner4(0, b"lock1"))
-    lock_owner = locker4(open_owner=open_to_lock_owner, new_lock_owner=True)
-    lock_ops = [ op.lock(WRITE_LT, False, 0, NFS4_UINT64_MAX, lock_owner) ]
-    res = sess1.compound([op.putfh(fh)] + lock_ops)
+    res = sess1.compound(cour_lockargs(fh, stateid))
     check(res, NFS4_OK)
 
     lease_time = _getleasetime(sess1)
-- 
2.27.0




[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