Esempio n. 1
0
def process():
    cpuinfo = CPUInfo()

    machine_types = [RE_MACHINE_TYPE.findall(line) for line in _get_cpuinfo()]
    machine_types = [i[0] for i in machine_types if i]
    if machine_types:
        # machine type should be same for all found cpus
        cpuinfo.machine_type = int(machine_types[0])
    api.produce(cpuinfo)
Esempio n. 2
0
def test_machine_type(monkeypatch):
    # cpuinfo doesn't contain a machine field
    mocked_cpuinfo = mocked_get_cpuinfo('cpuinfo_x86_64')
    monkeypatch.setattr(cpu, '_get_cpuinfo', mocked_cpuinfo)
    monkeypatch.setattr(api, 'produce', testutils.produce_mocked())
    cpu.process()
    assert api.produce.called == 1
    assert CPUInfo() == api.produce.model_instances[0]

    # cpuinfo contains a machine field
    api.produce.called = 0
    api.produce.model_instances = []
    mocked_cpuinfo.filename = 'cpuinfo_s390x'
    cpu.process()
    assert api.produce.called == 1
    assert CPUInfo(machine_type=2827) == api.produce.model_instances[0]
def test_ibmz_cpu_is_empty(monkeypatch, caplog):
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_S390X))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    monkeypatch.setattr(api, 'consume',
                        lambda x: iter([CPUInfo(machine_type=None)]))
    with caplog.at_level(logging.DEBUG):
        cpu.process()
    assert 'The machine (CPU) type is empty.' in caplog.text
def test_ibmz_cpu_supported(monkeypatch):
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_S390X))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    for sup_arch in cpu.SUPPORTED_MACHINE_TYPES:
        monkeypatch.setattr(api, 'consume',
                            lambda x: iter([CPUInfo(machine_type=sup_arch)]))
        cpu.process()
        assert not reporting.create_report.called
def test_ibmz_cpu_unsupported(monkeypatch):
    title_msg = 'The processor is not supported by the target system.'
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_S390X))
    monkeypatch.setattr(api, 'consume',
                        lambda x: iter([CPUInfo(machine_type=666)]))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    cpu.process()
    assert reporting.create_report.called
    assert title_msg == reporting.create_report.report_fields['title']
    assert reporting.Flags.INHIBITOR in reporting.create_report.report_fields[
        'flags']