diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-12-20 23:25:23 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-12-29 08:27:58 +0000 |
commit | f201b971d80e4020078dcec9a1c85d4d0a2cd02b (patch) | |
tree | eef64b49a78bba54ad53281555eaaf9d1f6961fb /test/suite_wslua.py | |
parent | 604aef7164f50d1f547c7c3d2b0b811be6129e4a (diff) |
test: add tests for Unicode paths in Lua and tshark -G folders
Check for potential Unicode-related problems on Windows.
Change-Id: I147c07749c5073a9ae00f07914dd80347d17c40f
Ping-Bug: 15118
Reviewed-on: https://code.wireshark.org/review/31154
Tested-by: Petri Dish Buildbot
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'test/suite_wslua.py')
-rw-r--r-- | test/suite_wslua.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/suite_wslua.py b/test/suite_wslua.py index a48f75d596..0119609f7f 100644 --- a/test/suite_wslua.py +++ b/test/suite_wslua.py @@ -11,6 +11,8 @@ import filecmp import os.path +import shutil +import subprocess import subprocesstest import unittest import fixtures @@ -276,3 +278,39 @@ class case_wslua(subprocesstest.SubprocessTestCase): def test_wslua_tvb_no_tree(self, check_lua_script): '''wslua tvb without a tree''' check_lua_script(self, 'tvb.lua', dns_port_pcap, True) + + +@fixtures.uses_fixtures +class case_wslua_unicode(subprocesstest.SubprocessTestCase): + def test_wslua_unicode(self, cmd_tshark, features, dirs, capture_file, unicode_env): + '''Check handling of unicode paths.''' + if not features.have_lua: + self.skipTest('Test requires Lua scripting support.') + + # Prepare test environment, put files in the right places. + uni_script = os.path.join(unicode_env.pluginsdir, 'script-Ф-€-中.lua') + shutil.copy(os.path.join(dirs.lua_dir, 'unicode.lua'), uni_script) + with open(unicode_env.path('load-Ф-€-中.lua'), 'w', encoding='utf8') as f: + f.write('return "Contents of Ф-€-中"\n') + uni_pcap = unicode_env.path('file-Ф-€-中.pcap') + shutil.copy(capture_file('empty.pcap'), uni_pcap) + + # Run process from a Unicode path as working directory. + proc = subprocess.Popen((cmd_tshark, '-r', uni_pcap), env=unicode_env.env, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=unicode_env.path()) + stdout, stderr = proc.communicate(timeout=60) + stdout_str = stdout.decode('utf8', 'replace') + stderr_str = stderr.decode('utf8', 'replace') + print("-- Begin stdout") + print(stdout_str) + print("-- End stdout") + if stderr_str: + print("-- Begin stderr") + print(stderr_str) + print("-- End stderr") + self.assertIn('All tests passed!', stdout_str) + assert stderr_str == "" + with open(unicode_env.path('written-by-lua-Ф-€-中.txt'), encoding='utf8') as f: + assert f.read() == 'Feedback from Lua: Ф-€-中\n' |