From d5e6ffd66181e28e243367201140dbe235da32df Mon Sep 17 00:00:00 2001 From: Masashi Honma Date: Thu, 31 Jan 2019 17:15:42 +0900 Subject: [PATCH] tests: Decode subprocess.check_output() return value for python3 Explicit conversion to str is needed here for python3 compatibility. Signed-off-by: Masashi Honma --- tests/hwsim/remotehost.py | 2 +- tests/hwsim/test_ap_eap.py | 18 +++++++++--------- tests/hwsim/test_ap_hs20.py | 2 +- tests/hwsim/test_hs20_filter.py | 6 +++--- tests/hwsim/test_hs20_pps_mo.py | 2 +- tests/hwsim/test_wmediumd.py | 2 +- tests/hwsim/wlantest.py | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/hwsim/remotehost.py b/tests/hwsim/remotehost.py index f18da4994..aa83c1d94 100644 --- a/tests/hwsim/remotehost.py +++ b/tests/hwsim/remotehost.py @@ -19,7 +19,7 @@ def execute_thread(command, reply): logger.debug("thread run: " + cmd) try: status = 0 - buf = subprocess.check_output(command, stderr=subprocess.STDOUT) + buf = subprocess.check_output(command, stderr=subprocess.STDOUT).decode() except subprocess.CalledProcessError as e: status = e.returncode buf = e.output diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index 38a0ed137..88dff5984 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -529,7 +529,7 @@ def _test_ap_wpa2_eap_sim_ext_replace_sim(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000000 " + rand]) + "GSM-AUTH-REQ 232010000000000 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -555,7 +555,7 @@ def _test_ap_wpa2_eap_sim_ext_replace_sim(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000009 " + rand]) + "GSM-AUTH-REQ 232010000000009 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -595,7 +595,7 @@ def _test_ap_wpa2_eap_sim_ext_replace_sim2(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000000 " + rand]) + "GSM-AUTH-REQ 232010000000000 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -622,7 +622,7 @@ def _test_ap_wpa2_eap_sim_ext_replace_sim2(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000009 " + rand]) + "GSM-AUTH-REQ 232010000000009 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -665,7 +665,7 @@ def _test_ap_wpa2_eap_sim_ext_replace_sim3(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000000 " + rand]) + "GSM-AUTH-REQ 232010000000000 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -698,7 +698,7 @@ def _test_ap_wpa2_eap_sim_ext_replace_sim3(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000009 " + rand]) + "GSM-AUTH-REQ 232010000000009 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -764,7 +764,7 @@ def _test_ap_wpa2_eap_sim_change_bssid(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000000 " + rand]) + "GSM-AUTH-REQ 232010000000000 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -805,7 +805,7 @@ def _test_ap_wpa2_eap_sim_no_change_set(dev, apdev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000000 " + rand]) + "GSM-AUTH-REQ 232010000000000 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() @@ -1707,7 +1707,7 @@ def run_ext_sim_auth(dev): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000000 " + rand]) + "GSM-AUTH-REQ 232010000000000 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index acc391732..75fef33c2 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -129,7 +129,7 @@ def interworking_ext_sim_auth(dev, method): res = subprocess.check_output(["../../hostapd/hlr_auc_gw", "-m", "auth_serv/hlr_auc_gw.milenage_db", - "GSM-AUTH-REQ 232010000000000 " + rand]) + "GSM-AUTH-REQ 232010000000000 " + rand]).decode() if "GSM-AUTH-RESP" not in res: raise Exception("Unexpected hlr_auc_gw response") resp = res.split(' ')[2].rstrip() diff --git a/tests/hwsim/test_hs20_filter.py b/tests/hwsim/test_hs20_filter.py index 5ae498cd7..545751c59 100644 --- a/tests/hwsim/test_hs20_filter.py +++ b/tests/hwsim/test_hs20_filter.py @@ -32,7 +32,7 @@ class IPAssign(object): if self._ipv6: # wait for DAD to finish while True: - o = subprocess.check_output(self._cmd + ['show', 'tentative', 'dev', self._iface]) + o = subprocess.check_output(self._cmd + ['show', 'tentative', 'dev', self._iface]).decode() if not self._addr in o: break time.sleep(0.1) @@ -167,7 +167,7 @@ def test_ip4_drop_gratuitous_arp(devs, apdevs, params): if "OK" not in hapd.request('DATA_TEST_FRAME ' + pkt): raise Exception("DATA_TEST_FRAME failed") - if hapd.own_addr() in subprocess.check_output(['ip', 'neigh', 'show']): + if hapd.own_addr() in subprocess.check_output(['ip', 'neigh', 'show']).decode(): raise Exception("gratuitous ARP frame updated erroneously") finally: subprocess.call(['ip', 'neigh', 'del', '10.0.0.1', 'dev', dev.ifname]) @@ -193,7 +193,7 @@ def test_ip6_drop_unsolicited_na(devs, apdevs, params): if "OK" not in hapd.request('DATA_TEST_FRAME ' + pkt): raise Exception("DATA_TEST_FRAME failed") - if hapd.own_addr() in subprocess.check_output(['ip', 'neigh', 'show']): + if hapd.own_addr() in subprocess.check_output(['ip', 'neigh', 'show']).decode(): raise Exception("unsolicited NA frame updated erroneously") finally: subprocess.call(['ip', '-6', 'neigh', 'del', 'fdaa::2', 'dev', dev.ifname]) diff --git a/tests/hwsim/test_hs20_pps_mo.py b/tests/hwsim/test_hs20_pps_mo.py index 5324cde1f..75c524ad6 100644 --- a/tests/hwsim/test_hs20_pps_mo.py +++ b/tests/hwsim/test_hs20_pps_mo.py @@ -20,7 +20,7 @@ def check_hs20_osu_client(): def set_pps(pps_mo): res = subprocess.check_output(["../../hs20/client/hs20-osu-client", - "set_pps", pps_mo]) + "set_pps", pps_mo]).decode() logger.info("set_pps result: " + res) def test_hs20_pps_mo_1(dev, apdev): diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py index d30f27c3f..cb322cf00 100644 --- a/tests/hwsim/test_wmediumd.py +++ b/tests/hwsim/test_wmediumd.py @@ -69,7 +69,7 @@ def get_wmediumd_version(): return LocalVariables.revs try: - verstr = subprocess.check_output(['wmediumd', '-V']) + verstr = subprocess.check_output(['wmediumd', '-V']).decode() except OSError as e: if e.errno == errno.ENOENT: raise HwsimSkip('wmediumd not available') diff --git a/tests/hwsim/wlantest.py b/tests/hwsim/wlantest.py index 75dcdb568..95c09bb99 100644 --- a/tests/hwsim/wlantest.py +++ b/tests/hwsim/wlantest.py @@ -111,7 +111,7 @@ class Wlantest: raise Exception("wlantest_cli failed") return ret[1] else: - return subprocess.check_output([self.wlantest_cli] + params) + return subprocess.check_output([self.wlantest_cli] + params).decode() def flush(self): res = self.cli_cmd(["flush"])