blob: 04b8679f7fff6d62663b19d71acafdf5fa8a29a6 [file] [log] [blame]
Rich Lane5ec97b82013-01-06 18:04:25 -08001#!/usr/bin/python
2
3import unittest
4import message
5import action
6import instruction
7import cstruct as ofp
8
9class flow_stats_pack(unittest.TestCase):
10 def runTest(self):
11 msg = message.flow_stats_entry()
12 match = ofp.ofp_match()
13 match.wildcards &= ~ofp.OFPFW_IN_PORT
14 act = action.action_output()
15 act.port = 3
16 msg.match = match
17 pkt = msg.pack()
18 self.assertEqual(len(pkt), 136)
19 inst = instruction.instruction_apply_actions()
20 self.assertTrue(inst.actions.add(act), "Could not add action")
21 self.assertTrue(msg.instructions.add(inst), "Could not add instructions")
22 #self.assertTrue(msg.actions.add(act), "Could not add action")
23 pkt = msg.pack()
24 # 160 = 136 for flow_stats_entry and 24 for instruction_list
25 self.assertEqual(len(pkt), 160)
26 rep = message.flow_stats_reply()
27 self.assertEqual(len(rep.pack()),12)
28 rep.stats.append(msg)
29 self.assertEqual(len(rep.pack()),172)
30
31
32
33class match_pack(unittest.TestCase):
34 def runTest(self):
35 match = ofp.ofp_match()
36 self.assertEqual(len(match.pack()), 88)
37
38
39if __name__ == '__main__':
40 unittest.main()