diff options
author | Gerald Combs <gerald@wireshark.org> | 2023-09-14 18:12:18 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2023-09-14 18:34:05 -0700 |
commit | a7cf7fd56198fdce5462788d634bdc0669cf85ea (patch) | |
tree | 3e95fe871d3969b2f25d5fd1d599f1e2bfe0fc82 /test/suite_nameres.py | |
parent | d6f2b30be12fc22cfa04bdd8734d87c09ddf9c3e (diff) |
test: Skip global name resolution tests on macOS
Global name resolution tests on macOS require adding a 'hosts' file to
Contents/MacOS in the application bundle. Newer versions of Xcode appear
to leave this unwritable after we've created our application bundle. We
arguably shouldn't modify the application bundle anyway, so skip global
name resolution tests if we have an application bundle.
Diffstat (limited to 'test/suite_nameres.py')
-rw-r--r-- | test/suite_nameres.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/test/suite_nameres.py b/test/suite_nameres.py index 7e05d98f91..50e6d5f703 100644 --- a/test/suite_nameres.py +++ b/test/suite_nameres.py @@ -19,25 +19,30 @@ tf_str = { True: 'TRUE', False: 'FALSE' } custom_profile_name = 'Custom Profile' @pytest.fixture -def nameres_env(test_env, program_path, conf_path): +def nameres_setup(program_path, conf_path): bundle_path = os.path.join(program_path, 'Wireshark.app', 'Contents', 'MacOS') if os.path.isdir(bundle_path): - global_path = bundle_path + # Don't modify our application bundle. + global_path = None else: global_path = program_path custom_profile_path = os.path.join(conf_path, 'profiles', custom_profile_name) os.makedirs(custom_profile_path) this_dir = os.path.dirname(__file__) hosts_path_pfx = os.path.join(this_dir, 'hosts.') - shutil.copyfile(hosts_path_pfx + 'global', os.path.join(global_path, 'hosts')) + + if global_path is not None: + shutil.copyfile(hosts_path_pfx + 'global', os.path.join(global_path, 'hosts')) shutil.copyfile(hosts_path_pfx + 'personal', os.path.join(conf_path, 'hosts')) shutil.copyfile(hosts_path_pfx + 'custom', os.path.join(custom_profile_path, 'hosts')) - return test_env + return global_path is not None @pytest.fixture -def check_name_resolution(cmd_tshark, capture_file, nameres_env): +def check_name_resolution(cmd_tshark, capture_file, nameres_setup, test_env): def check_name_resolution_real(o_net_name, o_external_name_res, o_hosts_file, custom_profile, grep_str, fail_on_match=False): + if grep_str.startswith('global') and not nameres_setup: + pytest.skip('Global name resolution tests would require modifying the application bundle') tshark_cmd = (cmd_tshark, '-r', capture_file('dns+icmp.pcapng.gz'), '-o', 'nameres.network_name: ' + tf_str[o_net_name], @@ -46,7 +51,7 @@ def check_name_resolution(cmd_tshark, capture_file, nameres_env): ) if custom_profile: tshark_cmd += ('-C', custom_profile_name) - proc = subprocess.run(tshark_cmd, check=True, capture_output=True, encoding='utf-8', env=nameres_env) + proc = subprocess.run(tshark_cmd, check=True, capture_output=True, encoding='utf-8', env=test_env) if fail_on_match: assert not grep_output(proc.stdout, grep_str) else: |