def test_cpuinfo(): cpu_info = CpuInfo(context_wrap(CPUINFO)) assert cpu_info.cpu_count == 2 assert cpu_info.socket_count == 2 assert cpu_info.vendor == "GenuineIntel" assert cpu_info.model_name == "Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz" assert cpu_info.get_processor_by_index(0) == { "cpus": "0", "sockets": "0", "vendors": "GenuineIntel", "models": "Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz", "model_ids": "45", "families": "6", "clockspeeds": "2900.000", "cache_sizes": "20480 KB", "cpu_cores": "1", "flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp" } assert cpu_info.cpu_speed == "2900.000" assert cpu_info.cache_size == "20480 KB" assert cpu_info.model_number == "45" assert "mmx" in cpu_info.flags assert "avx512f" not in cpu_info.flags for i, cpu in enumerate(cpu_info): assert cpu['cpus'] == str(i)
def test_power_cpuinfo(): cpu_info = CpuInfo(context_wrap(POWER_CPUINFO)) assert cpu_info.cpu_count == 28 assert cpu_info.socket_count == 0 for i, cpu in enumerate(cpu_info): assert cpu["cpu"] == "POWER7 (architected), altivec supported" assert cpu["revision"] == "2.0 (pvr 004a 0200)"
def test_arm_cpuinfo(): cpu_info = CpuInfo(context_wrap(ARM_CPUINFO)) assert cpu_info.cpu_count == 4 assert cpu_info.socket_count == 0 for i, cpu in enumerate(cpu_info): assert cpu["models"] == "ARMv7 Processor rev 5 (v7l)" assert cpu[ "features"] == "half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm" assert cpu["cpu_implementer"] == "0x41" assert cpu["cpu_architecture"] == "7" assert cpu["cpu_variant"] == "0x0" assert cpu["cpu_part"] == "0xc07" assert cpu["cpu_revision"] == "5"
def test_empty_cpuinfo(): cpu_info = CpuInfo(context_wrap("")) assert cpu_info.cpu_count == 0
def test_one_socket_cpuinfo(): cpu_info = CpuInfo(context_wrap(ONE_SOCKET_CPUINFO)) assert cpu_info.cpu_count == 8 assert cpu_info.socket_count == 1 assert cpu_info.core_total == 32
def test_cpuinfo_doc_examples(): env = { 'cpu_info': CpuInfo(context_wrap(CPUINFO)), } failed, total = doctest.testmod(cpuinfo, globs=env) assert failed == 0