tests: Decode subprocess.check_output() return value for python3

Explicit conversion to str is needed here for python3 compatibility.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
Masashi Honma 2019-01-31 17:15:42 +09:00 committed by Jouni Malinen
parent 1cfaecf70e
commit d5e6ffd661
7 changed files with 17 additions and 17 deletions

View file

@ -19,7 +19,7 @@ def execute_thread(command, reply):
logger.debug("thread run: " + cmd) logger.debug("thread run: " + cmd)
try: try:
status = 0 status = 0
buf = subprocess.check_output(command, stderr=subprocess.STDOUT) buf = subprocess.check_output(command, stderr=subprocess.STDOUT).decode()
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
status = e.returncode status = e.returncode
buf = e.output buf = e.output

View file

@ -529,7 +529,7 @@ def _test_ap_wpa2_eap_sim_ext_replace_sim(dev, apdev):
res = subprocess.check_output(["../../hostapd/hlr_auc_gw", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() 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", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() 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", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() 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", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() 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", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() 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", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() 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", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() 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", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() resp = res.split(' ')[2].rstrip()
@ -1707,7 +1707,7 @@ def run_ext_sim_auth(dev):
res = subprocess.check_output(["../../hostapd/hlr_auc_gw", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() resp = res.split(' ')[2].rstrip()

View file

@ -129,7 +129,7 @@ def interworking_ext_sim_auth(dev, method):
res = subprocess.check_output(["../../hostapd/hlr_auc_gw", res = subprocess.check_output(["../../hostapd/hlr_auc_gw",
"-m", "-m",
"auth_serv/hlr_auc_gw.milenage_db", "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: if "GSM-AUTH-RESP" not in res:
raise Exception("Unexpected hlr_auc_gw response") raise Exception("Unexpected hlr_auc_gw response")
resp = res.split(' ')[2].rstrip() resp = res.split(' ')[2].rstrip()

View file

@ -32,7 +32,7 @@ class IPAssign(object):
if self._ipv6: if self._ipv6:
# wait for DAD to finish # wait for DAD to finish
while True: 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: if not self._addr in o:
break break
time.sleep(0.1) 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): if "OK" not in hapd.request('DATA_TEST_FRAME ' + pkt):
raise Exception("DATA_TEST_FRAME failed") 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") raise Exception("gratuitous ARP frame updated erroneously")
finally: finally:
subprocess.call(['ip', 'neigh', 'del', '10.0.0.1', 'dev', dev.ifname]) 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): if "OK" not in hapd.request('DATA_TEST_FRAME ' + pkt):
raise Exception("DATA_TEST_FRAME failed") 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") raise Exception("unsolicited NA frame updated erroneously")
finally: finally:
subprocess.call(['ip', '-6', 'neigh', 'del', 'fdaa::2', 'dev', dev.ifname]) subprocess.call(['ip', '-6', 'neigh', 'del', 'fdaa::2', 'dev', dev.ifname])

View file

@ -20,7 +20,7 @@ def check_hs20_osu_client():
def set_pps(pps_mo): def set_pps(pps_mo):
res = subprocess.check_output(["../../hs20/client/hs20-osu-client", res = subprocess.check_output(["../../hs20/client/hs20-osu-client",
"set_pps", pps_mo]) "set_pps", pps_mo]).decode()
logger.info("set_pps result: " + res) logger.info("set_pps result: " + res)
def test_hs20_pps_mo_1(dev, apdev): def test_hs20_pps_mo_1(dev, apdev):

View file

@ -69,7 +69,7 @@ def get_wmediumd_version():
return LocalVariables.revs return LocalVariables.revs
try: try:
verstr = subprocess.check_output(['wmediumd', '-V']) verstr = subprocess.check_output(['wmediumd', '-V']).decode()
except OSError as e: except OSError as e:
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
raise HwsimSkip('wmediumd not available') raise HwsimSkip('wmediumd not available')

View file

@ -111,7 +111,7 @@ class Wlantest:
raise Exception("wlantest_cli failed") raise Exception("wlantest_cli failed")
return ret[1] return ret[1]
else: else:
return subprocess.check_output([self.wlantest_cli] + params) return subprocess.check_output([self.wlantest_cli] + params).decode()
def flush(self): def flush(self):
res = self.cli_cmd(["flush"]) res = self.cli_cmd(["flush"])