loxi-prep: rewrite vendor tests to use pyloxi message classes
diff --git a/tests/bsn_shell.py b/tests/bsn_shell.py
index 8886c80..2ac2f08 100644
--- a/tests/bsn_shell.py
+++ b/tests/bsn_shell.py
@@ -22,23 +22,17 @@
Use the BSN_SHELL_COMMAND vendor command to run the given command
and receive the output
"""
- m = ofp.message.vendor()
- m.vendor = 0x005c16c7
- m.data = struct.pack("!LL", 6, 0) + cmd
- rc = self.controller.message_send(m)
- self.assertNotEqual(rc, -1, "Error sending shell command")
+ m = ofp.message.bsn_shell_command(service=0, data=cmd)
+ self.controller.message_send(m)
out = ""
while True:
- m, r = self.controller.poll(ofp.OFPT_VENDOR, 60)
- self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID")
- subtype = struct.unpack("!L", m.data[:4])[0]
- if subtype == 7:
- out += m.data[4:]
- elif subtype == 8:
- status = struct.unpack("!LL", m.data)[1]
- return status, out
+ m, _ = self.controller.poll(ofp.OFPT_VENDOR, 60)
+ if isinstance(m, ofp.message.bsn_shell_output):
+ out += m.data
+ elif isinstance(m, ofp.message.bsn_shell_status):
+ return m.status, out
else:
- assert False, "Wrong subtype"
+ raise AssertionError("Unexpected message received")
def runTest(self):
status, out = self.bsn_shell_command("echo _one space_")