test suite reviews and discussions
 help / color / mirror / Atom feed
From: Marvin Liu <yong.liu@intel.com>
To: dts@dpdk.org
Cc: Marvin Liu <yong.liu@intel.com>
Subject: [dts] [PATCH 8/9] framework utils: move shared function from dts module
Date: Thu,  4 Aug 2016 13:38:21 +0800	[thread overview]
Message-ID: <1470289102-12677-9-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1470289102-12677-1-git-send-email-yong.liu@intel.com>

Some functions need shared with all modules in dts, remove them from dts
module to utils module. This will help on the decouple of each module.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/utils.py b/framework/utils.py
index 48bba0e..edfeeca 100644
--- a/framework/utils.py
+++ b/framework/utils.py
@@ -31,6 +31,10 @@
 
 import json         # json format
 import re
+import os
+import inspect
+
+DTS_ENV_PAT = r"DTS_*"
 
 
 def RED(text):
@@ -99,6 +103,7 @@ def remove_old_rsa_key(crb, ip):
             (ip.strip(), rsa_key_path)
     crb.send_expect(remove_rsa_key_cmd, "# ")
 
+
 def human_read_number(num):
     if num > 1000000:
         num /= 1000000
@@ -108,3 +113,28 @@ def human_read_number(num):
         return str(num) + "K"
     else:
         return str(num)
+
+
+def get_subclasses(module, clazz):
+    """
+    Get module attribute name and attribute.
+    """
+    for subclazz_name, subclazz in inspect.getmembers(module):
+        if hasattr(subclazz, '__bases__') and clazz in subclazz.__bases__:
+            yield (subclazz_name, subclazz)
+
+
+def copy_instance_attr(from_inst, to_inst):
+    for key in from_inst.__dict__.keys():
+        to_inst.__dict__[key] = from_inst.__dict__[key]
+
+
+def create_mask(indexes):
+    """
+    Convert index to hex mask.
+    """
+    val = 0
+    for index in indexes:
+        val |= 1 << int(index)
+
+    return hex(val).rstrip("L")
-- 
1.9.3

  parent reply	other threads:[~2016-08-04  5:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  5:38 [dts] [PATCH 0/9] optimize overall execution process Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 1/9] framework dts: optimize " Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 2/9] framework config: add concept for dut board Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 3/9] framework dut: remove dependency on dts module Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 4/9] framework rst: add class to handle RST report Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 5/9] framework settings: support global setting load and save Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 6/9] framework test_result: add class to handle result Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 7/9] framework test_case: add test case handle logic Marvin Liu
2016-08-04  5:38 ` Marvin Liu [this message]
2016-08-04  5:38 ` [dts] [PATCH 9/9] tests: remove dependencies of dts module Marvin Liu
2016-08-04  6:07 ` [dts] [PATCH 0/9] optimize overall execution process Liu, Yong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470289102-12677-9-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).