Test: More fixes and updates.
authorGerald Combs <gerald@wireshark.org>
Tue, 1 May 2018 00:12:20 +0000 (17:12 -0700)
committerGerald Combs <gerald@wireshark.org>
Tue, 1 May 2018 00:37:41 +0000 (00:37 +0000)
Move UAT file creation to config.py.

Run the text2pcap and some of the clopts tests under our default
environment.

Use "in" instead of "has_key".

Change-Id: Ie5c70fb33c29676672bed7bf8205cff0bba77f8a
Reviewed-on: https://code.wireshark.org/review/27234
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
test/config.py
test/suite_clopts.py
test/suite_decryption.py
test/suite_text2pcap.py

index 51531b866515c222adbbca009b7a691bfe6d75c6..b38bf7ceb145c736c4905d54cf9a851498b63946 100644 (file)
@@ -168,6 +168,8 @@ def setUpTestEnvironment():
     global conf_path
     global custom_profile_path
     global test_env
+
+    # Create our directories
     test_confdir = tempfile.mkdtemp(prefix='wireshark-tests.')
     home_path = os.path.join(test_confdir, 'home')
     if sys.platform.startswith('win32'):
@@ -180,6 +182,21 @@ def setUpTestEnvironment():
     # Test spaces while we're here.
     custom_profile_path = os.path.join(conf_path, 'profiles', custom_profile_name)
     os.makedirs(custom_profile_path)
+
+    # Populate our UAT files
+    uat_files = [
+        '80211_keys',
+        'dtlsdecrypttablefile',
+        'esp_sa',
+        'ssl_keys',
+        'c1222_decryption_table',
+        'ikev1_decryption_table',
+        'ikev2_decryption_table',
+    ]
+    for uat in uat_files:
+        setUpUatFile(uat)
+
+    # Set up our environment
     test_env = os.environ.copy()
     test_env['WIRESHARK_RUN_FROM_BUILD_DIRECTORY'] = '1'
     test_env[home_env] = home_path
index a5312c4ad5b24ab2b96ab0d91da0c8f5422b0324..894a3ceef7425ccd99334a3c16110c6bbfd0d10f 100644 (file)
@@ -180,7 +180,7 @@ class case_tshark_dump_glossaries(subprocesstest.SubprocessTestCase):
             self.assertTrue(decoded, '{} is not valid UTF-8'.format(glossary))
 
     def test_tshark_glossary_plugin_count(self):
-        self.runProcess((config.cmd_tshark, '-G', 'plugins'))
+        self.runProcess((config.cmd_tshark, '-G', 'plugins'), env=os.environ.copy())
         self.assertGreaterEqual(self.countOutput('dissector'), 10, 'Fewer than 10 dissector plugins found')
 
 
index 5813456e5f99eda8c48c6984a6a38b6093fca17f..a007b6f8e7bb64ca91c00d6bda6db4712fea7192 100644 (file)
@@ -14,19 +14,6 @@ import os.path
 import subprocesstest
 import unittest
 
-uat_files = [
-    '80211_keys',
-    'dtlsdecrypttablefile',
-    'esp_sa',
-    'ssl_keys',
-    'c1222_decryption_table',
-    'ikev1_decryption_table',
-    'ikev2_decryption_table',
-]
-for uat in uat_files:
-    config.setUpUatFile(uat)
-
-
 class case_decrypt_80211(subprocesstest.SubprocessTestCase):
     def test_80211_wpa_psk(self):
         '''IEEE 802.11 WPA PSK'''
index baf2ea0c187e92d182d5bed7247ce6e09bab6cac..3ee84f2b131d8e1b5f33fd46447b3434867a0e36 100644 (file)
@@ -115,7 +115,7 @@ def check_text2pcap(self, cap_file, file_type, expected_packets=None, expected_d
     #   in the output file are the same as in the input file
 
     pre_cap_info = check_capinfos_info(self, cap_file)
-    self.assertTrue(encap_to_link_type.has_key(pre_cap_info['encapsulation']))
+    self.assertTrue(pre_cap_info['encapsulation'] in encap_to_link_type)
 
     self.assertTrue(file_type in file_type_to_testout, 'Invalid file type')
 
@@ -128,7 +128,7 @@ def check_text2pcap(self, cap_file, file_type, expected_packets=None, expected_d
         cf = cf_path,
         of = testin_file,
     )
-    self.assertRun(tshark_cmd, shell=True)
+    self.assertRun(tshark_cmd, shell=True, env=os.environ.copy())
 
     testout_fname = file_type_to_testout[file_type]
     testout_file = self.filename_from_id(testout_fname)