def return_cores():
    sockets = topology.Socket(
        0, {
            0: topology.Core(0, {
                0: topology.CPU(0),
                4: topology.CPU(4)
            }),
            1: topology.Core(1, {
                1: topology.CPU(1),
                5: topology.CPU(5)
            }),
            2: topology.Core(2, {
                2: topology.CPU(2),
                6: topology.CPU(6)
            }),
            3: topology.Core(3, {
                3: topology.CPU(3),
                7: topology.CPU(7)
            }),
            4: topology.Core(4, {
                4: topology.CPU(4),
                8: topology.CPU(8)
            })
        })

    return topology.Platform({0: sockets})
Пример #2
0
def test_init_failure2(monkeypatch):
    # Set the procfs environment variable.
    monkeypatch.setenv(proc.ENV_PROC_FS, helpers.procfs_dir("ok"))

    sockets = topology.Platform({
        0: topology.Socket(0, {
            0: topology.Core(0, {
                0: topology.CPU(0),
                4: topology.CPU(4)
            }),
            1: topology.Core(1, {
                1: topology.CPU(1),
                5: topology.CPU(5)
            })
        })
    })

    with patch('intel.topology.parse', MagicMock(return_value=sockets)):
        temp_dir = tempfile.mkdtemp()
        with pytest.raises(RuntimeError) as err:
            init.init(os.path.join(temp_dir, "init"), 2, 1, "vertical",
                      "vertical")
        assert err is not None
        expected_msg = "No more free cores left to assign for controlplane"
        assert err.value.args[0] == expected_msg
def return_socket():
    socket = topology.Socket(0)
    core = topology.Core(0)
    socket.cores[0] = core
    cpu0 = topology.CPU(0)
    cpu1 = topology.CPU(1)
    core.cpus[0] = cpu0
    core.cpus[1] = cpu1
    return socket
def test_init_failure1(monkeypatch):
    # Set the procfs environment variable.
    monkeypatch.setenv(proc.ENV_PROC_FS, helpers.procfs_dir("ok"))

    sockets = {
        0: topology.Socket(0, {
            0: topology.Core(0, {
                0: topology.CPU(0),
                2: topology.CPU(2)
            }),
            1: topology.Core(1, {
                1: topology.CPU(1),
                3: topology.CPU(3)
            })
        })
    }

    with patch('intel.topology.parse', MagicMock(return_value=sockets)):
        temp_dir = tempfile.mkdtemp()
        with pytest.raises(RuntimeError):
            init.init(os.path.join(temp_dir, "init"), 2, 1)
def return_fake_platform():
    sockets = dict()
    sockets["0"] = topology.Socket("0")
    sockets["1"] = topology.Socket("1")

    core0 = topology.Core("0")
    core0.pool = "exclusive"
    cpu0 = topology.CPU("0")
    cpu0.isolated = True
    cpu3 = topology.CPU("3")
    cpu3.isolated = True
    core0.cpus["0"] = cpu0
    core0.cpus["3"] = cpu3
    sockets["0"].cores["0"] = core0

    core1 = topology.Core("1")
    core1.pool = "shared"
    cpu1 = topology.CPU("1")
    cpu1.isolated = True
    cpu4 = topology.CPU("4")
    cpu4.isolated = True
    core1.cpus["1"] = cpu1
    core1.cpus["4"] = cpu4
    sockets["0"].cores["1"] = core1

    core2 = topology.Core("2")
    core2.pool = "shared"
    cpu2 = topology.CPU("2")
    cpu5 = topology.CPU("5")
    core2.cpus["2"] = cpu2
    core2.cpus["5"] = cpu5
    sockets["0"].cores["2"] = core2

    return topology.Platform(sockets)
Пример #6
0
def test_init_failure3(monkeypatch):
    # Set the procfs environment variable.
    monkeypatch.setenv(proc.ENV_PROC_FS, helpers.procfs_dir("ok"))

    sockets = topology.Platform({
        0:
        topology.Socket(
            0, {
                0: topology.Core(0, {
                    0: topology.CPU(0),
                    4: topology.CPU(4)
                }),
                1: topology.Core(1, {
                    1: topology.CPU(1),
                    5: topology.CPU(5)
                }),
                2: topology.Core(2, {
                    2: topology.CPU(2),
                    6: topology.CPU(6)
                })
            })
    })

    with patch('intel.topology.parse', MagicMock(return_value=sockets)):
        with pytest.raises(RuntimeError) as err:
            init.init(2, 1, "vertical", "vertical", "-1", "fake-namespace")
        assert err is not None
        expected_msg = "No more free cores left to assign for infra"
        assert err.value.args[0] == expected_msg
Пример #7
0
def test_init_failure1(monkeypatch):
    # Set the procfs environment variable.
    monkeypatch.setenv(proc.ENV_PROC_FS, helpers.procfs_dir("ok"))

    sockets = topology.Platform({
        0:
        topology.Socket(
            0, {
                0: topology.Core(0, {
                    0: topology.CPU(0),
                    2: topology.CPU(2)
                }),
                1: topology.Core(1, {
                    1: topology.CPU(1),
                    3: topology.CPU(3)
                })
            })
    })

    with patch('intel.topology.parse', MagicMock(return_value=sockets)):
        with pytest.raises(RuntimeError):
            init.init(2, 1, "vertical", "vertical", "-1", "fake-namespace")
Пример #8
0
def quad_core():
    return topology.Socket(0, {
        0: topology.Core(0, {
            0: topology.CPU(0),
            4: topology.CPU(4)
        }),
        1: topology.Core(1, {
            1: topology.CPU(1),
            5: topology.CPU(5)
        }),
        2: topology.Core(2, {
            2: topology.CPU(2),
            6: topology.CPU(6)
        }),
        3: topology.Core(3, {
            3: topology.CPU(3),
            7: topology.CPU(7)
        })
    })