forked from osmocom/wireshark
Test: Fix capinfos output and command paths.
Convert capinfos output to UTF-8 in getCaptureInfo. Normalize our command paths, otherwise "./run/RelWithDebInfo/..." might be interpreted as the command "." with flags "/run", "/RelWithDebInfo", etc. on Windows. Change-Id: Ib7336a016db3ee0805739fc44913cb9c6895aaad Reviewed-on: https://code.wireshark.org/review/27239 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
48ab9adbd5
commit
74fd569018
|
@ -149,7 +149,7 @@ def setProgramPath(path):
|
|||
dotexe = '.exe'
|
||||
for cmd in commands:
|
||||
cmd_var = 'cmd_' + cmd
|
||||
cmd_path = os.path.join(path, cmd + dotexe)
|
||||
cmd_path = os.path.normpath(os.path.join(path, cmd + dotexe))
|
||||
if not os.path.exists(cmd_path) or not os.access(cmd_path, os.X_OK):
|
||||
cmd_path = None
|
||||
program_path = None
|
||||
|
|
|
@ -202,8 +202,12 @@ class SubprocessTestCase(unittest.TestCase):
|
|||
if capinfos_args is not None:
|
||||
capinfos_cmd += capinfos_args
|
||||
capinfos_cmd.append(cap_file)
|
||||
capinfos_stdout = str(subprocess.check_output(capinfos_cmd))
|
||||
self.log_fd_write_bytes(capinfos_stdout)
|
||||
capinfos_data = subprocess.check_output(capinfos_cmd)
|
||||
if sys.version_info[0] >= 3:
|
||||
capinfos_stdout = capinfos_data.decode('UTF-8', 'replace')
|
||||
else:
|
||||
capinfos_stdout = unicode(capinfos_data, 'UTF-8', 'replace')
|
||||
self.log_fd.write(capinfos_stdout)
|
||||
return capinfos_stdout
|
||||
|
||||
def checkPacketCount(self, num_packets, cap_file=None):
|
||||
|
|
|
@ -78,17 +78,18 @@ def check_capinfos_info(self, cap_file):
|
|||
}
|
||||
capinfos_out = self.getCaptureInfo(capinfos_args=('-t', '-E', '-c', '-d', '-M'), cap_file=cap_file)
|
||||
|
||||
for sp_key in str_pats:
|
||||
str_pat = '{}:\s+([\S ]+)'.format(str_pats[sp_key])
|
||||
str_res = re.search(str_pat, capinfos_out)
|
||||
self.assertTrue(str_res is not None, 'Failed to generate {}'.format(sp_key))
|
||||
cap_info[sp_key] = str_res.group(1)
|
||||
for ci_line in capinfos_out.splitlines():
|
||||
for sp_key in str_pats:
|
||||
str_pat = '{}:\s+([\S ]+)'.format(str_pats[sp_key])
|
||||
str_res = re.search(str_pat, ci_line)
|
||||
if str_res is not None:
|
||||
cap_info[sp_key] = str_res.group(1)
|
||||
|
||||
for ip_key in int_pats:
|
||||
int_pat = '{}:\s+(\d+)'.format(int_pats[ip_key])
|
||||
int_res = re.search(int_pat, capinfos_out)
|
||||
self.assertTrue(int_res is not None, 'Failed to generate {}'.format(ip_key))
|
||||
cap_info[ip_key] = int(int_res.group(1))
|
||||
for ip_key in int_pats:
|
||||
int_pat = '{}:\s+(\d+)'.format(int_pats[ip_key])
|
||||
int_res = re.search(int_pat, ci_line)
|
||||
if int_res is not None:
|
||||
cap_info[ip_key] = int(int_res.group(1))
|
||||
|
||||
return cap_info
|
||||
|
||||
|
|
Loading…
Reference in New Issue