aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasashi Honma <masashi.honma@gmail.com>2019-01-31 08:15:43 (GMT)
committerJouni Malinen <j@w1.fi>2019-02-04 10:26:33 (GMT)
commite285418bedde6b4bb7b89e8395d43c77a0769dbe (patch)
tree4566cdf5214d3c3ab6b7f41ae69fb368cf64bafb
parentf94df3c0b0f8a290a07da83e055af0602dffe8cf (diff)
downloadhostap-e285418bedde6b4bb7b89e8395d43c77a0769dbe.zip
hostap-e285418bedde6b4bb7b89e8395d43c77a0769dbe.tar.gz
hostap-e285418bedde6b4bb7b89e8395d43c77a0769dbe.tar.bz2
tests: HWSimController class with python3 compatible version
Update class HWSimController and netlink helpers to not depend on python2 implicit conversions. Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
-rw-r--r--tests/hwsim/hwsim.py2
-rw-r--r--tests/hwsim/netlink.py9
2 files changed, 5 insertions, 6 deletions
diff --git a/tests/hwsim/hwsim.py b/tests/hwsim/hwsim.py
index 9300922..bc1be85 100644
--- a/tests/hwsim/hwsim.py
+++ b/tests/hwsim/hwsim.py
@@ -22,7 +22,7 @@ HWSIM_ATTR_USE_CHANCTX = 15
class HWSimController(object):
def __init__(self):
self._conn = netlink.Connection(netlink.NETLINK_GENERIC)
- self._fid = netlink.genl_controller.get_family_id('MAC80211_HWSIM')
+ self._fid = netlink.genl_controller.get_family_id(b'MAC80211_HWSIM')
def create_radio(self, n_channels=None, use_chanctx=False,
use_p2p_device=False):
diff --git a/tests/hwsim/netlink.py b/tests/hwsim/netlink.py
index eef7909..eba6102 100644
--- a/tests/hwsim/netlink.py
+++ b/tests/hwsim/netlink.py
@@ -33,7 +33,7 @@ class Attr(object):
hdr = struct.pack("HH", len(self._data) + 4, self._type)
length = len(self._data)
pad = ((length + 4 - 1) & ~3 ) - length
- return hdr + self._data + '\0' * pad
+ return hdr + self._data + b'\x00' * pad
def __repr__(self):
return '<Attr type %d, data "%s">' % (self._type, repr(self._data))
@@ -71,7 +71,7 @@ class U8Attr(Attr):
class FlagAttr(Attr):
def __init__(self, attr_type):
- Attr.__init__(self, attr_type, "")
+ Attr.__init__(self, attr_type, b"")
class Nested(Attr):
def __init__(self, attr_type, attrs):
@@ -113,10 +113,9 @@ class Message(object):
self.pid = -1
payload = payload or []
if isinstance(payload, list):
- contents = []
+ self.payload = bytes()
for attr in payload:
- contents.append(attr._dump())
- self.payload = ''.join(contents)
+ self.payload += attr._dump()
else:
self.payload = payload