From 04fa9fc7fdc9df7704c775d2ba24a5ba167a1812 Mon Sep 17 00:00:00 2001 From: Masashi Honma Date: Sun, 3 Feb 2019 17:57:21 +0200 Subject: [PATCH] tests: Decode Popen() output values for python3 Explicit conversion to str is needed here for python3 compatibility. Signed-off-by: Masashi Honma --- tests/hwsim/test_ap_eap.py | 8 ++++---- tests/hwsim/test_ap_hs20.py | 14 +++++++------- tests/hwsim/test_ap_wps.py | 4 ++-- tests/hwsim/test_dbus.py | 4 ++-- tests/hwsim/test_wpas_ctrl.py | 2 +- tests/hwsim/test_wpas_mesh.py | 3 ++- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index d0826c210..17c000ff0 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -4224,7 +4224,7 @@ def ica_ocsp(cert, md="-sha256"): "-cert", cert, "-no_nonce", "-text" ] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - res = cmd.stdout.read() + "\n" + cmd.stderr.read() + res = cmd.stdout.read().decode() + "\n" + cmd.stderr.read().decode() cmd.stdout.close() cmd.stderr.close() cmd.wait() @@ -4241,7 +4241,7 @@ def ica_ocsp(cert, md="-sha256"): "-text" ] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - res = cmd.stdout.read() + "\n" + cmd.stderr.read() + res = cmd.stdout.read().decode() + "\n" + cmd.stderr.read().decode() cmd.stdout.close() cmd.stderr.close() cmd.wait() @@ -6028,7 +6028,7 @@ def test_ap_wpa2_eap_sim_db(dev, apdev, params): cmd = subprocess.Popen(['../../hostapd/hlr_auc_gw', '-m', fname, data], stdout=subprocess.PIPE) - res = cmd.stdout.read().strip() + res = cmd.stdout.read().decode().strip() cmd.stdout.close() logger.debug("hlr_auc_gw response: " + res) socket.sendto(res, self.client_address) @@ -6465,7 +6465,7 @@ def test_ap_wpa2_eap_psk_mac_addr_change(dev, apdev): hapd = hostapd.add_ap(apdev[0], params) cmd = subprocess.Popen(['ps', '-eo', 'pid,command'], stdout=subprocess.PIPE) - res = cmd.stdout.read() + res = cmd.stdout.read().decode() cmd.stdout.close() pid = 0 for p in res.splitlines(): diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 977b9d1f6..efc0c0b04 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -4564,7 +4564,7 @@ def send_arp(dev, dst_ll="ff:ff:ff:ff:ff:ff", src_ll=None, opcode=1, def get_permanent_neighbors(ifname): cmd = subprocess.Popen(['ip', 'nei'], stdout=subprocess.PIPE) - res = cmd.stdout.read() + res = cmd.stdout.read().decode() cmd.stdout.close() return [ line for line in res.splitlines() if "PERMANENT" in line and ifname in line ] @@ -4678,13 +4678,13 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): time.sleep(0.1) brcmd = subprocess.Popen(['brctl', 'show'], stdout=subprocess.PIPE) - res = brcmd.stdout.read() + res = brcmd.stdout.read().decode() brcmd.stdout.close() logger.info("Bridge setup: " + res) brcmd = subprocess.Popen(['brctl', 'showstp', 'ap-br0'], stdout=subprocess.PIPE) - res = brcmd.stdout.read() + res = brcmd.stdout.read().decode() brcmd.stdout.close() logger.info("Bridge showstp: " + res) @@ -4873,7 +4873,7 @@ def _test_proxyarp_open(dev, apdev, params, ebtables=False): if ebtables: cmd = subprocess.Popen(['ebtables', '-L', '--Lc'], stdout=subprocess.PIPE) - res = cmd.stdout.read() + res = cmd.stdout.read().decode() cmd.stdout.close() logger.info("ebtables results:\n" + res) @@ -5024,13 +5024,13 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): time.sleep(0.1) brcmd = subprocess.Popen(['brctl', 'show'], stdout=subprocess.PIPE) - res = brcmd.stdout.read() + res = brcmd.stdout.read().decode() brcmd.stdout.close() logger.info("Bridge setup: " + res) brcmd = subprocess.Popen(['brctl', 'showstp', 'ap-br0'], stdout=subprocess.PIPE) - res = brcmd.stdout.read() + res = brcmd.stdout.read().decode() brcmd.stdout.close() logger.info("Bridge showstp: " + res) @@ -5130,7 +5130,7 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False): if ebtables: cmd = subprocess.Popen(['ebtables', '-L', '--Lc'], stdout=subprocess.PIPE) - res = cmd.stdout.read() + res = cmd.stdout.read().decode() cmd.stdout.close() logger.info("ebtables results:\n" + res) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index ab555aff5..d6df94713 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -3905,7 +3905,7 @@ def test_ap_wps_wpa_cli_action(dev, apdev, test_params): arg = [ 'ps', 'ax' ] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE) - out = cmd.communicate()[0] + out = cmd.communicate()[0].decode() cmd.wait() logger.debug("Processes:\n" + out) if "wpa_cli -P %s -B -i %s" % (pidfile, dev[0].ifname) not in out: @@ -3931,7 +3931,7 @@ def test_ap_wps_wpa_cli_action(dev, apdev, test_params): arg = [ 'ps', 'ax' ] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE) - out = cmd.communicate()[0] + out = cmd.communicate()[0].decode() cmd.wait() logger.debug("Remaining processes:\n" + out) if "wpa_cli -P %s -B -i %s" % (pidfile, dev[0].ifname) in out: diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py index e0703fae0..a56ea51f1 100644 --- a/tests/hwsim/test_dbus.py +++ b/tests/hwsim/test_dbus.py @@ -5280,8 +5280,8 @@ def run_busctl(service, obj): cmd.wait() logger.info("busctl stdout:\n%s" % out[0].strip()) if len(out[1]) > 0: - logger.info("busctl stderr: %s" % out[1].strip()) - if "Duplicate property" in out[1]: + logger.info("busctl stderr: %s" % out[1].decode().strip()) + if "Duplicate property" in out[1].decode(): raise Exception("Duplicate property") def test_dbus_introspect_busctl(dev, apdev): diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index fece8f170..e55428297 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/tests/hwsim/test_wpas_ctrl.py @@ -1617,7 +1617,7 @@ def test_wpas_ctrl_wait(dev, apdev, test_params): prg = '../../wpa_supplicant/wpa_supplicant' arg = [ prg ] cmd = subprocess.Popen(arg, stdout=subprocess.PIPE) - out = cmd.communicate()[0] + out = cmd.communicate()[0].decode() cmd.wait() tracing = "Linux tracing" in out diff --git a/tests/hwsim/test_wpas_mesh.py b/tests/hwsim/test_wpas_mesh.py index 45317d0d3..9e116409d 100644 --- a/tests/hwsim/test_wpas_mesh.py +++ b/tests/hwsim/test_wpas_mesh.py @@ -272,7 +272,7 @@ def _test_mesh_open_rssi_threshold(dev, apdev, value, expected): cmd = subprocess.Popen([ "iw", "dev", dev[0].ifname, "get", "mesh_param", "mesh_rssi_threshold" ], stdout=subprocess.PIPE) - mesh_rssi_threshold = int(cmd.stdout.read().split(" ")[0]) + mesh_rssi_threshold = int(cmd.stdout.read().decode().split(" ")[0]) dev[0].mesh_group_remove() check_mesh_group_removed(dev[0]) @@ -1181,6 +1181,7 @@ def _test_mesh_open_vht_160(dev, apdev): reg = cmd.stdout.read() found = False for entry in reg.splitlines(): + entry = entry.decode() if "@ 160)" in entry and "DFS" not in entry: found = True break