def test_no_app_level_flexible():
    app_graph, mac_graph, n_keys_map = create_app_less()
    # The number of bits is 1 + 11 + 21 = 33, so it shouldn't fail
    routing_info = flexible_allocate(mac_graph, n_keys_map)

    # all but the bottom 8 bits should be the same
    app_mask = 0xFFFFFF00
    check_keys_for_application_partition_pairs(
        app_graph, mac_graph, routing_info, app_mask)
def test_big_flexible_fixed():
    app_graph, mac_graph, n_keys_map = create_big(True)

    # The number of bits is 1 + 11 + 21 = 33, so it shouldn't fail
    routing_info = flexible_allocate(mac_graph, n_keys_map)

    # all but the bottom 18 bits should be the same
    app_mask = 0xFFFC0000
    check_keys_for_application_partition_pairs(
        app_graph, mac_graph, routing_info, app_mask)
def test_flexible_allocator_with_fixed():
    # Allocate something and check it does the right thing
    app_graph, mac_graph, n_keys_map = create_graphs1(True)

    # The number of bits is 7 + 11 = 20, so it shouldn't fail
    routing_info = flexible_allocate(mac_graph, n_keys_map)

    # all but the bottom 11 bits should be the same
    app_mask = 0xFFFFF800
    check_keys_for_application_partition_pairs(
        app_graph, mac_graph, routing_info, app_mask)
def test_big_flexible_no_fixed():
    unittest_setup()
    app_graph, mac_graph, n_keys_map = create_big(False)

    # The number of bits is 1 + 11 + 21 = 33, so it shouldn't fail
    routing_info = flexible_allocate(mac_graph, n_keys_map)

    # The number of bits is 1 + 21 = 22, so it shouldn't fail
    # all but the bottom 21 bits should be the same
    app_mask = 0xFFE00000
    check_keys_for_application_partition_pairs(app_graph, mac_graph,
                                               routing_info, app_mask)
def test_no_edge():
    app_graph, mac_graph, n_keys_map = create_graphs_no_edge()
    flexible_allocate(mac_graph, n_keys_map)
    routing_info = global_allocate(mac_graph, n_keys_map)
    assert len(list(routing_info)) == 0
def test_fixed_only():
    app_graph, mac_graph, n_keys_map = create_graphs_only_fixed()
    flexible_allocate(mac_graph, n_keys_map)
    routing_info = global_allocate(mac_graph, n_keys_map)
    assert len(list(routing_info)) == 2