tests: Decode Popen() output for python3

Need to do this to avoid issues with following operations that assume
the output to be a str object.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
Masashi Honma 2019-01-31 17:16:02 +09:00 committed by Jouni Malinen
parent 15dfcb69df
commit 1c48c9bcf9
2 changed files with 10 additions and 10 deletions

View file

@ -90,7 +90,7 @@ class HapdRegCtrl:
def fst_clear_regdom():
cmd = subprocess.Popen([ "iw", "reg", "get" ], stdout=subprocess.PIPE)
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
if "country 00:" not in res:
subprocess.call(['iw', 'reg', 'set', '00'])

View file

@ -139,14 +139,14 @@ def log_ip_macsec():
cmd = subprocess.Popen([ "ip", "macsec", "show" ],
stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w'))
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip macsec:\n" + res)
def log_ip_link():
cmd = subprocess.Popen([ "ip", "link", "show" ],
stdout=subprocess.PIPE)
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip link:\n" + res)
@ -459,7 +459,7 @@ def log_ip_macsec_ns():
cmd = subprocess.Popen([ "ip", "macsec", "show" ],
stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w'))
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip macsec show:\n" + res)
@ -467,7 +467,7 @@ def log_ip_macsec_ns():
"ip", "macsec", "show" ],
stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w'))
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip macsec show (ns0):\n" + res)
@ -475,14 +475,14 @@ def log_ip_macsec_ns():
"ip", "macsec", "show" ],
stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w'))
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip macsec show (ns1):\n" + res)
def log_ip_link_ns():
cmd = subprocess.Popen([ "ip", "link", "show" ],
stdout=subprocess.PIPE)
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip link:\n" + res)
@ -490,7 +490,7 @@ def log_ip_link_ns():
"ip", "link", "show" ],
stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w'))
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip link show (ns0):\n" + res)
@ -498,7 +498,7 @@ def log_ip_link_ns():
"ip", "link", "show" ],
stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w'))
res = cmd.stdout.read()
res = cmd.stdout.read().decode()
cmd.stdout.close()
logger.info("ip link show (ns1):\n" + res)
@ -639,7 +639,7 @@ def run_macsec_psk_ns(dev, apdev, params):
c = subprocess.Popen(['ip', 'netns', 'exec', 'ns0',
'ping', '-c', '2', '192.168.248.18'],
stdout=subprocess.PIPE)
res = c.stdout.read()
res = c.stdout.read().decode()
c.stdout.close()
logger.info("ping:\n" + res)
if "2 packets transmitted, 2 received" not in res: