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 5/9] framework settings: support global setting load and save
Date: Thu,  4 Aug 2016 13:38:18 +0800	[thread overview]
Message-ID: <1470289102-12677-6-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1470289102-12677-1-git-send-email-yong.liu@intel.com>

Support save/load global settings. At most times, setting retrieved from
configuration file or input command, load in running module like dut
object and test suite object.

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

diff --git a/framework/settings.py b/framework/settings.py
index 57eacf2..0e18a15 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -31,6 +31,7 @@
 """
 Folders for framework running enviornment.
 """
+import os
 import re
 import socket
 
@@ -60,8 +61,8 @@ NICS = {
     'twinpond': '8086:1528',
     'twinville': '8086:1512',
     'sageville': '8086:1563',
-    'sagepond' : '8086:15ad',
-    'sagepond_vf':'8086:15a8',
+    'sagepond': '8086:15ad',
+    'sagepond_vf': '8086:15a8',
     'hartwell': '8086:10d3',
     '82545EM': '8086:100f',
     '82540EM': '8086:100e',
@@ -78,13 +79,13 @@ NICS = {
     'fortville_spirit': '8086:1583',
     'fortville_spirit_single': '8086:1584',
     'redrockcanyou': '8086:15a4',
-    'fortpark':'8086:374c',
-    'fortpark_TLV':'8086:37d0',
-    'fortpark_TLV_vf':'8086:37cd',
-    'fvl10g_vf':'8086:154c',
+    'fortpark': '8086:374c',
+    'fortpark_TLV': '8086:37d0',
+    'fortpark_TLV_vf': '8086:37cd',
+    'fvl10g_vf': '8086:154c',
     'atwood': '8086:15d5',
-    'ConnectX3':'15b3:1003',
-    'ConnectX4':'15b3:1013',
+    'ConnectX3': '15b3:1003',
+    'ConnectX4': '15b3:1013',
     'boulderrapid': '8086:15d0',
 }
 
@@ -102,7 +103,7 @@ DRIVERS = {
     'twinpond': 'ixgbe',
     'twinville': 'ixgbe',
     'sageville': 'ixgbe',
-    'sagepond' : 'ixgbe',
+    'sagepond': 'ixgbe',
     'sagepond_vf': 'ixgbevf',
     'hartwell': 'igb',
     '82545EM': 'igb',
@@ -120,13 +121,13 @@ DRIVERS = {
     'fortville_spirit': 'i40e',
     'fortville_spirit_single': 'i40e',
     'redrockcanyou': 'fm10k',
-    'fortpark':'i40e',
-    'fortpark_TLV':'i40e',
-    'fortpark_TLV_vf':'i40evf',
-    'fvl10g_vf':'i40evf',
+    'fortpark': 'i40e',
+    'fortpark_TLV': 'i40e',
+    'fortpark_TLV_vf': 'i40evf',
+    'fvl10g_vf': 'i40evf',
     'atwood': 'fm10k',
-    'ConnectX3':'mlx4_core',
-    'ConnectX4':'mlx5_core',
+    'ConnectX3': 'mlx4_core',
+    'ConnectX4': 'mlx5_core',
     'boulderrapid': 'fm10k',
 }
 
@@ -180,6 +181,18 @@ The log name seperater.
 """
 LOG_NAME_SEP = '.'
 
+"""
+DTS global environment variable
+"""
+DTS_ENV_PAT = r"DTS_*"
+PERF_SETTING = "DTS_PERF_ONLY"
+FUNC_SETTING = "DTS_FUNC_ONLY"
+HOST_DRIVER_SETTING = "DTS_HOST_DRIVER"
+HOST_NIC_SETTING = "DTS_HOST_NIC"
+DEBUG_SETTING = "DTS_DEBUG_ENABLE"
+DEBUG_CASE_SETTING = "DTS_DEBUGCASE_ENABLE"
+DPDK_RXMODE_SETTING = "DTS_DPDK_RXMODE"
+
 
 def get_nic_name(type):
     """
@@ -214,6 +227,7 @@ def get_netdev(crb, pci):
 
     return None
 
+
 def get_host_ip(address):
     ip_reg = r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}'
     m = re.match(ip_reg, address)
@@ -221,8 +235,54 @@ def get_host_ip(address):
         return address
     else:
         try:
-            result=socket.gethostbyaddr(address)
+            result = socket.gethostbyaddr(address)
             return result[2][0]
         except:
             print "couldn't look up %s" % address
             return ''
+
+
+def save_global_setting(key, value):
+    """
+    Save DTS global setting
+    """
+    if re.match(DTS_ENV_PAT, key):
+        env_key = key
+    else:
+        env_key = "DTS_" + key
+
+    os.environ[env_key] = value
+
+
+def load_global_setting(key):
+    """
+    Load DTS global setting
+    """
+    if re.match(DTS_ENV_PAT, key):
+        env_key = key
+    else:
+        env_key = "DTS_" + key
+
+    if env_key in os.environ.keys():
+        return os.environ[env_key]
+    else:
+        return ''
+
+
+def accepted_nic(pci_id):
+    """
+    Return True if the pci_id is a known NIC card in the settings file and if
+    it is selected in the execution file, otherwise it returns False.
+    """
+    nic = load_global_setting(HOST_NIC_SETTING)
+    if pci_id not in settings.NICS.values():
+        return False
+
+    if nic is 'any':
+        return True
+
+    else:
+        if pci_id == settings.NICS[nic]:
+            return True
+
+    return False
-- 
1.9.3

  parent reply	other threads:[~2016-08-04  5:38 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 ` Marvin Liu [this message]
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 ` [dts] [PATCH 8/9] framework utils: move shared function from dts module Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 9/9] tests: remove dependencies of " 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-6-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).