diff mbox

[1/2] nfs4client: add test name as a compound tag

Message ID 1403531763-13441-2-git-send-email-tigran.mkrtchyan@desy.de (mailing list archive)
State New, archived
Headers show

Commit Message

Mkrtchyan, Tigran June 23, 2014, 1:56 p.m. UTC
allowes to easy trace tests, e.q: [st_verify.py:_try_mand]

Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
---
 nfs4.1/nfs4client.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox

Patch

diff --git a/nfs4.1/nfs4client.py b/nfs4.1/nfs4client.py
index 6912565..c536897 100644
--- a/nfs4.1/nfs4client.py
+++ b/nfs4.1/nfs4client.py
@@ -9,6 +9,8 @@  import nfs_ops
 import time, struct
 import threading
 import hmac
+import inspect
+from os.path import basename
 from nfs4commoncode import CBCompoundState as CompoundState, \
      cb_encode_status as encode_status, \
      cb_encode_status_by_name as encode_status_by_name
@@ -82,6 +84,7 @@  class NFS4Client(rpc.Client, rpc.Server):
         return self.send_call(pipe, 1, p.get_buffer(), credinfo)
 
     def compound(self, *args, **kwargs):
+        self.tag = self.create_tag()
         xid = self.compound_async(*args, **kwargs)
         pipe = kwargs.get("pipe", None)
         res = self.listen(xid, pipe=pipe)
@@ -292,6 +295,14 @@  class NFS4Client(rpc.Client, rpc.Server):
         s.compound([op4.reclaim_complete(FALSE)])
         return s
 
+    def create_tag(self):
+        current_stack = inspect.stack()
+        stackid = 0
+        while basename(current_stack[stackid][1]) == 'environment.py' or basename(current_stack[stackid][1]) == 'nfs4client.py':
+              stackid = stackid + 1
+        test_name = '%s:%s' % (basename(current_stack[stackid][1]), current_stack[stackid][3])
+        return test_name
+
 class ClientStateProtection(object):
     def __init__(self, p_res, p_arg):
         self.type = p_res.spr_how