test: do not silently ignore feature detection failures
authorPeter Wu <peter@lekensteyn.nl>
Thu, 26 Jul 2018 21:47:20 +0000 (23:47 +0200)
committerPeter Wu <peter@lekensteyn.nl>
Thu, 26 Jul 2018 23:16:04 +0000 (23:16 +0000)
When ASAN memleak detection is enabled, any memory leak would result in
an exception and subsequently all features are marked as missing.
With the default profile, any Lua plugin or certain configurations could
cause a memory leak. To avoid such interference, set the configuration
path to a dummy location and warn whenever an error happens nonetheless.

Do not call setProgramPath() immediately, there is no "tshark" binary in
the current working directory anymore. Rely on test.py to set the path.

Change-Id: Idccc3d68eb6f6bb64d3a0b32897acecc65e0dfb6
Reviewed-on: https://code.wireshark.org/review/28867
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
test/config.py

index 21cc90fd11c36f36410b7dffae62d8dc2cd9fb8a..240875140c0622f88a501f7e12d68c7c8a5d0de1 100644 (file)
@@ -9,6 +9,7 @@
 #
 '''Configuration'''
 
+import logging
 import os
 import os.path
 import re
@@ -95,25 +96,25 @@ def getTsharkInfo():
     global have_kerberos
     global have_libgcrypt16
     global have_libgcrypt17
-    have_lua = False
-    have_nghttp2 = False
-    have_kerberos = False
-    have_libgcrypt16 = False
-    have_libgcrypt17 = False
+    if not cmd_tshark:
+        logging.warning("tshark binary is not yet set")
+        return
     try:
-        tshark_v_blob = str(subprocess.check_output((cmd_tshark, '--version'), stderr=subprocess.PIPE))
-        tshark_v = ' '.join(tshark_v_blob.splitlines())
-        if re.search('with +Lua', tshark_v):
-            have_lua = True
-        if re.search('with +nghttp2', tshark_v):
-            have_nghttp2 = True
-        if re.search('(with +MIT +Kerberos|with +Heimdal +Kerberos)', tshark_v):
-            have_kerberos = True
-        gcry_m = re.search('with +Gcrypt +([0-9]+\.[0-9]+)', tshark_v)
-        have_libgcrypt16 = gcry_m and float(gcry_m.group(1)) >= 1.6
-        have_libgcrypt17 = gcry_m and float(gcry_m.group(1)) >= 1.7
-    except:
-        pass
+        tshark_v = subprocess.check_output(
+            (cmd_tshark, '--version'),
+            stderr=subprocess.PIPE,
+            universal_newlines=True,
+            env={'WIRESHARK_CONFIG_DIR': '/dummy/non/existing'}
+        ).replace('\n', ' ')
+    except subprocess.CalledProcessError as e:
+        logging.warning("Failed to detect tshark features: %s", e)
+        tshark_v = ''
+    have_lua = bool(re.search('with +Lua', tshark_v))
+    have_nghttp2 = bool(re.search('with +nghttp2', tshark_v))
+    have_kerberos = bool(re.search('(with +MIT +Kerberos|with +Heimdal +Kerberos)', tshark_v))
+    gcry_m = re.search('with +Gcrypt +([0-9]+\.[0-9]+)', tshark_v)
+    have_libgcrypt16 = gcry_m and float(gcry_m.group(1)) >= 1.6
+    have_libgcrypt17 = gcry_m and float(gcry_m.group(1)) >= 1.7
 
 def getDefaultCaptureInterface():
     '''Choose a default capture interface for our platform. Currently Windows only.'''
@@ -255,4 +256,3 @@ if sys.platform.startswith('win32') or sys.platform.startswith('darwin'):
 
 # Initialize ourself.
 getPingCommand()
-setProgramPath(os.path.curdir)