def test_listener_creation(self):
        # Tests the creation of listening sockets

        # Create board connections
        connections = []
        connections.append(SCAMPConnection(
            remote_host=None))
        orig_connection = EIEIOConnection()
        connections.append(orig_connection)

        # Create transceiver
        trnx = Transceiver(version=5, connections=connections)

        # Register a UDP listeners
        connection_1 = trnx.register_udp_listener(
            callback=None, connection_class=EIEIOConnection)
        connection_2 = trnx.register_udp_listener(
            callback=None, connection_class=EIEIOConnection)
        connection_3 = trnx.register_udp_listener(
            callback=None, connection_class=EIEIOConnection,
            local_port=orig_connection.local_port)
        connection_4 = trnx.register_udp_listener(
            callback=None, connection_class=EIEIOConnection,
            local_port=orig_connection.local_port + 1)

        assert connection_1 == orig_connection
        assert connection_2 == orig_connection
        assert connection_3 == orig_connection
        assert connection_4 != orig_connection
Example #2
0
    def test_listener_creation(self):
        # Tests the creation of listening sockets

        # Create board connections
        connections = []
        connections.append(SCAMPConnection(remote_host=None))
        orig_connection = EIEIOConnection()
        connections.append(orig_connection)

        # Create transceiver
        with Transceiver(version=5, connections=connections) as trnx:
            # Register a UDP listeners
            connection_1 = trnx.register_udp_listener(
                callback=None, connection_class=EIEIOConnection)
            connection_2 = trnx.register_udp_listener(
                callback=None, connection_class=EIEIOConnection)
            connection_3 = trnx.register_udp_listener(
                callback=None,
                connection_class=EIEIOConnection,
                local_port=orig_connection.local_port)
            connection_4 = trnx.register_udp_listener(
                callback=None,
                connection_class=EIEIOConnection,
                local_port=orig_connection.local_port + 1)

            assert connection_1 == orig_connection
            assert connection_2 == orig_connection
            assert connection_3 == orig_connection
            assert connection_4 != orig_connection
    def test_listener_creation(self):
        # Test of buffer manager listener creation problem, where multiple
        # listeners were being created for the buffer manager traffic from
        # individual boards, where it's preferred all traffic is received by
        # a single listener

        # Create two vertices
        v1 = _TestVertex(10, "v1", 256)
        v2 = _TestVertex(10, "v2", 256)

        # Create two tags - important thing is port=None
        t1 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=1, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')
        t2 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=2, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')

        # Create 'Tags' object and add tags
        t = Tags()
        t.add_ip_tag(t1, v1)
        t.add_ip_tag(t2, v2)

        # Create board connections
        connections = []
        connections.append(SCAMPConnection(
            remote_host=None))
        connections.append(EIEIOConnection())

        # Create two placements and 'Placements' object
        pl1 = Placement(v1, 0, 1, 1)
        pl2 = Placement(v2, 0, 2, 1)
        pl = Placements([pl1, pl2])

        # Create transceiver
        trnx = Transceiver(version=5, connections=connections)
        # Alternatively, one can register a udp listener for testing via:
        # trnx.register_udp_listener(callback=None,
        #        connection_class=EIEIOConnection)

        # Create buffer manager
        bm = BufferManager(pl, t, trnx)

        # Register two listeners, and check the second listener uses the
        # first rather than creating a new one
        bm._add_buffer_listeners(vertex=v1)
        bm._add_buffer_listeners(vertex=v2)

        number_of_listeners = 0
        for i in bm._transceiver._udp_listenable_connections_by_class[
                EIEIOConnection]:
            # Check if listener is registered on connection - we only expect
            # one listener to be registered, as all connections can use the
            # same listener for the buffer manager
            if not i[1] is None:
                number_of_listeners += 1
            print i
        self.assertEqual(number_of_listeners, 1)
 def test_patch_version_smaller(self):
     self.assertFalse(
         Transceiver.is_scamp_version_compabible(
             (_SCAMP_VERSION[0], _SCAMP_VERSION[1], _SCAMP_VERSION[2] - 1)))
 def test_patch_version_bigger(self):
     self.assertTrue(
         Transceiver.is_scamp_version_compabible(
             (_SCAMP_VERSION[0], _SCAMP_VERSION[1], _SCAMP_VERSION[2] + 1)))
 def test_major_version_too_small(self):
     self.assertFalse(
         Transceiver.is_scamp_version_compabible(
             (_SCAMP_VERSION[0] - 1, 0, 0)))
 def test_version_same(self):
     self.assertTrue(
         Transceiver.is_scamp_version_compabible(
             (_SCAMP_VERSION[0], _SCAMP_VERSION[1], _SCAMP_VERSION[2])))
 def test_patch_version_smaller(self):
     self.assertFalse(Transceiver.is_scamp_version_compabible((
         _SCAMP_VERSION[0], _SCAMP_VERSION[1], _SCAMP_VERSION[2] - 1)))
 def test_patch_version_bigger(self):
     self.assertTrue(Transceiver.is_scamp_version_compabible((
         _SCAMP_VERSION[0], _SCAMP_VERSION[1], _SCAMP_VERSION[2] + 1)))
 def test_major_version_too_small(self):
     self.assertFalse(Transceiver.is_scamp_version_compabible((
         _SCAMP_VERSION[0] - 1, 0, 0)))
 def test_version_same(self):
     self.assertTrue(Transceiver.is_scamp_version_compabible((
         _SCAMP_VERSION[0], _SCAMP_VERSION[1], _SCAMP_VERSION[2])))