[7055] : Minor cleanup.

VOL-548:  Frameio test fix.  Submitted on behalf of Karthick Ramanarayanan

Change-Id: If05d89bdb027faa21dc7a8fd05d3014d6d2ad01a
diff --git a/tests/itests/run_as_root/test_frameio.py b/tests/itests/run_as_root/test_frameio.py
index bd8f770..ad62f98 100644
--- a/tests/itests/run_as_root/test_frameio.py
+++ b/tests/itests/run_as_root/test_frameio.py
@@ -36,7 +36,7 @@
 from twisted.trial.unittest import TestCase
 
 from common.frameio.frameio import FrameIOManager, BpfProgramFilter, \
-    FrameIOPortProxy
+    FrameIOPortProxy, FrameIOPort
 from common.utils.asleep import asleep
 from common.utils.deferred_utils import DeferredWithTimeout, TimeOutError
 
@@ -45,7 +45,6 @@
 
 
 class TestFrameIO(TestCase):
-
     @inlineCallbacks
     def make_veth_pairs_if_needed(self):
 
@@ -78,16 +77,18 @@
         rcvd = DeferredWithTimeout()
         p0 = self.mgr.open_port('veth0', none).up()
         p1 = self.mgr.open_port('veth1',
-                                    lambda p, f: rcvd.callback((p, f))).up()
+                                lambda p, f: rcvd.callback((p, f))).up()
 
         # sending to veth0 should result in receiving on veth1 and vice versa
         bogus_frame = 'bogus packet'
-        p0.send(bogus_frame)
+        bogus_frame_padded = bogus_frame + '\x00' * (
+                                FrameIOPort.MIN_PKT_SIZE - len(bogus_frame))
+        p0.send(bogus_frame_padded)
 
         # check that we receved packet
         port, frame = yield rcvd
         self.assertEqual(port, p1)
-        self.assertEqual(frame, bogus_frame)
+        self.assertEqual(frame, bogus_frame_padded)
 
     @inlineCallbacks
     def test_packet_send_receive_with_filter(self):
@@ -100,7 +101,7 @@
                                 filter=filter).up()
 
         # sending bogus packet would not be received
-        ip_packet = str(Ether()/IP(dst='123.123.123.123'))
+        ip_packet = str(Ether() / IP(dst='123.123.123.123'))
         p0.send(ip_packet)
 
         # check that we receved packet
@@ -141,6 +142,7 @@
                 queue.append(frame)
                 if len(queue1) == n and len(queue2) == n:
                     done.callback(None)
+
             return _append
 
         p1in = self.mgr.open_port('veth0', none).up()
@@ -175,6 +177,7 @@
                 queue.append(frame)
                 if len(queue1) == n / 2 and len(queue2) == n / 2:
                     done.callback(None)
+
             return _append
 
         filter = BpfProgramFilter('vlan 100')
@@ -187,7 +190,7 @@
         def send_packets(port, n):
             for i in xrange(n):
                 # packets have alternating VLAN ids 100 and 101
-                pkt = Ether()/Dot1Q(vlan=100 + i % 2)
+                pkt = Ether() / Dot1Q(vlan=100 + i % 2)
                 port.send(str(pkt))
                 yield asleep(0.00001 * random.random())  # to interleave
 
@@ -217,24 +220,25 @@
 
         # sending from pin1, should be received by pout1
         bogus_frame = 'bogus packet'
-        pin1.send(bogus_frame)
+        bogus_frame_padded = bogus_frame + '\x00' * (
+                                FrameIOPort.MIN_PKT_SIZE - len(bogus_frame))
+        pin1.send(bogus_frame_padded)
         port, frame = yield queue1.get()
         self.assertEqual(port, pout1)
-        self.assertEqual(frame, bogus_frame)
+        self.assertEqual(frame, bogus_frame_padded)
         self.assertEqual(len(queue1.pending), 0)
         self.assertEqual(len(queue2.pending), 0)
 
         # sending from pin2, should be received by pout1
-        bogus_frame = 'bogus packet'
-        pin2.send(bogus_frame)
+        pin2.send(bogus_frame_padded)
         port, frame = yield queue1.get()
         self.assertEqual(port, pout1)
-        self.assertEqual(frame, bogus_frame)
+        self.assertEqual(frame, bogus_frame_padded)
         self.assertEqual(len(queue1.pending), 0)
         self.assertEqual(len(queue2.pending), 0)
 
         # sending from pin1, should be received by both pouts
-        ip_packet = str(Ether()/IP(dst='123.123.123.123'))
+        ip_packet = str(Ether() / IP(dst='123.123.123.123'))
         pin1.send(ip_packet)
         port, frame = yield queue1.get()
         self.assertEqual(port, pout1)
@@ -246,7 +250,7 @@
         self.assertEqual(len(queue2.pending), 0)
 
         # sending from pin2, should be received by pout1
-        ip_packet = str(Ether()/IP(dst='123.123.123.123'))
+        ip_packet = str(Ether() / IP(dst='123.123.123.123'))
         pin2.send(ip_packet)
         port, frame = yield queue1.get()
         self.assertEqual(port, pout1)
@@ -265,4 +269,5 @@
 
 if __name__ == '__main__':
     import unittest
+
     unittest.main()