teststeps: Improvements of step driven TC
[vswitchperf.git] / tools / systeminfo.py
index 575dd87..f34bcce 100644 (file)
@@ -185,7 +185,8 @@ def get_bin_version(binary, regex):
     :returns: version string or None
     """
     try:
-        output = subprocess.check_output(binary, shell=True).decode().rstrip('\n')
+        output = str(subprocess.check_output(
+            binary, stderr=subprocess.STDOUT, shell=True).decode().rstrip('\n'))
     except subprocess.CalledProcessError:
         return None
 
@@ -227,10 +228,9 @@ def get_version(app_name):
         'testpmd' : r'RTE Version: \'\S+ ([0-9.]+)',
         'qemu' : r'QEMU emulator version ([0-9.]+)',
         'loopback_l2fwd' : os.path.join(S.getValue('ROOT_DIR'), 'src/l2fwd/l2fwd.c'),
-        'loopback_testpmd' : os.path.join(S.getValue('TOOLS')['dpdk_src'],
-                                          'lib/librte_eal/common/include/rte_version.h'),
         'ixnet' : os.path.join(S.getValue('TRAFFICGEN_IXNET_LIB_PATH'), 'pkgIndex.tcl'),
         'ixia' : os.path.join(S.getValue('TRAFFICGEN_IXIA_ROOT_DIR'), 'lib/ixTcl1.0/ixTclHal.tcl'),
+        'trex' : os.path.join(S.getValue('ROOT_DIR'), 'src/trex/trex'),
     }
 
 
@@ -255,7 +255,12 @@ def get_version(app_name):
         # stored at TOOS['dpdk_src'] directory
         tmp_ver = ['', '', '']
         dpdk_16 = False
-        with open(app_version_file['loopback_testpmd']) as file_:
+        # TOOLS dictionary is created during runtime and it is not
+        # available in some vsperf modes (e.g. -m trafficgen), thus
+        # following definition can't be part of app_version_file dict above
+        app_file = os.path.join(S.getValue('TOOLS')['dpdk_src'],
+                                'lib/librte_eal/common/include/rte_version.h')
+        with open(app_file) as file_:
             for line in file_:
                 if not line.strip():
                     continue
@@ -308,6 +313,9 @@ def get_version(app_name):
         app_version = match_line(app_version_file['ixia'], 'package provide IxTclHal')
         if app_version:
             app_version = app_version.split(' ')[3]
+    elif app_name.lower() == 'trex':
+        app_version = match_line(os.path.join(app_version_file['trex'], 'VERSION'), 'v')
+        app_git_tag = get_git_tag(app_version_file['trex'])
     elif app_name.lower() == 'xena':
         try:
             app_version = S.getValue('XENA_VERSION')