py-cpuinfo-5.0.0/0000755000175000017500000000000013444510311011703 5ustar hlehlepy-cpuinfo-5.0.0/tests/0000755000175000017500000000000013444510311013045 5ustar hlehlepy-cpuinfo-5.0.0/tests/test_invalid_cpu.py0000644000175000017500000000160113444505146016763 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '32bit' cpu_count = 1 is_windows = False raw_arch_string = 'unknown_cpu' class TestInvalidCPU(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) def test_arch_parse_unknown(self): # If the arch is unknown, the result should be null arch, bits = cpuinfo._parse_arch(DataSource.raw_arch_string) self.assertIsNone(arch) self.assertIsNone(bits) def test_check_arch_exception(self): # If the arch is unknown, it should raise and exception try: cpuinfo._check_arch() self.fail('Failed to raise Exception') except Exception as err: self.assertEqual('py-cpuinfo currently only works on X86 and some PPC and ARM CPUs.', err.args[0]) py-cpuinfo-5.0.0/tests/test_parse_errors.py0000644000175000017500000000611213444505146017176 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 1 is_windows = True raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_dmesg(): return True @staticmethod def has_var_run_dmesg_boot(): return True @staticmethod def has_cpufreq_info(): return True @staticmethod def has_sestatus(): return True @staticmethod def has_sysctl(): return True @staticmethod def has_isainfo(): return True @staticmethod def has_kstat(): return True @staticmethod def has_sysinfo(): return True @staticmethod def cat_proc_cpuinfo(): return 0, "" @staticmethod def cpufreq_info(): return 0, "" @staticmethod def sestatus_allow_execheap(): return True @staticmethod def sestatus_allow_execmem(): return True @staticmethod def dmesg_a(): return 0, "" @staticmethod def cat_var_run_dmesg_boot(): return 0, "" @staticmethod def sysctl_machdep_cpu_hw_cpufrequency(): return 0, "" @staticmethod def isainfo_vb(): return 0, "" @staticmethod def kstat_m_cpu_info(): return 0, "" @staticmethod def sysinfo_cpu(): return 0, "" @staticmethod def winreg_processor_brand(): return {} @staticmethod def winreg_vendor_id(): return {} @staticmethod def winreg_raw_arch_string(): return {} @staticmethod def winreg_hz_actual(): return {} @staticmethod def winreg_feature_bits(): return {} class TestParseErrors(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) def test_all(self): self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) #self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) #self.assertEqual({}, cpuinfo._get_cpu_info_internal()) py-cpuinfo-5.0.0/tests/test_linux_gentoo_2_2_x86_64.py0000644000175000017500000007017113444505146020670 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 2 is_windows = False raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_dmesg(): return True @staticmethod def has_lscpu(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 cpu MHz : 2793.652 cache size : 3072 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt xsave hypervisor lahf_lm bugs : bogomips : 5587.30 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 cpu MHz : 2793.652 cache size : 3072 KB physical id : 0 siblings : 2 core id : 1 cpu cores : 2 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt xsave hypervisor lahf_lm bugs : bogomips : 5587.30 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: ''' return returncode, output @staticmethod def dmesg_a(): returncode = 0 output = ''' =============================================================================== [ 0.000000] Linux version 4.5.2-aufs-r1 (root@jasmin) (gcc version 5.4.0 (Gentoo 5.4.0 p1.0, pie-0.6.5) ) #1 SMP Sun Jul 3 17:17:11 UTC 2016 [ 0.000000] Command line: BOOT_IMAGE=/isolinux/gentoo root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot initrd=/isolinux/gentoo.xz console=tty1 [ 0.000000] KERNEL supported cpus: [ 0.000000] Intel GenuineIntel [ 0.000000] AMD AuthenticAMD [ 0.000000] Centaur CentaurHauls [ 0.000000] x86/fpu: Supporting XSAVE feature 0x01: 'x87 floating point registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x02: 'SSE registers' [ 0.000000] x86/fpu: Enabled xstate features 0x3, context size is 576 bytes, using 'standard' format. [ 0.000000] x86/fpu: Using 'lazy' FPU context switches. [ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000dffeffff] usable [ 0.000000] BIOS-e820: [mem 0x00000000dfff0000-0x00000000dfffffff] ACPI data [ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000011fffffff] usable [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] SMBIOS 2.5 present. [ 0.000000] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 0.000000] Hypervisor detected: KVM [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved [ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable [ 0.000000] e820: last_pfn = 0x120000 max_arch_pfn = 0x400000000 [ 0.000000] MTRR default type: uncachable [ 0.000000] MTRR variable ranges disabled: [ 0.000000] x86/PAT: Configuration [0-7]: WB WC UC- UC WB WC UC- WT [ 0.000000] MTRR: Disabled [ 0.000000] CPU MTRRs all blank - virtualized system. [ 0.000000] e820: last_pfn = 0xdfff0 max_arch_pfn = 0x400000000 [ 0.000000] found SMP MP-table at [mem 0x0009fff0-0x0009ffff] mapped at [ffff88000009fff0] [ 0.000000] Base memory trampoline at [ffff880000099000] 99000 size 24576 [ 0.000000] BRK [0x13b4e000, 0x13b4efff] PGTABLE [ 0.000000] BRK [0x13b4f000, 0x13b4ffff] PGTABLE [ 0.000000] BRK [0x13b50000, 0x13b50fff] PGTABLE [ 0.000000] BRK [0x13b51000, 0x13b51fff] PGTABLE [ 0.000000] RAMDISK: [mem 0x7f894000-0x7fffffff] [ 0.000000] ACPI: Early table checksum verification disabled [ 0.000000] ACPI: RSDP 0x00000000000E0000 000024 (v02 VBOX ) [ 0.000000] ACPI: XSDT 0x00000000DFFF0030 00003C (v01 VBOX VBOXXSDT 00000001 ASL 00000061) [ 0.000000] ACPI: FACP 0x00000000DFFF00F0 0000F4 (v04 VBOX VBOXFACP 00000001 ASL 00000061) [ 0.000000] ACPI: DSDT 0x00000000DFFF0470 00210F (v01 VBOX VBOXBIOS 00000002 INTL 20160108) [ 0.000000] ACPI: FACS 0x00000000DFFF0200 000040 [ 0.000000] ACPI: FACS 0x00000000DFFF0200 000040 [ 0.000000] ACPI: APIC 0x00000000DFFF0240 00005C (v02 VBOX VBOXAPIC 00000001 ASL 00000061) [ 0.000000] ACPI: SSDT 0x00000000DFFF02A0 0001CC (v01 VBOX VBOXCPUT 00000002 INTL 20160108) [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00 [ 0.000000] kvm-clock: cpu 0, msr 1:1fffb001, primary cpu clock [ 0.000000] kvm-clock: using sched offset of 7895112535 cycles [ 0.000000] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns [ 0.000000] Zone ranges: [ 0.000000] DMA [mem 0x0000000000001000-0x0000000000ffffff] [ 0.000000] DMA32 [mem 0x0000000001000000-0x00000000ffffffff] [ 0.000000] Normal [mem 0x0000000100000000-0x000000011fffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000001000-0x000000000009efff] [ 0.000000] node 0: [mem 0x0000000000100000-0x00000000dffeffff] [ 0.000000] node 0: [mem 0x0000000100000000-0x000000011fffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x000000011fffffff] [ 0.000000] On node 0 totalpages: 1048462 [ 0.000000] DMA zone: 56 pages used for memmap [ 0.000000] DMA zone: 21 pages reserved [ 0.000000] DMA zone: 3998 pages, LIFO batch:0 [ 0.000000] DMA32 zone: 12488 pages used for memmap [ 0.000000] DMA32 zone: 913392 pages, LIFO batch:31 [ 0.000000] Normal zone: 1792 pages used for memmap [ 0.000000] Normal zone: 131072 pages, LIFO batch:31 [ 0.000000] ACPI: PM-Timer IO Port: 0x4008 [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] IOAPIC[0]: apic_id 2, version 32, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl) [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level) [ 0.000000] ACPI: IRQ0 used by override. [ 0.000000] ACPI: IRQ9 used by override. [ 0.000000] Using ACPI (MADT) for SMP configuration information [ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs [ 0.000000] e820: [mem 0xe0000000-0xfebfffff] available for PCI devices [ 0.000000] Booting paravirtualized kernel on KVM [ 0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1910969940391419 ns [ 0.000000] setup_percpu: NR_CPUS:64 nr_cpumask_bits:64 nr_cpu_ids:2 nr_node_ids:1 [ 0.000000] PERCPU: Embedded 32 pages/cpu @ffff88011fc00000 s90328 r8192 d32552 u1048576 [ 0.000000] pcpu-alloc: s90328 r8192 d32552 u1048576 alloc=1*2097152 [ 0.000000] pcpu-alloc: [0] 0 1 [ 0.000000] PV qspinlock hash table entries: 256 (order: 0, 4096 bytes) [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 1034105 [ 0.000000] Kernel command line: BOOT_IMAGE=/isolinux/gentoo root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot initrd=/isolinux/gentoo.xz console=tty1 [ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes) [ 0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes) [ 0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes) [ 0.000000] Calgary: detecting Calgary via BIOS EBDA area [ 0.000000] Calgary: Unable to locate Rio Grande table in EBDA - bailing! [ 0.000000] Memory: 4026248K/4193848K available (5358K kernel code, 481K rwdata, 2712K rodata, 1016K init, 16188K bss, 167600K reserved, 0K cma-reserved) [ 0.000000] Hierarchical RCU implementation. [ 0.000000] Build-time adjustment of leaf fanout to 64. [ 0.000000] RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=2. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=64, nr_cpu_ids=2 [ 0.000000] NR_IRQS:4352 nr_irqs:440 16 [ 0.000000] Console: colour VGA+ 80x25 [ 0.000000] console [tty1] enabled [ 0.000000] tsc: Detected 2793.652 MHz processor [ 0.141160] Calibrating delay loop (skipped) preset value.. 5587.30 BogoMIPS (lpj=2793652) [ 0.142104] pid_max: default: 32768 minimum: 301 [ 0.142638] ACPI: Core revision 20160108 [ 0.144223] ACPI: 2 ACPI AML tables successfully acquired and loaded [ 0.145332] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes) [ 0.145866] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes) [ 0.147608] CPU: Physical Processor ID: 0 [ 0.148126] CPU: Processor Core ID: 0 [ 0.148586] mce: CPU supports 0 MCE banks [ 0.149092] Last level iTLB entries: 4KB 512, 2MB 8, 4MB 8 [ 0.149586] Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32, 1GB 0 [ 0.152341] Freeing SMP alternatives memory: 24K (ffffffff92b78000 - ffffffff92b7e000) [ 0.163230] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 [ 0.265101] smpboot: CPU0: Intel(R) Pentium(R) CPU G640 @ 2.80GHz (family: 0x6, model: 0x2a, stepping: 0x7) [ 0.266299] Performance Events: unsupported p6 CPU model 42 no PMU driver, software events only. [ 0.267306] KVM setup paravirtual spinlock [ 0.267966] x86: Booting SMP configuration: [ 0.269313] .... node #0, CPUs: #1 [ 0.270050] kvm-clock: cpu 1, msr 1:1fffb041, secondary cpu clock [ 0.270195] mce: CPU supports 0 MCE banks [ 0.272308] x86: Booted up 1 node, 2 CPUs [ 0.274066] smpboot: Total of 2 processors activated (11174.60 BogoMIPS) [ 0.277750] devtmpfs: initialized [ 0.278904] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns [ 0.280007] NET: Registered protocol family 16 [ 0.282919] cpuidle: using governor ladder [ 0.287045] cpuidle: using governor menu [ 0.287596] ACPI: bus type PCI registered [ 0.288197] PCI: Using configuration type 1 for base access [ 0.296438] ACPI: Added _OSI(Module Device) [ 0.296920] ACPI: Added _OSI(Processor Device) [ 0.297365] ACPI: Added _OSI(3.0 _SCP Extensions) [ 0.297812] ACPI: Added _OSI(Processor Aggregator Device) [ 0.298811] ACPI: Executed 1 blocks of module-level executable AML code [ 0.301871] ACPI: Interpreter enabled [ 0.302325] ACPI: (supports S0 S5) [ 0.302733] ACPI: Using IOAPIC for interrupt routing [ 0.303373] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug [ 0.311397] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff]) [ 0.311943] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI] [ 0.312695] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM [ 0.313427] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge. [ 0.314671] PCI host bridge to bus 0000:00 [ 0.315139] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7 window] [ 0.315651] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff window] [ 0.316170] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window] [ 0.316921] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xffdfffff window] [ 0.317667] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.318183] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000 [ 0.318651] pci 0000:00:01.0: [8086:7000] type 00 class 0x060100 [ 0.319190] pci 0000:00:01.1: [8086:7111] type 00 class 0x01018a [ 0.319507] pci 0000:00:01.1: reg 0x20: [io 0xd000-0xd00f] [ 0.319637] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io 0x01f0-0x01f7] [ 0.320177] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io 0x03f6] [ 0.320691] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io 0x0170-0x0177] [ 0.321218] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io 0x0376] [ 0.321916] pci 0000:00:02.0: [80ee:beef] type 00 class 0x030000 [ 0.331110] pci 0000:00:02.0: reg 0x10: [mem 0xe0000000-0xe0ffffff pref] [ 0.355210] pci 0000:00:03.0: [8086:100e] type 00 class 0x020000 [ 0.362376] pci 0000:00:03.0: reg 0x10: [mem 0xf0000000-0xf001ffff] [ 0.368405] pci 0000:00:03.0: reg 0x18: [io 0xd010-0xd017] [ 0.382823] pci 0000:00:04.0: [80ee:cafe] type 00 class 0x088000 [ 0.385993] pci 0000:00:04.0: reg 0x10: [io 0xd020-0xd03f] [ 0.390088] pci 0000:00:04.0: reg 0x14: [mem 0xf0400000-0xf07fffff] [ 0.396674] pci 0000:00:04.0: reg 0x18: [mem 0xf0800000-0xf0803fff pref] [ 0.408760] pci 0000:00:05.0: [8086:2415] type 00 class 0x040100 [ 0.408846] pci 0000:00:05.0: reg 0x10: [io 0xd100-0xd1ff] [ 0.408903] pci 0000:00:05.0: reg 0x14: [io 0xd200-0xd23f] [ 0.409378] pci 0000:00:06.0: [106b:003f] type 00 class 0x0c0310 [ 0.412327] pci 0000:00:06.0: reg 0x10: [mem 0xf0804000-0xf0804fff] [ 0.438003] pci 0000:00:07.0: [8086:7113] type 00 class 0x068000 [ 0.438389] pci 0000:00:07.0: quirk: [io 0x4000-0x403f] claimed by PIIX4 ACPI [ 0.439849] pci 0000:00:07.0: quirk: [io 0x4100-0x410f] claimed by PIIX4 SMB [ 0.440790] pci 0000:00:0d.0: [8086:2829] type 00 class 0x010601 [ 0.446112] pci 0000:00:0d.0: reg 0x10: [io 0xd240-0xd247] [ 0.453981] pci 0000:00:0d.0: reg 0x18: [io 0xd250-0xd257] [ 0.465205] pci 0000:00:0d.0: reg 0x20: [io 0xd260-0xd26f] [ 0.468499] pci 0000:00:0d.0: reg 0x24: [mem 0xf0806000-0xf0807fff] [ 0.473155] pci_bus 0000:00: on NUMA node 0 [ 0.474092] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 9 10 *11) [ 0.476734] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 9 10 *11) [ 0.478927] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 9 *10 11) [ 0.480187] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 *9 10 11) [ 0.483221] ACPI: Enabled 2 GPEs in block 00 to 07 [ 0.484401] vgaarb: setting as boot device: PCI:0000:00:02.0 [ 0.484962] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none [ 0.486436] vgaarb: loaded [ 0.486866] vgaarb: bridge control possible 0000:00:02.0 [ 0.487529] SCSI subsystem initialized [ 0.488105] libata version 3.00 loaded. [ 0.488124] ACPI: bus type USB registered [ 0.488601] usbcore: registered new interface driver usbfs [ 0.489127] usbcore: registered new interface driver hub [ 0.489642] usbcore: registered new device driver usb [ 0.493140] PCI: Using ACPI for IRQ routing [ 0.493596] PCI: pci_cache_line_size set to 64 bytes [ 0.493741] e820: reserve RAM buffer [mem 0x0009fc00-0x0009ffff] [ 0.493748] e820: reserve RAM buffer [mem 0xdfff0000-0xdfffffff] [ 0.501262] clocksource: Switched to clocksource kvm-clock [ 0.501975] VFS: Disk quotas dquot_6.6.0 [ 0.502483] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes) [ 0.515233] pnp: PnP ACPI init [ 0.515724] pnp 00:00: Plug and Play ACPI device, IDs PNP0303 (active) [ 0.515794] pnp 00:01: Plug and Play ACPI device, IDs PNP0f03 (active) [ 0.516395] pnp: PnP ACPI: found 2 devices [ 0.521420] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns [ 0.523924] pci_bus 0000:00: resource 4 [io 0x0000-0x0cf7 window] [ 0.523928] pci_bus 0000:00: resource 5 [io 0x0d00-0xffff window] [ 0.523930] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff window] [ 0.523932] pci_bus 0000:00: resource 7 [mem 0xe0000000-0xffdfffff window] [ 0.526813] NET: Registered protocol family 2 [ 0.527577] TCP established hash table entries: 32768 (order: 6, 262144 bytes) [ 0.528532] TCP bind hash table entries: 32768 (order: 7, 524288 bytes) [ 0.529234] TCP: Hash tables configured (established 32768 bind 32768) [ 0.529765] UDP hash table entries: 2048 (order: 4, 65536 bytes) [ 0.530287] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes) [ 0.544043] NET: Registered protocol family 1 [ 0.544613] pci 0000:00:00.0: Limiting direct PCI/PCI transfers [ 0.545245] pci 0000:00:01.0: Activating ISA DMA hang workarounds [ 0.545791] pci 0000:00:02.0: Video device with shadowed ROM [ 0.547149] PCI: CLS 0 bytes, default 64 [ 0.547884] Trying to unpack rootfs image as initramfs... [ 1.394034] Freeing initrd memory: 7600K (ffff88007f894000 - ffff880080000000) [ 1.394891] PCI-DMA: Using software bounce buffering for IO (SWIOTLB) [ 1.395861] software IO TLB [mem 0xdbff0000-0xdfff0000] (64MB) mapped at [ffff8800dbff0000-ffff8800dffeffff] [ 1.397095] platform rtc_cmos: registered platform RTC device (no PNP device found) [ 1.397910] RAPL PMU detected, API unit is 2^-32 Joules, 3 fixed counters 10737418240 ms ovfl timer [ 1.398684] hw unit of domain pp0-core 2^-0 Joules [ 1.399166] hw unit of domain package 2^-0 Joules [ 1.399618] hw unit of domain pp1-gpu 2^-0 Joules [ 1.400492] futex hash table entries: 512 (order: 3, 32768 bytes) [ 1.401169] audit: initializing netlink subsys (disabled) [ 1.401668] audit: type=2000 audit(1488272619.420:1): initialized [ 1.402282] Initialise system trusted keyring [ 1.403474] squashfs: version 4.0 (2009/01/31) Phillip Lougher [ 1.404117] JFS: nTxBlock = 8192, nTxLock = 65536 [ 1.406745] SGI XFS with ACLs, security attributes, realtime, no debug enabled [ 1.408178] aufs 4.5-20160328 [ 1.418164] Key type asymmetric registered [ 1.418627] Asymmetric key parser 'x509' registered [ 1.419179] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253) [ 1.419974] io scheduler noop registered [ 1.420429] io scheduler deadline registered (default) [ 1.421010] start plist test [ 1.422756] end plist test [ 1.422768] Running rhashtable test nelem=8, max_size=0, shrinking=0 [ 1.423312] Test 00: [ 1.425541] Adding 50000 keys [ 1.453370] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.465493] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.466339] Deleting 50000 keys [ 1.472526] Duration of test: 46526457 ns [ 1.473240] Test 01: [ 1.474878] Adding 50000 keys [ 1.487127] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.496559] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.497384] Deleting 50000 keys [ 1.506520] Duration of test: 31074162 ns [ 1.507191] Test 02: [ 1.509281] Adding 50000 keys [ 1.522531] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.532936] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.533744] Deleting 50000 keys [ 1.541847] Duration of test: 32005815 ns [ 1.543742] Test 03: [ 1.545394] Adding 50000 keys [ 1.560340] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.568083] Traversal complete: counted=50000, nelems=50000, entries=50000, table-jumps=0 [ 1.568920] Deleting 50000 keys [ 1.578421] Duration of test: 32488444 ns [ 1.578926] Average test time: 35523719 [ 1.579370] Testing concurrent rhashtable access from 10 threads [ 1.649031] thread[6]: rhashtable_insert_fast failed [ 1.649033] thread[7]: rhashtable_insert_fast failed [ 1.649038] thread[9]: rhashtable_insert_fast failed [ 1.649039] thread[3]: rhashtable_insert_fast failed [ 1.649041] thread[8]: rhashtable_insert_fast failed [ 1.649043] thread[5]: rhashtable_insert_fast failed [ 1.649044] thread[1]: rhashtable_insert_fast failed [ 1.831026] Test failed: thread 1 returned: -12 [ 1.855279] Test failed: thread 3 returned: -12 [ 1.859276] Test failed: thread 5 returned: -12 [ 1.859887] Test failed: thread 6 returned: -12 [ 1.860379] Test failed: thread 7 returned: -12 [ 1.860838] Test failed: thread 8 returned: -12 [ 1.861335] Test failed: thread 9 returned: -12 [ 1.861782] Started 10 threads, 7 failed [ 1.862508] glob: 64 self-tests passed, 0 failed [ 1.863134] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled [ 1.863988] Linux agpgart interface v0.103 [ 1.864625] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 [ 1.865411] ACPI: Power Button [PWRF] [ 1.865899] input: Sleep Button as /devices/LNXSYSTM:00/LNXSLPBN:00/input/input1 [ 1.867173] ACPI: Sleep Button [SLPF] [ 1.868220] ACPI: Video Device [GFX0] (multi-head: yes rom: no post: no) [ 1.868877] input: Video Bus as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/LNXVIDEO:00/input/input2 [ 1.870085] xenfs: not registering filesystem on non-xen platform [ 1.877055] brd: module loaded [ 1.879394] loop: module loaded [ 1.880002] usbcore: registered new interface driver hwa-rc [ 1.880518] usbcore: registered new interface driver i1480-dfu-usb [ 1.881078] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 1.881591] ehci-pci: EHCI PCI platform driver [ 1.882074] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 1.882586] uhci_hcd: USB Universal Host Controller Interface driver [ 1.883306] usbcore: registered new interface driver wusb-cbaf [ 1.883805] usbcore: registered new interface driver cdc_wdm [ 1.884348] i8042: PNP: PS/2 Controller [PNP0303:PS2K,PNP0f03:PS2M] at 0x60,0x64 irq 1,12 [ 1.885658] serio: i8042 KBD port at 0x60,0x64 irq 1 [ 1.886150] serio: i8042 AUX port at 0x60,0x64 irq 12 [ 1.887401] mousedev: PS/2 mouse d ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 42 Model name: Intel(R) Pentium(R) CPU G640 @ 2.80GHz Stepping: 7 CPU MHz: 2793.652 BogoMIPS: 5587.30 Hypervisor vendor: KVM Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 3072K Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt xsave hypervisor lahf_lm ''' return returncode, output class TestLinuxGentoo_2_2_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(14, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(11, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(8, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(20, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.7937 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2793652000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'hypervisor', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave', 'xtopology'] , info['flags'] ) def test_get_cpu_info_from_dmesg(self): info = cpuinfo._get_cpu_info_from_dmesg() self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.8000 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2800000000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'hypervisor', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave', 'xtopology'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(2, info['count']) self.assertEqual('x86_64', info['raw_arch_string']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'hypervisor', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave', 'xtopology'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_ubuntu_16_04_x86_64.py0000644000175000017500000007312313444505146021066 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 2 is_windows = False raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_lscpu(): return True @staticmethod def has_dmesg(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 microcode : 0x29 cpu MHz : 1901.375 cache size : 3072 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes 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 rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave lahf_lm epb tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts bugs : bogomips : 5587.32 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 microcode : 0x29 cpu MHz : 2070.796 cache size : 3072 KB physical id : 0 siblings : 2 core id : 1 cpu cores : 2 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes 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 rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave lahf_lm epb tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts bugs : bogomips : 5587.32 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 42 Model name: Intel(R) Pentium(R) CPU G640 @ 2.80GHz Stepping: 7 CPU MHz: 2070.796 CPU max MHz: 2800.0000 CPU min MHz: 1600.0000 BogoMIPS: 5587.32 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 3072K NUMA node0 CPU(s): 0,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 rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave lahf_lm epb tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm arat pln pts ''' return returncode, output @staticmethod def dmesg_a(): returncode = 0 output = ''' [ 0.000000] microcode: CPU0 microcode updated early to revision 0x29, date = 2013-06-12 [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 4.4.0-64-generic (buildd@lgw01-56) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 (Ubuntu 4.4.0-64.85-generic 4.4.44) [ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-64-generic root=UUID=9112213a-3570-4904-8969-d5aab8825f6b ro quiet splash vt.handoff=7 [ 0.000000] KERNEL supported cpus: [ 0.000000] Intel GenuineIntel [ 0.000000] AMD AuthenticAMD [ 0.000000] Centaur CentaurHauls [ 0.000000] x86/fpu: Supporting XSAVE feature 0x01: 'x87 floating point registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x02: 'SSE registers' [ 0.000000] x86/fpu: Enabled xstate features 0x3, context size is 576 bytes, using 'standard' format. [ 0.000000] x86/fpu: Using 'eager' FPU context switches. [ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009d7ff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009d800-0x000000000009ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000001fffffff] usable [ 0.000000] BIOS-e820: [mem 0x0000000020000000-0x00000000201fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000020200000-0x000000003fffffff] usable [ 0.000000] BIOS-e820: [mem 0x0000000040000000-0x00000000401fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000040200000-0x00000000d878dfff] usable [ 0.000000] BIOS-e820: [mem 0x00000000d878e000-0x00000000d8792fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000d8793000-0x00000000d8796fff] usable [ 0.000000] BIOS-e820: [mem 0x00000000d8797000-0x00000000d8db1fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000d8db2000-0x00000000d9018fff] ACPI NVS [ 0.000000] BIOS-e820: [mem 0x00000000d9019000-0x00000000d9024fff] ACPI data [ 0.000000] BIOS-e820: [mem 0x00000000d9025000-0x00000000d9031fff] ACPI NVS [ 0.000000] BIOS-e820: [mem 0x00000000d9032000-0x00000000d9036fff] ACPI data [ 0.000000] BIOS-e820: [mem 0x00000000d9037000-0x00000000d9079fff] ACPI NVS [ 0.000000] BIOS-e820: [mem 0x00000000d907a000-0x00000000d9d3dfff] usable [ 0.000000] BIOS-e820: [mem 0x00000000d9d3e000-0x00000000d9ff1fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000d9ff2000-0x00000000d9ffffff] usable [ 0.000000] BIOS-e820: [mem 0x00000000db000000-0x00000000df1fffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fed00000-0x00000000fed03fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fed1c000-0x00000000fed1ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000ff000000-0x00000000ffffffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000041fdfffff] usable [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] SMBIOS 2.7 present. [ 0.000000] DMI: Hewlett-Packard s5-1224/2ADA, BIOS 7.11 04/28/2012 [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved [ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable [ 0.000000] e820: last_pfn = 0x41fe00 max_arch_pfn = 0x400000000 [ 0.000000] MTRR default type: uncachable [ 0.000000] MTRR fixed ranges enabled: [ 0.000000] 00000-9FFFF write-back [ 0.000000] A0000-BFFFF uncachable [ 0.000000] C0000-CFFFF write-protect [ 0.000000] D0000-E7FFF uncachable [ 0.000000] E8000-FFFFF write-protect [ 0.000000] MTRR variable ranges enabled: [ 0.000000] 0 base 000000000 mask C00000000 write-back [ 0.000000] 1 base 400000000 mask FE0000000 write-back [ 0.000000] 2 base 0E0000000 mask FE0000000 uncachable [ 0.000000] 3 base 0DC000000 mask FFC000000 uncachable [ 0.000000] 4 base 0DB000000 mask FFF000000 uncachable [ 0.000000] 5 base 41FE00000 mask FFFE00000 uncachable [ 0.000000] 6 disabled [ 0.000000] 7 disabled [ 0.000000] 8 disabled [ 0.000000] 9 disabled [ 0.000000] x86/PAT: Configuration [0-7]: WB WC UC- UC WB WC UC- WT [ 0.000000] original variable MTRRs [ 0.000000] reg 0, base: 0GB, range: 16GB, type WB [ 0.000000] reg 1, base: 16GB, range: 512MB, type WB [ 0.000000] reg 2, base: 3584MB, range: 512MB, type UC [ 0.000000] reg 3, base: 3520MB, range: 64MB, type UC [ 0.000000] reg 4, base: 3504MB, range: 16MB, type UC [ 0.000000] reg 5, base: 16894MB, range: 2MB, type UC [ 0.000000] total RAM covered: 16302M [ 0.000000] Found optimal setting for mtrr clean up [ 0.000000] gran_size: 64K chunk_size: 128M num_reg: 9 lose cover RAM: 0G [ 0.000000] New variable MTRRs [ 0.000000] reg 0, base: 0GB, range: 2GB, type WB [ 0.000000] reg 1, base: 2GB, range: 1GB, type WB [ 0.000000] reg 2, base: 3GB, range: 512MB, type WB [ 0.000000] reg 3, base: 3504MB, range: 16MB, type UC [ 0.000000] reg 4, base: 3520MB, range: 64MB, type UC [ 0.000000] reg 5, base: 4GB, range: 4GB, type WB [ 0.000000] reg 6, base: 8GB, range: 8GB, type WB [ 0.000000] reg 7, base: 16GB, range: 512MB, type WB [ 0.000000] reg 8, base: 16894MB, range: 2MB, type UC [ 0.000000] e820: update [mem 0xdb000000-0xffffffff] usable ==> reserved [ 0.000000] e820: last_pfn = 0xda000 max_arch_pfn = 0x400000000 [ 0.000000] found SMP MP-table at [mem 0x000fcc40-0x000fcc4f] mapped at [ffff8800000fcc40] [ 0.000000] Scanning 1 areas for low memory corruption [ 0.000000] Base memory trampoline at [ffff880000097000] 97000 size 24576 [ 0.000000] reserving inaccessible SNB gfx pages [ 0.000000] BRK [0x0220c000, 0x0220cfff] PGTABLE [ 0.000000] BRK [0x0220d000, 0x0220dfff] PGTABLE [ 0.000000] BRK [0x0220e000, 0x0220efff] PGTABLE [ 0.000000] BRK [0x0220f000, 0x0220ffff] PGTABLE [ 0.000000] BRK [0x02210000, 0x02210fff] PGTABLE [ 0.000000] BRK [0x02211000, 0x02211fff] PGTABLE [ 0.000000] RAMDISK: [mem 0x337fe000-0x35bf6fff] [ 0.000000] ACPI: Early table checksum verification disabled [ 0.000000] ACPI: RSDP 0x00000000000F0450 000024 (v02 HPQOEM) [ 0.000000] ACPI: XSDT 0x00000000D9019078 00006C (v01 HPQOEM SLIC-CPC 01072009 AMI 00010013) [ 0.000000] ACPI: FACP 0x00000000D90227B8 0000F4 (v04 HPQOEM SLIC-CPC 01072009 AMI 00010013) [ 0.000000] ACPI: DSDT 0x00000000D9019170 009645 (v02 HPQOEM SLIC-CPC 00000711 INTL 20051117) [ 0.000000] ACPI: FACS 0x00000000D9030F80 000040 [ 0.000000] ACPI: APIC 0x00000000D90228B0 000062 (v03 HPQOEM SLIC-CPC 01072009 AMI 00010013) [ 0.000000] ACPI: MCFG 0x00000000D9022918 00003C (v01 HPQOEM SLIC-CPC 01072009 MSFT 00000097) [ 0.000000] ACPI: SLIC 0x00000000D9022958 000176 (v01 HPQOEM SLIC-CPC 01072009 AMI 00010013) [ 0.000000] ACPI: HPET 0x00000000D9022AD0 000038 (v01 HPQOEM SLIC-CPC 01072009 AMI. 00000005) [ 0.000000] ACPI: SSDT 0x00000000D9022B08 00036D (v01 HPQOEM SLIC-CPC 00001000 INTL 20091112) [ 0.000000] ACPI: SSDT 0x00000000D9022E78 0008E4 (v01 HPQOEM SLIC-CPC 00003000 INTL 20051117) [ 0.000000] ACPI: SSDT 0x00000000D9023760 000A92 (v01 HPQOEM SLIC-CPC 00003000 INTL 20051117) [ 0.000000] ACPI: DBGP 0x00000000D90241F8 000034 (v01 HPQOEM SLIC-CPC 01072009 AMI 00010013) [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] No NUMA configuration found [ 0.000000] Faking a node at [mem 0x0000000000000000-0x000000041fdfffff] [ 0.000000] NODE_DATA(0) allocated [mem 0x41fdea000-0x41fdeefff] [ 0.000000] Zone ranges: [ 0.000000] DMA [mem 0x0000000000001000-0x0000000000ffffff] [ 0.000000] DMA32 [mem 0x0000000001000000-0x00000000ffffffff] [ 0.000000] Normal [mem 0x0000000100000000-0x000000041fdfffff] [ 0.000000] Device empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000001000-0x000000000009cfff] [ 0.000000] node 0: [mem 0x0000000000100000-0x000000001fffffff] [ 0.000000] node 0: [mem 0x0000000020200000-0x000000003fffffff] [ 0.000000] node 0: [mem 0x0000000040200000-0x00000000d878dfff] [ 0.000000] node 0: [mem 0x00000000d8793000-0x00000000d8796fff] [ 0.000000] node 0: [mem 0x00000000d907a000-0x00000000d9d3dfff] [ 0.000000] node 0: [mem 0x00000000d9ff2000-0x00000000d9ffffff] [ 0.000000] node 0: [mem 0x0000000100000000-0x000000041fdfffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x000000041fdfffff] [ 0.000000] On node 0 totalpages: 4165120 [ 0.000000] DMA zone: 64 pages used for memmap [ 0.000000] DMA zone: 156 pages reserved [ 0.000000] DMA zone: 3996 pages, LIFO batch:0 [ 0.000000] DMA32 zone: 13826 pages used for memmap [ 0.000000] DMA32 zone: 884836 pages, LIFO batch:31 [ 0.000000] Normal zone: 51192 pages used for memmap [ 0.000000] Normal zone: 3276288 pages, LIFO batch:31 [ 0.000000] Reserving Intel graphics stolen memory at 0xdb200000-0xdf1fffff [ 0.000000] ACPI: PM-Timer IO Port: 0x408 [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] high edge lint[0x1]) [ 0.000000] IOAPIC[0]: apic_id 2, version 32, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl) [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level) [ 0.000000] ACPI: IRQ0 used by override. [ 0.000000] ACPI: IRQ9 used by override. [ 0.000000] Using ACPI (MADT) for SMP configuration information [ 0.000000] ACPI: HPET id: 0x8086a701 base: 0xfed00000 [ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs [ 0.000000] PM: Registered nosave memory: [mem 0x00000000-0x00000fff] [ 0.000000] PM: Registered nosave memory: [mem 0x0009d000-0x0009dfff] [ 0.000000] PM: Registered nosave memory: [mem 0x0009e000-0x0009ffff] [ 0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000dffff] [ 0.000000] PM: Registered nosave memory: [mem 0x000e0000-0x000fffff] [ 0.000000] PM: Registered nosave memory: [mem 0x20000000-0x201fffff] [ 0.000000] PM: Registered nosave memory: [mem 0x40000000-0x401fffff] [ 0.000000] PM: Registered nosave memory: [mem 0xd878e000-0xd8792fff] [ 0.000000] PM: Registered nosave memory: [mem 0xd8797000-0xd8db1fff] [ 0.000000] PM: Registered nosave memory: [mem 0xd8db2000-0xd9018fff] [ 0.000000] PM: Registered nosave memory: [mem 0xd9019000-0xd9024fff] [ 0.000000] PM: Registered nosave memory: [mem 0xd9025000-0xd9031fff] [ 0.000000] PM: Registered nosave memory: [mem 0xd9032000-0xd9036fff] [ 0.000000] PM: Registered nosave memory: [mem 0xd9037000-0xd9079fff] [ 0.000000] PM: Registered nosave memory: [mem 0xd9d3e000-0xd9ff1fff] [ 0.000000] PM: Registered nosave memory: [mem 0xda000000-0xdaffffff] [ 0.000000] PM: Registered nosave memory: [mem 0xdb000000-0xdf1fffff] [ 0.000000] PM: Registered nosave memory: [mem 0xdf200000-0xf7ffffff] [ 0.000000] PM: Registered nosave memory: [mem 0xf8000000-0xfbffffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfc000000-0xfebfffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfec00000-0xfec00fff] [ 0.000000] PM: Registered nosave memory: [mem 0xfec01000-0xfecfffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfed00000-0xfed03fff] [ 0.000000] PM: Registered nosave memory: [mem 0xfed04000-0xfed1bfff] [ 0.000000] PM: Registered nosave memory: [mem 0xfed1c000-0xfed1ffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfed20000-0xfedfffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfee00000-0xfee00fff] [ 0.000000] PM: Registered nosave memory: [mem 0xfee01000-0xfeffffff] [ 0.000000] PM: Registered nosave memory: [mem 0xff000000-0xffffffff] [ 0.000000] e820: [mem 0xdf200000-0xf7ffffff] available for PCI devices [ 0.000000] Booting paravirtualized kernel on bare hardware [ 0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns [ 0.000000] setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:2 nr_node_ids:1 [ 0.000000] PERCPU: Embedded 33 pages/cpu @ffff88041fa00000 s98264 r8192 d28712 u1048576 [ 0.000000] pcpu-alloc: s98264 r8192 d28712 u1048576 alloc=1*2097152 [ 0.000000] pcpu-alloc: [0] 0 1 [ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 4099882 [ 0.000000] Policy zone: Normal [ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-64-generic root=UUID=9112213a-3570-4904-8969-d5aab8825f6b ro quiet splash vt.handoff=7 [ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes) [ 0.000000] Calgary: detecting Calgary via BIOS EBDA area [ 0.000000] Calgary: Unable to locate Rio Grande table in EBDA - bailing! [ 0.000000] Memory: 16275716K/16660480K available (8452K kernel code, 1293K rwdata, 3980K rodata, 1488K init, 1316K bss, 384764K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 [ 0.000000] Hierarchical RCU implementation. [ 0.000000] Build-time adjustment of leaf fanout to 64. [ 0.000000] RCU restricting CPUs from NR_CPUS=512 to nr_cpu_ids=2. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=64, nr_cpu_ids=2 [ 0.000000] NR_IRQS:33024 nr_irqs:440 16 [ 0.000000] vt handoff: transparent VT on vt#7 [ 0.000000] Console: colour dummy device 80x25 [ 0.000000] console [tty0] enabled [ 0.000000] clocksource: hpet: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 133484882848 ns [ 0.000000] hpet clockevent registered [ 0.000000] tsc: Fast TSC calibration using PIT [ 0.000000] tsc: Detected 2793.634 MHz processor [ 0.000031] Calibrating delay loop (skipped), value calculated using timer frequency.. 5587.26 BogoMIPS (lpj=11174536) [ 0.000033] pid_max: default: 32768 minimum: 301 [ 0.000038] ACPI: Core revision 20150930 [ 0.005982] ACPI: 4 ACPI AML tables successfully acquired and loaded [ 0.005999] Security Framework initialized [ 0.006001] Yama: becoming mindful. [ 0.006015] AppArmor: AppArmor initialized [ 0.006874] Dentry cache hash table entries: 2097152 (order: 12, 16777216 bytes) [ 0.009794] Inode-cache hash table entries: 1048576 (order: 11, 8388608 bytes) [ 0.011066] Mount-cache hash table entries: 32768 (order: 6, 262144 bytes) [ 0.011082] Mountpoint-cache hash table entries: 32768 (order: 6, 262144 bytes) [ 0.011317] Initializing cgroup subsys io [ 0.011320] Initializing cgroup subsys memory [ 0.011326] Initializing cgroup subsys devices [ 0.011328] Initializing cgroup subsys freezer [ 0.011330] Initializing cgroup subsys net_cls [ 0.011332] Initializing cgroup subsys perf_event [ 0.011334] Initializing cgroup subsys net_prio [ 0.011337] Initializing cgroup subsys hugetlb [ 0.011338] Initializing cgroup subsys pids [ 0.011357] CPU: Physical Processor ID: 0 [ 0.011358] CPU: Processor Core ID: 0 [ 0.011362] ENERGY_PERF_BIAS: Set to 'normal', was 'performance' [ 0.011363] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8) [ 0.011365] mce: CPU supports 7 MCE banks [ 0.011375] CPU0: Thermal monitoring enabled (TM1) [ 0.011381] process: using mwait in idle threads [ 0.011384] Last level iTLB entries: 4KB 512, 2MB 8, 4MB 8 [ 0.011384] Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32, 1GB 0 [ 0.011758] Freeing SMP alternatives memory: 32K (ffffffff820b9000 - ffffffff820c1000) [ 0.015837] ftrace: allocating 32123 entries in 126 pages [ 0.029893] smpboot: APIC(0) Converting physical 0 to logical package 0 [ 0.029895] smpboot: Max logical packages: 1 [ 0.030318] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 [ 0.070006] TSC deadline timer enabled [ 0.070009] smpboot: CPU0: Intel(R) Pentium(R) CPU G640 @ 2.80GHz (family: 0x6, model: 0x2a, stepping: 0x7) [ 0.070028] Performance Events: PEBS fmt1+, 16-deep LBR, SandyBridge events, full-width counters, Intel PMU driver. [ 0.070047] ... version: 3 [ 0.070048] ... bit width: 48 [ 0.070049] ... generic registers: 8 [ 0.070050] ... value mask: 0000ffffffffffff [ 0.070051] ... max period: 00007fffffffffff [ 0.070051] ... fixed-purpose events: 3 [ 0.070052] ... event mask: 00000007000000ff [ 0.070751] x86: Booting SMP configuration: [ 0.070752] .... node #0, CPUs: #1 [ 0.071267] microcode: CPU1 microcode updated early to revision 0x29, date = 2013-06-12 [ 0.073348] x86: Booted up 1 node, 2 CPUs [ 0.073351] smpboot: Total of 2 processors activated (11174.53 BogoMIPS) [ 0.073388] NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter. [ 0.074762] devtmpfs: initialized [ 0.078897] evm: security.selinux [ 0.078899] evm: security.SMACK64 [ 0.078899] evm: security.SMACK64EXEC [ 0.078900] evm: security.SMACK64TRANSMUTE [ 0.078901] evm: security.SMACK64MMAP [ 0.078902] evm: security.ima [ 0.078903] evm: security.capability [ 0.078959] PM: Registering ACPI NVS region [mem 0xd8db2000-0xd9018fff] (2519040 bytes) [ 0.078988] PM: Registering ACPI NVS region [mem 0xd9025000-0xd9031fff] (53248 bytes) [ 0.078990] PM: Registering ACPI NVS region [mem 0xd9037000-0xd9079fff] (274432 bytes) [ 0.079062] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [ 0.079131] pinctrl core: initialized pinctrl subsystem [ 0.079239] RTC time: 18:18:42, date: 03/01/17 [ 0.079337] NET: Registered protocol family 16 [ 0.090637] cpuidle: using governor ladder [ 0.097353] cpuidle: using governor menu [ 0.097358] PCCT header not found. [ 0.097447] ACPI FADT declares the system doesn't support PCIe ASPM, so disable it [ 0.097448] ACPI: bus type PCI registered [ 0.097450] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 [ 0.097510] PCI: MMCONFIG for domain 0000 [bus 00-3f] at [mem 0xf8000000-0xfbffffff] (base 0xf8000000) [ 0.097512] PCI: MMCONFIG at [mem 0xf8000000-0xfbffffff] reserved in E820 [ 0.097522] PCI: Using configuration type 1 for base access [ 0.097611] NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter. [ 0.097618] core: PMU erratum BJ122, BV98, HSD29 workaround disabled, HT off [ 0.109668] ACPI: Added _OSI(Module Device) [ 0.109670] ACPI: Added _OSI(Processor Device) [ 0.109671] ACPI: Added _OSI(3.0 _SCP Extensions) [ 0.109672] ACPI: Added _OSI(Processor Aggregator Device) [ 0.111896] ACPI: Executed 1 blocks of module-level executable AML code [ 0.114009] ACPI: Dynamic OEM Table Load: [ 0.114015] ACPI: SSDT 0xFFFF88040D710000 00083B (v01 PmRef Cpu0Cst 00003001 INTL 20051117) [ 0.114446] ACPI: Dynamic OEM Table Load: [ 0.114450] ACPI: SSDT 0xFFFF88040D02A000 000303 (v01 PmRef ApIst 00003000 INTL 20051117) [ 0.114826] ACPI: Dynamic OEM Table Load: [ 0.114829] ACPI: SSDT 0xFFFF88040D63AC00 000119 (v01 PmRef ApCst 00003000 INTL 20051117) [ 0.115263] ACPI: Interpreter enabled [ 0.115279] ACPI: (supports S0 S3 S4 S5) [ 0.115280] ACPI: Using IOAPIC for interrupt routing [ 0.115303] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug [ 0.120695] ACPI: Power Resource [FN00] (off) [ 0.120766] ACPI: Power Resource [FN01] (off) [ 0.120834] ACPI: Power Resource [FN02] (off) [ 0.120902] ACPI: Power Resource [FN03] (off) [ 0.120970] ACPI: Power Resource [FN04] (off) [ 0.121440] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-3e]) [ 0.121445] acpi PNP0A08:00: _OSC: OS supports [ExtendedConfig ASPM ClockPM Segments MSI] [ 0.121548] \_SB_.PCI0:_OSC invalid UUID [ 0.121549] _OSC request data:1 1f 0 [ 0.121553] acpi PNP0A08:00: _OSC failed (AE_ERROR); disabling ASPM [ 0.121947] PCI host bridge to bus 0000:00 [ 0.121950] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7 window] [ 0.121951] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff window] ''' return returncode, output class TestLinuxUbuntu_16_04_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(14, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(11, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(8, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(20, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.0708 GHz', info['hz_advertised']) self.assertEqual('2.0708 GHz', info['hz_actual']) self.assertEqual((2070796000, 0), info['hz_advertised_raw']) self.assertEqual((2070796000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual( ['acpi', 'aperfmperf', 'apic', 'arat', 'arch_perfmon', 'bts', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'ds_cpl', 'dtes64', 'dtherm', 'dts', 'eagerfpu', 'epb', 'ept', 'est', 'flexpriority', 'fpu', 'fxsr', 'ht', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pebs', 'pge', 'pln', 'pni', 'popcnt', 'pse', 'pse36', 'pts', 'rdtscp', 'rep_good', 'sep', 'ss', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr_shadow', 'tsc', 'tsc_deadline_timer', 'vme', 'vmx', 'vnmi', 'vpid', 'xsave', 'xsaveopt', 'xtopology', 'xtpr'] , info['flags'] ) def test_get_cpu_info_from_dmesg(self): info = cpuinfo._get_cpu_info_from_dmesg() self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.8000 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2800000000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('1.9014 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((1901375000, 0), info['hz_actual_raw']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['acpi', 'aperfmperf', 'apic', 'arat', 'arch_perfmon', 'bts', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'ds_cpl', 'dtes64', 'dtherm', 'dts', 'eagerfpu', 'epb', 'ept', 'est', 'flexpriority', 'fpu', 'fxsr', 'ht', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pebs', 'pge', 'pln', 'pni', 'popcnt', 'pse', 'pse36', 'pts', 'rdtscp', 'rep_good', 'sep', 'ss', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr_shadow', 'tsc', 'tsc_deadline_timer', 'vme', 'vmx', 'vnmi', 'vpid', 'xsave', 'xsaveopt', 'xtopology', 'xtpr'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('1.9014 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((1901375000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(2, info['count']) self.assertEqual('x86_64', info['raw_arch_string']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['acpi', 'aperfmperf', 'apic', 'arat', 'arch_perfmon', 'bts', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'ds_cpl', 'dtes64', 'dtherm', 'dts', 'eagerfpu', 'epb', 'ept', 'est', 'flexpriority', 'fpu', 'fxsr', 'ht', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pebs', 'pge', 'pln', 'pni', 'popcnt', 'pse', 'pse36', 'pts', 'rdtscp', 'rep_good', 'sep', 'ss', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr_shadow', 'tsc', 'tsc_deadline_timer', 'vme', 'vmx', 'vnmi', 'vpid', 'xsave', 'xsaveopt', 'xtopology', 'xtpr'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_fedora_24_ppc64le.py0000644000175000017500000005326013444505146021017 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 2 is_windows = False raw_arch_string = 'ppc64le' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_dmesg(): return True @staticmethod def has_lscpu(): return True @staticmethod def has_ibm_pa_features(): return True @staticmethod def ibm_pa_features(): returncode = 0 output = ''' /proc/device-tree/cpus/PowerPC,POWER7@1/ibm,pa-features 3ff60006 c08000c7 ''' return returncode, output @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 1 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) timebase : 512000000 platform : pSeries model : IBM pSeries (emulated by qemu) machine : CHRP IBM pSeries (emulated by qemu) ''' return returncode, output @staticmethod def dmesg_a(): returncode = 0 output = ''' [ 0.000000] Allocated 2359296 bytes for 1024 pacas at c00000000fdc0000 [ 0.000000] Using pSeries machine description [ 0.000000] Page sizes from device-tree: [ 0.000000] base_shift=12: shift=12, sllp=0x0000, avpnm=0x00000000, tlbiel=1, penc=0 [ 0.000000] base_shift=16: shift=16, sllp=0x0110, avpnm=0x00000000, tlbiel=1, penc=1 [ 0.000000] Page orders: linear mapping = 16, virtual = 16, io = 12, vmemmap = 16 [ 0.000000] Using 1TB segments [ 0.000000] Found initrd at 0xc000000003700000:0xc00000000492fa44 [ 0.000000] bootconsole [udbg0] enabled [ 0.000000] Partition configured for 2 cpus. [ 0.000000] CPU maps initialized for 1 thread per core [ 0.000000] (thread shift is 0) [ 0.000000] Freed 2293760 bytes for unused pacas [ 0.000000] Starting Linux ppc64le #1 SMP Tue May 24 12:23:26 UTC 2016 [ 0.000000] ----------------------------------------------------- [ 0.000000] ppc64_pft_size = 0x1a [ 0.000000] phys_mem_size = 0x140000000 [ 0.000000] cpu_features = 0x17fc7a6c18500249 [ 0.000000] possible = 0x1fffffef18500649 [ 0.000000] always = 0x0000000018100040 [ 0.000000] cpu_user_features = 0xdc0065c2 0xef000000 [ 0.000000] mmu_features = 0x58000001 [ 0.000000] firmware_features = 0x000000014052440b [ 0.000000] htab_hash_mask = 0x7ffff [ 0.000000] ----------------------------------------------------- [ 0.000000] Linux version 4.5.5-300.fc24.ppc64le (mockbuild@buildvm-ppc64le-02.ppc.fedoraproject.org) (gcc version 6.1.1 20160510 (Red Hat 6.1.1-2) (GCC) ) #1 SMP Tue May 24 12:23:26 UTC 2016 [ 0.000000] Node 0 Memory: 0x0-0x140000000 [ 0.000000] numa: Initmem setup node 0 [mem 0x00000000-0x13fffffff] [ 0.000000] numa: NODE_DATA [mem 0x13ffda100-0x13ffe3fff] [ 0.000000] Section 317 and 319 (node 0) have a circular dependency on usemap and pgdat allocations [ 0.000000] PCI host bridge /pci@800000020000000 ranges: [ 0.000000] IO 0x0000010080000000..0x000001008000ffff -> 0x0000000000000000 [ 0.000000] MEM 0x00000100a0000000..0x000001101fffffff -> 0x0000000080000000 [ 0.000000] PPC64 nvram contains 65536 bytes [ 0.000000] Top of RAM: 0x140000000, Total RAM: 0x140000000 [ 0.000000] Memory hole size: 0MB [ 0.000000] Zone ranges: [ 0.000000] DMA [mem 0x0000000000000000-0x000000013fffffff] [ 0.000000] DMA32 empty [ 0.000000] Normal empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000000000-0x000000013fffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000013fffffff] [ 0.000000] On node 0 totalpages: 81920 [ 0.000000] DMA zone: 80 pages used for memmap [ 0.000000] DMA zone: 0 pages reserved [ 0.000000] DMA zone: 81920 pages, LIFO batch:1 [ 0.000000] PERCPU: Embedded 3 pages/cpu @c00000013fe00000 s128792 r0 d67816 u524288 [ 0.000000] pcpu-alloc: s128792 r0 d67816 u524288 alloc=1*1048576 [ 0.000000] pcpu-alloc: [0] 0 1 [ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 81840 [ 0.000000] Policy zone: DMA [ 0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-4.5.5-300.fc24.ppc64le root=UUID=e310499a-7ae9-46e6-aeeb-e9babe31e019 ro no_timer_check console=tty1 console=ttyS0,115200n8 rhgb quiet console=hvc1 LANG=en_US.UTF-8 [ 0.000000] PID hash table entries: 4096 (order: -1, 32768 bytes) [ 0.000000] Sorting __ex_table... [ 0.000000] Memory: 5129088K/5242880K available (10048K kernel code, 1344K rwdata, 3028K rodata, 5312K init, 2684K bss, 113792K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=128, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 [ 0.000000] Hierarchical RCU implementation. [ 0.000000] Build-time adjustment of leaf fanout to 64. [ 0.000000] RCU restricting CPUs from NR_CPUS=1024 to nr_cpu_ids=2. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=64, nr_cpu_ids=2 [ 0.000000] NR_IRQS:512 nr_irqs:512 16 [ 0.000000] pic: no ISA interrupt controller [ 0.000000] time_init: decrementer frequency = 512.000000 MHz [ 0.000000] time_init: processor frequency = 3425.000000 MHz [ 0.000001] clocksource: timebase: mask: 0xffffffffffffffff max_cycles: 0x761537d007, max_idle_ns: 440795202126 ns [ 0.000003] clocksource: timebase mult[1f40000] shift[24] registered [ 0.000005] clockevent: decrementer mult[83126e98] shift[32] cpu[0] [ 0.000040] Console: colour dummy device 80x25 [ 0.000068] console [tty1] enabled [ 0.000088] pid_max: default: 32768 minimum: 301 [ 0.000125] Security Framework initialized [ 0.000127] Yama: becoming mindful. [ 0.000131] SELinux: Initializing. [ 0.000146] SELinux: Starting in permissive mode [ 0.000227] Dentry cache hash table entries: 1048576 (order: 7, 8388608 bytes) [ 0.001739] Inode-cache hash table entries: 524288 (order: 6, 4194304 bytes) [ 0.002484] Mount-cache hash table entries: 16384 (order: 1, 131072 bytes) [ 0.002486] Mountpoint-cache hash table entries: 16384 (order: 1, 131072 bytes) [ 0.002754] ftrace: allocating 25021 entries in 10 pages [ 0.012417] EEH: pSeries platform initialized [ 0.012430] POWER8 performance monitor hardware support registered [ 0.012433] power8-pmu: PMAO restore workaround active. [ 0.014048] Brought up 2 CPUs [ 0.014066] Node 0 CPUs: 0-1 [ 0.014588] devtmpfs: initialized [ 0.025860] EEH: devices created [ 0.025904] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.025964] atomic64_test: passed [ 0.026060] NET: Registered protocol family 16 [ 0.026973] EEH: No capable adapters found [ 0.027024] IBM eBus Device Driver [ 0.052266] cpuidle: using governor menu [ 0.052392] pstore: Registered nvram as persistent store backend [ 0.053138] PCI: Probing PCI hardware [ 0.053169] PCI host bridge to bus 0000:00 [ 0.053172] pci_bus 0000:00: root bus resource [io 0x10000-0x1ffff] (bus address [0x0000-0xffff]) [ 0.053174] pci_bus 0000:00: root bus resource [mem 0x100a0000000-0x1101fffffff] (bus address [0x80000000-0xfffffffff]) [ 0.053176] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.079786] IOMMU table initialized, virtual merging enabled [ 0.080038] PCI: Probing PCI hardware done [ 0.102679] vgaarb: loaded [ 0.102739] SCSI subsystem initialized [ 0.102766] libata version 3.00 loaded. [ 0.102802] usbcore: registered new interface driver usbfs [ 0.102810] usbcore: registered new interface driver hub [ 0.102823] usbcore: registered new device driver usb [ 0.103034] NetLabel: Initializing [ 0.103035] NetLabel: domain hash size = 128 [ 0.103035] NetLabel: protocols = UNLABELED CIPSOv4 [ 0.103044] NetLabel: unlabeled traffic allowed by default [ 0.103108] clocksource: Switched to clocksource timebase [ 0.110649] VFS: Disk quotas dquot_6.6.0 [ 0.110680] VFS: Dquot-cache hash table entries: 8192 (order 0, 65536 bytes) [ 0.110724] hugetlbfs: disabling because there are no supported hugepage sizes [ 0.113993] NET: Registered protocol family 2 [ 0.114128] TCP established hash table entries: 65536 (order: 3, 524288 bytes) [ 0.114243] TCP bind hash table entries: 65536 (order: 4, 1048576 bytes) [ 0.114372] TCP: Hash tables configured (established 65536 bind 65536) [ 0.114381] UDP hash table entries: 4096 (order: 1, 131072 bytes) [ 0.114398] UDP-Lite hash table entries: 4096 (order: 1, 131072 bytes) [ 0.114445] NET: Registered protocol family 1 [ 0.173318] PCI: CLS 0 bytes, default 128 [ 0.173399] Unpacking initramfs... [ 0.476072] Freeing initrd memory: 18560K (c000000003700000 - c000000004920000) [ 0.476263] RTAS daemon started [ 0.476812] rtas_flash: no firmware flash support [ 0.513298] futex hash table entries: 512 (order: 0, 65536 bytes) [ 0.513327] audit: initializing netlink subsys (disabled) [ 0.513355] audit: type=2000 audit(1491783180.510:1): initialized [ 0.513515] Initialise system trusted keyring [ 0.515510] zbud: loaded [ 0.516023] Key type big_key registered [ 0.516025] SELinux: Registering netfilter hooks [ 0.521239] NET: Registered protocol family 38 [ 0.521248] Key type asymmetric registered [ 0.521251] Asymmetric key parser 'x509' registered [ 0.521288] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 0.521315] io scheduler noop registered [ 0.521317] io scheduler deadline registered [ 0.521350] io scheduler cfq registered (default) [ 0.521402] pci_hotplug: PCI Hot Plug PCI Core version: 0.5 [ 0.521659] console [hvc1] enabled [ 0.521660] bootconsole [udbg0] disabled [ 0.521735] Linux agpgart interface v0.103 [ 0.521845] libphy: Fixed MDIO Bus: probed [ 0.521881] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 0.521889] ehci-pci: EHCI PCI platform driver [ 0.521898] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 0.521906] ohci-pci: OHCI PCI platform driver [ 0.522111] ohci-pci 0000:00:02.0: OHCI PCI host controller [ 0.522141] ohci-pci 0000:00:02.0: new USB bus registered, assigned bus number 1 [ 0.522220] ohci-pci 0000:00:02.0: irq 20, io mem 0x100e0002000 [ 0.573380] usb usb1: New USB device found, idVendor=1d6b, idProduct=0001 [ 0.573382] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 0.573384] usb usb1: Product: OHCI PCI host controller [ 0.573385] usb usb1: Manufacturer: Linux 4.5.5-300.fc24.ppc64le ohci_hcd [ 0.573386] usb usb1: SerialNumber: 0000:00:02.0 [ 0.573477] hub 1-0:1.0: USB hub found [ 0.573496] hub 1-0:1.0: 3 ports detected [ 0.573656] uhci_hcd: USB Universal Host Controller Interface driver [ 0.573694] usbcore: registered new interface driver usbserial [ 0.573699] usbcore: registered new interface driver usbserial_generic [ 0.573706] usbserial: USB Serial support registered for generic [ 0.573763] mousedev: PS/2 mouse device common for all mice [ 0.573863] rtc-generic rtc-generic: rtc core: registered rtc-generic as rtc0 [ 0.573932] device-mapper: uevent: version 1.0.3 [ 0.573994] device-mapper: ioctl: 4.34.0-ioctl (2015-10-28) initialised: dm-devel@redhat.com [ 0.574075] pseries_idle_driver registered [ 0.574087] hidraw: raw HID events driver (C) Jiri Kosina [ 0.574122] usbcore: registered new interface driver usbhid [ 0.574123] usbhid: USB HID core driver [ 0.574161] drop_monitor: Initializing network drop monitor service [ 0.574234] ip_tables: (C) 2000-2006 Netfilter Core Team [ 0.574249] Initializing XFRM netlink socket [ 0.574386] NET: Registered protocol family 10 [ 0.574535] mip6: Mobile IPv6 [ 0.574538] NET: Registered protocol family 17 [ 0.574586] Running MSI bitmap self-tests ... [ 0.574723] registered taskstats version 1 [ 0.574738] Loading compiled-in X.509 certificates [ 0.575418] Loaded X.509 cert 'Fedora kernel signing key: 5a5f33c227f5a1d54cd2ff7c19cb096bd38186c0' [ 0.575455] zswap: loaded using pool lzo/zbud [ 0.575662] rtc-generic rtc-generic: setting system clock to 2017-04-10 00:13:00 UTC (1491783180) [ 0.576274] Freeing unused kernel memory: 5312K (c000000000cd0000 - c000000001200000) [ 0.605405] random: systemd urandom read with 6 bits of entropy available [ 0.606905] systemd[1]: systemd 229 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN) [ 0.606941] systemd[1]: Detected virtualization kvm. [ 0.606945] systemd[1]: Detected architecture ppc64-le. [ 0.606947] systemd[1]: Running in initial RAM disk. [ 0.606954] systemd[1]: No hostname configured. [ 0.606958] systemd[1]: Set hostname to . [ 0.606978] systemd[1]: Initializing machine ID from random generator. [ 0.668692] systemd[1]: Reached target Timers. [ 0.669077] systemd[1]: Created slice System Slice. [ 0.669110] systemd[1]: Listening on Journal Socket (/dev/log). [ 0.669126] systemd[1]: Listening on udev Kernel Socket. [ 0.669149] systemd[1]: Listening on udev Control Socket. [ 0.669175] systemd[1]: Listening on Journal Socket. [ 0.669586] systemd[1]: Starting Setup Virtual Console... [ 0.669653] systemd[1]: Listening on Journal Audit Socket. [ 0.672129] systemd[1]: Starting Journal Service... [ 0.672138] systemd[1]: Reached target Sockets. [ 0.672147] systemd[1]: Reached target Slices. [ 0.672232] systemd[1]: Reached target Local File Systems. [ 0.672240] systemd[1]: Reached target Swap. [ 0.672673] systemd[1]: Starting Create list of required static device nodes for the current kernel... [ 0.674014] systemd[1]: Starting Apply Kernel Variables... [ 0.674919] systemd[1]: Started Setup Virtual Console. [ 0.679667] audit: type=1130 audit(1491783180.590:2): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-vconsole-setup comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 0.679905] systemd[1]: Started Create list of required static device nodes for the current kernel. [ 0.679919] audit: type=1130 audit(1491783180.590:3): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=kmod-static-nodes comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 0.680081] systemd[1]: Started Apply Kernel Variables. [ 0.680092] audit: type=1130 audit(1491783180.590:4): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-sysctl comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 0.680162] systemd[1]: Started Journal Service. [ 0.680185] audit: type=1130 audit(1491783180.590:5): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-journald comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 0.694615] audit: type=1130 audit(1491783180.610:6): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-tmpfiles-setup-dev comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 0.699549] audit: type=1130 audit(1491783180.610:7): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-udevd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 0.728515] audit: type=1130 audit(1491783180.640:8): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-udev-trigger comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 0.739200] virtio-pci 0000:00:05.0: enabling device (0100 -> 0101) [ 0.739411] virtio-pci 0000:00:05.0: virtio_pci: leaving for legacy driver [ 0.740075] virtio-pci 0000:00:04.0: enabling device (0100 -> 0103) [ 0.740437] virtio-pci 0000:00:04.0: virtio_pci: leaving for legacy driver [ 0.757865] virtio-pci 0000:00:03.0: enabling device (0100 -> 0103) [ 0.758321] virtio-pci 0000:00:03.0: virtio_pci: leaving for legacy driver [ 0.763011] virtio-pci 0000:00:01.0: enabling device (0100 -> 0103) [ 0.763502] virtio-pci 0000:00:01.0: virtio_pci: leaving for legacy driver [ 0.768465] vdb: vdb1 vdb2 vdb3 [ 0.830235] audit: type=1130 audit(1491783180.740:9): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=plymouth-start comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 2.148482] audit: type=1130 audit(1491783182.060:10): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=systemd-fsck-root comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success' [ 2.189824] EXT4-fs (vdb3): mounted filesystem with ordered data mode. Opts: (null) [ 2.301223] systemd-journald[109]: Received SIGTERM from PID 1 (systemd). [ 2.351807] SELinux: 32768 avtab hash slots, 104786 rules. [ 2.365146] SELinux: 32768 avtab hash slots, 104786 rules. [ 2.383721] SELinux: 8 users, 14 roles, 5012 types, 303 bools, 1 sens, 1024 cats [ 2.383724] SELinux: 92 classes, 104786 rules [ 2.386155] SELinux: Permission validate_trans in class security not defined in policy. [ 2.386249] SELinux: the above unknown classes and permissions will be allowed [ 2.386252] SELinux: Completing initialization. [ 2.386253] SELinux: Setting up existing superblocks. [ 2.426718] systemd[1]: Successfully loaded SELinux policy in 103.506ms. [ 2.444699] systemd[1]: Relabelled /dev and /run in 11.979ms. [ 2.589401] EXT4-fs (vdb3): re-mounted. Opts: (null) [ 2.599542] systemd-journald[240]: Received request to flush runtime journal from PID 1 [ 2.779725] systemd-journald[240]: File /var/log/journal/4e9a0e2b5c824908abfd9075364301d9/system.journal corrupted or uncleanly shut down, renaming and replacing. [ 2.850831] Adding 102399936k swap on /dev/vda. Priority:-1 extents:1 across:102399936k FS [ 3.237747] EXT4-fs (vdb2): mounted filesystem with ordered data mode. Opts: (null) [ 16.065643] netlink: 12 bytes leftover after parsing attributes in process `ip'. [ 20.101004] random: nonblocking pool is initialized [ 26.987127] systemd-journald[240]: File /var/log/journal/4e9a0e2b5c824908abfd9075364301d9/user-1000.journal corrupted or uncleanly shut down, renaming and replacing. [ 95.273698] systemd-journald[240]: File /var/log/journal/4e9a0e2b5c824908abfd9075364301d9/user-1001.journal corrupted or uncleanly shut down, renaming and replacing. ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: ppc64le Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 2 NUMA node(s): 1 Model: 2.1 (pvr 004b 0201) Model name: POWER8E (raw), altivec supported Hypervisor vendor: KVM Virtualization type: para L1d cache: 64K L1i cache: 32K NUMA node0 CPU(s): 0,1 ''' return returncode, output class TestLinuxFedora_24_ppc64le(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(3, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(5, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(1, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(14, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('64 KB', info['l1_data_cache_size']) self.assertEqual('POWER8E (raw), altivec supported', info['brand']) def test_get_cpu_info_from_ibm_pa_features(self): info = cpuinfo._get_cpu_info_from_ibm_pa_features() self.assertEqual( ['dss_2.02', 'dss_2.05', 'dss_2.06', 'fpu', 'lsd_in_dscr', 'ppr', 'slb', 'sso_2.06', 'ugr_in_dscr'], info['flags'] ) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('POWER8E (raw), altivec supported', info['brand']) self.assertEqual('3.4250 GHz', info['hz_advertised']) self.assertEqual('3.4250 GHz', info['hz_actual']) self.assertEqual((3425000000, 0), info['hz_advertised_raw']) self.assertEqual((3425000000, 0), info['hz_actual_raw']) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('POWER8E (raw), altivec supported', info['brand']) self.assertEqual('3.4250 GHz', info['hz_advertised']) self.assertEqual('3.4250 GHz', info['hz_actual']) self.assertEqual((3425000000, 0), info['hz_advertised_raw']) self.assertEqual((3425000000, 0), info['hz_actual_raw']) self.assertEqual('PPC_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(2, info['count']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('64 KB', info['l1_data_cache_size']) self.assertEqual('ppc64le', info['raw_arch_string']) self.assertEqual( ['dss_2.02', 'dss_2.05', 'dss_2.06', 'fpu', 'lsd_in_dscr', 'ppr', 'slb', 'sso_2.06', 'ugr_in_dscr'], info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_debian_8_7_1_ppc64le.py0000644000175000017500000006062113444505146021370 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 2 is_windows = False raw_arch_string = 'ppc64le' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_dmesg(): return True @staticmethod def has_lscpu(): return True @staticmethod def has_ibm_pa_features(): return True @staticmethod def ibm_pa_features(): returncode = 0 output = ''' /proc/device-tree/cpus/PowerPC,POWER8@0/ibm,pa-features 18 00 f6 3f c7 c0 80 f0 80 00 00 00 00 00 00 00...?............ 00 00 80 00 80 00 80 00 80 00 .......... ''' return returncode, output @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 cpu : POWER7 (raw), altivec supported clock : 1000.000000MHz revision : 2.3 (pvr 003f 0203) processor : 1 cpu : POWER7 (raw), altivec supported clock : 1000.000000MHz revision : 2.3 (pvr 003f 0203) timebase : 512000000 platform : pSeries model : IBM pSeries (emulated by qemu) machine : CHRP IBM pSeries (emulated by qemu) ''' return returncode, output @staticmethod def dmesg_a(): returncode = 0 output = ''' [ 0.000000] Allocated 4718592 bytes for 2048 pacas at c00000000fb80000 [ 0.000000] Using pSeries machine description [ 0.000000] Page sizes from device-tree: [ 0.000000] base_shift=12: shift=12, sllp=0x0000, avpnm=0x00000000, tlbiel=1, penc=0 [ 0.000000] base_shift=24: shift=24, sllp=0x0100, avpnm=0x00000001, tlbiel=0, penc=0 [ 0.000000] Page orders: linear mapping = 24, virtual = 12, io = 12, vmemmap = 24 [ 0.000000] Using 1TB segments [ 0.000000] kvm_cma: CMA: reserved 128 MiB [ 0.000000] Found initrd at 0xc000000002f00000:0xc000000003e49d2c [ 0.000000] Partition configured for 2 cpus. [ 0.000000] CPU maps initialized for 1 thread per core [ 0.000000] (thread shift is 0) [ 0.000000] Freed 4653056 bytes for unused pacas [ 0.000000] Starting Linux PPC64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) [ 0.000000] ----------------------------------------------------- [ 0.000000] ppc64_pft_size = 0x18 [ 0.000000] physicalMemorySize = 0x80000000 [ 0.000000] htab_hash_mask = 0x1ffff [ 0.000000] ----------------------------------------------------- [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 3.16.0-4-powerpc64le (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) [ 0.000000] [boot]0012 Setup Arch [ 0.000000] Node 0 Memory: 0x0-0x80000000 [ 0.000000] PCI host bridge /pci@800000020000000 ranges: [ 0.000000] IO 0x0000010080000000..0x000001008000ffff -> 0x0000000000000000 [ 0.000000] MEM 0x00000100a0000000..0x000001101fffffff -> 0x0000000080000000 [ 0.000000] PPC64 nvram contains 65536 bytes [ 0.000000] Unable to enable relocation on exceptions: -55 [ 0.000000] Zone ranges: [ 0.000000] DMA [mem 0x00000000-0x7fffffff] [ 0.000000] Normal empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x00000000-0x7fffffff] [ 0.000000] On node 0 totalpages: 32768 [ 0.000000] DMA zone: 28 pages used for memmap [ 0.000000] DMA zone: 0 pages reserved [ 0.000000] DMA zone: 32768 pages, LIFO batch:1 [ 0.000000] [boot]0015 Setup Done [ 0.000000] PERCPU: Embedded 2 pages/cpu @c000000000e00000 s102400 r0 d28672 u524288 [ 0.000000] pcpu-alloc: s102400 r0 d28672 u524288 alloc=1*1048576 [ 0.000000] pcpu-alloc: [0] 0 1 [ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 32740 [ 0.000000] Policy zone: DMA [ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinux-3.16.0-4-powerpc64le root=UUID=35034901-f68b-4f2f-8073-ced7a2a5cd6f ro quiet [ 0.000000] PID hash table entries: 4096 (order: -1, 32768 bytes) [ 0.000000] Sorting __ex_table... [ 0.000000] Memory: 1918848K/2097152K available (7168K kernel code, 1280K rwdata, 1740K rodata, 896K init, 2197K bss, 178304K reserved) [ 0.000000] Hierarchical RCU implementation. [ 0.000000] CONFIG_RCU_FANOUT set to non-default value of 32 [ 0.000000] RCU dyntick-idle grace-period acceleration is enabled. [ 0.000000] RCU restricting CPUs from NR_CPUS=2048 to nr_cpu_ids=2. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 [ 0.000000] NR_IRQS:512 nr_irqs:512 16 [ 0.000000] pic: no ISA interrupt controller [ 0.000000] time_init: decrementer frequency = 512.000000 MHz [ 0.000000] time_init: processor frequency = 1000.000000 MHz [ 0.000350] clocksource: timebase mult[1f40000] shift[24] registered [ 0.000553] clockevent: decrementer mult[83126e98] shift[32] cpu[0] [ 0.013730] Console: colour dummy device 80x25 [ 0.014989] console [tty0] enabled [ 0.016748] pid_max: default: 32768 minimum: 301 [ 0.018500] Security Framework initialized [ 0.021966] AppArmor: AppArmor disabled by boot time parameter [ 0.022018] Yama: disabled by default; enable with sysctl kernel.yama.* [ 0.024790] Dentry cache hash table entries: 262144 (order: 5, 2097152 bytes) [ 0.037906] Inode-cache hash table entries: 131072 (order: 4, 1048576 bytes) [ 0.044210] Mount-cache hash table entries: 8192 (order: 0, 65536 bytes) [ 0.044309] Mountpoint-cache hash table entries: 8192 (order: 0, 65536 bytes) [ 0.057531] Initializing cgroup subsys memory [ 0.058793] Initializing cgroup subsys devices [ 0.062342] Initializing cgroup subsys freezer [ 0.062505] Initializing cgroup subsys net_cls [ 0.062628] Initializing cgroup subsys blkio [ 0.062729] Initializing cgroup subsys perf_event [ 0.062819] Initializing cgroup subsys net_prio [ 0.063556] ftrace: allocating 19452 entries in 8 pages [ 0.184012] EEH: pSeries platform initialized [ 0.184491] POWER7 performance monitor hardware support registered [ 0.751584] Brought up 2 CPUs [ 0.753947] Node 0 CPUs: 0-1 [ 0.755683] Enabling Asymmetric SMT scheduling [ 0.781637] devtmpfs: initialized [ 0.860457] EEH: devices created [ 0.890259] NET: Registered protocol family 16 [ 0.894867] EEH: No capable adapters found [ 0.896240] IBM eBus Device Driver [ 0.904539] cpuidle: using governor ladder [ 0.904768] cpuidle: using governor menu [ 0.915985] PCI: Probing PCI hardware [ 0.917879] no ibm,pcie-link-speed-stats property [ 0.919431] PCI host bridge to bus 0000:00 [ 0.919853] pci_bus 0000:00: root bus resource [io 0x10000-0x1ffff] (bus address [0x0000-0xffff]) [ 0.919975] pci_bus 0000:00: root bus resource [mem 0x100a0000000-0x1101fffffff] (bus address [0x80000000-0xfffffffff]) [ 0.920199] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.934921] IOMMU table initialized, virtual merging enabled [ 0.957593] PCI: Probing PCI hardware done [ 0.957881] opal: Node not found [ 0.957994] opal_async_comp_init: Opal node not found [ 1.068654] vgaarb: device added: PCI:0000:00:06.0,decodes=io+mem,owns=mem,locks=none [ 1.068755] vgaarb: loaded [ 1.068811] vgaarb: bridge control possible 0000:00:06.0 [ 1.084667] SCSI subsystem initialized [ 1.086205] libata version 3.00 loaded. [ 1.106689] Switched to clocksource timebase [ 1.285639] NET: Registered protocol family 2 [ 1.325801] TCP established hash table entries: 16384 (order: 1, 131072 bytes) [ 1.326813] TCP bind hash table entries: 16384 (order: 2, 262144 bytes) [ 1.329251] TCP: Hash tables configured (established 16384 bind 16384) [ 1.330103] TCP: reno registered [ 1.330292] UDP hash table entries: 2048 (order: 0, 65536 bytes) [ 1.331073] UDP-Lite hash table entries: 2048 (order: 0, 65536 bytes) [ 1.343933] NET: Registered protocol family 1 [ 1.402765] PCI: CLS 0 bytes, default 128 [ 1.408278] Unpacking initramfs... [ 3.824598] Freeing initrd memory: 15616K (c000000002f00000 - c000000003e40000) [ 3.827574] RTAS daemon started [ 3.850567] Hypercall H_BEST_ENERGY not supported [ 3.870435] futex hash table entries: 512 (order: 0, 65536 bytes) [ 3.875072] audit: initializing netlink subsys (disabled) [ 3.876188] audit: type=2000 audit(1489574672.324:1): initialized [ 3.897565] HugeTLB registered 16 MB page size, pre-allocated 0 pages [ 3.898287] zbud: loaded [ 3.955364] VFS: Disk quotas dquot_6.5.2 [ 3.957415] Dquot-cache hash table entries: 8192 (order 0, 65536 bytes) [ 3.962329] msgmni has been set to 4036 [ 3.991438] alg: No test for stdrng (krng) [ 3.993562] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 3.995908] io scheduler noop registered [ 3.996000] io scheduler deadline registered [ 3.999199] io scheduler cfq registered (default) [ 4.002993] pci_hotplug: PCI Hot Plug PCI Core version: 0.5 [ 4.003323] pciehp: PCI Express Hot Plug Controller Driver version: 0.4 [ 4.005685] Using unsupported 800x600 vga at 100a0000000, depth=32, pitch=3200 [ 4.038614] Console: switching to colour frame buffer device 100x37 [ 4.050446] fb0: Open Firmware frame buffer device on /pci@800000020000000/vga@6 [ 4.064118] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 4.069855] Linux agpgart interface v0.103 [ 4.074416] mousedev: PS/2 mouse device common for all mice [ 4.076553] rtc-generic rtc-generic: rtc core: registered rtc-generic as rtc0 [ 4.078500] pseries_idle_driver registered [ 4.078781] ledtrig-cpu: registered to indicate activity on CPUs [ 4.079478] TCP: cubic registered [ 4.236623] NET: Registered protocol family 10 [ 4.297808] mip6: Mobile IPv6 [ 4.298028] NET: Registered protocol family 17 [ 4.298291] mpls_gso: MPLS GSO support [ 4.306632] registered taskstats version 1 [ 4.326061] rtc-generic rtc-generic: setting system clock to 2017-03-15 10:44:33 UTC (1489574673) [ 4.326427] PM: Hibernation image not present or could not be loaded. [ 4.378547] Freeing unused kernel memory: 896K (c0000000008c0000 - c0000000009a0000) [ 5.397702] systemd-udevd[62]: starting version 215 [ 5.465837] random: systemd-udevd: uninitialized urandom read (16 bytes read, 12 bits of entropy available) [ 6.151699] virtio-pci 0000:00:05.0: enabling device (0100 -> 0101) [ 6.199143] virtio-pci 0000:00:04.0: enabling device (0100 -> 0103) [ 6.201578] virtio-pci 0000:00:03.0: enabling device (0100 -> 0103) [ 6.376882] 8139cp: 8139cp: 10/100 PCI Ethernet driver v1.3 (Mar 22, 2004) [ 6.383373] 8139cp 0000:00:01.0: enabling device (0100 -> 0103) [ 6.391941] usbcore: registered new interface driver usbfs [ 6.392361] usbcore: registered new interface driver hub [ 6.395494] 8139cp 0000:00:01.0 eth0: RTL-8139C+ at 0xd000080080022100, 52:54:00:f7:51:69, IRQ 17 [ 6.422151] usbcore: registered new device driver usb [ 6.489837] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 6.545154] 8139too: 8139too Fast Ethernet driver 0.9.28 [ 6.558285] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 6.563301] ehci-pci: EHCI PCI platform driver [ 6.577800] ohci-pci: OHCI PCI platform driver [ 6.583639] ohci-pci 0000:00:02.0: OHCI PCI host controller [ 6.584250] ohci-pci 0000:00:02.0: new USB bus registered, assigned bus number 1 [ 6.588455] ohci-pci 0000:00:02.0: irq 20, io mem 0x100e0022000 [ 6.683252] usb usb1: New USB device found, idVendor=1d6b, idProduct=0001 [ 6.683315] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 6.684539] usb usb1: Product: OHCI PCI host controller [ 6.684614] usb usb1: Manufacturer: Linux 3.16.0-4-powerpc64le ohci_hcd [ 6.684655] usb usb1: SerialNumber: 0000:00:02.0 [ 6.706756] hub 1-0:1.0: USB hub found [ 6.709342] hub 1-0:1.0: 3 ports detected [ 6.856073] ibmvscsi 2000: SRP_VERSION: 16.a [ 6.858663] scsi0 : IBM POWER Virtual SCSI Adapter 1.5.9 [ 6.890482] ibmvscsi 2000: partner initialization complete [ 6.892225] ibmvscsi 2000: host srp version: 16.a, host partition qemu (0), OS 2, max io 2097152 [ 6.892445] ibmvscsi 2000: sent SRP login [ 6.892623] ibmvscsi 2000: SRP_LOGIN succeeded [ 6.960435] scsi 0:0:0:0: CD-ROM QEMU QEMU CD-ROM 2.5+ PQ: 0 ANSI: 5 [ 7.110257] usb 1-1: new full-speed USB device number 2 using ohci-pci [ 7.354618] usb 1-1: New USB device found, idVendor=0627, idProduct=0001 [ 7.354884] usb 1-1: New USB device strings: Mfr=1, Product=4, SerialNumber=5 [ 7.354915] usb 1-1: Product: QEMU USB Keyboard [ 7.354941] usb 1-1: Manufacturer: QEMU [ 7.354965] usb 1-1: SerialNumber: 42 [ 7.593230] usb 1-2: new full-speed USB device number 3 using ohci-pci [ 7.803140] usb 1-2: New USB device found, idVendor=0627, idProduct=0001 [ 7.803189] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=5 [ 7.803217] usb 1-2: Product: QEMU USB Mouse [ 7.803243] usb 1-2: Manufacturer: QEMU [ 7.803271] usb 1-2: SerialNumber: 42 [ 8.001788] usb 1-3: new full-speed USB device number 4 using ohci-pci [ 8.236126] usb 1-3: New USB device found, idVendor=0409, idProduct=55aa [ 8.236170] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 8.236197] usb 1-3: Product: QEMU USB Hub [ 8.236221] usb 1-3: Manufacturer: QEMU [ 8.236246] usb 1-3: SerialNumber: 314159-pci@800000020000000:02.0-3 [ 8.247796] hub 1-3:1.0: USB hub found [ 8.252272] vda: vda1 vda2 vda3 [ 8.255820] hub 1-3:1.0: 8 ports detected [ 8.575937] hidraw: raw HID events driver (C) Jiri Kosina [ 8.710814] usbcore: registered new interface driver usbhid [ 8.710897] usbhid: USB HID core driver [ 8.800556] input: QEMU QEMU USB Keyboard as /devices/pci0000:00/0000:00:02.0/usb1/1-1/1-1:1.0/0003:0627:0001.0001/input/input0 [ 8.813522] hid-generic 0003:0627:0001.0001: input,hidraw0: USB HID v1.11 Keyboard [QEMU QEMU USB Keyboard] on usb-0000:00:02.0-1/input0 [ 8.838628] input: QEMU QEMU USB Mouse as /devices/pci0000:00/0000:00:02.0/usb1/1-2/1-2:1.0/0003:0627:0001.0002/input/input1 [ 8.852773] hid-generic 0003:0627:0001.0002: input,hidraw1: USB HID v0.01 Mouse [QEMU QEMU USB Mouse] on usb-0000:00:02.0-2/input0 [ 9.684157] sr0: scsi3-mmc drive: 16x/50x cd/rw xa/form2 cdda tray [ 9.684447] cdrom: Uniform CD-ROM driver Revision: 3.20 [ 9.694687] sr 0:0:0:0: Attached scsi CD-ROM sr0 [ 9.733955] sr 0:0:0:0: Attached scsi generic sg0 type 5 [ 12.126890] EXT4-fs (vda2): mounted filesystem with ordered data mode. Opts: (null) [ 13.780089] random: systemd: uninitialized urandom read (16 bytes read, 86 bits of entropy available) [ 13.820325] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR) [ 13.827143] systemd[1]: Detected architecture 'ppc64-le'. [ 13.993889] systemd[1]: Inserted module 'autofs4' [ 14.005253] systemd[1]: Set hostname to . [ 14.043401] systemd[1]: /etc/mtab is not a symlink or not pointing to /proc/self/mounts. This is not supported anymore. Please make sure to replace this file by a symlink to avoid incorrect or misleading mount(8) output. [ 15.192167] random: systemd-sysv-ge: uninitialized urandom read (16 bytes read, 97 bits of entropy available) [ 15.731488] random: systemd: uninitialized urandom read (16 bytes read, 106 bits of entropy available) [ 15.735903] random: systemd: uninitialized urandom read (16 bytes read, 106 bits of entropy available) [ 15.738841] random: systemd: uninitialized urandom read (16 bytes read, 106 bits of entropy available) [ 15.835926] random: systemd: uninitialized urandom read (16 bytes read, 108 bits of entropy available) [ 15.838244] random: systemd: uninitialized urandom read (16 bytes read, 108 bits of entropy available) [ 15.839286] random: systemd: uninitialized urandom read (16 bytes read, 108 bits of entropy available) [ 15.950852] random: systemd: uninitialized urandom read (16 bytes read, 108 bits of entropy available) [ 16.361318] systemd[1]: Starting Forward Password Requests to Wall Directory Watch. [ 16.365674] systemd[1]: Started Forward Password Requests to Wall Directory Watch. [ 16.370172] systemd[1]: Expecting device dev-hvc0.device... [ 16.373395] systemd[1]: Starting Remote File Systems (Pre). [ 16.373853] systemd[1]: Reached target Remote File Systems (Pre). [ 16.375171] systemd[1]: Starting Arbitrary Executable File Formats File System Automount Point. [ 16.385704] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point. [ 16.386238] systemd[1]: Starting Encrypted Volumes. [ 16.386600] systemd[1]: Reached target Encrypted Volumes. [ 16.387000] systemd[1]: Starting Dispatch Password Requests to Console Directory Watch. [ 16.388184] systemd[1]: Started Dispatch Password Requests to Console Directory Watch. [ 16.388464] systemd[1]: Starting Paths. [ 16.388712] systemd[1]: Reached target Paths. [ 16.391942] systemd[1]: Expecting device dev-vda3.device... [ 16.392254] systemd[1]: Expecting device dev-disk-by\x2duuid-5a63f1d4\x2ddd93\x2d45fa\x2d8b04\x2d531d13b2f573.device... [ 16.392543] systemd[1]: Starting Root Slice. [ 16.394191] systemd[1]: Created slice Root Slice. [ 16.394525] systemd[1]: Starting /dev/initctl Compatibility Named Pipe. [ 16.397746] systemd[1]: Listening on /dev/initctl Compatibility Named Pipe. [ 16.398476] systemd[1]: Starting Delayed Shutdown Socket. [ 16.400495] systemd[1]: Listening on Delayed Shutdown Socket. [ 16.401265] systemd[1]: Starting Journal Socket (/dev/log). [ 16.402434] systemd[1]: Listening on Journal Socket (/dev/log). [ 16.402815] systemd[1]: Starting udev Control Socket. [ 16.403586] systemd[1]: Listening on udev Control Socket. [ 16.403922] systemd[1]: Starting udev Kernel Socket. [ 16.404558] systemd[1]: Listening on udev Kernel Socket. [ 16.405281] systemd[1]: Starting User and Session Slice. [ 16.407097] systemd[1]: Created slice User and Session Slice. [ 16.407376] systemd[1]: Starting Journal Socket. [ 16.408701] systemd[1]: Listening on Journal Socket. [ 16.409425] systemd[1]: Starting System Slice. [ 16.411517] systemd[1]: Created slice System Slice. [ 16.412696] systemd[1]: Starting Increase datagram queue length... [ 16.471051] systemd[1]: Mounting Debug File System... [ 16.534646] systemd[1]: Mounting Huge Pages File System... [ 16.609411] systemd[1]: Started Set Up Additional Binary Formats. [ 16.624922] systemd[1]: Starting Create list of required static device nodes for the current kernel... [ 16.699997] systemd[1]: Mounting POSIX Message Queue File System... [ 16.858052] systemd[1]: Starting Load Kernel Modules... [ 16.997970] systemd[1]: Starting udev Coldplug all Devices... [ 17.162057] systemd[1]: Starting system-getty.slice. [ 17.170940] systemd[1]: Created slice system-getty.slice. [ 17.182649] systemd[1]: Starting system-serial\x2dgetty.slice. [ 17.202996] systemd[1]: Created slice system-serial\x2dgetty.slice. [ 17.225948] systemd[1]: Started File System Check on Root Device. [ 17.227635] systemd[1]: Starting Slices. [ 17.227932] systemd[1]: Reached target Slices. [ 17.474563] systemd[1]: Started Increase datagram queue length. [ 17.576418] systemd[1]: Started Create list of required static device nodes for the current kernel. [ 17.643118] systemd[1]: Mounted Debug File System. [ 17.698436] systemd[1]: Mounted Huge Pages File System. [ 17.790500] systemd[1]: Mounted POSIX Message Queue File System. [ 18.208240] fuse init (API version 7.23) [ 18.405814] systemd[1]: Started Load Kernel Modules. [ 19.057106] systemd[1]: Mounting FUSE Control File System... [ 19.099902] systemd[1]: Starting Apply Kernel Variables... [ 19.175166] systemd[1]: Mounted Configuration File System. [ 19.191354] systemd[1]: Starting Create Static Device Nodes in /dev... [ 19.252059] systemd[1]: Starting Syslog Socket. [ 19.264507] systemd[1]: Listening on Syslog Socket. [ 19.293762] systemd[1]: Starting Journal Service... [ 19.424427] systemd[1]: Started Journal Service. [ 21.339528] systemd-udevd[153]: starting version 215 [ 22.636196] random: nonblocking pool is initialized [ 26.801725] [drm] Initialized drm 1.1.0 20060810 [ 27.190191] checking generic (100a0000000 1d4c00) vs hw (100a0000000 1000000) [ 27.190254] fb: switching to bochsdrmfb from OFfb vga [ 27.192042] Console: switching to colour dummy device 80x25 [ 27.316647] [drm] Found bochs VGA, ID 0xb0c5. [ 27.316718] [drm] Framebuffer size 16384 kB @ 0x100a0000000, mmio @ 0x100e0000000. [ 27.352534] [TTM] Zone kernel: Available graphics memory: 1033696 kiB [ 27.352610] [TTM] Initializing pool allocator [ 27.699633] Console: switching to colour frame buffer device 128x48 [ 28.241859] bochs-drm 0000:00:06.0: fb0: bochsdrmfb frame buffer device [ 28.241914] bochs-drm 0000:00:06.0: registered panic notifier [ 28.270473] [drm] Initialized bochs-drm 1.0.0 20130925 for 0000:00:06.0 on minor 0 [ 32.871945] Adding 2187200k swap on /dev/vda3. Priority:-1 extents:1 across:2187200k FS [ 37.271870] EXT4-fs (vda2): re-mounted. Opts: errors=remount-ro [ 39.257446] systemd-journald[148]: Received request to flush runtime journal from PID 1 [ 66.682979] RPC: Registered named UNIX socket transport module. [ 66.683180] RPC: Registered udp transport module. [ 66.683239] ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: ppc64le Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 2 NUMA node(s): 1 Model: IBM pSeries (emulated by qemu) L1d cache: 32K L1i cache: 32K NUMA node0 CPU(s): 0,1 ''' return returncode, output class TestLinuxDebian_8_7_1_ppc64le(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(2, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(5, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(1, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(14, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual(2, len(info)) def test_get_cpu_info_from_ibm_pa_features(self): info = cpuinfo._get_cpu_info_from_ibm_pa_features() self.assertEqual( ['dabr', 'dabrx', 'dsisr', 'fpu', 'lp', 'mmu', 'pp', 'rislb', 'run', 'slb', 'sprg3'], info['flags'] ) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('POWER7 (raw), altivec supported', info['brand']) self.assertEqual('1.0000 GHz', info['hz_advertised']) self.assertEqual('1.0000 GHz', info['hz_actual']) self.assertEqual((1000000000, 0), info['hz_advertised_raw']) self.assertEqual((1000000000, 0), info['hz_actual_raw']) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('POWER7 (raw), altivec supported', info['brand']) self.assertEqual('1.0000 GHz', info['hz_advertised']) self.assertEqual('1.0000 GHz', info['hz_actual']) self.assertEqual((1000000000, 0), info['hz_advertised_raw']) self.assertEqual((1000000000, 0), info['hz_actual_raw']) self.assertEqual('PPC_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(2, info['count']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('ppc64le', info['raw_arch_string']) self.assertEqual( ['dabr', 'dabrx', 'dsisr', 'fpu', 'lp', 'mmu', 'pp', 'rislb', 'run', 'slb', 'sprg3'], info['flags'] ) py-cpuinfo-5.0.0/tests/test_solaris_11_x86_32.py0000644000175000017500000001142413444505146017460 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '32bit' cpu_count = 4 is_windows = False raw_arch_string = 'i86pc' can_cpuid = False @staticmethod def has_isainfo(): return True @staticmethod def has_kstat(): return True @staticmethod def isainfo_vb(): returncode = 0 output = ''' 64-bit amd64 applications ssse3 tscp ahf sse3 sse2 sse fxsr mmx cmov amd_sysc cx8 tsc fpu ''' return returncode, output @staticmethod def kstat_m_cpu_info(): returncode = 0 output = ''' module: cpu_info instance: 0 name: cpu_info0 class: misc brand Intel(r) Core(tm) i7 CPU 870 @ 2.93GHz cache_id 0 chip_id 0 clock_MHz 2931 clog_id 0 core_id 0 cpu_type i386 crtime 20.105018108 cstates_count 519253:519254 cstates_nsec 3370827137067:327348735595 current_clock_Hz 2930505167 current_cstate 0 current_pstate 0 family 6 fpu_type i387 compatible implementation x86 (chipid 0x0 GenuineIntel 106E5 family 6 model 30 step 5 clock 2933 MHz) max_ncpu_per_chip 4 max_ncpu_per_core 1 max_pwrcap 0 model 30 ncore_per_chip 4 ncpu_per_chip 4 pg_id 1 pkg_core_id 0 pstates_count null pstates_nsec null snaptime 3678.092364544 socket_type Unknown state on-line state_begin 1435089171 stepping 5 supported_frequencies_Hz 2930505167 supported_max_cstates 1 supported_max_pstates 0 vendor_id GenuineIntel ''' return returncode, output class TestSolaris(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(10, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(16, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_kstat(self): info = cpuinfo._get_cpu_info_from_kstat() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(r) Core(tm) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9310 GHz', info['hz_advertised']) self.assertEqual('2.9305 GHz', info['hz_actual']) self.assertEqual((2931000000, 0), info['hz_advertised_raw']) self.assertEqual((2930505167, 0), info['hz_actual_raw']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['ahf', 'amd_sysc', 'cmov', 'cx8', 'fpu', 'fxsr', 'mmx', 'sse', 'sse2', 'sse3', 'ssse3', 'tsc', 'tscp'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(r) Core(tm) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9310 GHz', info['hz_advertised']) self.assertEqual('2.9305 GHz', info['hz_actual']) self.assertEqual((2931000000, 0), info['hz_advertised_raw']) self.assertEqual((2930505167, 0), info['hz_actual_raw']) self.assertEqual('X86_32', info['arch']) self.assertEqual(32, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('i86pc', info['raw_arch_string']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['ahf', 'amd_sysc', 'cmov', 'cx8', 'fpu', 'fxsr', 'mmx', 'sse', 'sse2', 'sse3', 'ssse3', 'tsc', 'tscp'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_actual.py0000644000175000017500000001277213444505146015752 0ustar hlehle import unittest from cpuinfo import * import helpers class TestActual(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) def tearDown(self): helpers.restore_data_source(cpuinfo) def test_all(self): os_type = helpers.get_os_type() if os_type == 'BeOS': self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cpufreq_info()) self.assertEqual({}, cpuinfo._get_cpu_info_from_lscpu()) self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertTrue(len(cpuinfo._get_cpu_info_from_sysinfo()) > 0) #self.assertTrue(len(cpuinfo._get_cpu_info_from_cpuid()) > 0) self.assertTrue(len(cpuinfo.get_cpu_info()) > 0) elif os_type == 'BSD': self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cpufreq_info()) self.assertEqual({}, cpuinfo._get_cpu_info_from_lscpu()) self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertTrue(len(cpuinfo._get_cpu_info_from_dmesg()) > 0) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) # FIXME: This fails by segfaulting for some reason #self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) self.assertTrue(len(cpuinfo.get_cpu_info()) > 0) elif os_type == 'Cygwin': self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cpufreq_info()) self.assertEqual({}, cpuinfo._get_cpu_info_from_lscpu()) self.assertTrue(len(cpuinfo._get_cpu_info_from_proc_cpuinfo()) > 0) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) # FIXME: This fails by segfaulting for some reason #self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) self.assertTrue(len(cpuinfo.get_cpu_info()) > 0) elif os_type == 'MacOS': self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cpufreq_info()) self.assertEqual({}, cpuinfo._get_cpu_info_from_lscpu()) self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) self.assertTrue(len(cpuinfo._get_cpu_info_from_sysctl()) > 0) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) # FIXME: This fails by segfaulting for some reason #self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) self.assertTrue(len(cpuinfo.get_cpu_info()) > 0) elif os_type == 'Linux': self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cpufreq_info()) #self.assertTrue(len(cpuinfo._get_cpu_info_from_lscpu()) > 0) self.assertTrue(len(cpuinfo._get_cpu_info_from_proc_cpuinfo()) > 0) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) #self.assertTrue(len(cpuinfo._get_cpu_info_from_cpuid()) > 0) self.assertTrue(len(cpuinfo.get_cpu_info()) > 0) elif os_type == 'Solaris': self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cpufreq_info()) self.assertEqual({}, cpuinfo._get_cpu_info_from_lscpu()) self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertTrue(len(cpuinfo._get_cpu_info_from_kstat()) > 0) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) # FIXME: This fails by segfaulting for some reason #self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) self.assertTrue(len(cpuinfo.get_cpu_info()) > 0) elif os_type == 'Windows': self.assertTrue(len(cpuinfo._get_cpu_info_from_registry()) > 0) self.assertEqual({}, cpuinfo._get_cpu_info_from_cpufreq_info()) self.assertEqual({}, cpuinfo._get_cpu_info_from_lscpu()) self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) #self.assertTrue(len(cpuinfo._get_cpu_info_from_cpuid()) > 0) self.assertTrue(len(cpuinfo.get_cpu_info()) > 0) else: raise AssertionError('Unexpected OS type "{0}".'.format(os_type)) py-cpuinfo-5.0.0/tests/test_osx_10_9_x86_64.py0000644000175000017500000001142013444505146017045 0ustar hlehle # OS X 10.9 Mavericks # Darwin version 13 import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 4 is_windows = False raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_sysctl(): return True @staticmethod def sysctl_machdep_cpu_hw_cpufrequency(): returncode = 0 output = ''' machdep.cpu.max_basic: 5 machdep.cpu.max_ext: 2147483656 machdep.cpu.vendor: GenuineIntel machdep.cpu.brand_string: Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz machdep.cpu.family: 6 machdep.cpu.model: 58 machdep.cpu.extmodel: 3 machdep.cpu.extfamily: 0 machdep.cpu.stepping: 9 machdep.cpu.feature_bits: 395049983 2147484161 machdep.cpu.leaf7_feature_bits: 832 machdep.cpu.extfeature_bits: 672139264 1 machdep.cpu.signature: 198313 machdep.cpu.brand: 0 machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH MMX FXSR SSE SSE2 HTT SSE3 SSSE3 VMM machdep.cpu.leaf7_features: ENFSTRG BMI2 AVX2 machdep.cpu.extfeatures: SYSCALL XD EM64T LAHF RDTSCP machdep.cpu.logical_per_package: 4 machdep.cpu.cores_per_package: 4 machdep.cpu.microcode_version: 25 machdep.cpu.processor_flag: 1 machdep.cpu.mwait.linesize_min: 0 machdep.cpu.mwait.linesize_max: 0 machdep.cpu.mwait.extensions: 3 machdep.cpu.mwait.sub_Cstates: 0 machdep.cpu.cache.linesize: 64 machdep.cpu.cache.L2_associativity: 8 machdep.cpu.cache.size: 256 machdep.cpu.tlb.inst.large: 8 machdep.cpu.tlb.data.small: 64 machdep.cpu.tlb.data.small_level1: 128 machdep.cpu.tlb.shared: 1024 machdep.cpu.address_bits.physical: 39 machdep.cpu.address_bits.virtual: 48 machdep.cpu.core_count: 4 machdep.cpu.thread_count: 4 hw.cpufrequency: 2890000000 ''' return returncode, output class TestOSX_10_9(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(11, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(17, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_sysctl(self): info = cpuinfo._get_cpu_info_from_sysctl() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz', info['brand']) self.assertEqual('3.1000 GHz', info['hz_advertised']) self.assertEqual('2.8900 GHz', info['hz_actual']) self.assertEqual((3100000000, 0), info['hz_advertised_raw']) self.assertEqual((2890000000, 0), info['hz_actual_raw']) self.assertEqual('256', info['l2_cache_size']) self.assertEqual(9, info['stepping']) self.assertEqual(58, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'avx2', 'bmi2', 'clfsh', 'cmov', 'cx8', 'de', 'em64t', 'enfstrg', 'fpu', 'fxsr', 'htt', 'lahf', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'pae', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'ssse3', 'syscall', 'tsc', 'vme', 'vmm', 'xd', ] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz', info['brand']) self.assertEqual('3.1000 GHz', info['hz_advertised']) self.assertEqual('2.8900 GHz', info['hz_actual']) self.assertEqual((3100000000, 0), info['hz_advertised_raw']) self.assertEqual((2890000000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('x86_64', info['raw_arch_string']) self.assertEqual('256', info['l2_cache_size']) self.assertEqual(9, info['stepping']) self.assertEqual(58, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'avx2', 'bmi2', 'clfsh', 'cmov', 'cx8', 'de', 'em64t', 'enfstrg', 'fpu', 'fxsr', 'htt', 'lahf', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'pae', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'ssse3', 'syscall', 'tsc', 'vme', 'vmm', 'xd', ] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_raspberry_pi_model_b_arm.py0000644000175000017500000000665713444505146022746 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '32bit' cpu_count = 1 is_windows = False raw_arch_string = 'armv6l' @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_lscpu(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' Processor : ARMv6-compatible processor rev 7 (v6l) BogoMIPS : 697.95 Features : swp half thumb fastmult vfp edsp java tls CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xb76 CPU revision : 7 Hardware : BCM2708 Revision : 000d Serial : 0000000066564a8f ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: armv6l Byte Order: Little Endian CPU(s): 1 On-line CPU(s) list: 0 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 1 CPU max MHz: 700.0000 CPU min MHz: 700.0000 ''' return returncode, output class TestLinux_RaspberryPiModelB(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(4, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(3, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(13, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('700.0000 MHz', info['hz_advertised']) self.assertEqual('700.0000 MHz', info['hz_actual']) self.assertEqual((700000000, 0), info['hz_advertised_raw']) self.assertEqual((700000000, 0), info['hz_actual_raw']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('BCM2708', info['hardware']) self.assertEqual('ARMv6-compatible processor rev 7 (v6l)', info['brand']) self.assertEqual( ['edsp', 'fastmult', 'half', 'java', 'swp', 'thumb', 'tls', 'vfp'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('BCM2708', info['hardware']) self.assertEqual('ARMv6-compatible processor rev 7 (v6l)', info['brand']) self.assertEqual('700.0000 MHz', info['hz_advertised']) self.assertEqual('700.0000 MHz', info['hz_actual']) self.assertEqual((700000000, 0), info['hz_advertised_raw']) self.assertEqual((700000000, 0), info['hz_actual_raw']) self.assertEqual('ARM_7', info['arch']) self.assertEqual(32, info['bits']) self.assertEqual(1, info['count']) self.assertEqual('armv6l', info['raw_arch_string']) self.assertEqual( ['edsp', 'fastmult', 'half', 'java', 'swp', 'thumb', 'tls', 'vfp'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_pcbsd_10_x86_64.py0000644000175000017500000000732313444505146017106 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 1 is_windows = False raw_arch_string = 'amd64' can_cpuid = False @staticmethod def has_dmesg(): return True @staticmethod def dmesg_a(): retcode = 0 output = '''Copyright (c) 1992-2014 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 10.0-RELEASE-p17 #0: Tue Sep 16 14:33:46 UTC 2014 root@amd64-builder.pcbsd.org:/usr/obj/usr/src/sys/GENERIC amd64 FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610 CPU: Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz (2993.39-MHz K8-class CPU) Origin = "GenuineIntel" Id = 0x306c3 Family = 0x6 Model = 0x3c Stepping = 3 Features=0x78bfbff Features2=0x209 AMD Features=0x28100800 AMD Features2=0x1 TSC: P-state invariant ''' return retcode, output class TestPCBSD(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(6, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(12, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_dmesg(self): info = cpuinfo._get_cpu_info_from_dmesg() self.assertEqual('Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz', info['brand']) self.assertEqual('3.1000 GHz', info['hz_advertised']) self.assertEqual('3.1000 GHz', info['hz_actual']) self.assertEqual((3100000000, 0), info['hz_advertised_raw']) self.assertEqual((3100000000, 0), info['hz_actual_raw']) self.assertEqual( ['apic', 'clflush', 'cmov', 'cx8', 'de', 'fpu', 'fxsr', 'lahf', 'lm', 'mca', 'mce', 'mmx', 'mon', 'msr', 'mtrr', 'nx', 'pae', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'ssse3', 'syscall', 'tsc', 'vme'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz', info['brand']) self.assertEqual('3.1000 GHz', info['hz_advertised']) self.assertEqual('3.1000 GHz', info['hz_actual']) self.assertEqual((3100000000, 0), info['hz_advertised_raw']) self.assertEqual((3100000000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(1, info['count']) self.assertEqual('amd64', info['raw_arch_string']) self.assertEqual( ['apic', 'clflush', 'cmov', 'cx8', 'de', 'fpu', 'fxsr', 'lahf', 'lm', 'mca', 'mce', 'mmx', 'mon', 'msr', 'mtrr', 'nx', 'pae', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'ssse3', 'syscall', 'tsc', 'vme'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_osx_10_12_x86_64.py0000644000175000017500000001402713444505146017125 0ustar hlehle # OS X 10.12 Sierra # Darwin version 16 import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 4 is_windows = False raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_sysctl(): return True @staticmethod def sysctl_machdep_cpu_hw_cpufrequency(): returncode = 0 output = ''' machdep.cpu.tsc_ccc.denominator: 0 machdep.cpu.tsc_ccc.numerator: 0 machdep.cpu.thread_count: 4 machdep.cpu.core_count: 2 machdep.cpu.address_bits.virtual: 48 machdep.cpu.address_bits.physical: 36 machdep.cpu.tlb.shared: 512 machdep.cpu.tlb.data.large: 32 machdep.cpu.tlb.data.small: 64 machdep.cpu.tlb.inst.large: 8 machdep.cpu.tlb.inst.small: 64 machdep.cpu.cache.size: 256 machdep.cpu.cache.L2_associativity: 8 machdep.cpu.cache.linesize: 64 machdep.cpu.arch_perf.fixed_width: 48 machdep.cpu.arch_perf.fixed_number: 3 machdep.cpu.arch_perf.events: 0 machdep.cpu.arch_perf.events_number: 7 machdep.cpu.arch_perf.width: 48 machdep.cpu.arch_perf.number: 4 machdep.cpu.arch_perf.version: 3 machdep.cpu.xsave.extended_state1: 1 0 0 0 machdep.cpu.xsave.extended_state: 7 832 832 0 machdep.cpu.thermal.energy_policy: 1 machdep.cpu.thermal.hardware_feedback: 0 machdep.cpu.thermal.package_thermal_intr: 1 machdep.cpu.thermal.fine_grain_clock_mod: 1 machdep.cpu.thermal.core_power_limits: 1 machdep.cpu.thermal.ACNT_MCNT: 1 machdep.cpu.thermal.thresholds: 2 machdep.cpu.thermal.invariant_APIC_timer: 1 machdep.cpu.thermal.dynamic_acceleration: 1 machdep.cpu.thermal.sensor: 1 machdep.cpu.mwait.sub_Cstates: 135456 machdep.cpu.mwait.extensions: 3 machdep.cpu.mwait.linesize_max: 64 machdep.cpu.mwait.linesize_min: 64 machdep.cpu.processor_flag: 4 machdep.cpu.microcode_version: 40 machdep.cpu.cores_per_package: 8 machdep.cpu.logical_per_package: 16 machdep.cpu.extfeatures: SYSCALL XD EM64T LAHF RDTSCP TSCI machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0 machdep.cpu.brand: 0 machdep.cpu.signature: 132775 machdep.cpu.extfeature_bits: 4967106816 machdep.cpu.feature_bits: 2286390448420027391 machdep.cpu.stepping: 7 machdep.cpu.extfamily: 0 machdep.cpu.extmodel: 2 machdep.cpu.model: 42 machdep.cpu.family: 6 machdep.cpu.brand_string: Intel(R) Core(TM) i5-2557M CPU @ 1.70GHz machdep.cpu.vendor: GenuineIntel machdep.cpu.max_ext: 2147483656 machdep.cpu.max_basic: 13 hw.cpufrequency: 1700000000 ''' return returncode, output class TestOSX_10_12(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(11, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(17, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_sysctl(self): info = cpuinfo._get_cpu_info_from_sysctl() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i5-2557M CPU @ 1.70GHz', info['brand']) self.assertEqual('1.7000 GHz', info['hz_advertised']) self.assertEqual('1.7000 GHz', info['hz_actual']) self.assertEqual((1700000000, 0), info['hz_advertised_raw']) self.assertEqual((1700000000, 0), info['hz_actual_raw']) self.assertEqual('256', info['l2_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['acpi', 'aes', 'apic', 'avx1.0', 'clfsh', 'cmov', 'cx16', 'cx8', 'de', 'ds', 'dscpl', 'dtes64', 'em64t', 'est', 'fpu', 'fxsr', 'htt', 'lahf', 'mca', 'mce', 'mmx', 'mon', 'msr', 'mtrr', 'osxsave', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pge', 'popcnt', 'pse', 'pse36', 'rdtscp', 'sep', 'smx', 'ss', 'sse', 'sse2', 'sse3', 'sse4.1', 'sse4.2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr', 'tsc', 'tsci', 'tsctmr', 'vme', 'vmx', 'x2apic', 'xd', 'xsave'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i5-2557M CPU @ 1.70GHz', info['brand']) self.assertEqual('1.7000 GHz', info['hz_advertised']) self.assertEqual('1.7000 GHz', info['hz_actual']) self.assertEqual((1700000000, 0), info['hz_advertised_raw']) self.assertEqual((1700000000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('x86_64', info['raw_arch_string']) self.assertEqual('256', info['l2_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['acpi', 'aes', 'apic', 'avx1.0', 'clfsh', 'cmov', 'cx16', 'cx8', 'de', 'ds', 'dscpl', 'dtes64', 'em64t', 'est', 'fpu', 'fxsr', 'htt', 'lahf', 'mca', 'mce', 'mmx', 'mon', 'msr', 'mtrr', 'osxsave', 'pae', 'pat', 'pbe', 'pcid', 'pclmulqdq', 'pdcm', 'pge', 'popcnt', 'pse', 'pse36', 'rdtscp', 'sep', 'smx', 'ss', 'sse', 'sse2', 'sse3', 'sse4.1', 'sse4.2', 'ssse3', 'syscall', 'tm', 'tm2', 'tpr', 'tsc', 'tsci', 'tsctmr', 'vme', 'vmx', 'x2apic', 'xd', 'xsave'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_beagle_bone_arm.py0000644000175000017500000000774213444505146021002 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '32bit' cpu_count = 1 is_windows = False raw_arch_string = 'armv7l' @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_cpufreq_info(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 model name : ARMv6-compatible processor rev 7 (v6l) Features : swp half thumb fastmult vfp edsp java tls CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xb76 CPU revision : 7 Hardware : BCM2708 Revision : 0010 Serial : 00000000be6d9ba0 ''' return returncode, output @staticmethod def cpufreq_info(): returncode = 0 output = ''' cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: generic_cpu0 CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 300 us. hardware limits: 300 MHz - 1000 MHz available frequency steps: 300 MHz, 600 MHz, 800 MHz, 1000 MHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 300 MHz and 1000 MHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 1000 MHz. cpufreq stats: 300 MHz:0.00%, 600 MHz:0.00%, 800 MHz:0.00%, 1000 MHz:100.00% ''' return returncode, output class TestLinux_BeagleBone(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(4, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(3, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(13, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_cpufreq_info(self): info = cpuinfo._get_cpu_info_from_cpufreq_info() self.assertEqual('1.0000 GHz', info['hz_advertised']) self.assertEqual('1.0000 GHz', info['hz_actual']) self.assertEqual((1000000000, 0), info['hz_advertised_raw']) self.assertEqual((1000000000, 0), info['hz_actual_raw']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('BCM2708', info['hardware']) self.assertEqual('ARMv6-compatible processor rev 7 (v6l)', info['brand']) self.assertEqual( ['edsp', 'fastmult', 'half', 'java', 'swp', 'thumb', 'tls', 'vfp'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('BCM2708', info['hardware']) self.assertEqual('ARMv6-compatible processor rev 7 (v6l)', info['brand']) self.assertEqual('1.0000 GHz', info['hz_advertised']) self.assertEqual('1.0000 GHz', info['hz_actual']) self.assertEqual((1000000000, 0), info['hz_advertised_raw']) self.assertEqual((1000000000, 0), info['hz_actual_raw']) self.assertEqual('ARM_7', info['arch']) self.assertEqual(32, info['bits']) self.assertEqual(1, info['count']) self.assertEqual('armv7l', info['raw_arch_string']) self.assertEqual( ['edsp', 'fastmult', 'half', 'java', 'swp', 'thumb', 'tls', 'vfp'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_aarch64_64.py0000644000175000017500000001217113444505146017452 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 6 is_windows = False raw_arch_string = 'aarch64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_lscpu(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 90 BogoMIPS : 200.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics CPU implementer : 0x43 CPU architecture: 8 CPU variant : 0x1 CPU part : 0x0a1 CPU revision : 0 processor : 91 BogoMIPS : 200.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics CPU implementer : 0x43 CPU architecture: 8 CPU variant : 0x1 CPU part : 0x0a1 CPU revision : 0 processor : 92 BogoMIPS : 200.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics CPU implementer : 0x43 CPU architecture: 8 CPU variant : 0x1 CPU part : 0x0a1 CPU revision : 0 processor : 93 BogoMIPS : 200.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics CPU implementer : 0x43 CPU architecture: 8 CPU variant : 0x1 CPU part : 0x0a1 CPU revision : 0 processor : 94 BogoMIPS : 200.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics CPU implementer : 0x43 CPU architecture: 8 CPU variant : 0x1 CPU part : 0x0a1 CPU revision : 0 processor : 95 BogoMIPS : 200.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics CPU implementer : 0x43 CPU architecture: 8 CPU variant : 0x1 CPU part : 0x0a1 CPU revision : 0 ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: aarch64 Byte Order: Little Endian CPU(s): 96 On-line CPU(s) list: 0-95 Thread(s) per core: 1 Core(s) per socket: 48 Socket(s): 2 NUMA node(s): 2 L1d cache: 32K L1i cache: 78K L2 cache: 16384K NUMA node0 CPU(s): 0-47 NUMA node1 CPU(s): 48-95 ''' return returncode, output class TestLinux_Aarch_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(3, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(1, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(10, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('78 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('16384 KB', info['l2_cache_size']) self.assertEqual(3, len(info)) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual( ['aes', 'asimd', 'atomics', 'crc32', 'evtstrm', 'fp', 'pmull', 'sha1', 'sha2'] , info['flags'] ) @unittest.skip("FIXME: This fails because it does not have a way to get CPU brand string and Hz.") def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('', info['vendor_id']) self.assertEqual('FIXME', info['hardware']) self.assertEqual('FIXME', info['brand']) self.assertEqual('FIXME', info['hz_advertised']) self.assertEqual('FIXME', info['hz_actual']) self.assertEqual((1000000000, 0), info['hz_advertised_raw']) self.assertEqual((1000000000, 0), info['hz_actual_raw']) self.assertEqual('ARM_8', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(6, info['count']) self.assertEqual('aarch64', info['raw_arch_string']) self.assertEqual('78K', info['l1_instruction_cache_size']) self.assertEqual('32K', info['l1_data_cache_size']) self.assertEqual('16384K', info['l2_cache_size']) self.assertEqual(0, info['l2_cache_line_size']) self.assertEqual(0, info['l2_cache_associativity']) self.assertEqual('', info['l3_cache_size']) self.assertEqual(0, info['stepping']) self.assertEqual(0, info['model']) self.assertEqual(0, info['family']) self.assertEqual(0, info['processor_type']) self.assertEqual(0, info['extended_model']) self.assertEqual(0, info['extended_family']) self.assertEqual( ['aes', 'asimd', 'atomics', 'crc32', 'evtstrm', 'fp', 'pmull', 'sha1', 'sha2'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_debian_8_5_x86_64.py0000644000175000017500000006663013444505146020635 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 2 is_windows = False raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_dmesg(): return True @staticmethod def has_lscpu(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 cpu MHz : 2793.652 cache size : 3072 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt xsave hypervisor lahf_lm bogomips : 5587.30 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 cpu MHz : 2793.652 cache size : 3072 KB physical id : 0 siblings : 2 core id : 1 cpu cores : 2 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt xsave hypervisor lahf_lm bogomips : 5587.30 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: ''' return returncode, output @staticmethod def dmesg_a(): returncode = 0 output = ''' [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 3.16.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) [ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.16.0-4-amd64 root=UUID=12618f16-cbe6-4b2b-9f80-b71195be06e7 ro quiet [ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000dffeffff] usable [ 0.000000] BIOS-e820: [mem 0x00000000dfff0000-0x00000000dfffffff] ACPI data [ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000011fffffff] usable [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] SMBIOS 2.5 present. [ 0.000000] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 0.000000] Hypervisor detected: KVM [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved [ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable [ 0.000000] AGP: No AGP bridge found [ 0.000000] e820: last_pfn = 0x120000 max_arch_pfn = 0x400000000 [ 0.000000] MTRR default type: uncachable [ 0.000000] MTRR variable ranges disabled: [ 0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106 [ 0.000000] CPU MTRRs all blank - virtualized system. [ 0.000000] e820: last_pfn = 0xdfff0 max_arch_pfn = 0x400000000 [ 0.000000] found SMP MP-table at [mem 0x0009fff0-0x0009ffff] mapped at [ffff88000009fff0] [ 0.000000] Base memory trampoline at [ffff880000099000] 99000 size 24576 [ 0.000000] init_memory_mapping: [mem 0x00000000-0x000fffff] [ 0.000000] [mem 0x00000000-0x000fffff] page 4k [ 0.000000] BRK [0x01af4000, 0x01af4fff] PGTABLE [ 0.000000] BRK [0x01af5000, 0x01af5fff] PGTABLE [ 0.000000] BRK [0x01af6000, 0x01af6fff] PGTABLE [ 0.000000] init_memory_mapping: [mem 0x11fe00000-0x11fffffff] [ 0.000000] [mem 0x11fe00000-0x11fffffff] page 2M [ 0.000000] BRK [0x01af7000, 0x01af7fff] PGTABLE [ 0.000000] init_memory_mapping: [mem 0x11c000000-0x11fdfffff] [ 0.000000] [mem 0x11c000000-0x11fdfffff] page 2M [ 0.000000] init_memory_mapping: [mem 0x100000000-0x11bffffff] [ 0.000000] [mem 0x100000000-0x11bffffff] page 2M [ 0.000000] init_memory_mapping: [mem 0x00100000-0xdffeffff] [ 0.000000] [mem 0x00100000-0x001fffff] page 4k [ 0.000000] [mem 0x00200000-0xdfdfffff] page 2M [ 0.000000] [mem 0xdfe00000-0xdffeffff] page 4k [ 0.000000] RAMDISK: [mem 0x3634a000-0x3719cfff] [ 0.000000] ACPI: Early table checksum verification disabled [ 0.000000] ACPI: RSDP 0x00000000000E0000 000024 (v02 VBOX ) [ 0.000000] ACPI: XSDT 0x00000000DFFF0030 00003C (v01 VBOX VBOXXSDT 00000001 ASL 00000061) [ 0.000000] ACPI: FACP 0x00000000DFFF00F0 0000F4 (v04 VBOX VBOXFACP 00000001 ASL 00000061) [ 0.000000] ACPI: DSDT 0x00000000DFFF0470 00210F (v01 VBOX VBOXBIOS 00000002 INTL 20160108) [ 0.000000] ACPI: FACS 0x00000000DFFF0200 000040 [ 0.000000] ACPI: FACS 0x00000000DFFF0200 000040 [ 0.000000] ACPI: APIC 0x00000000DFFF0240 00005C (v02 VBOX VBOXAPIC 00000001 ASL 00000061) [ 0.000000] ACPI: SSDT 0x00000000DFFF02A0 0001CC (v01 VBOX VBOXCPUT 00000002 INTL 20160108) [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] No NUMA configuration found [ 0.000000] Faking a node at [mem 0x0000000000000000-0x000000011fffffff] [ 0.000000] Initmem setup node 0 [mem 0x00000000-0x11fffffff] [ 0.000000] NODE_DATA [mem 0x11fff7000-0x11fffbfff] [ 0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00 [ 0.000000] kvm-clock: cpu 0, msr 1:1ffef001, primary cpu clock [ 0.000000] [ffffea0000000000-ffffea0003ffffff] PMD -> [ffff88011b600000-ffff88011effffff] on node 0 [ 0.000000] Zone ranges: [ 0.000000] DMA [mem 0x00001000-0x00ffffff] [ 0.000000] DMA32 [mem 0x01000000-0xffffffff] [ 0.000000] Normal [mem 0x100000000-0x11fffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x00001000-0x0009efff] [ 0.000000] node 0: [mem 0x00100000-0xdffeffff] [ 0.000000] node 0: [mem 0x100000000-0x11fffffff] [ 0.000000] On node 0 totalpages: 1048462 [ 0.000000] DMA zone: 56 pages used for memmap [ 0.000000] DMA zone: 21 pages reserved [ 0.000000] DMA zone: 3998 pages, LIFO batch:0 [ 0.000000] DMA32 zone: 12488 pages used for memmap [ 0.000000] DMA32 zone: 913392 pages, LIFO batch:31 [ 0.000000] Normal zone: 1792 pages used for memmap [ 0.000000] Normal zone: 131072 pages, LIFO batch:31 [ 0.000000] ACPI: PM-Timer IO Port: 0x4008 [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled) [ 0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled) [ 0.000000] ACPI: IOAPIC (id[0x02] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 2, version 32, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl) [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level) [ 0.000000] ACPI: IRQ0 used by override. [ 0.000000] ACPI: IRQ2 used by override. [ 0.000000] ACPI: IRQ9 used by override. [ 0.000000] Using ACPI (MADT) for SMP configuration information [ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs [ 0.000000] nr_irqs_gsi: 40 [ 0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x0009ffff] [ 0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000effff] [ 0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff] [ 0.000000] PM: Registered nosave memory: [mem 0xdfff0000-0xdfffffff] [ 0.000000] PM: Registered nosave memory: [mem 0xe0000000-0xfebfffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfec00000-0xfec00fff] [ 0.000000] PM: Registered nosave memory: [mem 0xfec01000-0xfedfffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfee00000-0xfee00fff] [ 0.000000] PM: Registered nosave memory: [mem 0xfee01000-0xfffbffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfffc0000-0xffffffff] [ 0.000000] e820: [mem 0xe0000000-0xfebfffff] available for PCI devices [ 0.000000] Booting paravirtualized kernel on KVM [ 0.000000] setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:2 nr_node_ids:1 [ 0.000000] PERCPU: Embedded 27 pages/cpu @ffff88011fc00000 s80960 r8192 d21440 u1048576 [ 0.000000] pcpu-alloc: s80960 r8192 d21440 u1048576 alloc=1*2097152 [ 0.000000] pcpu-alloc: [0] 0 1 [ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 1034105 [ 0.000000] Policy zone: Normal [ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.16.0-4-amd64 root=UUID=12618f16-cbe6-4b2b-9f80-b71195be06e7 ro quiet [ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes) [ 0.000000] xsave: enabled xstate_bv 0x3, cntxt size 0x240 [ 0.000000] AGP: Checking aperture... [ 0.000000] AGP: No AGP bridge found [ 0.000000] Calgary: detecting Calgary via BIOS EBDA area [ 0.000000] Calgary: Unable to locate Rio Grande table in EBDA - bailing! [ 0.000000] Memory: 4041880K/4193848K available (5237K kernel code, 947K rwdata, 1836K rodata, 1204K init, 840K bss, 151968K reserved) [ 0.000000] Hierarchical RCU implementation. [ 0.000000] RCU dyntick-idle grace-period acceleration is enabled. [ 0.000000] RCU restricting CPUs from NR_CPUS=512 to nr_cpu_ids=2. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 [ 0.000000] NR_IRQS:33024 nr_irqs:512 16 [ 0.000000] Console: colour VGA+ 80x25 [ 0.000000] console [tty0] enabled [ 0.000000] tsc: Detected 2793.652 MHz processor [ 9.015923] Calibrating delay loop (skipped) preset value.. 5587.30 BogoMIPS (lpj=11174608) [ 9.015926] pid_max: default: 32768 minimum: 301 [ 9.015934] ACPI: Core revision 20140424 [ 9.017020] ACPI: All ACPI Tables successfully acquired [ 9.017050] Security Framework initialized [ 9.017058] AppArmor: AppArmor disabled by boot time parameter [ 9.017059] Yama: disabled by default; enable with sysctl kernel.yama.* [ 9.017855] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes) [ 9.019277] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes) [ 9.019613] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes) [ 9.019619] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes) [ 9.019883] Initializing cgroup subsys memory [ 9.019888] Initializing cgroup subsys devices [ 9.019895] Initializing cgroup subsys freezer [ 9.019897] Initializing cgroup subsys net_cls [ 9.019901] Initializing cgroup subsys blkio [ 9.019904] Initializing cgroup subsys perf_event [ 9.019906] Initializing cgroup subsys net_prio [ 9.019987] CPU: Physical Processor ID: 0 [ 9.019988] CPU: Processor Core ID: 0 [ 9.020005] mce: CPU supports 0 MCE banks [ 9.020039] Last level iTLB entries: 4KB 512, 2MB 8, 4MB 8 Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32, 1GB 0 tlb_flushall_shift: 6 [ 9.020376] Freeing SMP alternatives memory: 20K (ffffffff81a1b000 - ffffffff81a20000) [ 9.024990] ftrace: allocating 21697 entries in 85 pages [ 9.059874] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 [ 9.059878] smpboot: CPU0: Intel(R) Pentium(R) CPU G640 @ 2.80GHz (fam: 06, model: 2a, stepping: 07) [ 9.164299] Performance Events: unsupported p6 CPU model 42 no PMU driver, software events only. [ 9.165780] NMI watchdog: disabled (cpu0): hardware events not enabled [ 9.165895] x86: Booting SMP configuration: [ 9.165897] .... node #0, CPUs: #1 [ 9.176166] kvm-clock: cpu 1, msr 1:1ffef041, secondary cpu clock [ 9.177165] mce: CPU supports 0 MCE banks [ 9.179301] x86: Booted up 1 node, 2 CPUs [ 9.179305] smpboot: Total of 2 processors activated (11174.60 BogoMIPS) [ 9.180688] devtmpfs: initialized [ 9.187316] pinctrl core: initialized pinctrl subsystem [ 9.187487] NET: Registered protocol family 16 [ 9.187619] cpuidle: using governor ladder [ 9.187623] cpuidle: using governor menu [ 9.187667] ACPI: bus type PCI registered [ 9.187669] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 [ 9.187894] PCI: Using configuration type 1 for base access [ 9.204747] ACPI: Added _OSI(Module Device) [ 9.204751] ACPI: Added _OSI(Processor Device) [ 9.204752] ACPI: Added _OSI(3.0 _SCP Extensions) [ 9.204753] ACPI: Added _OSI(Processor Aggregator Device) [ 9.205356] ACPI: Executed 1 blocks of module-level executable AML code [ 9.207882] ACPI: Interpreter enabled [ 9.207888] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S1_] (20140424/hwxface-580) [ 9.207891] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S2_] (20140424/hwxface-580) [ 9.207894] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S3_] (20140424/hwxface-580) [ 9.207897] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S4_] (20140424/hwxface-580) [ 9.207902] ACPI: (supports S0 S5) [ 9.207904] ACPI: Using IOAPIC for interrupt routing [ 9.208077] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug [ 9.211597] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff]) [ 9.211603] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI] [ 9.211607] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM [ 9.211681] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge. [ 9.211887] PCI host bridge to bus 0000:00 [ 9.211890] pci_bus 0000:00: root bus resource [bus 00-ff] [ 9.211892] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7] [ 9.211893] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff] [ 9.211895] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff] [ 9.211896] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xffdfffff] [ 9.211930] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000 [ 9.212373] pci 0000:00:01.0: [8086:7000] type 00 class 0x060100 [ 9.212889] pci 0000:00:01.1: [8086:7111] type 00 class 0x01018a [ 9.213393] pci 0000:00:01.1: reg 0x20: [io 0xd000-0xd00f] [ 9.213530] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io 0x01f0-0x01f7] [ 9.213532] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io 0x03f6] [ 9.213533] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io 0x0170-0x0177] [ 9.213534] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io 0x0376] [ 9.213732] pci 0000:00:02.0: [80ee:beef] type 00 class 0x030000 [ 9.216760] pci 0000:00:02.0: reg 0x10: [mem 0xe0000000-0xe0ffffff pref] [ 9.239260] pci 0000:00:03.0: [8086:100e] type 00 class 0x020000 [ 9.242528] pci 0000:00:03.0: reg 0x10: [mem 0xf0000000-0xf001ffff] [ 9.250446] pci 0000:00:03.0: reg 0x18: [io 0xd010-0xd017] [ 9.267404] pci 0000:00:04.0: [80ee:cafe] type 00 class 0x088000 [ 9.270818] pci 0000:00:04.0: reg 0x10: [io 0xd020-0xd03f] [ 9.276122] pci 0000:00:04.0: reg 0x14: [mem 0xf0400000-0xf07fffff] [ 9.279813] pci 0000:00:04.0: reg 0x18: [mem 0xf0800000-0xf0803fff pref] [ 9.293767] pci 0000:00:05.0: [8086:2415] type 00 class 0x040100 [ 9.293857] pci 0000:00:05.0: reg 0x10: [io 0xd100-0xd1ff] [ 9.293917] pci 0000:00:05.0: reg 0x14: [io 0xd200-0xd23f] [ 9.294374] pci 0000:00:06.0: [106b:003f] type 00 class 0x0c0310 [ 9.297803] pci 0000:00:06.0: reg 0x10: [mem 0xf0804000-0xf0804fff] [ 9.317868] pci 0000:00:07.0: [8086:7113] type 00 class 0x068000 [ 9.318252] pci 0000:00:07.0: quirk: [io 0x4000-0x403f] claimed by PIIX4 ACPI [ 9.318262] pci 0000:00:07.0: quirk: [io 0x4100-0x410f] claimed by PIIX4 SMB [ 9.318538] pci 0000:00:0d.0: [8086:2829] type 00 class 0x010601 [ 9.321461] pci 0000:00:0d.0: reg 0x10: [io 0xd240-0xd247] [ 9.328895] pci 0000:00:0d.0: reg 0x18: [io 0xd250-0xd257] [ 9.336455] pci 0000:00:0d.0: reg 0x20: [io 0xd260-0xd26f] [ 9.339258] pci 0000:00:0d.0: reg 0x24: [mem 0xf0806000-0xf0807fff] [ 9.345202] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 9 10 *11) [ 9.345408] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 9 10 *11) [ 9.345488] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 9 *10 11) [ 9.345567] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 *9 10 11) [ 9.345694] ACPI: Enabled 2 GPEs in block 00 to 07 [ 9.346069] vgaarb: setting as boot device: PCI:0000:00:02.0 [ 9.346072] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none [ 9.346074] vgaarb: loaded [ 9.346075] vgaarb: bridge control possible 0000:00:02.0 [ 9.346163] PCI: Using ACPI for IRQ routing [ 9.346165] PCI: pci_cache_line_size set to 64 bytes [ 9.346311] e820: reserve RAM buffer [mem 0x0009fc00-0x0009ffff] [ 9.346317] e820: reserve RAM buffer [mem 0xdfff0000-0xdfffffff] [ 9.346558] Switched to clocksource kvm-clock [ 9.353995] pnp: PnP ACPI init [ 9.354008] ACPI: bus type PNP registered [ 9.354101] pnp 00:00: Plug and Play ACPI device, IDs PNP0303 (active) [ 9.354188] pnp 00:01: Plug and Play ACPI device, IDs PNP0f03 (active) [ 9.354752] pnp: PnP ACPI: found 2 devices [ 9.354753] ACPI: bus type PNP unregistered [ 9.371389] pci_bus 0000:00: resource 4 [io 0x0000-0x0cf7] [ 9.371393] pci_bus 0000:00: resource 5 [io 0x0d00-0xffff] [ 9.371395] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff] [ 9.371396] pci_bus 0000:00: resource 7 [mem 0xe0000000-0xffdfffff] [ 9.371619] NET: Registered protocol family 2 [ 9.372196] TCP established hash table entries: 32768 (order: 6, 262144 bytes) [ 9.372267] TCP bind hash table entries: 32768 (order: 7, 524288 bytes) [ 9.372334] TCP: Hash tables configured (established 32768 bind 32768) [ 9.372351] TCP: reno registered [ 9.372357] UDP hash table entries: 2048 (order: 4, 65536 bytes) [ 9.372372] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes) [ 9.372507] NET: Registered protocol family 1 [ 9.372527] pci 0000:00:00.0: Limiting direct PCI/PCI transfers [ 9.372559] pci 0000:00:01.0: Activating ISA DMA hang workarounds [ 9.372585] pci 0000:00:02.0: Video device with shadowed ROM [ 9.374015] PCI: CLS 0 bytes, default 64 [ 9.374087] Unpacking initramfs... [ 9.647919] Freeing initrd memory: 14668K (ffff88003634a000 - ffff88003719d000) [ 9.648004] PCI-DMA: Using software bounce buffering for IO (SWIOTLB) [ 9.648007] software IO TLB [mem 0xdbff0000-0xdfff0000] (64MB) mapped at [ffff8800dbff0000-ffff8800dffeffff] [ 9.648272] platform rtc_cmos: registered platform RTC device (no PNP device found) [ 9.648443] RAPL PMU detected, hw unit 2^-0 Joules, API unit is 2^-32 Joules, 3 fixed counters 10737418240 ms ovfl timer [ 9.648548] microcode: CPU0 sig=0x206a7, pf=0x10, revision=0x0 [ 9.648562] microcode: CPU1 sig=0x206a7, pf=0x10, revision=0x0 [ 9.648612] microcode: Microcode Update Driver: v2.00 , Peter Oruba [ 9.649451] futex hash table entries: 512 (order: 3, 32768 bytes) [ 9.649573] audit: initializing netlink subsys (disabled) [ 9.649598] audit: type=2000 audit(1488395362.069:1): initialized [ 9.650419] HugeTLB registered 2 MB page size, pre-allocated 0 pages [ 9.650441] zbud: loaded [ 9.650973] VFS: Disk quotas dquot_6.5.2 [ 9.651008] Dquot-cache hash table entries: 512 (order 0, 4096 bytes) [ 9.651084] msgmni has been set to 7922 [ 9.651798] alg: No test for stdrng (krng) [ 9.651846] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 9.651937] io scheduler noop registered [ 9.651941] io scheduler deadline registered [ 9.652016] io scheduler cfq registered (default) [ 9.652115] pci_hotplug: PCI Hot Plug PCI Core version: 0.5 [ 9.652132] pciehp: PCI Express Hot Plug Controller Driver version: 0.4 [ 9.652154] intel_idle: does not run on family 6 model 42 [ 9.652172] GHES: HEST is not enabled! [ 9.652242] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled [ 9.652548] Linux agpgart interface v0.103 [ 9.652677] i8042: PNP: PS/2 Controller [PNP0303:PS2K,PNP0f03:PS2M] at 0x60,0x64 irq 1,12 [ 9.653166] serio: i8042 KBD port at 0x60,0x64 irq 1 [ 9.653171] serio: i8042 AUX port at 0x60,0x64 irq 12 [ 9.653271] mousedev: PS/2 mouse device common for all mice [ 9.653687] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input0 [ 9.653824] rtc_cmos rtc_cmos: rtc core: registered rtc_cmos as rtc0 [ 9.653882] rtc_cmos rtc_cmos: alarms up to one day, 114 bytes nvram [ 9.653896] ledtrig-cpu: registered to indicate activity on CPUs [ 9.653961] AMD IOMMUv2 driver by Joerg Roedel [ 9.653962] AMD IOMMUv2 functionality not available on this system [ 9.654038] TCP: cubic registered [ 9.654234] NET: Registered protocol family 10 [ 9.654554] mip6: Mobile IPv6 [ 9.654558] NET: Registered protocol family 17 [ 9.654564] mpls_gso: MPLS GSO support [ 9.654770] registered taskstats version 1 [ 9.656357] rtc_cmos rtc_cmos: setting system clock to 2017-03-01 19:09:11 UTC (1488395351) [ 9.656427] PM: Hibernation image not present or could not be loaded. [ 9.663167] Freeing unused kernel memory: 1204K (ffffffff818ee000 - ffffffff81a1b000) [ 9.663171] Write protecting the kernel read-only data: 8192k [ 9.663645] Freeing unused kernel memory: 896K (ffff880001520000 - ffff880001600000) [ 9.664120] Freeing unused kernel memory: 212K (ffff8800017cb000 - ffff880001800000) [ 9.677467] systemd-udevd[60]: starting version 215 [ 9.677730] random: systemd-udevd urandom read with 2 bits of entropy available [ 9.698416] ACPI: bus type USB registered [ 9.698445] usbcore: registered new interface driv ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 42 Model name: Intel(R) Pentium(R) CPU G640 @ 2.80GHz Stepping: 7 CPU MHz: 2793.652 BogoMIPS: 5587.30 Hypervisor vendor: KVM Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 3072K NUMA node0 CPU(s): 0,1 ''' return returncode, output class TestLinuxDebian_8_5_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(13, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(11, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(8, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(20, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.7937 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2793652000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) def test_get_cpu_info_from_dmesg(self): info = cpuinfo._get_cpu_info_from_dmesg() self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.8000 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2800000000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'hypervisor', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave', 'xtopology'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(2, info['count']) self.assertEqual('x86_64', info['raw_arch_string']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'hypervisor', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave', 'xtopology'] , info['flags'] ) py-cpuinfo-5.0.0/tests/helpers.py0000644000175000017500000003174213444505146015102 0ustar hlehle#!/usr/bin/env python # -*- coding: UTF-8 -*- # Copyright (c) 2014-2019, Matthew Brennan Jones # Py-cpuinfo gets CPU info with pure Python 2 & 3 # It uses the MIT License # It is hosted at: https://github.com/workhorsy/py-cpuinfo # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. class EmptyDataSource(object): @staticmethod def has_proc_cpuinfo(): return False @staticmethod def has_lscpu(): return False @staticmethod def has_ibm_pa_features(): return False @staticmethod def has_wmic(): return False @staticmethod def has_dmesg(): return False @staticmethod def has_var_run_dmesg_boot(): return False @staticmethod def has_cpufreq_info(): return False @staticmethod def has_sestatus(): return False @staticmethod def has_sysctl(): return False @staticmethod def has_isainfo(): return False @staticmethod def has_kstat(): return False @staticmethod def has_sysinfo(): return False def get_os_type(): import platform os_type = 'Unknown' # Figure out the general OS type uname = platform.system().strip().strip('"').strip("'").strip().lower() if 'beos' in uname or 'haiku' in uname: os_type = 'BeOS' elif 'bsd' in uname or 'gnu/kfreebsd' in uname: os_type = 'BSD' elif 'cygwin' in uname: os_type = 'Cygwin' elif 'darwin' in uname: os_type = 'MacOS' elif 'linux' in uname: os_type = 'Linux' elif 'solaris' in uname or 'sunos' in uname: os_type = 'Solaris' elif 'windows' in uname: os_type = 'Windows' return os_type def monkey_patch_data_source(cpuinfo, NewDataSource): # Replace all methods with ones that return false _actual_monkey_patch_data_source(cpuinfo, EmptyDataSource) # Copy any methods that are the same over _actual_monkey_patch_data_source(cpuinfo, NewDataSource) def _actual_monkey_patch_data_source(cpuinfo, NewDataSource): if hasattr(NewDataSource, 'bits'): cpuinfo.DataSource.bits = NewDataSource.bits if hasattr(NewDataSource, 'cpu_count'): cpuinfo.DataSource.cpu_count = NewDataSource.cpu_count if hasattr(NewDataSource, 'is_windows'): cpuinfo.DataSource.is_windows = NewDataSource.is_windows if hasattr(NewDataSource, 'raw_arch_string'): cpuinfo.DataSource.raw_arch_string = NewDataSource.raw_arch_string if hasattr(NewDataSource, 'can_cpuid'): cpuinfo.DataSource.can_cpuid = NewDataSource.can_cpuid if hasattr(NewDataSource, 'has_proc_cpuinfo'): cpuinfo.DataSource.has_proc_cpuinfo = staticmethod(NewDataSource.has_proc_cpuinfo) if hasattr(NewDataSource, 'has_dmesg'): cpuinfo.DataSource.has_dmesg = staticmethod(NewDataSource.has_dmesg) if hasattr(NewDataSource, 'has_var_run_dmesg_boot'): cpuinfo.DataSource.has_var_run_dmesg_boot = staticmethod(NewDataSource.has_var_run_dmesg_boot) if hasattr(NewDataSource, 'has_cpufreq_info'): cpuinfo.DataSource.has_cpufreq_info = staticmethod(NewDataSource.has_cpufreq_info) if hasattr(NewDataSource, 'has_sestatus'): cpuinfo.DataSource.has_sestatus = staticmethod(NewDataSource.has_sestatus) if hasattr(NewDataSource, 'has_sysctl'): cpuinfo.DataSource.has_sysctl = staticmethod(NewDataSource.has_sysctl) if hasattr(NewDataSource, 'has_isainfo'): cpuinfo.DataSource.has_isainfo = staticmethod(NewDataSource.has_isainfo) if hasattr(NewDataSource, 'has_kstat'): cpuinfo.DataSource.has_kstat = staticmethod(NewDataSource.has_kstat) if hasattr(NewDataSource, 'has_sysinfo'): cpuinfo.DataSource.has_sysinfo = staticmethod(NewDataSource.has_sysinfo) if hasattr(NewDataSource, 'has_ibm_pa_features'): cpuinfo.DataSource.has_ibm_pa_features = staticmethod(NewDataSource.has_ibm_pa_features) if hasattr(NewDataSource, 'has_wmic'): cpuinfo.DataSource.has_wmic = staticmethod(NewDataSource.has_wmic) if hasattr(NewDataSource, 'has_lscpu'): cpuinfo.DataSource.has_lscpu = staticmethod(NewDataSource.has_lscpu) if hasattr(NewDataSource, 'cat_proc_cpuinfo'): cpuinfo.DataSource.cat_proc_cpuinfo = staticmethod(NewDataSource.cat_proc_cpuinfo) if hasattr(NewDataSource, 'cpufreq_info'): cpuinfo.DataSource.cpufreq_info = staticmethod(NewDataSource.cpufreq_info) if hasattr(NewDataSource, 'sestatus_allow_execheap'): cpuinfo.DataSource.sestatus_allow_execheap = staticmethod(NewDataSource.sestatus_allow_execheap) if hasattr(NewDataSource, 'sestatus_allow_execmem'): cpuinfo.DataSource.sestatus_allow_execmem = staticmethod(NewDataSource.sestatus_allow_execmem) if hasattr(NewDataSource, 'dmesg_a'): cpuinfo.DataSource.dmesg_a = staticmethod(NewDataSource.dmesg_a) if hasattr(NewDataSource, 'cat_var_run_dmesg_boot'): cpuinfo.DataSource.cat_var_run_dmesg_boot = staticmethod(NewDataSource.cat_var_run_dmesg_boot) if hasattr(NewDataSource, 'sysctl_machdep_cpu_hw_cpufrequency'): cpuinfo.DataSource.sysctl_machdep_cpu_hw_cpufrequency = staticmethod(NewDataSource.sysctl_machdep_cpu_hw_cpufrequency) if hasattr(NewDataSource, 'isainfo_vb'): cpuinfo.DataSource.isainfo_vb = staticmethod(NewDataSource.isainfo_vb) if hasattr(NewDataSource, 'kstat_m_cpu_info'): cpuinfo.DataSource.kstat_m_cpu_info = staticmethod(NewDataSource.kstat_m_cpu_info) if hasattr(NewDataSource, 'lscpu'): cpuinfo.DataSource.lscpu = staticmethod(NewDataSource.lscpu) if hasattr(NewDataSource, 'ibm_pa_features'): cpuinfo.DataSource.ibm_pa_features = staticmethod(NewDataSource.ibm_pa_features) if hasattr(NewDataSource, 'wmic_cpu'): cpuinfo.DataSource.wmic_cpu = staticmethod(NewDataSource.wmic_cpu) if hasattr(NewDataSource, 'sysinfo_cpu'): cpuinfo.DataSource.sysinfo_cpu = staticmethod(NewDataSource.sysinfo_cpu) if hasattr(NewDataSource, 'winreg_processor_brand'): cpuinfo.DataSource.winreg_processor_brand = staticmethod(NewDataSource.winreg_processor_brand) if hasattr(NewDataSource, 'winreg_vendor_id'): cpuinfo.DataSource.winreg_vendor_id = staticmethod(NewDataSource.winreg_vendor_id) if hasattr(NewDataSource, 'winreg_raw_arch_string'): cpuinfo.DataSource.winreg_raw_arch_string = staticmethod(NewDataSource.winreg_raw_arch_string) if hasattr(NewDataSource, 'winreg_hz_actual'): cpuinfo.DataSource.winreg_hz_actual = staticmethod(NewDataSource.winreg_hz_actual) if hasattr(NewDataSource, 'winreg_feature_bits'): cpuinfo.DataSource.winreg_feature_bits = staticmethod(NewDataSource.winreg_feature_bits) def backup_data_source(cpuinfo): BackupDataSource = type('BackupDataSource', (object,), {}) cpuinfo.BackupDataSource = BackupDataSource() cpuinfo.BackupDataSource.bits = cpuinfo.DataSource.bits cpuinfo.BackupDataSource.cpu_count = cpuinfo.DataSource.cpu_count cpuinfo.BackupDataSource.is_windows = cpuinfo.DataSource.is_windows cpuinfo.BackupDataSource.raw_arch_string = cpuinfo.DataSource.raw_arch_string cpuinfo.BackupDataSource.can_cpuid = cpuinfo.DataSource.can_cpuid cpuinfo.BackupDataSource.has_proc_cpuinfo = staticmethod(cpuinfo.DataSource.has_proc_cpuinfo) cpuinfo.BackupDataSource.has_dmesg = staticmethod(cpuinfo.DataSource.has_dmesg) cpuinfo.BackupDataSource.has_var_run_dmesg_boot = staticmethod(cpuinfo.DataSource.has_var_run_dmesg_boot) cpuinfo.BackupDataSource.has_cpufreq_info = staticmethod(cpuinfo.DataSource.has_cpufreq_info) cpuinfo.BackupDataSource.has_sestatus = staticmethod(cpuinfo.DataSource.has_sestatus) cpuinfo.BackupDataSource.has_sysctl = staticmethod(cpuinfo.DataSource.has_sysctl) cpuinfo.BackupDataSource.has_isainfo = staticmethod(cpuinfo.DataSource.has_isainfo) cpuinfo.BackupDataSource.has_kstat = staticmethod(cpuinfo.DataSource.has_kstat) cpuinfo.BackupDataSource.has_sysinfo = staticmethod(cpuinfo.DataSource.has_sysinfo) cpuinfo.BackupDataSource.has_lscpu = staticmethod(cpuinfo.DataSource.has_lscpu) cpuinfo.BackupDataSource.has_ibm_pa_features = staticmethod(cpuinfo.DataSource.has_ibm_pa_features) cpuinfo.BackupDataSource.has_wmic = staticmethod(cpuinfo.DataSource.has_wmic) cpuinfo.BackupDataSource.cat_proc_cpuinfo = staticmethod(cpuinfo.DataSource.cat_proc_cpuinfo) cpuinfo.BackupDataSource.cpufreq_info = staticmethod(cpuinfo.DataSource.cpufreq_info) cpuinfo.BackupDataSource.sestatus_allow_execheap = staticmethod(cpuinfo.DataSource.sestatus_allow_execheap) cpuinfo.BackupDataSource.sestatus_allow_execmem = staticmethod(cpuinfo.DataSource.sestatus_allow_execmem) cpuinfo.BackupDataSource.dmesg_a = staticmethod(cpuinfo.DataSource.dmesg_a) cpuinfo.BackupDataSource.cat_var_run_dmesg_boot = staticmethod(cpuinfo.DataSource.cat_var_run_dmesg_boot) cpuinfo.BackupDataSource.sysctl_machdep_cpu_hw_cpufrequency = staticmethod(cpuinfo.DataSource.sysctl_machdep_cpu_hw_cpufrequency) cpuinfo.BackupDataSource.isainfo_vb = staticmethod(cpuinfo.DataSource.isainfo_vb) cpuinfo.BackupDataSource.kstat_m_cpu_info = staticmethod(cpuinfo.DataSource.kstat_m_cpu_info) cpuinfo.BackupDataSource.lscpu = staticmethod(cpuinfo.DataSource.lscpu) cpuinfo.BackupDataSource.ibm_pa_features = staticmethod(cpuinfo.DataSource.ibm_pa_features) cpuinfo.BackupDataSource.wmic_cpu = staticmethod(cpuinfo.DataSource.wmic_cpu) cpuinfo.BackupDataSource.sysinfo_cpu = staticmethod(cpuinfo.DataSource.sysinfo_cpu) cpuinfo.BackupDataSource.winreg_processor_brand = staticmethod(cpuinfo.DataSource.winreg_processor_brand) cpuinfo.BackupDataSource.winreg_vendor_id = staticmethod(cpuinfo.DataSource.winreg_vendor_id) cpuinfo.BackupDataSource.winreg_raw_arch_string = staticmethod(cpuinfo.DataSource.winreg_raw_arch_string) cpuinfo.BackupDataSource.winreg_hz_actual = staticmethod(cpuinfo.DataSource.winreg_hz_actual) cpuinfo.BackupDataSource.winreg_feature_bits = staticmethod(cpuinfo.DataSource.winreg_feature_bits) def restore_data_source(cpuinfo): cpuinfo.DataSource.bits = cpuinfo.BackupDataSource.bits cpuinfo.DataSource.cpu_count = cpuinfo.BackupDataSource.cpu_count cpuinfo.DataSource.is_windows = cpuinfo.BackupDataSource.is_windows cpuinfo.DataSource.raw_arch_string = cpuinfo.BackupDataSource.raw_arch_string cpuinfo.DataSource.can_cpuid = cpuinfo.BackupDataSource.can_cpuid cpuinfo.DataSource.has_proc_cpuinfo = cpuinfo.BackupDataSource.has_proc_cpuinfo cpuinfo.DataSource.has_dmesg = cpuinfo.BackupDataSource.has_dmesg cpuinfo.DataSource.has_var_run_dmesg_boot = cpuinfo.BackupDataSource.has_var_run_dmesg_boot cpuinfo.DataSource.has_cpufreq_info = cpuinfo.BackupDataSource.has_cpufreq_info cpuinfo.DataSource.has_sestatus = cpuinfo.BackupDataSource.has_sestatus cpuinfo.DataSource.has_sysctl = cpuinfo.BackupDataSource.has_sysctl cpuinfo.DataSource.has_isainfo = cpuinfo.BackupDataSource.has_isainfo cpuinfo.DataSource.has_kstat = cpuinfo.BackupDataSource.has_kstat cpuinfo.DataSource.has_sysinfo = cpuinfo.BackupDataSource.has_sysinfo cpuinfo.DataSource.has_lscpu = cpuinfo.BackupDataSource.has_lscpu cpuinfo.DataSource.has_ibm_pa_features = cpuinfo.BackupDataSource.has_ibm_pa_features cpuinfo.DataSource.has_wmic = cpuinfo.BackupDataSource.has_wmic cpuinfo.DataSource.cat_proc_cpuinfo = cpuinfo.BackupDataSource.cat_proc_cpuinfo cpuinfo.DataSource.cpufreq_info = cpuinfo.BackupDataSource.cpufreq_info cpuinfo.DataSource.sestatus_allow_execheap = cpuinfo.BackupDataSource.sestatus_allow_execheap cpuinfo.DataSource.sestatus_allow_execmem = cpuinfo.BackupDataSource.sestatus_allow_execmem cpuinfo.DataSource.dmesg_a = cpuinfo.BackupDataSource.dmesg_a cpuinfo.DataSource.cat_var_run_dmesg_boot = cpuinfo.BackupDataSource.cat_var_run_dmesg_boot cpuinfo.DataSource.sysctl_machdep_cpu_hw_cpufrequency = cpuinfo.BackupDataSource.sysctl_machdep_cpu_hw_cpufrequency cpuinfo.DataSource.isainfo_vb = cpuinfo.BackupDataSource.isainfo_vb cpuinfo.DataSource.kstat_m_cpu_info = cpuinfo.BackupDataSource.kstat_m_cpu_info cpuinfo.DataSource.lscpu = cpuinfo.BackupDataSource.lscpu cpuinfo.DataSource.ibm_pa_features = cpuinfo.BackupDataSource.ibm_pa_features cpuinfo.DataSource.wmic_cpu = cpuinfo.BackupDataSource.wmic_cpu cpuinfo.DataSource.sysinfo_cpu = cpuinfo.BackupDataSource.sysinfo_cpu cpuinfo.DataSource.winreg_processor_brand = cpuinfo.BackupDataSource.winreg_processor_brand cpuinfo.DataSource.winreg_vendor_id = cpuinfo.BackupDataSource.winreg_vendor_id cpuinfo.DataSource.winreg_raw_arch_string = cpuinfo.BackupDataSource.winreg_raw_arch_string cpuinfo.DataSource.winreg_hz_actual = cpuinfo.BackupDataSource.winreg_hz_actual cpuinfo.DataSource.winreg_feature_bits = cpuinfo.BackupDataSource.winreg_feature_bits py-cpuinfo-5.0.0/tests/test_linux_debian_8_x86_64.py0000644000175000017500000001013113444505146020372 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 1 is_windows = False raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 30 model name : Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz stepping : 5 microcode : 0x616 cpu MHz : 2928.283 cache size : 6144 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl pni ssse3 lahf_lm bogomips : 5856.56 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: ''' return returncode, output class TestLinuxDebian_8_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(11, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(17, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9283 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2928283000, 0), info['hz_actual_raw']) self.assertEqual('6144 KB', info['l3_cache_size']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nopl', 'nx', 'pae', 'pat', 'pge', 'pni', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'ssse3', 'syscall', 'tsc', 'vme'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9283 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2928283000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(1, info['count']) self.assertEqual('x86_64', info['raw_arch_string']) self.assertEqual('6144 KB', info['l3_cache_size']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nopl', 'nx', 'pae', 'pat', 'pge', 'pni', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'ssse3', 'syscall', 'tsc', 'vme'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_cpuid.py0000644000175000017500000000103313444505146015571 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 1 is_windows = False raw_arch_string = 'INVALID' can_cpuid = True class TestCPUID(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) # Make sure this returns {} on an invalid arch def test_return_empty(self): self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) py-cpuinfo-5.0.0/tests/test_windows_10_x86_64.py0000644000175000017500000001105313444505146017500 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 4 is_windows = True raw_arch_string = 'AMD64' can_cpuid = False @staticmethod def has_wmic(): return True @staticmethod def wmic_cpu(): returncode = 0 output = ''' Caption=Intel64 Family 6 Model 69 Stepping 1 CurrentClockSpeed=2494 Description=Intel64 Family 6 Model 69 Stepping 1 L2CacheSize=512 L3CacheSize=3072 Manufacturer=GenuineIntel Name=Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz ''' return returncode, output @staticmethod def winreg_processor_brand(): return 'Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz' @staticmethod def winreg_vendor_id(): return 'GenuineIntel' @staticmethod def winreg_raw_arch_string(): return 'AMD64' @staticmethod def winreg_hz_actual(): return 2494 @staticmethod def winreg_feature_bits(): return 1025196031 class TestWindows_10_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(11, len(cpuinfo._get_cpu_info_from_wmic())); self.assertEqual(7, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(18, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_wmic(self): info = cpuinfo._get_cpu_info_from_wmic() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz', info['brand']) self.assertEqual('1.9000 GHz', info['hz_advertised']) self.assertEqual('2.4940 GHz', info['hz_actual']) self.assertEqual((1900000000, 0), info['hz_advertised_raw']) self.assertEqual((2494000000, 0), info['hz_actual_raw']) self.assertEqual(1, info['stepping']) self.assertEqual(69, info['model']) self.assertEqual(6, info['family']) self.assertEqual('512 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) def test_get_cpu_info_from_registry(self): info = cpuinfo._get_cpu_info_from_registry() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz', info['brand']) self.assertEqual('1.9000 GHz', info['hz_advertised']) self.assertEqual('2.4940 GHz', info['hz_actual']) self.assertEqual((1900000000, 0), info['hz_advertised_raw']) self.assertEqual((2494000000, 0), info['hz_actual_raw']) if "logger" in dir(unittest): unittest.logger("FIXME: Missing flags such as sse3 and sse4") self.assertEqual( ['3dnow', 'acpi', 'clflush', 'cmov', 'de', 'dts', 'fxsr', 'ia64', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'pse', 'sep', 'serial', 'ss', 'sse', 'sse2', 'tm', 'tsc'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz', info['brand']) self.assertEqual('1.9000 GHz', info['hz_advertised']) self.assertEqual('2.4940 GHz', info['hz_actual']) self.assertEqual((1900000000, 0), info['hz_advertised_raw']) self.assertEqual((2494000000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('AMD64', info['raw_arch_string']) self.assertEqual(1, info['stepping']) self.assertEqual(69, info['model']) self.assertEqual(6, info['family']) self.assertEqual('512 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) if "logger" in dir(unittest): unittest.logger("FIXME: Missing flags such as sse3 and sse4") self.assertEqual( ['3dnow', 'acpi', 'clflush', 'cmov', 'de', 'dts', 'fxsr', 'ia64', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'pse', 'sep', 'serial', 'ss', 'sse', 'sse2', 'tm', 'tsc'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_parse_cpu_string.py0000644000175000017500000000743013444505146020043 0ustar hlehle import unittest from cpuinfo import * import helpers class TestParseCPUString(unittest.TestCase): def test_parse_cpu_string(self): processor_brand, hz_actual, scale, vendor_id, stepping, model, family = \ cpuinfo._parse_cpu_string("Intel(R) Pentium(R) CPU G640 @ 2.80GHz (fam: 06, model: 2a, stepping: 07)") self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', processor_brand) self.assertEqual('2.8', hz_actual) self.assertEqual(9, scale) self.assertEqual(None, vendor_id) self.assertEqual(7, stepping) self.assertEqual(42, model) self.assertEqual(6, family) processor_brand, hz_actual, scale, vendor_id, stepping, model, family = \ cpuinfo._parse_cpu_string("Intel(R) Pentium(R) CPU G640 @ 2.80GHz (family: 0x6, model: 0x2a, stepping: 0x7)") self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', processor_brand) self.assertEqual('2.8', hz_actual) self.assertEqual(9, scale) self.assertEqual(None, vendor_id) self.assertEqual(7, stepping) self.assertEqual(42, model) self.assertEqual(6, family) processor_brand, hz_actual, scale, vendor_id, stepping, model, family = \ cpuinfo._parse_cpu_string("Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz") self.assertEqual("Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz", processor_brand) self.assertEqual('2.93', hz_actual) self.assertEqual(9, scale) self.assertEqual(None, vendor_id) self.assertEqual(None, stepping) self.assertEqual(None, model) self.assertEqual(None, family) processor_brand, hz_actual, scale, vendor_id, stepping, model, family = \ cpuinfo._parse_cpu_string("Intel(R) Pentium(R) CPU G640 @ 2.80GHz (2793.73-MHz K8-class CPU)") self.assertEqual("Intel(R) Pentium(R) CPU G640 @ 2.80GHz", processor_brand) self.assertEqual('2.8', hz_actual) self.assertEqual(9, scale) self.assertEqual(None, vendor_id) self.assertEqual(None, stepping) self.assertEqual(None, model) self.assertEqual(None, family) # NOTE: No @ symbol processor_brand, hz_actual, scale, vendor_id, stepping, model, family = \ cpuinfo._parse_cpu_string("Intel(R) Pentium(R) D CPU 3.20GHz") self.assertEqual("Intel(R) Pentium(R) D CPU 3.20GHz", processor_brand) self.assertEqual('3.2', hz_actual) self.assertEqual(9, scale) self.assertEqual(None, vendor_id) self.assertEqual(None, stepping) self.assertEqual(None, model) self.assertEqual(None, family) def test_to_friendly_hz(self): scale, hz_brand = cpuinfo._get_hz_string_from_brand('Intel(R) Pentium(R) CPU G640 @ 2.80GHz') self.assertEqual(9, scale) self.assertEqual('2.8', hz_brand) self.assertEqual('2.8000 GHz', cpuinfo._to_friendly_hz(hz_brand, scale)) scale, hz_brand = cpuinfo._get_hz_string_from_brand('Intel(R) Pentium(R) CPU @ 1.20MHz') self.assertEqual(6, scale) self.assertEqual('1.2', hz_brand) self.assertEqual('1.2000 MHz', cpuinfo._to_friendly_hz(hz_brand, scale)) scale, hz_brand = cpuinfo._get_hz_string_from_brand('Intel(R) Pentium(R) D CPU 3.20GHz') self.assertEqual(9, scale) self.assertEqual('3.2', hz_brand) self.assertEqual('3.2000 GHz', cpuinfo._to_friendly_hz(hz_brand, scale)) def test_to_raw_hz(self): scale, hz_brand = cpuinfo._get_hz_string_from_brand('Intel(R) Pentium(R) CPU G640 @ 2.80GHz') self.assertEqual(9, scale) self.assertEqual('2.8', hz_brand) self.assertEqual((2800000000, 0), cpuinfo._to_raw_hz(hz_brand, scale)) scale, hz_brand = cpuinfo._get_hz_string_from_brand('Intel(R) Pentium(R) CPU @ 1.20MHz') self.assertEqual(6, scale) self.assertEqual('1.2', hz_brand) self.assertEqual((1200000, 0), cpuinfo._to_raw_hz(hz_brand, scale)) # NOTE: No @ symbol scale, hz_brand = cpuinfo._get_hz_string_from_brand('Intel(R) Pentium(R) D CPU 3.20GHz') self.assertEqual(9, scale) self.assertEqual('3.2', hz_brand) self.assertEqual((3200000000, 0), cpuinfo._to_raw_hz(hz_brand, scale)) py-cpuinfo-5.0.0/tests/test_example.py0000644000175000017500000000457113444505146016132 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 1 is_windows = False raw_arch_string = 'x86_64' @staticmethod def has_proc_cpuinfo(): return False @staticmethod def has_dmesg(): return False @staticmethod def has_var_run_dmesg_boot(): return False @staticmethod def has_cpufreq_info(): return False @staticmethod def has_sestatus(): return False @staticmethod def has_sysctl(): return False @staticmethod def has_isainfo(): return False @staticmethod def has_kstat(): return False @staticmethod def has_sysinfo(): return False @staticmethod def has_lscpu(): return False @staticmethod def cat_proc_cpuinfo(): return 1, None @staticmethod def cpufreq_info(): return 1, None @staticmethod def sestatus_allow_execheap(): return False @staticmethod def sestatus_allow_execmem(): return False @staticmethod def dmesg_a(): return 1, None @staticmethod def cat_var_run_dmesg_boot(): return 1, None @staticmethod def sysctl_machdep_cpu_hw_cpufrequency(): return 1, None @staticmethod def isainfo_vb(): return 1, None @staticmethod def kstat_m_cpu_info(): return 1, None @staticmethod def lscpu(): return 1, None @staticmethod def sysinfo_cpu(): return 1, None @staticmethod def winreg_processor_brand(): return None @staticmethod def winreg_vendor_id(): return None @staticmethod def winreg_raw_arch_string(): return None @staticmethod def winreg_hz_actual(): return None @staticmethod def winreg_feature_bits(): return None class TestExample(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) def test_all(self): self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) #self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) #self.assertEqual({}, cpuinfo._get_cpu_info_internal()) py-cpuinfo-5.0.0/tests/test_haiku_x86_32.py0000644000175000017500000001024313444505146016602 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '32bit' cpu_count = 4 is_windows = False raw_arch_string = 'BePC' can_cpuid = False @staticmethod def has_sysinfo(): return True @staticmethod def sysinfo_cpu(): returncode = 0 output = ''' 4 Intel Core i7, revision 46e5 running at 2928MHz (ID: 0x00000000 0x00000000) CPU #0: "Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz" Type 0, family 6, model 30, stepping 5, features 0x178bfbbf FPU VME DE PSE TSC MSR MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CFLUSH MMX FXSTR SSE SSE2 HTT Extended Intel: 0x00000201 SSE3 SSSE3 Extended AMD: type 0, family 0, model 0, stepping 0, features 0x08000000 RDTSCP Power Management Features: L2 Data cache 8-way set associative, 1 lines/tag, 64 bytes/line L2 cache: 0 KB, 1-way set associative, 0 lines/tag, 63 bytes/line Data TLB: 2M/4M-bytes pages, 4-way set associative, 32 entries Data TLB: 4k-byte pages, 4-way set associative, 64 entries Inst TLB: 2M/4M-bytes pages, fully associative, 7 entries L3 cache: 8192 KB, 16-way set associative, 64-bytes/line Inst TLB: 4K-bytes pages, 4-way set associative, 128 entries 64-byte Prefetching L1 data cache: 32 KB, 8-way set associative, 64 bytes/line L2 cache: 256 KB (MLC), 8-way set associative, 64-bytes/line Shared 2nd-level TLB: 4K, 4-way set associative, 512 entries Unknown cache descriptor 0x09 ''' return returncode, output class TestHaiku_x86_32(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(9, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(15, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_sysinfo(self): info = cpuinfo._get_cpu_info_from_sysinfo() self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9300 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2930000000, 0), info['hz_actual_raw']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'cflush', 'cmov', 'cx8', 'de', 'fpu', 'fxstr', 'htt', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'ssse3', 'tsc', 'vme'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9300 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2930000000, 0), info['hz_actual_raw']) self.assertEqual('X86_32', info['arch']) self.assertEqual(32, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('BePC', info['raw_arch_string']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'cflush', 'cmov', 'cx8', 'de', 'fpu', 'fxstr', 'htt', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'ssse3', 'tsc', 'vme'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_haiku_x86_64.py0000644000175000017500000001064513444505146016615 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 4 is_windows = False raw_arch_string = 'BePC' can_cpuid = False @staticmethod def has_sysinfo(): return True @staticmethod def sysinfo_cpu(): returncode = 0 output = ''' 1 Intel Core i7, revision 106e5 running at 2933MHz CPU #0: "Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz" Signature: 0x0106e5; Type 0, family 6, model 30, stepping 5 Features: 0x078bfbff FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CFLUSH MMX FXSTR SSE SSE2 Extended Features (0x00000001): 0x00180209 SSE3 MONITOR SSSE3 SSE4.1 SSE4.2 Extended Features (0x80000001): 0x28100800 SCE NX RDTSCP 64 L2 Data cache fully associative, 1 lines/tag, 64 bytes/line L2 cache: 0 KB, 1-way set associative, 0 lines/tag, 63 bytes/line L0 Data TLB: 2M/4M-bytes pages, 4-way set associative, 32 entries Data TLB: 4k-byte pages, 4-way set associative, 64 entries Inst TLB: 2M/4M-bytes pages, fully associative, 7 entries L3 cache: 8192 KB, 16-way set associative, 64-bytes/line Inst TLB: 4K-bytes pages, 4-way set associative, 128 entries 64-byte Prefetching L1 data cache: 32 KB, 8-way set associative, 64 bytes/line L2 cache: 256 KB (MLC), 8-way set associative, 64-bytes/line Shared 2nd-level TLB: 4K, 4-way set associative, 512 entries Unknown cache descriptor 0x09 ''' return returncode, output class TestHaiku_x86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(9, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(15, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_sysinfo(self): info = cpuinfo._get_cpu_info_from_sysinfo() self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9300 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2930000000, 0), info['hz_actual_raw']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['64', 'apic', 'cflush', 'cmov', 'cx8', 'de', 'fpu', 'fxstr', 'mca', 'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nx', 'pae', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sce', 'sep', 'sse', 'sse2', 'sse3', 'sse4.1', 'sse4.2', 'ssse3', 'tsc', 'vme'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9300 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2930000000, 0), info['hz_actual_raw']) self.assertEqual('X86_32', info['arch']) self.assertEqual(32, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('BePC', info['raw_arch_string']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['64', 'apic', 'cflush', 'cmov', 'cx8', 'de', 'fpu', 'fxstr', 'mca', 'mce', 'mmx', 'monitor', 'msr', 'mtrr', 'nx', 'pae', 'pat', 'pge', 'pse', 'pse36', 'rdtscp', 'sce', 'sep', 'sse', 'sse2', 'sse3', 'sse4.1', 'sse4.2', 'ssse3', 'tsc', 'vme'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_odroid_c2_aarch64.py0000644000175000017500000001635713444505146021077 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 4 is_windows = False raw_arch_string = 'aarch64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_lscpu(): return True @staticmethod def has_cpufreq_info(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 BogoMIPS : 2.00 Features : fp asimd crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 processor : 1 BogoMIPS : 2.00 Features : fp asimd crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 processor : 2 BogoMIPS : 2.00 Features : fp asimd crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 processor : 3 BogoMIPS : 2.00 Features : fp asimd crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 Hardware : ODROID-C2 Revision : 020c ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: aarch64 Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 4 CPU max MHz: 1536.0000 CPU min MHz: 100.0000 ''' return returncode, output @staticmethod def cpufreq_info(): returncode = 0 output = ''' cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: meson_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 200 us. hardware limits: 100.0 MHz - 1.54 GHz available frequency steps: 100.0 MHz, 250 MHz, 500 MHz, 1000 MHz, 1.30 GHz, 1.54 GHz available cpufreq governors: hotplug, interactive, conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 100.0 MHz and 1.54 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.54 GHz. cpufreq stats: 100.0 MHz:0.00%, 250 MHz:0.00%, 500 MHz:0.00%, 1000 MHz:0.00%, 1.30 GHz:0.00%, 1.54 GHz:100.00% (439) analyzing CPU 1: driver: meson_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 200 us. hardware limits: 100.0 MHz - 1.54 GHz available frequency steps: 100.0 MHz, 250 MHz, 500 MHz, 1000 MHz, 1.30 GHz, 1.54 GHz available cpufreq governors: hotplug, interactive, conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 100.0 MHz and 1.54 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.54 GHz. cpufreq stats: 100.0 MHz:0.00%, 250 MHz:0.00%, 500 MHz:0.00%, 1000 MHz:0.00%, 1.30 GHz:0.00%, 1.54 GHz:100.00% (439) analyzing CPU 2: driver: meson_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 200 us. hardware limits: 100.0 MHz - 1.54 GHz available frequency steps: 100.0 MHz, 250 MHz, 500 MHz, 1000 MHz, 1.30 GHz, 1.54 GHz available cpufreq governors: hotplug, interactive, conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 100.0 MHz and 1.54 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.54 GHz. cpufreq stats: 100.0 MHz:0.00%, 250 MHz:0.00%, 500 MHz:0.00%, 1000 MHz:0.00%, 1.30 GHz:0.00%, 1.54 GHz:100.00% (439) analyzing CPU 3: driver: meson_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 200 us. hardware limits: 100.0 MHz - 1.54 GHz available frequency steps: 100.0 MHz, 250 MHz, 500 MHz, 1000 MHz, 1.30 GHz, 1.54 GHz available cpufreq governors: hotplug, interactive, conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 100.0 MHz and 1.54 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.54 GHz. cpufreq stats: 100.0 MHz:0.00%, 250 MHz:0.00%, 500 MHz:0.00%, 1000 MHz:0.00%, 1.30 GHz:0.00%, 1.54 GHz:100.00% (439) ''' return returncode, output class TestLinux_Odroid_C2_Aarch_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(4, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(4, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(2, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(12, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_cpufreq_info(self): info = cpuinfo._get_cpu_info_from_cpufreq_info() self.assertEqual('1.5400 GHz', info['hz_advertised']) self.assertEqual('1.5400 GHz', info['hz_actual']) self.assertEqual((1540000000, 0), info['hz_advertised_raw']) self.assertEqual((1540000000, 0), info['hz_actual_raw']) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('1.5360 GHz', info['hz_advertised']) self.assertEqual('1.5360 GHz', info['hz_actual']) self.assertEqual((1536000000, 0), info['hz_advertised_raw']) self.assertEqual((1536000000, 0), info['hz_actual_raw']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('ODROID-C2', info['hardware']) self.assertEqual( ['asimd', 'crc32', 'fp'], info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('ODROID-C2', info['hardware']) self.assertEqual('1.5400 GHz', info['hz_advertised']) self.assertEqual('1.5400 GHz', info['hz_actual']) self.assertEqual((1540000000, 0), info['hz_advertised_raw']) self.assertEqual((1540000000, 0), info['hz_actual_raw']) self.assertEqual('ARM_8', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('aarch64', info['raw_arch_string']) self.assertEqual( ['asimd', 'crc32', 'fp'], info['flags'] ) py-cpuinfo-5.0.0/tests/test_cli.py0000644000175000017500000000213213444505146015235 0ustar hlehle import unittest from cpuinfo import * import helpers class TestCLI(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) def tearDown(self): helpers.restore_data_source(cpuinfo) def test_json(self): from subprocess import Popen, PIPE import json command = [sys.executable, 'cpuinfo/cpuinfo.py', '--json'] p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) output = p1.communicate()[0] self.assertEqual(0, p1.returncode) if not IS_PY2: output = output.decode(encoding='UTF-8') info = json.loads(output, object_hook = cpuinfo._utf_to_str) self.assertEqual(list(cpuinfo.CPUINFO_VERSION), info['cpuinfo_version']) def test_default(self): from subprocess import Popen, PIPE command = [sys.executable, 'cpuinfo/cpuinfo.py'] p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) output = p1.communicate()[0] self.assertEqual(0, p1.returncode) if not IS_PY2: output = output.decode(encoding='UTF-8') version = output.split('Cpuinfo Version: ')[1].split('\n')[0].strip() self.assertEqual(str(cpuinfo.CPUINFO_VERSION), version) py-cpuinfo-5.0.0/tests/test_linux_fedora_24_x86_64.py0000644000175000017500000006663013444505146020505 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 2 is_windows = False raw_arch_string = 'x86_64' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_dmesg(): return True @staticmethod def has_lscpu(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 cpu MHz : 2793.652 cache size : 3072 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt xsave hypervisor lahf_lm bogomips : 5587.30 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G640 @ 2.80GHz stepping : 7 cpu MHz : 2793.652 cache size : 3072 KB physical id : 0 siblings : 2 core id : 1 cpu cores : 2 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt xsave hypervisor lahf_lm bogomips : 5587.30 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: ''' return returncode, output @staticmethod def dmesg_a(): returncode = 0 output = ''' [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 3.16.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) [ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.16.0-4-amd64 root=UUID=12618f16-cbe6-4b2b-9f80-b71195be06e7 ro quiet [ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000dffeffff] usable [ 0.000000] BIOS-e820: [mem 0x00000000dfff0000-0x00000000dfffffff] ACPI data [ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000011fffffff] usable [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] SMBIOS 2.5 present. [ 0.000000] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 0.000000] Hypervisor detected: KVM [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved [ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable [ 0.000000] AGP: No AGP bridge found [ 0.000000] e820: last_pfn = 0x120000 max_arch_pfn = 0x400000000 [ 0.000000] MTRR default type: uncachable [ 0.000000] MTRR variable ranges disabled: [ 0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106 [ 0.000000] CPU MTRRs all blank - virtualized system. [ 0.000000] e820: last_pfn = 0xdfff0 max_arch_pfn = 0x400000000 [ 0.000000] found SMP MP-table at [mem 0x0009fff0-0x0009ffff] mapped at [ffff88000009fff0] [ 0.000000] Base memory trampoline at [ffff880000099000] 99000 size 24576 [ 0.000000] init_memory_mapping: [mem 0x00000000-0x000fffff] [ 0.000000] [mem 0x00000000-0x000fffff] page 4k [ 0.000000] BRK [0x01af4000, 0x01af4fff] PGTABLE [ 0.000000] BRK [0x01af5000, 0x01af5fff] PGTABLE [ 0.000000] BRK [0x01af6000, 0x01af6fff] PGTABLE [ 0.000000] init_memory_mapping: [mem 0x11fe00000-0x11fffffff] [ 0.000000] [mem 0x11fe00000-0x11fffffff] page 2M [ 0.000000] BRK [0x01af7000, 0x01af7fff] PGTABLE [ 0.000000] init_memory_mapping: [mem 0x11c000000-0x11fdfffff] [ 0.000000] [mem 0x11c000000-0x11fdfffff] page 2M [ 0.000000] init_memory_mapping: [mem 0x100000000-0x11bffffff] [ 0.000000] [mem 0x100000000-0x11bffffff] page 2M [ 0.000000] init_memory_mapping: [mem 0x00100000-0xdffeffff] [ 0.000000] [mem 0x00100000-0x001fffff] page 4k [ 0.000000] [mem 0x00200000-0xdfdfffff] page 2M [ 0.000000] [mem 0xdfe00000-0xdffeffff] page 4k [ 0.000000] RAMDISK: [mem 0x3634a000-0x3719cfff] [ 0.000000] ACPI: Early table checksum verification disabled [ 0.000000] ACPI: RSDP 0x00000000000E0000 000024 (v02 VBOX ) [ 0.000000] ACPI: XSDT 0x00000000DFFF0030 00003C (v01 VBOX VBOXXSDT 00000001 ASL 00000061) [ 0.000000] ACPI: FACP 0x00000000DFFF00F0 0000F4 (v04 VBOX VBOXFACP 00000001 ASL 00000061) [ 0.000000] ACPI: DSDT 0x00000000DFFF0470 00210F (v01 VBOX VBOXBIOS 00000002 INTL 20160108) [ 0.000000] ACPI: FACS 0x00000000DFFF0200 000040 [ 0.000000] ACPI: FACS 0x00000000DFFF0200 000040 [ 0.000000] ACPI: APIC 0x00000000DFFF0240 00005C (v02 VBOX VBOXAPIC 00000001 ASL 00000061) [ 0.000000] ACPI: SSDT 0x00000000DFFF02A0 0001CC (v01 VBOX VBOXCPUT 00000002 INTL 20160108) [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] No NUMA configuration found [ 0.000000] Faking a node at [mem 0x0000000000000000-0x000000011fffffff] [ 0.000000] Initmem setup node 0 [mem 0x00000000-0x11fffffff] [ 0.000000] NODE_DATA [mem 0x11fff7000-0x11fffbfff] [ 0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00 [ 0.000000] kvm-clock: cpu 0, msr 1:1ffef001, primary cpu clock [ 0.000000] [ffffea0000000000-ffffea0003ffffff] PMD -> [ffff88011b600000-ffff88011effffff] on node 0 [ 0.000000] Zone ranges: [ 0.000000] DMA [mem 0x00001000-0x00ffffff] [ 0.000000] DMA32 [mem 0x01000000-0xffffffff] [ 0.000000] Normal [mem 0x100000000-0x11fffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x00001000-0x0009efff] [ 0.000000] node 0: [mem 0x00100000-0xdffeffff] [ 0.000000] node 0: [mem 0x100000000-0x11fffffff] [ 0.000000] On node 0 totalpages: 1048462 [ 0.000000] DMA zone: 56 pages used for memmap [ 0.000000] DMA zone: 21 pages reserved [ 0.000000] DMA zone: 3998 pages, LIFO batch:0 [ 0.000000] DMA32 zone: 12488 pages used for memmap [ 0.000000] DMA32 zone: 913392 pages, LIFO batch:31 [ 0.000000] Normal zone: 1792 pages used for memmap [ 0.000000] Normal zone: 131072 pages, LIFO batch:31 [ 0.000000] ACPI: PM-Timer IO Port: 0x4008 [ 0.000000] ACPI: Local APIC address 0xfee00000 [ 0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled) [ 0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled) [ 0.000000] ACPI: IOAPIC (id[0x02] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 2, version 32, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl) [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level) [ 0.000000] ACPI: IRQ0 used by override. [ 0.000000] ACPI: IRQ2 used by override. [ 0.000000] ACPI: IRQ9 used by override. [ 0.000000] Using ACPI (MADT) for SMP configuration information [ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs [ 0.000000] nr_irqs_gsi: 40 [ 0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x0009ffff] [ 0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000effff] [ 0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff] [ 0.000000] PM: Registered nosave memory: [mem 0xdfff0000-0xdfffffff] [ 0.000000] PM: Registered nosave memory: [mem 0xe0000000-0xfebfffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfec00000-0xfec00fff] [ 0.000000] PM: Registered nosave memory: [mem 0xfec01000-0xfedfffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfee00000-0xfee00fff] [ 0.000000] PM: Registered nosave memory: [mem 0xfee01000-0xfffbffff] [ 0.000000] PM: Registered nosave memory: [mem 0xfffc0000-0xffffffff] [ 0.000000] e820: [mem 0xe0000000-0xfebfffff] available for PCI devices [ 0.000000] Booting paravirtualized kernel on KVM [ 0.000000] setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:2 nr_node_ids:1 [ 0.000000] PERCPU: Embedded 27 pages/cpu @ffff88011fc00000 s80960 r8192 d21440 u1048576 [ 0.000000] pcpu-alloc: s80960 r8192 d21440 u1048576 alloc=1*2097152 [ 0.000000] pcpu-alloc: [0] 0 1 [ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 1034105 [ 0.000000] Policy zone: Normal [ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.16.0-4-amd64 root=UUID=12618f16-cbe6-4b2b-9f80-b71195be06e7 ro quiet [ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes) [ 0.000000] xsave: enabled xstate_bv 0x3, cntxt size 0x240 [ 0.000000] AGP: Checking aperture... [ 0.000000] AGP: No AGP bridge found [ 0.000000] Calgary: detecting Calgary via BIOS EBDA area [ 0.000000] Calgary: Unable to locate Rio Grande table in EBDA - bailing! [ 0.000000] Memory: 4041880K/4193848K available (5237K kernel code, 947K rwdata, 1836K rodata, 1204K init, 840K bss, 151968K reserved) [ 0.000000] Hierarchical RCU implementation. [ 0.000000] RCU dyntick-idle grace-period acceleration is enabled. [ 0.000000] RCU restricting CPUs from NR_CPUS=512 to nr_cpu_ids=2. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 [ 0.000000] NR_IRQS:33024 nr_irqs:512 16 [ 0.000000] Console: colour VGA+ 80x25 [ 0.000000] console [tty0] enabled [ 0.000000] tsc: Detected 2793.652 MHz processor [ 9.015923] Calibrating delay loop (skipped) preset value.. 5587.30 BogoMIPS (lpj=11174608) [ 9.015926] pid_max: default: 32768 minimum: 301 [ 9.015934] ACPI: Core revision 20140424 [ 9.017020] ACPI: All ACPI Tables successfully acquired [ 9.017050] Security Framework initialized [ 9.017058] AppArmor: AppArmor disabled by boot time parameter [ 9.017059] Yama: disabled by default; enable with sysctl kernel.yama.* [ 9.017855] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes) [ 9.019277] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes) [ 9.019613] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes) [ 9.019619] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes) [ 9.019883] Initializing cgroup subsys memory [ 9.019888] Initializing cgroup subsys devices [ 9.019895] Initializing cgroup subsys freezer [ 9.019897] Initializing cgroup subsys net_cls [ 9.019901] Initializing cgroup subsys blkio [ 9.019904] Initializing cgroup subsys perf_event [ 9.019906] Initializing cgroup subsys net_prio [ 9.019987] CPU: Physical Processor ID: 0 [ 9.019988] CPU: Processor Core ID: 0 [ 9.020005] mce: CPU supports 0 MCE banks [ 9.020039] Last level iTLB entries: 4KB 512, 2MB 8, 4MB 8 Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32, 1GB 0 tlb_flushall_shift: 6 [ 9.020376] Freeing SMP alternatives memory: 20K (ffffffff81a1b000 - ffffffff81a20000) [ 9.024990] ftrace: allocating 21697 entries in 85 pages [ 9.059874] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 [ 9.059878] smpboot: CPU0: Intel(R) Pentium(R) CPU G640 @ 2.80GHz (fam: 06, model: 2a, stepping: 07) [ 9.164299] Performance Events: unsupported p6 CPU model 42 no PMU driver, software events only. [ 9.165780] NMI watchdog: disabled (cpu0): hardware events not enabled [ 9.165895] x86: Booting SMP configuration: [ 9.165897] .... node #0, CPUs: #1 [ 9.176166] kvm-clock: cpu 1, msr 1:1ffef041, secondary cpu clock [ 9.177165] mce: CPU supports 0 MCE banks [ 9.179301] x86: Booted up 1 node, 2 CPUs [ 9.179305] smpboot: Total of 2 processors activated (11174.60 BogoMIPS) [ 9.180688] devtmpfs: initialized [ 9.187316] pinctrl core: initialized pinctrl subsystem [ 9.187487] NET: Registered protocol family 16 [ 9.187619] cpuidle: using governor ladder [ 9.187623] cpuidle: using governor menu [ 9.187667] ACPI: bus type PCI registered [ 9.187669] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 [ 9.187894] PCI: Using configuration type 1 for base access [ 9.204747] ACPI: Added _OSI(Module Device) [ 9.204751] ACPI: Added _OSI(Processor Device) [ 9.204752] ACPI: Added _OSI(3.0 _SCP Extensions) [ 9.204753] ACPI: Added _OSI(Processor Aggregator Device) [ 9.205356] ACPI: Executed 1 blocks of module-level executable AML code [ 9.207882] ACPI: Interpreter enabled [ 9.207888] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S1_] (20140424/hwxface-580) [ 9.207891] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S2_] (20140424/hwxface-580) [ 9.207894] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S3_] (20140424/hwxface-580) [ 9.207897] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S4_] (20140424/hwxface-580) [ 9.207902] ACPI: (supports S0 S5) [ 9.207904] ACPI: Using IOAPIC for interrupt routing [ 9.208077] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug [ 9.211597] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff]) [ 9.211603] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI] [ 9.211607] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM [ 9.211681] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge. [ 9.211887] PCI host bridge to bus 0000:00 [ 9.211890] pci_bus 0000:00: root bus resource [bus 00-ff] [ 9.211892] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7] [ 9.211893] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff] [ 9.211895] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff] [ 9.211896] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xffdfffff] [ 9.211930] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000 [ 9.212373] pci 0000:00:01.0: [8086:7000] type 00 class 0x060100 [ 9.212889] pci 0000:00:01.1: [8086:7111] type 00 class 0x01018a [ 9.213393] pci 0000:00:01.1: reg 0x20: [io 0xd000-0xd00f] [ 9.213530] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io 0x01f0-0x01f7] [ 9.213532] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io 0x03f6] [ 9.213533] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io 0x0170-0x0177] [ 9.213534] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io 0x0376] [ 9.213732] pci 0000:00:02.0: [80ee:beef] type 00 class 0x030000 [ 9.216760] pci 0000:00:02.0: reg 0x10: [mem 0xe0000000-0xe0ffffff pref] [ 9.239260] pci 0000:00:03.0: [8086:100e] type 00 class 0x020000 [ 9.242528] pci 0000:00:03.0: reg 0x10: [mem 0xf0000000-0xf001ffff] [ 9.250446] pci 0000:00:03.0: reg 0x18: [io 0xd010-0xd017] [ 9.267404] pci 0000:00:04.0: [80ee:cafe] type 00 class 0x088000 [ 9.270818] pci 0000:00:04.0: reg 0x10: [io 0xd020-0xd03f] [ 9.276122] pci 0000:00:04.0: reg 0x14: [mem 0xf0400000-0xf07fffff] [ 9.279813] pci 0000:00:04.0: reg 0x18: [mem 0xf0800000-0xf0803fff pref] [ 9.293767] pci 0000:00:05.0: [8086:2415] type 00 class 0x040100 [ 9.293857] pci 0000:00:05.0: reg 0x10: [io 0xd100-0xd1ff] [ 9.293917] pci 0000:00:05.0: reg 0x14: [io 0xd200-0xd23f] [ 9.294374] pci 0000:00:06.0: [106b:003f] type 00 class 0x0c0310 [ 9.297803] pci 0000:00:06.0: reg 0x10: [mem 0xf0804000-0xf0804fff] [ 9.317868] pci 0000:00:07.0: [8086:7113] type 00 class 0x068000 [ 9.318252] pci 0000:00:07.0: quirk: [io 0x4000-0x403f] claimed by PIIX4 ACPI [ 9.318262] pci 0000:00:07.0: quirk: [io 0x4100-0x410f] claimed by PIIX4 SMB [ 9.318538] pci 0000:00:0d.0: [8086:2829] type 00 class 0x010601 [ 9.321461] pci 0000:00:0d.0: reg 0x10: [io 0xd240-0xd247] [ 9.328895] pci 0000:00:0d.0: reg 0x18: [io 0xd250-0xd257] [ 9.336455] pci 0000:00:0d.0: reg 0x20: [io 0xd260-0xd26f] [ 9.339258] pci 0000:00:0d.0: reg 0x24: [mem 0xf0806000-0xf0807fff] [ 9.345202] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 9 10 *11) [ 9.345408] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 9 10 *11) [ 9.345488] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 9 *10 11) [ 9.345567] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 *9 10 11) [ 9.345694] ACPI: Enabled 2 GPEs in block 00 to 07 [ 9.346069] vgaarb: setting as boot device: PCI:0000:00:02.0 [ 9.346072] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none [ 9.346074] vgaarb: loaded [ 9.346075] vgaarb: bridge control possible 0000:00:02.0 [ 9.346163] PCI: Using ACPI for IRQ routing [ 9.346165] PCI: pci_cache_line_size set to 64 bytes [ 9.346311] e820: reserve RAM buffer [mem 0x0009fc00-0x0009ffff] [ 9.346317] e820: reserve RAM buffer [mem 0xdfff0000-0xdfffffff] [ 9.346558] Switched to clocksource kvm-clock [ 9.353995] pnp: PnP ACPI init [ 9.354008] ACPI: bus type PNP registered [ 9.354101] pnp 00:00: Plug and Play ACPI device, IDs PNP0303 (active) [ 9.354188] pnp 00:01: Plug and Play ACPI device, IDs PNP0f03 (active) [ 9.354752] pnp: PnP ACPI: found 2 devices [ 9.354753] ACPI: bus type PNP unregistered [ 9.371389] pci_bus 0000:00: resource 4 [io 0x0000-0x0cf7] [ 9.371393] pci_bus 0000:00: resource 5 [io 0x0d00-0xffff] [ 9.371395] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff] [ 9.371396] pci_bus 0000:00: resource 7 [mem 0xe0000000-0xffdfffff] [ 9.371619] NET: Registered protocol family 2 [ 9.372196] TCP established hash table entries: 32768 (order: 6, 262144 bytes) [ 9.372267] TCP bind hash table entries: 32768 (order: 7, 524288 bytes) [ 9.372334] TCP: Hash tables configured (established 32768 bind 32768) [ 9.372351] TCP: reno registered [ 9.372357] UDP hash table entries: 2048 (order: 4, 65536 bytes) [ 9.372372] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes) [ 9.372507] NET: Registered protocol family 1 [ 9.372527] pci 0000:00:00.0: Limiting direct PCI/PCI transfers [ 9.372559] pci 0000:00:01.0: Activating ISA DMA hang workarounds [ 9.372585] pci 0000:00:02.0: Video device with shadowed ROM [ 9.374015] PCI: CLS 0 bytes, default 64 [ 9.374087] Unpacking initramfs... [ 9.647919] Freeing initrd memory: 14668K (ffff88003634a000 - ffff88003719d000) [ 9.648004] PCI-DMA: Using software bounce buffering for IO (SWIOTLB) [ 9.648007] software IO TLB [mem 0xdbff0000-0xdfff0000] (64MB) mapped at [ffff8800dbff0000-ffff8800dffeffff] [ 9.648272] platform rtc_cmos: registered platform RTC device (no PNP device found) [ 9.648443] RAPL PMU detected, hw unit 2^-0 Joules, API unit is 2^-32 Joules, 3 fixed counters 10737418240 ms ovfl timer [ 9.648548] microcode: CPU0 sig=0x206a7, pf=0x10, revision=0x0 [ 9.648562] microcode: CPU1 sig=0x206a7, pf=0x10, revision=0x0 [ 9.648612] microcode: Microcode Update Driver: v2.00 , Peter Oruba [ 9.649451] futex hash table entries: 512 (order: 3, 32768 bytes) [ 9.649573] audit: initializing netlink subsys (disabled) [ 9.649598] audit: type=2000 audit(1488395362.069:1): initialized [ 9.650419] HugeTLB registered 2 MB page size, pre-allocated 0 pages [ 9.650441] zbud: loaded [ 9.650973] VFS: Disk quotas dquot_6.5.2 [ 9.651008] Dquot-cache hash table entries: 512 (order 0, 4096 bytes) [ 9.651084] msgmni has been set to 7922 [ 9.651798] alg: No test for stdrng (krng) [ 9.651846] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 9.651937] io scheduler noop registered [ 9.651941] io scheduler deadline registered [ 9.652016] io scheduler cfq registered (default) [ 9.652115] pci_hotplug: PCI Hot Plug PCI Core version: 0.5 [ 9.652132] pciehp: PCI Express Hot Plug Controller Driver version: 0.4 [ 9.652154] intel_idle: does not run on family 6 model 42 [ 9.652172] GHES: HEST is not enabled! [ 9.652242] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled [ 9.652548] Linux agpgart interface v0.103 [ 9.652677] i8042: PNP: PS/2 Controller [PNP0303:PS2K,PNP0f03:PS2M] at 0x60,0x64 irq 1,12 [ 9.653166] serio: i8042 KBD port at 0x60,0x64 irq 1 [ 9.653171] serio: i8042 AUX port at 0x60,0x64 irq 12 [ 9.653271] mousedev: PS/2 mouse device common for all mice [ 9.653687] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input0 [ 9.653824] rtc_cmos rtc_cmos: rtc core: registered rtc_cmos as rtc0 [ 9.653882] rtc_cmos rtc_cmos: alarms up to one day, 114 bytes nvram [ 9.653896] ledtrig-cpu: registered to indicate activity on CPUs [ 9.653961] AMD IOMMUv2 driver by Joerg Roedel [ 9.653962] AMD IOMMUv2 functionality not available on this system [ 9.654038] TCP: cubic registered [ 9.654234] NET: Registered protocol family 10 [ 9.654554] mip6: Mobile IPv6 [ 9.654558] NET: Registered protocol family 17 [ 9.654564] mpls_gso: MPLS GSO support [ 9.654770] registered taskstats version 1 [ 9.656357] rtc_cmos rtc_cmos: setting system clock to 2017-03-01 19:09:11 UTC (1488395351) [ 9.656427] PM: Hibernation image not present or could not be loaded. [ 9.663167] Freeing unused kernel memory: 1204K (ffffffff818ee000 - ffffffff81a1b000) [ 9.663171] Write protecting the kernel read-only data: 8192k [ 9.663645] Freeing unused kernel memory: 896K (ffff880001520000 - ffff880001600000) [ 9.664120] Freeing unused kernel memory: 212K (ffff8800017cb000 - ffff880001800000) [ 9.677467] systemd-udevd[60]: starting version 215 [ 9.677730] random: systemd-udevd urandom read with 2 bits of entropy available [ 9.698416] ACPI: bus type USB registered [ 9.698445] usbcore: registered new interface driv ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 42 Model name: Intel(R) Pentium(R) CPU G640 @ 2.80GHz Stepping: 7 CPU MHz: 2793.652 BogoMIPS: 5587.30 Hypervisor vendor: KVM Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 3072K NUMA node0 CPU(s): 0,1 ''' return returncode, output class TestLinuxFedora_24_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(13, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(11, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(8, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(20, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.7937 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2793652000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) def test_get_cpu_info_from_dmesg(self): info = cpuinfo._get_cpu_info_from_dmesg() self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.8000 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2800000000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'hypervisor', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave', 'xtopology'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.7937 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2793652000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(2, info['count']) self.assertEqual('x86_64', info['raw_arch_string']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('32 KB', info['l1_data_cache_size']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('3072 KB', info['l3_cache_size']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'clflush', 'cmov', 'constant_tsc', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'ht', 'hypervisor', 'lahf_lm', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdtscp', 'rep_good', 'sep', 'sse', 'sse2', 'sse4_1', 'sse4_2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave', 'xtopology'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_odroid_xu3_arm_32.py0000644000175000017500000003126013444505146021133 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '32bit' cpu_count = 8 is_windows = False raw_arch_string = 'armv7l' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_lscpu(): return True @staticmethod def has_cpufreq_info(): return True @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 84.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 3 processor : 1 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 84.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 3 processor : 2 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 84.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 3 processor : 3 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 84.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 3 processor : 4 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 36.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x2 CPU part : 0xc0f CPU revision : 3 processor : 5 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 36.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x2 CPU part : 0xc0f CPU revision : 3 processor : 6 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 36.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x2 CPU part : 0xc0f CPU revision : 3 processor : 7 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 36.00 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x2 CPU part : 0xc0f CPU revision : 3 Hardware : ODROID-XU3 Revision : 0100 Serial : 0000000000000000 ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: armv7l Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 2 Model name: ARMv7 Processor rev 3 (v7l) CPU max MHz: 1400.0000 CPU min MHz: 200.0000 ''' return returncode, output @staticmethod def cpufreq_info(): returncode = 0 output = ''' cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 1.40 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 1.40 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.40 GHz (asserted by call to hardware). cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901) analyzing CPU 1: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 1.40 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 1.40 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.40 GHz (asserted by call to hardware). cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901) analyzing CPU 2: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 1.40 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 1.40 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.40 GHz (asserted by call to hardware). cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901) analyzing CPU 3: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 0 1 2 3 CPUs which need to have their frequency coordinated by software: 0 1 2 3 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 1.40 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 1.40 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 1.40 GHz (asserted by call to hardware). cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901) analyzing CPU 4: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 4 5 6 7 CPUs which need to have their frequency coordinated by software: 4 5 6 7 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 2.00 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 2.00 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 2.00 GHz (asserted by call to hardware). cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653) analyzing CPU 5: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 4 5 6 7 CPUs which need to have their frequency coordinated by software: 4 5 6 7 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 2.00 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 2.00 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 2.00 GHz (asserted by call to hardware). cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653) analyzing CPU 6: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 4 5 6 7 CPUs which need to have their frequency coordinated by software: 4 5 6 7 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 2.00 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 2.00 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 2.00 GHz (asserted by call to hardware). cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653) analyzing CPU 7: driver: exynos_cpufreq CPUs which run at the same hardware frequency: 4 5 6 7 CPUs which need to have their frequency coordinated by software: 4 5 6 7 maximum transition latency: 100.0 us. hardware limits: 200 MHz - 2.00 GHz available cpufreq governors: interactive, conservative, ondemand, powersave, performance current policy: frequency should be within 200 MHz and 2.00 GHz. The governor "interactive" may decide which speed to use within this range. current CPU frequency is 2.00 GHz (asserted by call to hardware). cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653) ''' return returncode, output class TestLinux_Odroid_XU3_arm_32(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(4, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(5, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(3, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(13, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_cpufreq_info(self): info = cpuinfo._get_cpu_info_from_cpufreq_info() self.assertEqual('1.4000 GHz', info['hz_advertised']) self.assertEqual('1.4000 GHz', info['hz_actual']) self.assertEqual((1400000000, 0), info['hz_advertised_raw']) self.assertEqual((1400000000, 0), info['hz_actual_raw']) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('ARMv7 Processor rev 3 (v7l)', info['brand']) self.assertEqual('1.4000 GHz', info['hz_advertised']) self.assertEqual('1.4000 GHz', info['hz_actual']) self.assertEqual((1400000000, 0), info['hz_advertised_raw']) self.assertEqual((1400000000, 0), info['hz_actual_raw']) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('ARMv7 Processor rev 3 (v7l)', info['brand']) self.assertEqual('ODROID-XU3', info['hardware']) self.assertEqual( ['edsp', 'fastmult', 'half', 'idiva', 'idivt', 'neon', 'swp', 'thumb', 'tls', 'vfp', 'vfpv3', 'vfpv4' ], info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('ARMv7 Processor rev 3 (v7l)', info['brand']) self.assertEqual('ODROID-XU3', info['hardware']) self.assertEqual('1.4000 GHz', info['hz_advertised']) self.assertEqual('1.4000 GHz', info['hz_actual']) self.assertEqual((1400000000, 0), info['hz_advertised_raw']) self.assertEqual((1400000000, 0), info['hz_actual_raw']) self.assertEqual('ARM_7', info['arch']) self.assertEqual(32, info['bits']) self.assertEqual(8, info['count']) self.assertEqual('armv7l', info['raw_arch_string']) self.assertEqual( ['edsp', 'fastmult', 'half', 'idiva', 'idivt', 'neon', 'swp', 'thumb', 'tls', 'vfp', 'vfpv3', 'vfpv4' ], info['flags'] ) py-cpuinfo-5.0.0/tests/test_linux_rhel_7_3_ppc64le.py0000644000175000017500000006361013444505146020654 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 16 is_windows = False raw_arch_string = 'ppc64le' can_cpuid = False @staticmethod def has_proc_cpuinfo(): return True @staticmethod def has_dmesg(): return True @staticmethod def has_lscpu(): return True @staticmethod def has_ibm_pa_features(): return True @staticmethod def ibm_pa_features(): returncode = 0 output = ''' /proc/device-tree/cpus/PowerPC,POWER7@1/ibm,pa-features 3ff60006 c08000c7 ''' return returncode, output @staticmethod def cat_proc_cpuinfo(): returncode = 0 output = ''' processor : 0 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 1 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 2 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 3 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 4 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 5 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 6 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 7 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 8 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 9 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 10 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 11 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 12 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 13 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 14 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) processor : 15 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201) timebase : 512000000 platform : pSeries model : IBM pSeries (emulated by qemu) machine : CHRP IBM pSeries (emulated by qemu) ''' return returncode, output @staticmethod def dmesg_a(): returncode = 0 output = ''' [3269512.154534] convolution_var[11236]: unhandled signal 4 at 00003fff6c390004 nip 00003fff6c390004 lr 00003fff9a648d58 code 30001 [3269512.234818] convolution_var[11344]: unhandled signal 5 at 00003fff84390000 nip 00003fff84390000 lr 00003fffb2217ce0 code 30001 [3269512.234823] convolution_var[11347]: unhandled signal 11 at 0000000000000304 nip 00003fff8439001c lr 00003fffb2217ce0 code 30001 [3269512.292530] convolution_var[11435]: unhandled signal 11 at 0000000000000304 nip 00003fff565d001c lr 00003fff84457ce0 code 30001 [3269512.553601] convolution_var[11518]: unhandled signal 11 at 00003fff61278b68 nip 00003fff61278b68 lr 00003fff8f0d7ce0 code 30002 [3269515.267175] convolution_var[11623]: unhandled signal 5 at 00003fff70450000 nip 00003fff70450000 lr 00003fff9e2d7ce0 code 30001 [3269515.278982] convolution_var[11704]: unhandled signal 11 at 00003fff5e028b68 nip 00003fff5e028b68 lr 00003fff8be87ce0 code 30002 [3269516.050175] convolution_var[11803]: unhandled signal 4 at 00003fff73890008 nip 00003fff73890008 lr 00003fffa1717ce0 code 30001 [3269516.494489] convolution_var[11917]: unhandled signal 11 at 00003fff4c588b48 nip 00003fff4c588b48 lr 00003fff7a3e7ce0 code 30002 [3269516.494496] convolution_var[11918]: unhandled signal 11 at 00003fff4c588b98 nip 00003fff4c588b98 lr 00003fff7a3e7ce0 code 30002 [3269517.347386] convolution_var[12040]: unhandled signal 4 at 00003fff7c530000 nip 00003fff7c530000 lr 00003fffaa3b7ce0 code 30001 [3269517.494333] convolution_var[12299]: unhandled signal 4 at 00003fff88fe0008 nip 00003fff88fe0008 lr 00003fffb6e67ce0 code 30001 [3269517.494347] convolution_var[12301]: unhandled signal 5 at 00003fff88fe0100 nip 00003fff88fe0100 lr 00003fffb6e67ce0 code 30001 [3269517.515814] convolution_var[12120]: unhandled signal 4 at 00003fff6fbd0004 nip 00003fff6fbd0004 lr 00003fff9da57ce0 code 30001 [3269517.516110] convolution_var[12121]: unhandled signal 4 at 00003fff6fbd00c8 nip 00003fff6fbd00c8 lr 00003fff9da57ce0 code 30001 [3269520.521582] _exception: 10 callbacks suppressed [3269520.521591] convolution_var[12805]: unhandled signal 5 at 00003fff53c70000 nip 00003fff53c70000 lr 00003fff81af7ce0 code 30001 [3269528.348091] convolution_var[12977]: unhandled signal 4 at 00003fff51190008 nip 00003fff51190008 lr 00003fff7f017ce0 code 30001 [3269528.490362] convolution_var[13076]: unhandled signal 5 at 00003fff77e80000 nip 00003fff77e80000 lr 00003fffa5d07ce0 code 30001 [3269528.529240] convolution_var[13168]: unhandled signal 4 at 00003fff5cf70018 nip 00003fff5cf70018 lr 00003fff8adf7ce0 code 30001 [3269528.529260] convolution_var[13165]: unhandled signal 5 at 00003fff5cf70000 nip 00003fff5cf70000 lr 00003fff8adf7ce0 code 30001 [3269528.582530] convolution_var[13249]: unhandled signal 5 at 00003fff58660000 nip 00003fff58660000 lr 00003fff864e7ce0 code 30001 [3269528.582599] convolution_var[13242]: unhandled signal 5 at 00003fff586600c0 nip 00003fff586600c0 lr 00003fff864e7ce0 code 30001 [3269528.754904] convolution_var[13330]: unhandled signal 4 at 00003fff6c870018 nip 00003fff6c870018 lr 00003fff9a6f7ce0 code 30001 [3269528.754911] convolution_var[13328]: unhandled signal 5 at 00003fff6c870000 nip 00003fff6c870000 lr 00003fff9a6f7ce0 code 30001 [3269529.063266] convolution_var[13411]: unhandled signal 5 at 00003fff88e00000 nip 00003fff88e00000 lr 00003fffb6c87ce0 code 30001 [3269539.946696] _exception: 8 callbacks suppressed [3269539.946703] convolution_tes[14002]: unhandled signal 11 at 0000000000005359 nip 00003fff4a2b0008 lr 00003fff4a2b0004 code 30001 [3269540.270205] convolution_tes[14014]: unhandled signal 11 at 000000000000535a nip 00003fff5d8f0000 lr 00003fff8bba8d58 code 30001 [3269540.370546] convolution_tes[14007]: unhandled signal 4 at 00003fff4e3d0000 nip 00003fff4e3d0000 lr 00003fff7c688d58 code 30001 [3269540.410762] convolution_tes[14057]: unhandled signal 4 at 00003fff6e140004 nip 00003fff6e140004 lr 00003fff9c3f8d58 code 30001 [3269540.426502] convolution_tes[14034]: unhandled signal 11 at 0000000000005359 nip 00003fff5fd10008 lr 00003fff5fd10004 code 30001 [3269540.702543] convolution_tes[14059]: unhandled signal 11 at 00003fff63518b50 nip 00003fff63518b50 lr 00003fff91628d58 code 30002 [3269542.514020] convolution_tes[14155]: unhandled signal 11 at 0000000000005357 nip 00003fff63c40008 lr 00003fff63c40004 code 30001 [3269542.879959] convolution_tes[14889]: unhandled signal 5 at 00003fff87610030 nip 00003fff87610030 lr 00003fffb5497ce0 code 30001 [3269543.056385] convolution_tes[14979]: unhandled signal 5 at 00003fff85bf0030 nip 00003fff85bf0030 lr 00003fffb3a77ce0 code 30001 [3269543.106248] convolution_tes[14809]: unhandled signal 11 at 0000000000006354 nip 00003fff78930008 lr 00003fff78930004 code 30001 [3269549.407969] _exception: 4 callbacks suppressed [3269549.407976] convolution_dim[15825]: unhandled signal 4 at 00003fff656201b0 nip 00003fff656201b0 lr 00003fff934a7ce0 code 30001 [3269549.407989] convolution_dim[15821]: unhandled signal 4 at 00003fff65620008 nip 00003fff65620008 lr 00003fff934a7ce0 code 30001 [3269549.691129] convolution_dim[15792]: unhandled signal 11 at 00003fff5b49535c nip 00003fff5b49535c lr 00003fff5af90004 code 30002 [3269553.222974] copy_test_cpu[16296]: unhandled signal 4 at 00003fff96790004 nip 00003fff96790004 lr 00003fffb0a38d58 code 30001 [3269553.346577] pad_test_cpu_pa[16409]: unhandled signal 4 at 00003fff5d7a0000 nip 00003fff5d7a0000 lr 00003fff8b627ce0 code 30001 [3269556.099815] params_test_cpu[16532]: unhandled signal 4 at 00003fff7d8b0008 nip 00003fff7d8b0008 lr 00003fffab737ce0 code 30001 [3269556.192880] prng_test_cpu_p[16637]: unhandled signal 11 at 00003fff7f178b48 nip 00003fff7f178b48 lr 00003fffacfd7ce0 code 30002 [3269556.870898] reshape_test_cp[16728]: unhandled signal 11 at 00003fff7b048b48 nip 00003fff7b048b48 lr 00003fffa8ea7ce0 code 30002 [3269556.903001] reshape_test_cp[16795]: unhandled signal 11 at 00003fff7c708b48 nip 00003fff7c708b48 lr 00003fffaa567ce0 code 30002 [3269557.003338] dot_operation_t[16891]: unhandled signal 4 at 00003fff66c70000 nip 00003fff66c70000 lr 00003fff94af7ce0 code 30001 [3269557.370482] reduce_test_cpu[16967]: unhandled signal 5 at 00003fff857a0000 nip 00003fff857a0000 lr 00003fffb3a37ce0 code 30001 [3269557.880800] dynamic_ops_tes[17047]: unhandled signal 5 at 00003fff73650000 nip 00003fff73650000 lr 00003fffa14d7ce0 code 30001 [3269560.308483] replay_test_cpu[17146]: unhandled signal 11 at 0000000000000100 nip 00003fff79300004 lr 00003fffa7187ce0 code 30001 [3269560.367931] dot_operation_s[17227]: unhandled signal 4 at 00003fff699e0000 nip 00003fff699e0000 lr 00003fff97867ce0 code 30001 [3269562.120943] slice_test_cpu_[17324]: unhandled signal 4 at 00003fff7fa10008 nip 00003fff7fa10008 lr 00003fffad897ce0 code 30001 [3269562.219657] slice_test_cpu_[17390]: unhandled signal 4 at 00003fff5a4d0008 nip 00003fff5a4d0008 lr 00003fff88357ce0 code 30001 [3269562.955471] vector_ops_redu[17512]: unhandled signal 11 at 00003fff57778b48 nip 00003fff57778b48 lr 00003fff855d7ce0 code 30002 [3269563.076629] multidimensiona[17593]: unhandled signal 5 at 00003fff57870004 nip 00003fff57870004 lr 00003fff856f7ce0 code 30001 [3269563.221596] slice_test_cpu_[17676]: unhandled signal 4 at 00003fff4cee0008 nip 00003fff4cee0008 lr 00003fff7adb7ce0 code 30001 [3269563.698994] reshape_motion_[17773]: unhandled signal 11 at 00003fff70e08b98 nip 00003fff70e08b98 lr 00003fff9ec67ce0 code 30002 [3269564.681067] select_test_cpu[17872]: unhandled signal 11 at 00003fff5ba08b48 nip 00003fff5ba08b48 lr 00003fff89867ce0 code 30002 [3269564.777619] scalar_computat[17953]: unhandled signal 4 at 00003fff6d3b0008 nip 00003fff6d3b0008 lr 00003fff9b237ce0 code 30001 [3269564.790486] scalar_computat[18034]: unhandled signal 5 at 00003fff83610000 nip 00003fff83610000 lr 00003fffb1497ce0 code 30001 [3269565.287122] scalar_computat[18115]: unhandled signal 11 at 00003fff86588b48 nip 00003fff86588b48 lr 00003fffb43e7ce0 code 30002 [3269569.216594] scalar_computat[18241]: unhandled signal 5 at 00003fff5b360004 nip 00003fff5b360004 lr 00003fff891e7ce0 code 30001 [3269569.621130] scalar_computat[18346]: unhandled signal 5 at 00003fff82d70004 nip 00003fff82d70004 lr 00003fffb0bf7ce0 code 30001 [3269569.710500] scalar_computat[18427]: unhandled signal 5 at 00003fff4b4f0000 nip 00003fff4b4f0000 lr 00003fff79377ce0 code 30001 [3269569.876037] scalar_computat[18514]: unhandled signal 5 at 00003fff76050000 nip 00003fff76050000 lr 00003fffa3ed7ce0 code 30001 [3269569.898662] scalar_computat[18606]: unhandled signal 11 at 00003fff7d7f8b48 nip 00003fff7d7f8b48 lr 00003fffab657ce0 code 30002 [3269570.506464] scalar_computat[18691]: unhandled signal 5 at 00003fff716a0000 nip 00003fff716a0000 lr 00003fff9f527ce0 code 30001 [3269570.599202] scalar_computat[18774]: unhandled signal 5 at 00003fff64410000 nip 00003fff64410000 lr 00003fff92297ce0 code 30001 [3269572.942730] scalar_computat[18867]: unhandled signal 5 at 00003fff77d30000 nip 00003fff77d30000 lr 00003fffa5bb7ce0 code 30001 [3269576.610680] scalar_computat[18966]: unhandled signal 5 at 00003fff87c00000 nip 00003fff87c00000 lr 00003fffb5a87ce0 code 30001 [3269576.708070] scalar_computat[19047]: unhandled signal 11 at 000000000000100c nip 000000000000100c lr 00003fff52a80008 code 30001 [3269581.598515] scalar_computat[19139]: unhandled signal 5 at 00003fff54490000 nip 00003fff54490000 lr 00003fff82317ce0 code 30001 [3269582.171060] scalar_computat[19237]: unhandled signal 4 at 00003fff68110008 nip 00003fff68110008 lr 00003fff95f97ce0 code 30001 [3269583.009677] scalar_computat[19337]: unhandled signal 4 at 00003fff67130008 nip 00003fff67130008 lr 00003fff94fb7ce0 code 30001 [3269583.292630] slice_test_cpu_[19413]: unhandled signal 4 at 00003fff6f110000 nip 00003fff6f110000 lr 00003fff9cf97ce0 code 30001 [3269583.448451] slice_test_cpu_[19497]: unhandled signal 4 at 00003fff7eac0000 nip 00003fff7eac0000 lr 00003fffac947ce0 code 30001 [3269584.161867] slice_test_cpu_[19598]: unhandled signal 4 at 00003fff78720000 nip 00003fff78720000 lr 00003fffa65a7ce0 code 30001 [3269584.600430] slice_test_cpu_[19679]: unhandled signal 5 at 00003fff6c510004 nip 00003fff6c510004 lr 00003fff9a397ce0 code 30001 [3269586.198292] slice_test_cpu_[19769]: unhandled signal 5 at 00003fff60dc0004 nip 00003fff60dc0004 lr 00003fff8ec47ce0 code 30001 [3269587.335554] slice_test_cpu_[19868]: unhandled signal 4 at 00003fff7c460008 nip 00003fff7c460008 lr 00003fffaa3a7ce0 code 30001 [3269587.337351] slice_test_cpu_[19945]: unhandled signal 4 at 00003fff4cf50008 nip 00003fff4cf50008 lr 00003fff7aea7ce0 code 30001 [3269587.812645] slice_test_cpu_[20039]: unhandled signal 5 at 00003fff60c60000 nip 00003fff60c60000 lr 00003fff8eae7ce0 code 30001 [3269593.957612] slice_test_cpu_[20237]: unhandled signal 5 at 00003fff6bc10000 nip 00003fff6bc10000 lr 00003fff99a97ce0 code 30001 [3269594.113130] slice_test_cpu_[20327]: unhandled signal 5 at 00003fff50680000 nip 00003fff50680000 lr 00003fff7e507ce0 code 30001 [3269594.478182] slice_test_cpu_[20451]: unhandled signal 5 at 00003fff49ed0004 nip 00003fff49ed0004 lr 00003fff77d57ce0 code 30001 [3269594.480120] slice_test_cpu_[20534]: unhandled signal 5 at 00003fff864f0000 nip 00003fff864f0000 lr 00003fffb4377ce0 code 30001 [3269594.910096] slice_test_cpu_[20641]: unhandled signal 5 at 00003fff71b90004 nip 00003fff71b90004 lr 00003fff9fa17ce0 code 30001 [3269595.075412] slice_test_cpu_[20742]: unhandled signal 5 at 00003fff6e850004 nip 00003fff6e850004 lr 00003fff9c6d7ce0 code 30001 [3269595.201874] slice_test_cpu_[20823]: unhandled signal 5 at 00003fff860c0000 nip 00003fff860c0000 lr 00003fffb3f47ce0 code 30001 [3269595.376406] slice_test_cpu_[20905]: unhandled signal 5 at 00003fff840d0000 nip 00003fff840d0000 lr 00003fffb1f57ce0 code 30001 [3269595.392470] slice_test_cpu_[20980]: unhandled signal 4 at 00003fff590b0000 nip 00003fff590b0000 lr 00003fff86f37ce0 code 30001 [3269595.956190] slice_test_cpu_[21073]: unhandled signal 4 at 00003fff4f540000 nip 00003fff4f540000 lr 00003fff7d3c7ce0 code 30001 [3269599.193940] _exception: 4 callbacks suppressed [3269599.193949] reshape_test_cp[21584]: unhandled signal 4 at 00003fff81e20000 nip 00003fff81e20000 lr 00003fffafca7ce0 code 30001 [3269599.216800] slice_test_cpu_[21665]: unhandled signal 4 at 00003fff69f70000 nip 00003fff69f70000 lr 00003fff97e67ce0 code 30001 [3269599.445597] reshape_test_cp[21746]: unhandled signal 4 at 00003fff78d40000 nip 00003fff78d40000 lr 00003fffa6bc7ce0 code 30001 [3269602.512667] reshape_test_cp[21841]: unhandled signal 11 at 00003fff52e88b48 nip 00003fff52e88b48 lr 00003fff80ce7ce0 code 30002 [3269602.605673] reshape_test_cp[21936]: unhandled signal 11 at 00003fff54a68b48 nip 00003fff54a68b48 lr 00003fff828c7ce0 code 30002 [3269603.484456] reshape_test_cp[22051]: unhandled signal 11 at 00003fff5b038b50 nip 00003fff5b038b50 lr 00003fff5b010004 code 30002 [3269603.644983] reshape_test_cp[22144]: unhandled signal 4 at 00003fff73370000 nip 00003fff73370000 lr 00003fffa11f7ce0 code 30001 [3269603.695153] reshape_test_cp[22225]: unhandled signal 11 at 00003fff80e08b48 nip 00003fff80e08b48 lr 00003fffaec67ce0 code 30002 [3269603.856123] reshape_test_cp[22306]: unhandled signal 4 at 00003fff684e0000 nip 00003fff684e0000 lr 00003fff96367ce0 code 30001 [3269604.061299] reshape_test_cp[22396]: unhandled signal 11 at 0000000000006354 nip 00003fff51890008 lr 00003fff51890004 code 30001 [3269604.457348] reshape_test_cp[22478]: unhandled signal 4 at 00003fff72eb0000 nip 00003fff72eb0000 lr 00003fffa0d37ce0 code 30001 [3269604.642991] reshape_test_cp[22559]: unhandled signal 11 at 0000000000006354 nip 00003fff61d20008 lr 00003fff61d20004 code 30001 [3269605.527665] reshape_test_cp[22658]: unhandled signal 4 at 00003fff713e0000 nip 00003fff713e0000 lr 00003fff9f267ce0 code 30001 [3269605.976692] reshape_test_cp[22748]: unhandled signal 11 at 00003fff87608b48 nip 00003fff87608b48 lr 00003fffb5467ce0 code 30002 [3269605.992050] reshape_test_cp[22829]: unhandled signal 11 at 00003fff518c8b50 nip 00003fff518c8b50 lr 00003fff518a0004 code 30002 [3269608.472197] reshape_test_cp[22919]: unhandled signal 11 at 00003fff79bb8b48 nip 00003fff79bb8b48 lr 00003fffa7a17ce0 code 30002 [3269611.248566] reshape_test_cp[23045]: unhandled signal 11 at 0000000000006354 nip 00003fff81aa0008 lr 00003fff81aa0004 code 30001 [3269611.412038] reshape_test_cp[23138]: unhandled signal 11 at 0000000000006354 nip 00003fff80170008 lr 00003fff80170004 code 30001 [3269612.034633] reshape_test_cp[23249]: unhandled signal 4 at 00003fff79bb0000 nip 00003fff79bb0000 lr 00003fffa7a37ce0 code 30001 [3269612.349955] reshape_test_cp[23341]: unhandled signal 11 at 00003fff65c68b48 nip 00003fff65c68b48 lr 00003fff93ac7ce0 code 30002 [3269612.369781] reshape_test_cp[23424]: unhandled signal 11 at 0000000000006354 nip 00003fff7f190008 lr 00003fff7f190004 code 30001 [3269612.496757] reshape_test_cp[23587]: unhandled signal 4 at 00003fff81db0008 nip 00003fff81db0008 lr 00003fffafc37ce0 code 30001 [3269612.631287] reshape_test_cp[23693]: unhandled signal 11 at 00003fff6db38b50 nip 00003fff6db38b50 lr 00003fff6db10004 code 30002 [3269612.639145] reshape_test_cp[23677]: unhandled signal 11 at 0000000000006354 nip 00003fff49750008 lr 00003fff49750004 code 30001 [3269612.935010] reshape_test_cp[23932]: unhandled signal 4 at 00003fff7ef00000 nip 00003fff7ef00000 lr 00003fffacd87ce0 code 30001 [3269613.204962] reshape_test_cp[24005]: unhandled signal 11 at 0000000000006354 nip 00003fff6e890008 lr 00003fff6e890004 code 30001 [3269622.226190] _exception: 1 callbacks suppressed [3269622.226199] reduce_test_cpu[24212]: unhandled signal 5 at 00003fff563f0000 nip 00003fff563f0000 lr 00003fff84277ce0 code 30001 [3269622.452519] reduce_test_cpu[24314]: unhandled signal 11 at 00003fff7d7943e1 nip 00003fff5c780008 lr 00003fff8a607ce0 code 30002 [3269622.733732] reduce_test_cpu[24394]: unhandled signal 5 at 00003fff4c8e0000 nip 00003fff4c8e0000 lr 00003fff7a767ce0 code 30001 [3269622.965474] reduce_test_cpu[24489]: unhandled signal 11 at 00003fff4e1c8b48 nip 00003fff4e1c8b48 lr 00003fff7c027ce0 code 30002 [3269623.056180] reduce_test_cpu[24570]: unhandled signal 11 at 00003fff85a18b48 nip 00003fff85a18b48 lr 00003fffb3877ce0 code 30002 [3269623.126112] reduce_test_cpu[24651]: unhandled signal 5 at 00003fff73240000 nip 00003fff73240000 lr 00003fffa10c7ce0 code 30001 [3269623.346425] reduce_test_cpu[24742]: unhandled signal 11 at 00003fff708d8b48 nip 00003fff708d8b48 lr 00003fff9e737ce0 code 30002 [3269623.850463] reduce_test_cpu[24823]: unhandled signal 5 at 00003fff72f70000 nip 00003fff72f70000 lr 00003fffa0df7ce0 code 30001 [3269627.974103] reduce_test_cpu[24992]: unhandled signal 4 at 00003fff72600000 nip 00003fff72600000 lr 00003fffa0487ce0 code 30001 [3269628.219758] reduce_test_cpu[25085]: unhandled signal 11 at c0000005b700c08b nip 00003fff7b570004 lr 00003fffa94f7ce0 code 30001 [3269628.255963] reduce_test_cpu[25161]: unhandled signal 5 at 00003fff4acc0000 nip 00003fff4acc0000 lr 00003fff78b47ce0 code 30001 [3269628.304725] reduce_test_cpu[25236]: unhandled signal 5 at 00003fff69bc0000 nip 00003fff69bc0000 lr 00003fff97a47ce0 code 30001 [3269628.397040] reduce_test_cpu[25324]: unhandled signal 5 at 00003fff81880000 nip 00003fff81880000 lr 00003fffaf707ce0 code 30001 [3269628.463472] reduce_test_cpu[25410]: unhandled signal 4 at 00003fff648b0008 nip 00003fff648b0008 lr 00003fff92737ce0 code 30001 [3269629.249223] reduce_test_cpu[25560]: unhandled signal 11 at 00003fff6c718b48 nip 00003fff6c718b48 lr 00003fff9a577ce0 code 30002 [3269629.249869] reduce_test_cpu[25491]: unhandled signal 4 at 00003fff4fe20000 nip 00003fff4fe20000 lr 00003fff7e267ce0 code 30001 [3269629.291868] reduce_test_cpu[25653]: unhandled signal 5 at 00003fff593c0000 nip 00003fff593c0000 lr 00003fff87247ce0 code 30001 [3269629.316239] reduce_test_cpu[25736]: unhandled signal 4 at 00003fff4af30000 nip 00003fff4af30000 lr 00003fff78db7ce0 code 30001 [3269633.231330] _exception: 1 callbacks suppressed [3269633.231337] reduce_test_cpu[25990]: unhandled signal 11 at 00003fff4f0c8b48 nip 00003fff4f0c8b48 lr 00003fff7cf27ce0 code 30002 [3269633.323894] reduce_test_cpu[26070]: unhandled signal 11 at 00003fff53008b48 nip 00003fff53008b48 lr 00003fff80e67ce0 code 30002 [3269633.551347] reduce_test_cpu[26161]: unhandled signal 11 at 00003fff9f4143e1 nip 00003fff7ec00008 lr 00003fffaca87ce0 code 30002 [3269633.600659] reduce_test_cpu[26234]: unhandled signal 5 at 00003fff88dd0000 nip 00003fff88dd0000 lr 00003fffb6c57ce0 code 30001 [3269633.639976] reduce_test_cpu[26323]: unhandled signal 11 at 00003fff6d2e8b48 nip 00003fff6d2e8b48 lr 00003fff9b147ce0 code 30002 [3269633.944369] reduce_test_cpu[26488]: unhandled signal 11 at 00003fff80b58b48 nip 00003fff80b58b48 lr 00003fffae9b7ce0 code 30002 [3269634.096959] reduce_test_cpu[26650]: unhandled signal 5 at 00003fff5f520000 nip 00003fff5f520000 lr 00003fff8d3a7ce0 code 30001 [3269634.098910] reduce_test_cpu[26407]: unhandled signal 5 at 00003fff4cfd0000 nip 00003fff4cfd0000 lr 00003fff7b417ce0 code 30001 [3269634.138050] reduce_test_cpu[26728]: unhandled signal 5 at 00003fff51e10000 nip 00003fff51e10000 lr 00003fff7fc97ce0 code 30001 [3269634.198210] reduce_test_cpu[26799]: unhandled signal 11 at 00003fff52758b48 nip 00003fff52758b48 lr 00003fff805b7ce0 code 30002 [3269641.876559] _exception: 2 callbacks suppressed [3269641.876568] reduce_test_cpu[27004]: unhandled signal 5 at 00003fff67700000 nip 00003fff67700000 lr 00003fff95587ce0 code 30001 [3269641.881005] reduce_test_cpu[27043]: unhandled signal 11 at c0000005eefe008b nip 00003fff59770004 lr 00003fff876f7ce0 code 30001 [3269642.639571] reduce_test_cpu[27183]: unhandled signal 5 at 00003fff7f4f0000 nip 00003fff7f4f0000 lr 00003fffad377ce0 code 30001 [3269644.519379] reduce_test_cpu[27296]: unhandled signal 5 at 00003fff60340000 nip 00003fff60340000 lr 00003fff8e1c7ce0 code 30001 [3269644.778430] reduce_test_cpu[27378]: unhandled signal 5 at 00003fff4eb40000 nip 00003fff4eb40000 lr 00003fff7ca67ce0 code 30001 [3269645.284242] reduce_test_cpu[27473]: unhandled signal 5 at 00003fff74ec0000 nip 00003fff74ec0000 lr 00003fffa2d47ce0 code 30001 [3269645.538095] reduce_test_cpu[27555]: unhandled signal 5 at 00003fff84c80000 nip 00003fff84c80000 lr 00003fffb2b07ce0 code 30001 [3269647.309798] reduce_test_cpu[27649]: unhandled signal 5 at 00003fff82a30000 nip 00003fff82a30000 lr 00003fffb08b7ce0 code 30001 [ ''' return returncode, output @staticmethod def lscpu(): returncode = 0 output = ''' Architecture: ppc64le Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Thread(s) per core: 1 Core(s) per socket: 16 Socket(s): 1 NUMA node(s): 1 Model: 2.1 (pvr 004b 0201) Model name: POWER8E (raw), altivec supported L1d cache: 64K L1i cache: 32K NUMA node0 CPU(s): 0-15 ''' return returncode, output class TestLinuxRHEL_7_3_ppc64le(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(3, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(5, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(1, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(14, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_lscpu(self): info = cpuinfo._get_cpu_info_from_lscpu() self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('64 KB', info['l1_data_cache_size']) self.assertEqual('POWER8E (raw), altivec supported', info['brand']) def test_get_cpu_info_from_ibm_pa_features(self): info = cpuinfo._get_cpu_info_from_ibm_pa_features() self.assertEqual( ['dss_2.02', 'dss_2.05', 'dss_2.06', 'fpu', 'lsd_in_dscr', 'ppr', 'slb', 'sso_2.06', 'ugr_in_dscr'], info['flags'] ) def test_get_cpu_info_from_proc_cpuinfo(self): info = cpuinfo._get_cpu_info_from_proc_cpuinfo() self.assertEqual('POWER8E (raw), altivec supported', info['brand']) self.assertEqual('3.4250 GHz', info['hz_advertised']) self.assertEqual('3.4250 GHz', info['hz_actual']) self.assertEqual((3425000000, 0), info['hz_advertised_raw']) self.assertEqual((3425000000, 0), info['hz_actual_raw']) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('POWER8E (raw), altivec supported', info['brand']) self.assertEqual('3.4250 GHz', info['hz_advertised']) self.assertEqual('3.4250 GHz', info['hz_actual']) self.assertEqual((3425000000, 0), info['hz_advertised_raw']) self.assertEqual((3425000000, 0), info['hz_actual_raw']) self.assertEqual('PPC_64', info['arch']) self.assertEqual('32 KB', info['l1_instruction_cache_size']) self.assertEqual('64 KB', info['l1_data_cache_size']) self.assertEqual(64, info['bits']) self.assertEqual(16, info['count']) self.assertEqual('ppc64le', info['raw_arch_string']) self.assertEqual( ['dss_2.02', 'dss_2.05', 'dss_2.06', 'fpu', 'lsd_in_dscr', 'ppr', 'slb', 'sso_2.06', 'ugr_in_dscr'], info['flags'] ) py-cpuinfo-5.0.0/tests/test_free_bsd_11_x86_64.py0000644000175000017500000001342113444505146017561 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 1 is_windows = False raw_arch_string = 'amd64' can_cpuid = False @staticmethod def has_dmesg(): return True @staticmethod def has_var_run_dmesg_boot(): return True @staticmethod def dmesg_a(): retcode = 0 output = '''Copyright (c) 1992-2014 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 10.0-RELEASE-p17 #0: Tue Sep 16 14:33:46 UTC 2014 root@amd64-builder.pcbsd.org:/usr/obj/usr/src/sys/GENERIC amd64 FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610 VT(vga): text 80x25 CPU: Intel(R) Pentium(R) CPU G640 @ 2.80GHz (2793.73-MHz K8-class CPU) Origin="GenuineIntel" Id=0x206a7 Family=0x6 Model=02a Stepping=7 Features=0x1783fbff Features2=0xc982203 AMD Features=0x28100800 AMD Features2=0x1 TSC: P-state invariant ''' return retcode, output @staticmethod def cat_var_run_dmesg_boot(): retcode = 0 output = ''' VT(vga): text 80x25 CPU: Intel(R) Pentium(R) CPU G640 @ 2.80GHz (2793.73-MHz K8-class CPU) Origin="GenuineIntel" Id=0x206a7 Family=0x6 Model=02a Stepping=7 Features=0x1783fbff Features2=0xc982203 AMD Features=0x28100800 AMD Features2=0x1 TSC: P-state invariant ''' return retcode, output class TestFreeBSD_11_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(10, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(10, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(16, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_dmesg(self): info = cpuinfo._get_cpu_info_from_dmesg() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.8000 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2800000000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'cmov', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'htt', 'lahf', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nx', 'osxsave', 'pae', 'pat', 'pclmulqdq', 'pge', 'popcnt', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'sse4.1', 'sse4.2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave'] , info['flags'] ) def test_get_cpu_info_from_cat_var_run_dmesg_boot(self): info = cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.8000 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2800000000, 0), info['hz_actual_raw']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'cmov', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'htt', 'lahf', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nx', 'osxsave', 'pae', 'pat', 'pclmulqdq', 'pge', 'popcnt', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'sse4.1', 'sse4.2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Pentium(R) CPU G640 @ 2.80GHz', info['brand']) self.assertEqual('2.8000 GHz', info['hz_advertised']) self.assertEqual('2.8000 GHz', info['hz_actual']) self.assertEqual((2800000000, 0), info['hz_advertised_raw']) self.assertEqual((2800000000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(1, info['count']) self.assertEqual('amd64', info['raw_arch_string']) self.assertEqual(7, info['stepping']) self.assertEqual(42, info['model']) self.assertEqual(6, info['family']) self.assertEqual( ['apic', 'cmov', 'cx16', 'cx8', 'de', 'fpu', 'fxsr', 'htt', 'lahf', 'lm', 'mca', 'mce', 'mmx', 'msr', 'mtrr', 'nx', 'osxsave', 'pae', 'pat', 'pclmulqdq', 'pge', 'popcnt', 'pse', 'pse36', 'rdtscp', 'sep', 'sse', 'sse2', 'sse3', 'sse4.1', 'sse4.2', 'ssse3', 'syscall', 'tsc', 'vme', 'xsave'] , info['flags'] ) py-cpuinfo-5.0.0/tests/test_windows_8_x86_64.py0000644000175000017500000001103613444505146017430 0ustar hlehle import unittest from cpuinfo import * import helpers class MockDataSource(object): bits = '64bit' cpu_count = 4 is_windows = True raw_arch_string = 'AMD64' can_cpuid = False @staticmethod def has_wmic(): return True @staticmethod def wmic_cpu(): returncode = 0 output = ''' Caption=Intel64 Family 6 Model 30 Stepping 5 CurrentClockSpeed=2933 Description=Intel64 Family 6 Model 30 Stepping 5 L2CacheSize=256 L3CacheSize=8192 Manufacturer=GenuineIntel Name=Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz ''' return returncode, output @staticmethod def winreg_processor_brand(): return 'Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz' @staticmethod def winreg_vendor_id(): return 'GenuineIntel' @staticmethod def winreg_raw_arch_string(): return 'AMD64' @staticmethod def winreg_hz_actual(): return 2933 @staticmethod def winreg_feature_bits(): return 756629502 class TestWindows_8_X86_64(unittest.TestCase): def setUp(self): helpers.backup_data_source(cpuinfo) helpers.monkey_patch_data_source(cpuinfo, MockDataSource) def tearDown(self): helpers.restore_data_source(cpuinfo) ''' Make sure calls return the expected number of fields. ''' def test_returns(self): self.assertEqual(11, len(cpuinfo._get_cpu_info_from_wmic())); self.assertEqual(7, len(cpuinfo._get_cpu_info_from_registry())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_lscpu())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) self.assertEqual(18, len(cpuinfo._get_cpu_info_internal())) def test_get_cpu_info_from_wmic(self): info = cpuinfo._get_cpu_info_from_wmic() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9330 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2933000000, 0), info['hz_actual_raw']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('8192 KB', info['l3_cache_size']) def test_get_cpu_info_from_registry(self): info = cpuinfo._get_cpu_info_from_registry() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9330 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2933000000, 0), info['hz_actual_raw']) if "logger" in dir(unittest): unittest.logger("FIXME: Missing flags such as sse3 and sse4") self.assertEqual( ['acpi', 'clflush', 'cmov', 'de', 'dts', 'fxsr', 'ia64', 'mce', 'mmx', 'msr', 'mtrr', 'sep', 'serial', 'ss', 'sse', 'sse2', 'tm', 'tsc'] , info['flags'] ) def test_all(self): info = cpuinfo._get_cpu_info_internal() self.assertEqual('GenuineIntel', info['vendor_id']) self.assertEqual('Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz', info['brand']) self.assertEqual('2.9300 GHz', info['hz_advertised']) self.assertEqual('2.9330 GHz', info['hz_actual']) self.assertEqual((2930000000, 0), info['hz_advertised_raw']) self.assertEqual((2933000000, 0), info['hz_actual_raw']) self.assertEqual('X86_64', info['arch']) self.assertEqual(64, info['bits']) self.assertEqual(4, info['count']) self.assertEqual('AMD64', info['raw_arch_string']) self.assertEqual(5, info['stepping']) self.assertEqual(30, info['model']) self.assertEqual(6, info['family']) self.assertEqual('256 KB', info['l2_cache_size']) self.assertEqual('8192 KB', info['l3_cache_size']) if "logger" in dir(unittest): unittest.logger("FIXME: Missing flags such as sse3 and sse4") self.assertEqual( ['acpi', 'clflush', 'cmov', 'de', 'dts', 'fxsr', 'ia64', 'mce', 'mmx', 'msr', 'mtrr', 'sep', 'serial', 'ss', 'sse', 'sse2', 'tm', 'tsc'] , info['flags'] ) py-cpuinfo-5.0.0/LICENSE0000644000175000017500000000214713444505146012726 0ustar hlehleThe MIT License (MIT) Copyright (c) 2014-2019 Matthew Brennan Jones Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. py-cpuinfo-5.0.0/py_cpuinfo.egg-info/0000755000175000017500000000000013444510311015550 5ustar hlehlepy-cpuinfo-5.0.0/py_cpuinfo.egg-info/top_level.txt0000644000175000017500000000001013444510311020271 0ustar hlehlecpuinfo py-cpuinfo-5.0.0/py_cpuinfo.egg-info/PKG-INFO0000644000175000017500000000163513444510311016652 0ustar hlehleMetadata-Version: 1.1 Name: py-cpuinfo Version: 5.0.0 Summary: Get CPU info with pure Python 2 & 3 Home-page: https://github.com/workhorsy/py-cpuinfo Author: Matthew Brennan Jones Author-email: matthew.brennan.jones@gmail.com License: MIT Description: py-cpuinfo ========== Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work without any extra programs or libraries, beyond what your OS provides. It does not require any compilation(C/C++, assembly, et cetera) to use. It works with Python 2 and 3. Documentation can be viewed here: https://github.com/workhorsy/py-cpuinfo Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Topic :: Utilities Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 py-cpuinfo-5.0.0/py_cpuinfo.egg-info/SOURCES.txt0000644000175000017500000000233313444510311017435 0ustar hlehleChangeLog LICENSE MANIFEST.in README.rst setup.py test_suite.py cpuinfo/__init__.py cpuinfo/__main__.py cpuinfo/cpuinfo.py py_cpuinfo.egg-info/PKG-INFO py_cpuinfo.egg-info/SOURCES.txt py_cpuinfo.egg-info/dependency_links.txt py_cpuinfo.egg-info/entry_points.txt py_cpuinfo.egg-info/top_level.txt tests/helpers.py tests/test_actual.py tests/test_cli.py tests/test_cpuid.py tests/test_example.py tests/test_free_bsd_11_x86_64.py tests/test_haiku_x86_32.py tests/test_haiku_x86_64.py tests/test_invalid_cpu.py tests/test_linux_aarch64_64.py tests/test_linux_beagle_bone_arm.py tests/test_linux_debian_8_5_x86_64.py tests/test_linux_debian_8_7_1_ppc64le.py tests/test_linux_debian_8_x86_64.py tests/test_linux_fedora_24_ppc64le.py tests/test_linux_fedora_24_x86_64.py tests/test_linux_gentoo_2_2_x86_64.py tests/test_linux_odroid_c2_aarch64.py tests/test_linux_odroid_xu3_arm_32.py tests/test_linux_raspberry_pi_model_b_arm.py tests/test_linux_rhel_7_3_ppc64le.py tests/test_linux_ubuntu_16_04_x86_64.py tests/test_osx_10_12_x86_64.py tests/test_osx_10_9_x86_64.py tests/test_parse_cpu_string.py tests/test_parse_errors.py tests/test_pcbsd_10_x86_64.py tests/test_solaris_11_x86_32.py tests/test_windows_10_x86_64.py tests/test_windows_8_x86_64.pypy-cpuinfo-5.0.0/py_cpuinfo.egg-info/dependency_links.txt0000644000175000017500000000000113444510311021616 0ustar hlehle py-cpuinfo-5.0.0/py_cpuinfo.egg-info/entry_points.txt0000644000175000017500000000005213444510311021043 0ustar hlehle[console_scripts] cpuinfo = cpuinfo:main py-cpuinfo-5.0.0/test_suite.py0000644000175000017500000001003213444505146014453 0ustar hlehle#!/usr/bin/env python # -*- coding: UTF-8 -*- # Copyright (c) 2014-2019, Matthew Brennan Jones # Py-cpuinfo gets CPU info with pure Python 2 & 3 # It uses the MIT License # It is hosted at: https://github.com/workhorsy/py-cpuinfo # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import os, sys import unittest # Add the path of all the tests to this path sys.path.append(os.path.realpath('tests')) # Import all the test files from test_example import TestExample from test_parse_errors import TestParseErrors from test_parse_cpu_string import TestParseCPUString from test_invalid_cpu import TestInvalidCPU from test_linux_debian_8_x86_64 import TestLinuxDebian_8_X86_64 from test_linux_debian_8_5_x86_64 import TestLinuxDebian_8_5_X86_64 from test_linux_debian_8_7_1_ppc64le import TestLinuxDebian_8_7_1_ppc64le from test_linux_ubuntu_16_04_x86_64 import TestLinuxUbuntu_16_04_X86_64 from test_linux_fedora_24_x86_64 import TestLinuxFedora_24_X86_64 from test_linux_fedora_24_ppc64le import TestLinuxFedora_24_ppc64le from test_linux_aarch64_64 import TestLinux_Aarch_64 from test_linux_gentoo_2_2_x86_64 import TestLinuxGentoo_2_2_X86_64 from test_linux_rhel_7_3_ppc64le import TestLinuxRHEL_7_3_ppc64le from test_linux_beagle_bone_arm import TestLinux_BeagleBone from test_linux_raspberry_pi_model_b_arm import TestLinux_RaspberryPiModelB from test_linux_odroid_c2_aarch64 import TestLinux_Odroid_C2_Aarch_64 from test_linux_odroid_xu3_arm_32 import TestLinux_Odroid_XU3_arm_32 from test_pcbsd_10_x86_64 import TestPCBSD from test_free_bsd_11_x86_64 import TestFreeBSD_11_X86_64 from test_osx_10_9_x86_64 import TestOSX_10_9 from test_osx_10_12_x86_64 import TestOSX_10_12 from test_solaris_11_x86_32 import TestSolaris from test_haiku_x86_32 import TestHaiku_x86_32 from test_haiku_x86_64 import TestHaiku_x86_64 from test_windows_8_x86_64 import TestWindows_8_X86_64 from test_windows_10_x86_64 import TestWindows_10_X86_64 from test_cpuid import TestCPUID from test_actual import TestActual from test_cli import TestCLI if __name__ == '__main__': def logger(msg): import inspect print("\n{0}:{1}".format(msg, inspect.stack()[1][1:3])) unittest.logger = logger # Get all the tests tests = [ TestParseCPUString, TestExample, TestParseErrors, TestInvalidCPU, TestLinuxDebian_8_X86_64, TestLinuxDebian_8_5_X86_64, TestLinuxDebian_8_7_1_ppc64le, TestLinuxUbuntu_16_04_X86_64, TestLinuxFedora_24_X86_64, TestLinuxFedora_24_ppc64le, TestLinux_Aarch_64, TestLinuxGentoo_2_2_X86_64, TestLinuxRHEL_7_3_ppc64le, TestLinux_BeagleBone, TestLinux_RaspberryPiModelB, TestLinux_Odroid_C2_Aarch_64, TestLinux_Odroid_XU3_arm_32, TestFreeBSD_11_X86_64, TestPCBSD, TestOSX_10_9, TestOSX_10_12, TestSolaris, TestHaiku_x86_32, TestHaiku_x86_64, TestWindows_8_X86_64, TestWindows_10_X86_64, TestCPUID, TestActual, TestCLI ] # Add the tests to the suite suite = unittest.TestSuite() for test in tests: suite.addTest(unittest.makeSuite(test)) # Run the tests runner = unittest.TextTestRunner() runner.run(suite) py-cpuinfo-5.0.0/README.rst0000644000175000017500000000052213444505146013403 0ustar hlehlepy-cpuinfo ========== Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work without any extra programs or libraries, beyond what your OS provides. It does not require any compilation(C/C++, assembly, et cetera) to use. It works with Python 2 and 3. Documentation can be viewed here: https://github.com/workhorsy/py-cpuinfo py-cpuinfo-5.0.0/MANIFEST.in0000644000175000017500000000007413444505146013454 0ustar hlehleinclude README.rst ChangeLog LICENSE tests/* test_suite.py py-cpuinfo-5.0.0/setup.py0000644000175000017500000000204613444506734013435 0ustar hlehle# Copyright (c) 2014-2019, Matthew Brennan Jones # Py-cpuinfo gets CPU info with pure Python 2 & 3 # It uses the MIT License # It is hosted at: https://github.com/workhorsy/py-cpuinfo import os from setuptools import setup with open(os.path.join(os.getcwd(), 'README.rst'), 'r') as f: readme_content = f.read() setup( name = "py-cpuinfo", version = "5.0.0", author = "Matthew Brennan Jones", author_email = "matthew.brennan.jones@gmail.com", description = "Get CPU info with pure Python 2 & 3", long_description=readme_content, license = "MIT", url = "https://github.com/workhorsy/py-cpuinfo", packages=['cpuinfo'], test_suite="test_suite", entry_points = { 'console_scripts': ['cpuinfo = cpuinfo:main'], }, classifiers=[ "Development Status :: 5 - Production/Stable", "Topic :: Utilities", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3" ], ) py-cpuinfo-5.0.0/ChangeLog0000644000175000017500000001024513444506655013477 0ustar hlehle03/20/2019 Release 5.0.0 * Fixed Bug #117: Remove PyInstaller hacks * Fixed Bug #108: Client script runs multiple times without __main__ * Fixed Bug #113: Add option to return results in json * Fixed Bug #110: Always tries to run wmic in get_system_info.py 04/01/2018 Release 4.0.0 * Fixed Bug #80: Broken when using Pyinstaller * Fixed Bug #77: Get L1, L2, and L3 cache info from lscpu * Fixed Bug #79: Byte formats are inconsistent * Fixed Bug #81: Byte formatter breaks on non strings * Fixed Bug #84: Fixed wrong setup of CPUID machine code and added more flags * Fixed Bug #88: Get Windows CPU info with wmic * Fixed Bug #94: Fails to detect winreg imported as _winreg in get_system_info * Fixed Bug #95: Include if Python is 32 or 64 bit in get_system_info * Fixed Bug #87: lscpu gets brand field twice * Fixed Bug #96: Include Python version in output * Fixed Bug #85: CPUID HZ measurement is scaled wrong * Fixed Bug #100: Officially drop support for Python 2.6 * Fixed Bug #101: Made it only check the dmesg boot log on Linux * Fixed Bug #102: Parsing Haiku sysinfo fails 06/10/2017 Release 3.3.0 * Fixed Bug #70: subprocess.Popen breaks under Windows GUI app * Fixed Bug #72: Fails to parse invalid CPUID result. 04/19/2017 Release 3.2.0 * Fixed Bug #68: Broken Qemu guest CPU flag parsing on Ubuntu 17.04 POWER8 04/19/2017 Release 3.1.0 * Fixed Bug #63: Include py-cpuinfo version in output * Fixed Bug #29: Missing AVX2 CPU flag on OS X * Fixed Bug #41: Broken on Odroid XU3 armhf ARM 32bit * Fixed Bug #61: Not working on RHEL7.3 ppc64le * Fixed Bug #56: Not working on Red Flag Linux ppc64le * Fixed Bug #55: Not working on Fedora 24 ppc64le 04/05/2017 Release 3.0.0 * Change API to hide low level functions * Fixed Bug #51: Combine data from all sources instead of picking one * Fixed Bug #59: Not working on OS X 10.12 Sierra * Fixed Bug #58: Change version number format * Fixed Bug #60: Not working on ARM64 odroid-c2 03/13/2017 Release 0.2.7 * Fixed Bug #53: CPUID breaks test suite when SE Linux is on (Fedora 25) * Fixed Bug #54: CPUID breaks when it returns nothing (Fedora 26) 02/27/2017 Release 0.2.6 * New release because pypi does not allow deleting broken uploads 02/27/2017 Release 0.2.5 * New release because pypi does not allow deleting broken uploads 02/27/2017 Release 0.2.4 * Fixed Bug #35: Add basic documentation * Fixed Bug #36: Make test suite test real functions too * Fixed Bug #38: get_cpu_info_from_cpuid breaks with Python3 * Fixed Bug #47: Include sysctl leaf7_features and extfeatures flags 02/23/2016 Release 0.2.3 * Fixed Bug #34: Fixed issue with imports breaking in python3 02/23/2016 Release 0.2.2 * Same as previous release. Pypi bug broke uploaded files. 02/23/2016 Release 0.2.0 * Fixed Bug #32: Please ship tests to pypi * Fixed Bug #31: Make "python -m cpuinfo" possible * Fixed Bug #5: Importing is different depending on install method 12/16/2015 Release 0.1.8 * New release to get around the brokenness of pypi 12/16/2015 Release 0.1.7 * Fixed Bug #23: CPUID failure segfaults Python * Fixed Bug #16: Make it work on Raspberry Pi * FIxed Bug #27: System exit called if CPU is not supported 07/07/2015 Release 0.1.6 * Fixed Bug #25: dmesg is missing extra Features in flags * Fixed Bug #19: Add a test suite * Fixed Bug #24: CPUID breaks on brands with many NULL terminators 06/14/2015 Release 0.1.5 * Fixed Bug #17: Make a script for easy gathering of CPU info * Fixed Bug #21: Getting CPU info from dmesg fails on Linux but not BSD * Fixed Bug #20: Subprocess stderr is sometimes printed to console * Fixed Bug #15: Make it work on a BeagleBone * Fixed Bug #10: Stepping parse TypeError on ARM 02/11/2015 Release 0.1.4 * New release to get around the brokenness of pypi 02/11/2015 Release 0.1.3 * Fixed Bug #11: Support cpu strings that do not have @ in them * Fixed Bug #13: Support cpu strings that do not have Hz in them 09/30/2014 Release 0.1.2 * Added support for installing to binary path. * Fixed issue with crashing in python 3. 09/23/2014 Release 0.1.1 * Fixed Bug #3: It is not obvious if Hz Raw is the current Hz, or the advertised Hz * Fixed Bug #2: Wrong CPU frequency in get_cpu_info_from_proc_cpuinfo() py-cpuinfo-5.0.0/PKG-INFO0000644000175000017500000000163513444510311013005 0ustar hlehleMetadata-Version: 1.1 Name: py-cpuinfo Version: 5.0.0 Summary: Get CPU info with pure Python 2 & 3 Home-page: https://github.com/workhorsy/py-cpuinfo Author: Matthew Brennan Jones Author-email: matthew.brennan.jones@gmail.com License: MIT Description: py-cpuinfo ========== Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work without any extra programs or libraries, beyond what your OS provides. It does not require any compilation(C/C++, assembly, et cetera) to use. It works with Python 2 and 3. Documentation can be viewed here: https://github.com/workhorsy/py-cpuinfo Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Topic :: Utilities Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 py-cpuinfo-5.0.0/setup.cfg0000644000175000017500000000004613444510311013524 0ustar hlehle[egg_info] tag_build = tag_date = 0 py-cpuinfo-5.0.0/cpuinfo/0000755000175000017500000000000013444510311013346 5ustar hlehlepy-cpuinfo-5.0.0/cpuinfo/__init__.py0000644000175000017500000000015013444505146015465 0ustar hlehle import sys if sys.version_info[0] == 2: from cpuinfo import * else: from cpuinfo.cpuinfo import * py-cpuinfo-5.0.0/cpuinfo/__main__.py0000644000175000017500000000004113444505146015445 0ustar hlehle import cpuinfo cpuinfo.main() py-cpuinfo-5.0.0/cpuinfo/cpuinfo.py0000644000175000017500000020272013444506554015404 0ustar hlehle#!/usr/bin/env python # -*- coding: UTF-8 -*- # Copyright (c) 2014-2019, Matthew Brennan Jones # Py-cpuinfo gets CPU info with pure Python 2 & 3 # It uses the MIT License # It is hosted at: https://github.com/workhorsy/py-cpuinfo # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CPUINFO_VERSION = (5, 0, 0) import os, sys import platform import multiprocessing import ctypes try: import _winreg as winreg except ImportError as err: try: import winreg except ImportError as err: pass IS_PY2 = sys.version_info[0] == 2 class DataSource(object): bits = platform.architecture()[0] cpu_count = multiprocessing.cpu_count() is_windows = platform.system().lower() == 'windows' raw_arch_string = platform.machine() can_cpuid = True @staticmethod def has_proc_cpuinfo(): return os.path.exists('/proc/cpuinfo') @staticmethod def has_dmesg(): return len(_program_paths('dmesg')) > 0 @staticmethod def has_var_run_dmesg_boot(): uname = platform.system().strip().strip('"').strip("'").strip().lower() return 'linux' in uname and os.path.exists('/var/run/dmesg.boot') @staticmethod def has_cpufreq_info(): return len(_program_paths('cpufreq-info')) > 0 @staticmethod def has_sestatus(): return len(_program_paths('sestatus')) > 0 @staticmethod def has_sysctl(): return len(_program_paths('sysctl')) > 0 @staticmethod def has_isainfo(): return len(_program_paths('isainfo')) > 0 @staticmethod def has_kstat(): return len(_program_paths('kstat')) > 0 @staticmethod def has_sysinfo(): return len(_program_paths('sysinfo')) > 0 @staticmethod def has_lscpu(): return len(_program_paths('lscpu')) > 0 @staticmethod def has_ibm_pa_features(): return len(_program_paths('lsprop')) > 0 @staticmethod def has_wmic(): returncode, output = _run_and_get_stdout(['wmic', 'os', 'get', 'Version']) return returncode == 0 and len(output) > 0 @staticmethod def cat_proc_cpuinfo(): return _run_and_get_stdout(['cat', '/proc/cpuinfo']) @staticmethod def cpufreq_info(): return _run_and_get_stdout(['cpufreq-info']) @staticmethod def sestatus_allow_execheap(): return _run_and_get_stdout(['sestatus', '-b'], ['grep', '-i', '"allow_execheap"'])[1].strip().lower().endswith('on') @staticmethod def sestatus_allow_execmem(): return _run_and_get_stdout(['sestatus', '-b'], ['grep', '-i', '"allow_execmem"'])[1].strip().lower().endswith('on') @staticmethod def dmesg_a(): return _run_and_get_stdout(['dmesg', '-a']) @staticmethod def cat_var_run_dmesg_boot(): return _run_and_get_stdout(['cat', '/var/run/dmesg.boot']) @staticmethod def sysctl_machdep_cpu_hw_cpufrequency(): return _run_and_get_stdout(['sysctl', 'machdep.cpu', 'hw.cpufrequency']) @staticmethod def isainfo_vb(): return _run_and_get_stdout(['isainfo', '-vb']) @staticmethod def kstat_m_cpu_info(): return _run_and_get_stdout(['kstat', '-m', 'cpu_info']) @staticmethod def sysinfo_cpu(): return _run_and_get_stdout(['sysinfo', '-cpu']) @staticmethod def lscpu(): return _run_and_get_stdout(['lscpu']) @staticmethod def ibm_pa_features(): import glob ibm_features = glob.glob('/proc/device-tree/cpus/*/ibm,pa-features') if ibm_features: return _run_and_get_stdout(['lsprop', ibm_features[0]]) @staticmethod def wmic_cpu(): return _run_and_get_stdout(['wmic', 'cpu', 'get', 'Name,CurrentClockSpeed,L2CacheSize,L3CacheSize,Description,Caption,Manufacturer', '/format:list']) @staticmethod def winreg_processor_brand(): key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0") processor_brand = winreg.QueryValueEx(key, "ProcessorNameString")[0] winreg.CloseKey(key) return processor_brand @staticmethod def winreg_vendor_id(): key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0") vendor_id = winreg.QueryValueEx(key, "VendorIdentifier")[0] winreg.CloseKey(key) return vendor_id @staticmethod def winreg_raw_arch_string(): key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment") raw_arch_string = winreg.QueryValueEx(key, "PROCESSOR_ARCHITECTURE")[0] winreg.CloseKey(key) return raw_arch_string @staticmethod def winreg_hz_actual(): key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0") hz_actual = winreg.QueryValueEx(key, "~Mhz")[0] winreg.CloseKey(key) hz_actual = _to_hz_string(hz_actual) return hz_actual @staticmethod def winreg_feature_bits(): key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Hardware\Description\System\CentralProcessor\0") feature_bits = winreg.QueryValueEx(key, "FeatureSet")[0] winreg.CloseKey(key) return feature_bits def _program_paths(program_name): paths = [] exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep)) path = os.environ['PATH'] for p in os.environ['PATH'].split(os.pathsep): p = os.path.join(p, program_name) if os.access(p, os.X_OK): paths.append(p) for e in exts: pext = p + e if os.access(pext, os.X_OK): paths.append(pext) return paths def _run_and_get_stdout(command, pipe_command=None): from subprocess import Popen, PIPE if not pipe_command: p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) output = p1.communicate()[0] if not IS_PY2: output = output.decode(encoding='UTF-8') return p1.returncode, output else: p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) p2 = Popen(pipe_command, stdin=p1.stdout, stdout=PIPE, stderr=PIPE) p1.stdout.close() output = p2.communicate()[0] if not IS_PY2: output = output.decode(encoding='UTF-8') return p2.returncode, output # Make sure we are running on a supported system def _check_arch(): arch, bits = _parse_arch(DataSource.raw_arch_string) if not arch in ['X86_32', 'X86_64', 'ARM_7', 'ARM_8', 'PPC_64']: raise Exception("py-cpuinfo currently only works on X86 and some PPC and ARM CPUs.") def _obj_to_b64(thing): import pickle import base64 a = thing b = pickle.dumps(a) c = base64.b64encode(b) d = c.decode('utf8') return d def _b64_to_obj(thing): import pickle import base64 try: a = base64.b64decode(thing) b = pickle.loads(a) return b except: return {} def _utf_to_str(input): if IS_PY2 and isinstance(input, unicode): return input.encode('utf-8') elif isinstance(input, list): return [_utf_to_str(element) for element in input] elif isinstance(input, dict): return {_utf_to_str(key): _utf_to_str(value) for key, value in input.items()} else: return input def _copy_new_fields(info, new_info): keys = [ 'vendor_id', 'hardware', 'brand', 'hz_advertised', 'hz_actual', 'hz_advertised_raw', 'hz_actual_raw', 'arch', 'bits', 'count', 'raw_arch_string', 'l2_cache_size', 'l2_cache_line_size', 'l2_cache_associativity', 'stepping', 'model', 'family', 'processor_type', 'extended_model', 'extended_family', 'flags', 'l3_cache_size', 'l1_data_cache_size', 'l1_instruction_cache_size' ] for key in keys: if new_info.get(key, None) and not info.get(key, None): info[key] = new_info[key] elif key == 'flags' and new_info.get('flags'): for f in new_info['flags']: if f not in info['flags']: info['flags'].append(f) info['flags'].sort() def _get_field_actual(cant_be_number, raw_string, field_names): for line in raw_string.splitlines(): for field_name in field_names: field_name = field_name.lower() if ':' in line: left, right = line.split(':', 1) left = left.strip().lower() right = right.strip() if left == field_name and len(right) > 0: if cant_be_number: if not right.isdigit(): return right else: return right return None def _get_field(cant_be_number, raw_string, convert_to, default_value, *field_names): retval = _get_field_actual(cant_be_number, raw_string, field_names) # Convert the return value if retval and convert_to: try: retval = convert_to(retval) except: retval = default_value # Return the default if there is no return value if retval is None: retval = default_value return retval def _get_hz_string_from_brand(processor_brand): # Just return 0 if the processor brand does not have the Hz if not 'hz' in processor_brand.lower(): return (1, '0.0') hz_brand = processor_brand.lower() scale = 1 if hz_brand.endswith('mhz'): scale = 6 elif hz_brand.endswith('ghz'): scale = 9 if '@' in hz_brand: hz_brand = hz_brand.split('@')[1] else: hz_brand = hz_brand.rsplit(None, 1)[1] hz_brand = hz_brand.rstrip('mhz').rstrip('ghz').strip() hz_brand = _to_hz_string(hz_brand) return (scale, hz_brand) def _to_friendly_hz(ticks, scale): # Get the raw Hz as a string left, right = _to_raw_hz(ticks, scale) ticks = '{0}.{1}'.format(left, right) # Get the location of the dot, and remove said dot dot_index = ticks.index('.') ticks = ticks.replace('.', '') # Get the Hz symbol and scale symbol = "Hz" scale = 0 if dot_index > 9: symbol = "GHz" scale = 9 elif dot_index > 6: symbol = "MHz" scale = 6 elif dot_index > 3: symbol = "KHz" scale = 3 # Get the Hz with the dot at the new scaled point ticks = '{0}.{1}'.format(ticks[:-scale-1], ticks[-scale-1:]) # Format the ticks to have 4 numbers after the decimal # and remove any superfluous zeroes. ticks = '{0:.4f} {1}'.format(float(ticks), symbol) ticks = ticks.rstrip('0') return ticks def _to_raw_hz(ticks, scale): # Scale the numbers ticks = ticks.lstrip('0') old_index = ticks.index('.') ticks = ticks.replace('.', '') ticks = ticks.ljust(scale + old_index+1, '0') new_index = old_index + scale ticks = '{0}.{1}'.format(ticks[:new_index], ticks[new_index:]) left, right = ticks.split('.') left, right = int(left), int(right) return (left, right) def _to_hz_string(ticks): # Convert to string ticks = '{0}'.format(ticks) # Add decimal if missing if '.' not in ticks: ticks = '{0}.0'.format(ticks) # Remove trailing zeros ticks = ticks.rstrip('0') # Add one trailing zero for empty right side if ticks.endswith('.'): ticks = '{0}0'.format(ticks) return ticks def _to_friendly_bytes(input): import re if not input: return input input = "{0}".format(input) formats = { r"^[0-9]+B$" : 'B', r"^[0-9]+K$" : 'KB', r"^[0-9]+M$" : 'MB', r"^[0-9]+G$" : 'GB' } for pattern, friendly_size in formats.items(): if re.match(pattern, input): return "{0} {1}".format(input[ : -1].strip(), friendly_size) return input def _parse_cpu_string(cpu_string): # Get location of fields at end of string fields_index = cpu_string.find('(', cpu_string.find('@')) #print(fields_index) # Processor Brand processor_brand = cpu_string if fields_index != -1: processor_brand = cpu_string[0 : fields_index].strip() #print('processor_brand: ', processor_brand) fields = None if fields_index != -1: fields = cpu_string[fields_index : ] #print('fields: ', fields) # Hz scale, hz_brand = _get_hz_string_from_brand(processor_brand) # Various fields vendor_id, stepping, model, family = (None, None, None, None) if fields: try: fields = fields.rsplit('(', 1)[1].split(')')[0].split(',') fields = [f.strip().lower() for f in fields] fields = [f.split(':') for f in fields] fields = [{f[0].strip() : f[1].strip()} for f in fields] #print('fields: ', fields) for field in fields: name = list(field.keys())[0] value = list(field.values())[0] #print('name:{0}, value:{1}'.format(name, value)) if name == 'origin': vendor_id = value.strip('"') elif name == 'stepping': stepping = int(value.lstrip('0x'), 16) elif name == 'model': model = int(value.lstrip('0x'), 16) elif name in ['fam', 'family']: family = int(value.lstrip('0x'), 16) except: #raise pass return (processor_brand, hz_brand, scale, vendor_id, stepping, model, family) def _parse_dmesg_output(output): try: # Get all the dmesg lines that might contain a CPU string lines = output.split(' CPU0:')[1:] + \ output.split(' CPU1:')[1:] + \ output.split(' CPU:')[1:] + \ output.split('\nCPU0:')[1:] + \ output.split('\nCPU1:')[1:] + \ output.split('\nCPU:')[1:] lines = [l.split('\n')[0].strip() for l in lines] # Convert the lines to CPU strings cpu_strings = [_parse_cpu_string(l) for l in lines] # Find the CPU string that has the most fields best_string = None highest_count = 0 for cpu_string in cpu_strings: count = sum([n is not None for n in cpu_string]) if count > highest_count: highest_count = count best_string = cpu_string # If no CPU string was found, return {} if not best_string: return {} processor_brand, hz_actual, scale, vendor_id, stepping, model, family = best_string # Origin if ' Origin=' in output: fields = output[output.find(' Origin=') : ].split('\n')[0] fields = fields.strip().split() fields = [n.strip().split('=') for n in fields] fields = [{n[0].strip().lower() : n[1].strip()} for n in fields] #print('fields: ', fields) for field in fields: name = list(field.keys())[0] value = list(field.values())[0] #print('name:{0}, value:{1}'.format(name, value)) if name == 'origin': vendor_id = value.strip('"') elif name == 'stepping': stepping = int(value.lstrip('0x'), 16) elif name == 'model': model = int(value.lstrip('0x'), 16) elif name in ['fam', 'family']: family = int(value.lstrip('0x'), 16) #print('FIELDS: ', (vendor_id, stepping, model, family)) # Features flag_lines = [] for category in [' Features=', ' Features2=', ' AMD Features=', ' AMD Features2=']: if category in output: flag_lines.append(output.split(category)[1].split('\n')[0]) flags = [] for line in flag_lines: line = line.split('<')[1].split('>')[0].lower() for flag in line.split(','): flags.append(flag) flags.sort() # Convert from GHz/MHz string to Hz scale, hz_advertised = _get_hz_string_from_brand(processor_brand) info = { 'vendor_id' : vendor_id, 'brand' : processor_brand, 'stepping' : stepping, 'model' : model, 'family' : family, 'flags' : flags } if hz_advertised and hz_advertised != '0.0': info['hz_advertised'] = _to_friendly_hz(hz_advertised, scale) info['hz_actual'] = _to_friendly_hz(hz_actual, scale) if hz_advertised and hz_advertised != '0.0': info['hz_advertised_raw'] = _to_raw_hz(hz_advertised, scale) info['hz_actual_raw'] = _to_raw_hz(hz_actual, scale) return {k: v for k, v in info.items() if v} except: #raise pass return {} def _parse_arch(raw_arch_string): import re arch, bits = None, None raw_arch_string = raw_arch_string.lower() # X86 if re.match('^i\d86$|^x86$|^x86_32$|^i86pc$|^ia32$|^ia-32$|^bepc$', raw_arch_string): arch = 'X86_32' bits = 32 elif re.match('^x64$|^x86_64$|^x86_64t$|^i686-64$|^amd64$|^ia64$|^ia-64$', raw_arch_string): arch = 'X86_64' bits = 64 # ARM elif re.match('^armv8-a|aarch64$', raw_arch_string): arch = 'ARM_8' bits = 64 elif re.match('^armv7$|^armv7[a-z]$|^armv7-[a-z]$|^armv6[a-z]$', raw_arch_string): arch = 'ARM_7' bits = 32 elif re.match('^armv8$|^armv8[a-z]$|^armv8-[a-z]$', raw_arch_string): arch = 'ARM_8' bits = 32 # PPC elif re.match('^ppc32$|^prep$|^pmac$|^powermac$', raw_arch_string): arch = 'PPC_32' bits = 32 elif re.match('^powerpc$|^ppc64$|^ppc64le$', raw_arch_string): arch = 'PPC_64' bits = 64 # SPARC elif re.match('^sparc32$|^sparc$', raw_arch_string): arch = 'SPARC_32' bits = 32 elif re.match('^sparc64$|^sun4u$|^sun4v$', raw_arch_string): arch = 'SPARC_64' bits = 64 return (arch, bits) def _is_bit_set(reg, bit): mask = 1 << bit is_set = reg & mask > 0 return is_set class CPUID(object): def __init__(self): self.prochandle = None # Figure out if SE Linux is on and in enforcing mode self.is_selinux_enforcing = False # Just return if the SE Linux Status Tool is not installed if not DataSource.has_sestatus(): return # Figure out if we can execute heap and execute memory can_selinux_exec_heap = DataSource.sestatus_allow_execheap() can_selinux_exec_memory = DataSource.sestatus_allow_execmem() self.is_selinux_enforcing = (not can_selinux_exec_heap or not can_selinux_exec_memory) def _asm_func(self, restype=None, argtypes=(), byte_code=[]): byte_code = bytes.join(b'', byte_code) address = None if DataSource.is_windows: # Allocate a memory segment the size of the byte code, and make it executable size = len(byte_code) # Alloc at least 1 page to ensure we own all pages that we want to change protection on if size < 0x1000: size = 0x1000 MEM_COMMIT = ctypes.c_ulong(0x1000) PAGE_READWRITE = ctypes.c_ulong(0x4) pfnVirtualAlloc = ctypes.windll.kernel32.VirtualAlloc pfnVirtualAlloc.restype = ctypes.c_void_p address = pfnVirtualAlloc(None, ctypes.c_size_t(size), MEM_COMMIT, PAGE_READWRITE) if not address: raise Exception("Failed to VirtualAlloc") # Copy the byte code into the memory segment memmove = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t)(ctypes._memmove_addr) if memmove(address, byte_code, size) < 0: raise Exception("Failed to memmove") # Enable execute permissions PAGE_EXECUTE = ctypes.c_ulong(0x10) old_protect = ctypes.c_ulong(0) pfnVirtualProtect = ctypes.windll.kernel32.VirtualProtect res = pfnVirtualProtect(ctypes.c_void_p(address), ctypes.c_size_t(size), PAGE_EXECUTE, ctypes.byref(old_protect)) if not res: raise Exception("Failed VirtualProtect") # Flush Instruction Cache # First, get process Handle if not self.prochandle: pfnGetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess pfnGetCurrentProcess.restype = ctypes.c_void_p self.prochandle = ctypes.c_void_p(pfnGetCurrentProcess()) # Actually flush cache res = ctypes.windll.kernel32.FlushInstructionCache(self.prochandle, ctypes.c_void_p(address), ctypes.c_size_t(size)) if not res: raise Exception("Failed FlushInstructionCache") else: # Allocate a memory segment the size of the byte code size = len(byte_code) pfnvalloc = ctypes.pythonapi.valloc pfnvalloc.restype = ctypes.c_void_p address = pfnvalloc(ctypes.c_size_t(size)) if not address: raise Exception("Failed to valloc") # Mark the memory segment as writeable only if not self.is_selinux_enforcing: WRITE = 0x2 if ctypes.pythonapi.mprotect(ctypes.c_void_p(address), size, WRITE) < 0: raise Exception("Failed to mprotect") # Copy the byte code into the memory segment if ctypes.pythonapi.memmove(ctypes.c_void_p(address), byte_code, ctypes.c_size_t(size)) < 0: raise Exception("Failed to memmove") # Mark the memory segment as writeable and executable only if not self.is_selinux_enforcing: WRITE_EXECUTE = 0x2 | 0x4 if ctypes.pythonapi.mprotect(ctypes.c_void_p(address), size, WRITE_EXECUTE) < 0: raise Exception("Failed to mprotect") # Cast the memory segment into a function functype = ctypes.CFUNCTYPE(restype, *argtypes) fun = functype(address) return fun, address def _run_asm(self, *byte_code): # Convert the byte code into a function that returns an int restype = ctypes.c_uint32 argtypes = () func, address = self._asm_func(restype, argtypes, byte_code) # Call the byte code like a function retval = func() byte_code = bytes.join(b'', byte_code) size = ctypes.c_size_t(len(byte_code)) # Free the function memory segment if DataSource.is_windows: MEM_RELEASE = ctypes.c_ulong(0x8000) ctypes.windll.kernel32.VirtualFree(ctypes.c_void_p(address), ctypes.c_size_t(0), MEM_RELEASE) else: # Remove the executable tag on the memory READ_WRITE = 0x1 | 0x2 if ctypes.pythonapi.mprotect(ctypes.c_void_p(address), size, READ_WRITE) < 0: raise Exception("Failed to mprotect") ctypes.pythonapi.free(ctypes.c_void_p(address)) return retval # FIXME: We should not have to use different instructions to # set eax to 0 or 1, on 32bit and 64bit machines. def _zero_eax(self): return ( b"\x31\xC0" # xor eax,eax ) def _zero_ecx(self): return ( b"\x31\xC9" # xor ecx,ecx ) def _one_eax(self): return ( b"\xB8\x01\x00\x00\x00" # mov eax,0x1" ) # http://en.wikipedia.org/wiki/CPUID#EAX.3D0:_Get_vendor_ID def get_vendor_id(self): # EBX ebx = self._run_asm( self._zero_eax(), b"\x0F\xA2" # cpuid b"\x89\xD8" # mov ax,bx b"\xC3" # ret ) # ECX ecx = self._run_asm( self._zero_eax(), b"\x0f\xa2" # cpuid b"\x89\xC8" # mov ax,cx b"\xC3" # ret ) # EDX edx = self._run_asm( self._zero_eax(), b"\x0f\xa2" # cpuid b"\x89\xD0" # mov ax,dx b"\xC3" # ret ) # Each 4bits is a ascii letter in the name vendor_id = [] for reg in [ebx, edx, ecx]: for n in [0, 8, 16, 24]: vendor_id.append(chr((reg >> n) & 0xFF)) vendor_id = ''.join(vendor_id) return vendor_id # http://en.wikipedia.org/wiki/CPUID#EAX.3D1:_Processor_Info_and_Feature_Bits def get_info(self): # EAX eax = self._run_asm( self._one_eax(), b"\x0f\xa2" # cpuid b"\xC3" # ret ) # Get the CPU info stepping = (eax >> 0) & 0xF # 4 bits model = (eax >> 4) & 0xF # 4 bits family = (eax >> 8) & 0xF # 4 bits processor_type = (eax >> 12) & 0x3 # 2 bits extended_model = (eax >> 16) & 0xF # 4 bits extended_family = (eax >> 20) & 0xFF # 8 bits return { 'stepping' : stepping, 'model' : model, 'family' : family, 'processor_type' : processor_type, 'extended_model' : extended_model, 'extended_family' : extended_family } # http://en.wikipedia.org/wiki/CPUID#EAX.3D80000000h:_Get_Highest_Extended_Function_Supported def get_max_extension_support(self): # Check for extension support max_extension_support = self._run_asm( b"\xB8\x00\x00\x00\x80" # mov ax,0x80000000 b"\x0f\xa2" # cpuid b"\xC3" # ret ) return max_extension_support # http://en.wikipedia.org/wiki/CPUID#EAX.3D1:_Processor_Info_and_Feature_Bits def get_flags(self, max_extension_support): # EDX edx = self._run_asm( self._one_eax(), b"\x0f\xa2" # cpuid b"\x89\xD0" # mov ax,dx b"\xC3" # ret ) # ECX ecx = self._run_asm( self._one_eax(), b"\x0f\xa2" # cpuid b"\x89\xC8" # mov ax,cx b"\xC3" # ret ) # Get the CPU flags flags = { 'fpu' : _is_bit_set(edx, 0), 'vme' : _is_bit_set(edx, 1), 'de' : _is_bit_set(edx, 2), 'pse' : _is_bit_set(edx, 3), 'tsc' : _is_bit_set(edx, 4), 'msr' : _is_bit_set(edx, 5), 'pae' : _is_bit_set(edx, 6), 'mce' : _is_bit_set(edx, 7), 'cx8' : _is_bit_set(edx, 8), 'apic' : _is_bit_set(edx, 9), #'reserved1' : _is_bit_set(edx, 10), 'sep' : _is_bit_set(edx, 11), 'mtrr' : _is_bit_set(edx, 12), 'pge' : _is_bit_set(edx, 13), 'mca' : _is_bit_set(edx, 14), 'cmov' : _is_bit_set(edx, 15), 'pat' : _is_bit_set(edx, 16), 'pse36' : _is_bit_set(edx, 17), 'pn' : _is_bit_set(edx, 18), 'clflush' : _is_bit_set(edx, 19), #'reserved2' : _is_bit_set(edx, 20), 'dts' : _is_bit_set(edx, 21), 'acpi' : _is_bit_set(edx, 22), 'mmx' : _is_bit_set(edx, 23), 'fxsr' : _is_bit_set(edx, 24), 'sse' : _is_bit_set(edx, 25), 'sse2' : _is_bit_set(edx, 26), 'ss' : _is_bit_set(edx, 27), 'ht' : _is_bit_set(edx, 28), 'tm' : _is_bit_set(edx, 29), 'ia64' : _is_bit_set(edx, 30), 'pbe' : _is_bit_set(edx, 31), 'pni' : _is_bit_set(ecx, 0), 'pclmulqdq' : _is_bit_set(ecx, 1), 'dtes64' : _is_bit_set(ecx, 2), 'monitor' : _is_bit_set(ecx, 3), 'ds_cpl' : _is_bit_set(ecx, 4), 'vmx' : _is_bit_set(ecx, 5), 'smx' : _is_bit_set(ecx, 6), 'est' : _is_bit_set(ecx, 7), 'tm2' : _is_bit_set(ecx, 8), 'ssse3' : _is_bit_set(ecx, 9), 'cid' : _is_bit_set(ecx, 10), #'reserved3' : _is_bit_set(ecx, 11), 'fma' : _is_bit_set(ecx, 12), 'cx16' : _is_bit_set(ecx, 13), 'xtpr' : _is_bit_set(ecx, 14), 'pdcm' : _is_bit_set(ecx, 15), #'reserved4' : _is_bit_set(ecx, 16), 'pcid' : _is_bit_set(ecx, 17), 'dca' : _is_bit_set(ecx, 18), 'sse4_1' : _is_bit_set(ecx, 19), 'sse4_2' : _is_bit_set(ecx, 20), 'x2apic' : _is_bit_set(ecx, 21), 'movbe' : _is_bit_set(ecx, 22), 'popcnt' : _is_bit_set(ecx, 23), 'tscdeadline' : _is_bit_set(ecx, 24), 'aes' : _is_bit_set(ecx, 25), 'xsave' : _is_bit_set(ecx, 26), 'osxsave' : _is_bit_set(ecx, 27), 'avx' : _is_bit_set(ecx, 28), 'f16c' : _is_bit_set(ecx, 29), 'rdrnd' : _is_bit_set(ecx, 30), 'hypervisor' : _is_bit_set(ecx, 31) } # Get a list of only the flags that are true flags = [k for k, v in flags.items() if v] # http://en.wikipedia.org/wiki/CPUID#EAX.3D7.2C_ECX.3D0:_Extended_Features if max_extension_support >= 7: # EBX ebx = self._run_asm( self._zero_ecx(), b"\xB8\x07\x00\x00\x00" # mov eax,7 b"\x0f\xa2" # cpuid b"\x89\xD8" # mov ax,bx b"\xC3" # ret ) # ECX ecx = self._run_asm( self._zero_ecx(), b"\xB8\x07\x00\x00\x00" # mov eax,7 b"\x0f\xa2" # cpuid b"\x89\xC8" # mov ax,cx b"\xC3" # ret ) # Get the extended CPU flags extended_flags = { #'fsgsbase' : _is_bit_set(ebx, 0), #'IA32_TSC_ADJUST' : _is_bit_set(ebx, 1), 'sgx' : _is_bit_set(ebx, 2), 'bmi1' : _is_bit_set(ebx, 3), 'hle' : _is_bit_set(ebx, 4), 'avx2' : _is_bit_set(ebx, 5), #'reserved' : _is_bit_set(ebx, 6), 'smep' : _is_bit_set(ebx, 7), 'bmi2' : _is_bit_set(ebx, 8), 'erms' : _is_bit_set(ebx, 9), 'invpcid' : _is_bit_set(ebx, 10), 'rtm' : _is_bit_set(ebx, 11), 'pqm' : _is_bit_set(ebx, 12), #'FPU CS and FPU DS deprecated' : _is_bit_set(ebx, 13), 'mpx' : _is_bit_set(ebx, 14), 'pqe' : _is_bit_set(ebx, 15), 'avx512f' : _is_bit_set(ebx, 16), 'avx512dq' : _is_bit_set(ebx, 17), 'rdseed' : _is_bit_set(ebx, 18), 'adx' : _is_bit_set(ebx, 19), 'smap' : _is_bit_set(ebx, 20), 'avx512ifma' : _is_bit_set(ebx, 21), 'pcommit' : _is_bit_set(ebx, 22), 'clflushopt' : _is_bit_set(ebx, 23), 'clwb' : _is_bit_set(ebx, 24), 'intel_pt' : _is_bit_set(ebx, 25), 'avx512pf' : _is_bit_set(ebx, 26), 'avx512er' : _is_bit_set(ebx, 27), 'avx512cd' : _is_bit_set(ebx, 28), 'sha' : _is_bit_set(ebx, 29), 'avx512bw' : _is_bit_set(ebx, 30), 'avx512vl' : _is_bit_set(ebx, 31), 'prefetchwt1' : _is_bit_set(ecx, 0), 'avx512vbmi' : _is_bit_set(ecx, 1), 'umip' : _is_bit_set(ecx, 2), 'pku' : _is_bit_set(ecx, 3), 'ospke' : _is_bit_set(ecx, 4), #'reserved' : _is_bit_set(ecx, 5), 'avx512vbmi2' : _is_bit_set(ecx, 6), #'reserved' : _is_bit_set(ecx, 7), 'gfni' : _is_bit_set(ecx, 8), 'vaes' : _is_bit_set(ecx, 9), 'vpclmulqdq' : _is_bit_set(ecx, 10), 'avx512vnni' : _is_bit_set(ecx, 11), 'avx512bitalg' : _is_bit_set(ecx, 12), #'reserved' : _is_bit_set(ecx, 13), 'avx512vpopcntdq' : _is_bit_set(ecx, 14), #'reserved' : _is_bit_set(ecx, 15), #'reserved' : _is_bit_set(ecx, 16), #'mpx0' : _is_bit_set(ecx, 17), #'mpx1' : _is_bit_set(ecx, 18), #'mpx2' : _is_bit_set(ecx, 19), #'mpx3' : _is_bit_set(ecx, 20), #'mpx4' : _is_bit_set(ecx, 21), 'rdpid' : _is_bit_set(ecx, 22), #'reserved' : _is_bit_set(ecx, 23), #'reserved' : _is_bit_set(ecx, 24), #'reserved' : _is_bit_set(ecx, 25), #'reserved' : _is_bit_set(ecx, 26), #'reserved' : _is_bit_set(ecx, 27), #'reserved' : _is_bit_set(ecx, 28), #'reserved' : _is_bit_set(ecx, 29), 'sgx_lc' : _is_bit_set(ecx, 30), #'reserved' : _is_bit_set(ecx, 31) } # Get a list of only the flags that are true extended_flags = [k for k, v in extended_flags.items() if v] flags += extended_flags # http://en.wikipedia.org/wiki/CPUID#EAX.3D80000001h:_Extended_Processor_Info_and_Feature_Bits if max_extension_support >= 0x80000001: # EBX ebx = self._run_asm( b"\xB8\x01\x00\x00\x80" # mov ax,0x80000001 b"\x0f\xa2" # cpuid b"\x89\xD8" # mov ax,bx b"\xC3" # ret ) # ECX ecx = self._run_asm( b"\xB8\x01\x00\x00\x80" # mov ax,0x80000001 b"\x0f\xa2" # cpuid b"\x89\xC8" # mov ax,cx b"\xC3" # ret ) # Get the extended CPU flags extended_flags = { 'fpu' : _is_bit_set(ebx, 0), 'vme' : _is_bit_set(ebx, 1), 'de' : _is_bit_set(ebx, 2), 'pse' : _is_bit_set(ebx, 3), 'tsc' : _is_bit_set(ebx, 4), 'msr' : _is_bit_set(ebx, 5), 'pae' : _is_bit_set(ebx, 6), 'mce' : _is_bit_set(ebx, 7), 'cx8' : _is_bit_set(ebx, 8), 'apic' : _is_bit_set(ebx, 9), #'reserved' : _is_bit_set(ebx, 10), 'syscall' : _is_bit_set(ebx, 11), 'mtrr' : _is_bit_set(ebx, 12), 'pge' : _is_bit_set(ebx, 13), 'mca' : _is_bit_set(ebx, 14), 'cmov' : _is_bit_set(ebx, 15), 'pat' : _is_bit_set(ebx, 16), 'pse36' : _is_bit_set(ebx, 17), #'reserved' : _is_bit_set(ebx, 18), 'mp' : _is_bit_set(ebx, 19), 'nx' : _is_bit_set(ebx, 20), #'reserved' : _is_bit_set(ebx, 21), 'mmxext' : _is_bit_set(ebx, 22), 'mmx' : _is_bit_set(ebx, 23), 'fxsr' : _is_bit_set(ebx, 24), 'fxsr_opt' : _is_bit_set(ebx, 25), 'pdpe1gp' : _is_bit_set(ebx, 26), 'rdtscp' : _is_bit_set(ebx, 27), #'reserved' : _is_bit_set(ebx, 28), 'lm' : _is_bit_set(ebx, 29), '3dnowext' : _is_bit_set(ebx, 30), '3dnow' : _is_bit_set(ebx, 31), 'lahf_lm' : _is_bit_set(ecx, 0), 'cmp_legacy' : _is_bit_set(ecx, 1), 'svm' : _is_bit_set(ecx, 2), 'extapic' : _is_bit_set(ecx, 3), 'cr8_legacy' : _is_bit_set(ecx, 4), 'abm' : _is_bit_set(ecx, 5), 'sse4a' : _is_bit_set(ecx, 6), 'misalignsse' : _is_bit_set(ecx, 7), '3dnowprefetch' : _is_bit_set(ecx, 8), 'osvw' : _is_bit_set(ecx, 9), 'ibs' : _is_bit_set(ecx, 10), 'xop' : _is_bit_set(ecx, 11), 'skinit' : _is_bit_set(ecx, 12), 'wdt' : _is_bit_set(ecx, 13), #'reserved' : _is_bit_set(ecx, 14), 'lwp' : _is_bit_set(ecx, 15), 'fma4' : _is_bit_set(ecx, 16), 'tce' : _is_bit_set(ecx, 17), #'reserved' : _is_bit_set(ecx, 18), 'nodeid_msr' : _is_bit_set(ecx, 19), #'reserved' : _is_bit_set(ecx, 20), 'tbm' : _is_bit_set(ecx, 21), 'topoext' : _is_bit_set(ecx, 22), 'perfctr_core' : _is_bit_set(ecx, 23), 'perfctr_nb' : _is_bit_set(ecx, 24), #'reserved' : _is_bit_set(ecx, 25), 'dbx' : _is_bit_set(ecx, 26), 'perftsc' : _is_bit_set(ecx, 27), 'pci_l2i' : _is_bit_set(ecx, 28), #'reserved' : _is_bit_set(ecx, 29), #'reserved' : _is_bit_set(ecx, 30), #'reserved' : _is_bit_set(ecx, 31) } # Get a list of only the flags that are true extended_flags = [k for k, v in extended_flags.items() if v] flags += extended_flags flags.sort() return flags # http://en.wikipedia.org/wiki/CPUID#EAX.3D80000002h.2C80000003h.2C80000004h:_Processor_Brand_String def get_processor_brand(self, max_extension_support): processor_brand = "" # Processor brand string if max_extension_support >= 0x80000004: instructions = [ b"\xB8\x02\x00\x00\x80", # mov ax,0x80000002 b"\xB8\x03\x00\x00\x80", # mov ax,0x80000003 b"\xB8\x04\x00\x00\x80" # mov ax,0x80000004 ] for instruction in instructions: # EAX eax = self._run_asm( instruction, # mov ax,0x8000000? b"\x0f\xa2" # cpuid b"\x89\xC0" # mov ax,ax b"\xC3" # ret ) # EBX ebx = self._run_asm( instruction, # mov ax,0x8000000? b"\x0f\xa2" # cpuid b"\x89\xD8" # mov ax,bx b"\xC3" # ret ) # ECX ecx = self._run_asm( instruction, # mov ax,0x8000000? b"\x0f\xa2" # cpuid b"\x89\xC8" # mov ax,cx b"\xC3" # ret ) # EDX edx = self._run_asm( instruction, # mov ax,0x8000000? b"\x0f\xa2" # cpuid b"\x89\xD0" # mov ax,dx b"\xC3" # ret ) # Combine each of the 4 bytes in each register into the string for reg in [eax, ebx, ecx, edx]: for n in [0, 8, 16, 24]: processor_brand += chr((reg >> n) & 0xFF) # Strip off any trailing NULL terminators and white space processor_brand = processor_brand.strip("\0").strip() return processor_brand # http://en.wikipedia.org/wiki/CPUID#EAX.3D80000006h:_Extended_L2_Cache_Features def get_cache(self, max_extension_support): cache_info = {} # Just return if the cache feature is not supported if max_extension_support < 0x80000006: return cache_info # ECX ecx = self._run_asm( b"\xB8\x06\x00\x00\x80" # mov ax,0x80000006 b"\x0f\xa2" # cpuid b"\x89\xC8" # mov ax,cx b"\xC3" # ret ) cache_info = { 'size_kb' : ecx & 0xFF, 'line_size_b' : (ecx >> 12) & 0xF, 'associativity' : (ecx >> 16) & 0xFFFF } return cache_info def get_ticks(self): retval = None if DataSource.bits == '32bit': # Works on x86_32 restype = None argtypes = (ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) get_ticks_x86_32, address = self._asm_func(restype, argtypes, [ b"\x55", # push bp b"\x89\xE5", # mov bp,sp b"\x31\xC0", # xor ax,ax b"\x0F\xA2", # cpuid b"\x0F\x31", # rdtsc b"\x8B\x5D\x08", # mov bx,[di+0x8] b"\x8B\x4D\x0C", # mov cx,[di+0xc] b"\x89\x13", # mov [bp+di],dx b"\x89\x01", # mov [bx+di],ax b"\x5D", # pop bp b"\xC3" # ret ] ) high = ctypes.c_uint32(0) low = ctypes.c_uint32(0) get_ticks_x86_32(ctypes.byref(high), ctypes.byref(low)) retval = ((high.value << 32) & 0xFFFFFFFF00000000) | low.value elif DataSource.bits == '64bit': # Works on x86_64 restype = ctypes.c_uint64 argtypes = () get_ticks_x86_64, address = self._asm_func(restype, argtypes, [ b"\x48", # dec ax b"\x31\xC0", # xor ax,ax b"\x0F\xA2", # cpuid b"\x0F\x31", # rdtsc b"\x48", # dec ax b"\xC1\xE2\x20", # shl dx,byte 0x20 b"\x48", # dec ax b"\x09\xD0", # or ax,dx b"\xC3", # ret ] ) retval = get_ticks_x86_64() return retval def get_raw_hz(self): import time start = self.get_ticks() time.sleep(1) end = self.get_ticks() ticks = (end - start) return ticks def _actual_get_cpu_info_from_cpuid(queue): ''' Warning! This function has the potential to crash the Python runtime. Do not call it directly. Use the _get_cpu_info_from_cpuid function instead. It will safely call this function in another process. ''' # Pipe all output to nothing sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w') # Get the CPU arch and bits arch, bits = _parse_arch(DataSource.raw_arch_string) # Return none if this is not an X86 CPU if not arch in ['X86_32', 'X86_64']: queue.put(_obj_to_b64({})) return # Return none if SE Linux is in enforcing mode cpuid = CPUID() if cpuid.is_selinux_enforcing: queue.put(_obj_to_b64({})) return # Get the cpu info from the CPUID register max_extension_support = cpuid.get_max_extension_support() cache_info = cpuid.get_cache(max_extension_support) info = cpuid.get_info() processor_brand = cpuid.get_processor_brand(max_extension_support) # Get the Hz and scale hz_actual = cpuid.get_raw_hz() hz_actual = _to_hz_string(hz_actual) # Get the Hz and scale scale, hz_advertised = _get_hz_string_from_brand(processor_brand) info = { 'vendor_id' : cpuid.get_vendor_id(), 'hardware' : '', 'brand' : processor_brand, 'hz_advertised' : _to_friendly_hz(hz_advertised, scale), 'hz_actual' : _to_friendly_hz(hz_actual, 0), 'hz_advertised_raw' : _to_raw_hz(hz_advertised, scale), 'hz_actual_raw' : _to_raw_hz(hz_actual, 0), 'l2_cache_size' : _to_friendly_bytes(cache_info['size_kb']), 'l2_cache_line_size' : cache_info['line_size_b'], 'l2_cache_associativity' : hex(cache_info['associativity']), 'stepping' : info['stepping'], 'model' : info['model'], 'family' : info['family'], 'processor_type' : info['processor_type'], 'extended_model' : info['extended_model'], 'extended_family' : info['extended_family'], 'flags' : cpuid.get_flags(max_extension_support) } info = {k: v for k, v in info.items() if v} queue.put(_obj_to_b64(info)) def _get_cpu_info_from_cpuid(): ''' Returns the CPU info gathered by querying the X86 cpuid register in a new process. Returns {} on non X86 cpus. Returns {} if SELinux is in enforcing mode. ''' from multiprocessing import Process, Queue # Return {} if can't cpuid if not DataSource.can_cpuid: return {} # Get the CPU arch and bits arch, bits = _parse_arch(DataSource.raw_arch_string) # Return {} if this is not an X86 CPU if not arch in ['X86_32', 'X86_64']: return {} try: # Start running the function in a subprocess queue = Queue() p = Process(target=_actual_get_cpu_info_from_cpuid, args=(queue,)) p.start() # Wait for the process to end, while it is still alive while p.is_alive(): p.join(0) # Return {} if it failed if p.exitcode != 0: return {} # Return the result, only if there is something to read if not queue.empty(): output = queue.get() return _b64_to_obj(output) except: pass # Return {} if everything failed return {} def _get_cpu_info_from_proc_cpuinfo(): ''' Returns the CPU info gathered from /proc/cpuinfo. Returns {} if /proc/cpuinfo is not found. ''' try: # Just return {} if there is no cpuinfo if not DataSource.has_proc_cpuinfo(): return {} returncode, output = DataSource.cat_proc_cpuinfo() if returncode != 0: return {} # Various fields vendor_id = _get_field(False, output, None, '', 'vendor_id', 'vendor id', 'vendor') processor_brand = _get_field(True, output, None, None, 'model name','cpu', 'processor') cache_size = _get_field(False, output, None, '', 'cache size') stepping = _get_field(False, output, int, 0, 'stepping') model = _get_field(False, output, int, 0, 'model') family = _get_field(False, output, int, 0, 'cpu family') hardware = _get_field(False, output, None, '', 'Hardware') # Flags flags = _get_field(False, output, None, None, 'flags', 'Features') if flags: flags = flags.split() flags.sort() # Convert from MHz string to Hz hz_actual = _get_field(False, output, None, '', 'cpu MHz', 'cpu speed', 'clock') hz_actual = hz_actual.lower().rstrip('mhz').strip() hz_actual = _to_hz_string(hz_actual) # Convert from GHz/MHz string to Hz scale, hz_advertised = (0, None) try: scale, hz_advertised = _get_hz_string_from_brand(processor_brand) except Exception: pass info = { 'hardware' : hardware, 'brand' : processor_brand, 'l3_cache_size' : _to_friendly_bytes(cache_size), 'flags' : flags, 'vendor_id' : vendor_id, 'stepping' : stepping, 'model' : model, 'family' : family, } # Make the Hz the same for actual and advertised if missing any if not hz_advertised or hz_advertised == '0.0': hz_advertised = hz_actual scale = 6 elif not hz_actual or hz_actual == '0.0': hz_actual = hz_advertised # Add the Hz if there is one if _to_raw_hz(hz_advertised, scale) > (0, 0): info['hz_advertised'] = _to_friendly_hz(hz_advertised, scale) info['hz_advertised_raw'] = _to_raw_hz(hz_advertised, scale) if _to_raw_hz(hz_actual, scale) > (0, 0): info['hz_actual'] = _to_friendly_hz(hz_actual, 6) info['hz_actual_raw'] = _to_raw_hz(hz_actual, 6) info = {k: v for k, v in info.items() if v} return info except: #raise # NOTE: To have this throw on error, uncomment this line return {} def _get_cpu_info_from_cpufreq_info(): ''' Returns the CPU info gathered from cpufreq-info. Returns {} if cpufreq-info is not found. ''' try: scale, hz_brand = 1, '0.0' if not DataSource.has_cpufreq_info(): return {} returncode, output = DataSource.cpufreq_info() if returncode != 0: return {} hz_brand = output.split('current CPU frequency is')[1].split('\n')[0] i = hz_brand.find('Hz') assert(i != -1) hz_brand = hz_brand[0 : i+2].strip().lower() if hz_brand.endswith('mhz'): scale = 6 elif hz_brand.endswith('ghz'): scale = 9 hz_brand = hz_brand.rstrip('mhz').rstrip('ghz').strip() hz_brand = _to_hz_string(hz_brand) info = { 'hz_advertised' : _to_friendly_hz(hz_brand, scale), 'hz_actual' : _to_friendly_hz(hz_brand, scale), 'hz_advertised_raw' : _to_raw_hz(hz_brand, scale), 'hz_actual_raw' : _to_raw_hz(hz_brand, scale), } info = {k: v for k, v in info.items() if v} return info except: #raise # NOTE: To have this throw on error, uncomment this line return {} def _get_cpu_info_from_lscpu(): ''' Returns the CPU info gathered from lscpu. Returns {} if lscpu is not found. ''' try: if not DataSource.has_lscpu(): return {} returncode, output = DataSource.lscpu() if returncode != 0: return {} info = {} new_hz = _get_field(False, output, None, None, 'CPU max MHz', 'CPU MHz') if new_hz: new_hz = _to_hz_string(new_hz) scale = 6 info['hz_advertised'] = _to_friendly_hz(new_hz, scale) info['hz_actual'] = _to_friendly_hz(new_hz, scale) info['hz_advertised_raw'] = _to_raw_hz(new_hz, scale) info['hz_actual_raw'] = _to_raw_hz(new_hz, scale) vendor_id = _get_field(False, output, None, None, 'Vendor ID') if vendor_id: info['vendor_id'] = vendor_id brand = _get_field(False, output, None, None, 'Model name') if brand: info['brand'] = brand family = _get_field(False, output, None, None, 'CPU family') if family and family.isdigit(): info['family'] = int(family) stepping = _get_field(False, output, None, None, 'Stepping') if stepping and stepping.isdigit(): info['stepping'] = int(stepping) model = _get_field(False, output, None, None, 'Model') if model and model.isdigit(): info['model'] = int(model) l1_data_cache_size = _get_field(False, output, None, None, 'L1d cache') if l1_data_cache_size: info['l1_data_cache_size'] = _to_friendly_bytes(l1_data_cache_size) l1_instruction_cache_size = _get_field(False, output, None, None, 'L1i cache') if l1_instruction_cache_size: info['l1_instruction_cache_size'] = _to_friendly_bytes(l1_instruction_cache_size) l2_cache_size = _get_field(False, output, None, None, 'L2 cache') if l2_cache_size: info['l2_cache_size'] = _to_friendly_bytes(l2_cache_size) l3_cache_size = _get_field(False, output, None, None, 'L3 cache') if l3_cache_size: info['l3_cache_size'] = _to_friendly_bytes(l3_cache_size) # Flags flags = _get_field(False, output, None, None, 'flags', 'Features') if flags: flags = flags.split() flags.sort() info['flags'] = flags info = {k: v for k, v in info.items() if v} return info except: #raise # NOTE: To have this throw on error, uncomment this line return {} def _get_cpu_info_from_dmesg(): ''' Returns the CPU info gathered from dmesg. Returns {} if dmesg is not found or does not have the desired info. ''' # Just return {} if there is no dmesg if not DataSource.has_dmesg(): return {} # If dmesg fails return {} returncode, output = DataSource.dmesg_a() if output == None or returncode != 0: return {} return _parse_dmesg_output(output) # https://openpowerfoundation.org/wp-content/uploads/2016/05/LoPAPR_DRAFT_v11_24March2016_cmt1.pdf # page 767 def _get_cpu_info_from_ibm_pa_features(): ''' Returns the CPU info gathered from lsprop /proc/device-tree/cpus/*/ibm,pa-features Returns {} if lsprop is not found or ibm,pa-features does not have the desired info. ''' try: # Just return {} if there is no lsprop if not DataSource.has_ibm_pa_features(): return {} # If ibm,pa-features fails return {} returncode, output = DataSource.ibm_pa_features() if output == None or returncode != 0: return {} # Filter out invalid characters from output value = output.split("ibm,pa-features")[1].lower() value = [s for s in value if s in list('0123456789abcfed')] value = ''.join(value) # Get data converted to Uint32 chunks left = int(value[0 : 8], 16) right = int(value[8 : 16], 16) # Get the CPU flags flags = { # Byte 0 'mmu' : _is_bit_set(left, 0), 'fpu' : _is_bit_set(left, 1), 'slb' : _is_bit_set(left, 2), 'run' : _is_bit_set(left, 3), #'reserved' : _is_bit_set(left, 4), 'dabr' : _is_bit_set(left, 5), 'ne' : _is_bit_set(left, 6), 'wtr' : _is_bit_set(left, 7), # Byte 1 'mcr' : _is_bit_set(left, 8), 'dsisr' : _is_bit_set(left, 9), 'lp' : _is_bit_set(left, 10), 'ri' : _is_bit_set(left, 11), 'dabrx' : _is_bit_set(left, 12), 'sprg3' : _is_bit_set(left, 13), 'rislb' : _is_bit_set(left, 14), 'pp' : _is_bit_set(left, 15), # Byte 2 'vpm' : _is_bit_set(left, 16), 'dss_2.05' : _is_bit_set(left, 17), #'reserved' : _is_bit_set(left, 18), 'dar' : _is_bit_set(left, 19), #'reserved' : _is_bit_set(left, 20), 'ppr' : _is_bit_set(left, 21), 'dss_2.02' : _is_bit_set(left, 22), 'dss_2.06' : _is_bit_set(left, 23), # Byte 3 'lsd_in_dscr' : _is_bit_set(left, 24), 'ugr_in_dscr' : _is_bit_set(left, 25), #'reserved' : _is_bit_set(left, 26), #'reserved' : _is_bit_set(left, 27), #'reserved' : _is_bit_set(left, 28), #'reserved' : _is_bit_set(left, 29), #'reserved' : _is_bit_set(left, 30), #'reserved' : _is_bit_set(left, 31), # Byte 4 'sso_2.06' : _is_bit_set(right, 0), #'reserved' : _is_bit_set(right, 1), #'reserved' : _is_bit_set(right, 2), #'reserved' : _is_bit_set(right, 3), #'reserved' : _is_bit_set(right, 4), #'reserved' : _is_bit_set(right, 5), #'reserved' : _is_bit_set(right, 6), #'reserved' : _is_bit_set(right, 7), # Byte 5 'le' : _is_bit_set(right, 8), 'cfar' : _is_bit_set(right, 9), 'eb' : _is_bit_set(right, 10), 'lsq_2.07' : _is_bit_set(right, 11), #'reserved' : _is_bit_set(right, 12), #'reserved' : _is_bit_set(right, 13), #'reserved' : _is_bit_set(right, 14), #'reserved' : _is_bit_set(right, 15), # Byte 6 'dss_2.07' : _is_bit_set(right, 16), #'reserved' : _is_bit_set(right, 17), #'reserved' : _is_bit_set(right, 18), #'reserved' : _is_bit_set(right, 19), #'reserved' : _is_bit_set(right, 20), #'reserved' : _is_bit_set(right, 21), #'reserved' : _is_bit_set(right, 22), #'reserved' : _is_bit_set(right, 23), # Byte 7 #'reserved' : _is_bit_set(right, 24), #'reserved' : _is_bit_set(right, 25), #'reserved' : _is_bit_set(right, 26), #'reserved' : _is_bit_set(right, 27), #'reserved' : _is_bit_set(right, 28), #'reserved' : _is_bit_set(right, 29), #'reserved' : _is_bit_set(right, 30), #'reserved' : _is_bit_set(right, 31), } # Get a list of only the flags that are true flags = [k for k, v in flags.items() if v] flags.sort() info = { 'flags' : flags } info = {k: v for k, v in info.items() if v} return info except: return {} def _get_cpu_info_from_cat_var_run_dmesg_boot(): ''' Returns the CPU info gathered from /var/run/dmesg.boot. Returns {} if dmesg is not found or does not have the desired info. ''' # Just return {} if there is no /var/run/dmesg.boot if not DataSource.has_var_run_dmesg_boot(): return {} # If dmesg.boot fails return {} returncode, output = DataSource.cat_var_run_dmesg_boot() if output == None or returncode != 0: return {} return _parse_dmesg_output(output) def _get_cpu_info_from_sysctl(): ''' Returns the CPU info gathered from sysctl. Returns {} if sysctl is not found. ''' try: # Just return {} if there is no sysctl if not DataSource.has_sysctl(): return {} # If sysctl fails return {} returncode, output = DataSource.sysctl_machdep_cpu_hw_cpufrequency() if output == None or returncode != 0: return {} # Various fields vendor_id = _get_field(False, output, None, None, 'machdep.cpu.vendor') processor_brand = _get_field(True, output, None, None, 'machdep.cpu.brand_string') cache_size = _get_field(False, output, None, None, 'machdep.cpu.cache.size') stepping = _get_field(False, output, int, 0, 'machdep.cpu.stepping') model = _get_field(False, output, int, 0, 'machdep.cpu.model') family = _get_field(False, output, int, 0, 'machdep.cpu.family') # Flags flags = _get_field(False, output, None, '', 'machdep.cpu.features').lower().split() flags.extend(_get_field(False, output, None, '', 'machdep.cpu.leaf7_features').lower().split()) flags.extend(_get_field(False, output, None, '', 'machdep.cpu.extfeatures').lower().split()) flags.sort() # Convert from GHz/MHz string to Hz scale, hz_advertised = _get_hz_string_from_brand(processor_brand) hz_actual = _get_field(False, output, None, None, 'hw.cpufrequency') hz_actual = _to_hz_string(hz_actual) info = { 'vendor_id' : vendor_id, 'brand' : processor_brand, 'hz_advertised' : _to_friendly_hz(hz_advertised, scale), 'hz_actual' : _to_friendly_hz(hz_actual, 0), 'hz_advertised_raw' : _to_raw_hz(hz_advertised, scale), 'hz_actual_raw' : _to_raw_hz(hz_actual, 0), 'l2_cache_size' : _to_friendly_bytes(cache_size), 'stepping' : stepping, 'model' : model, 'family' : family, 'flags' : flags } info = {k: v for k, v in info.items() if v} return info except: return {} def _get_cpu_info_from_sysinfo(): ''' Returns the CPU info gathered from sysinfo. Returns {} if sysinfo is not found. ''' info = _get_cpu_info_from_sysinfo_v1() info.update(_get_cpu_info_from_sysinfo_v2()) return info def _get_cpu_info_from_sysinfo_v1(): ''' Returns the CPU info gathered from sysinfo. Returns {} if sysinfo is not found. ''' try: # Just return {} if there is no sysinfo if not DataSource.has_sysinfo(): return {} # If sysinfo fails return {} returncode, output = DataSource.sysinfo_cpu() if output == None or returncode != 0: return {} # Various fields vendor_id = '' #_get_field(False, output, None, None, 'CPU #0: ') processor_brand = output.split('CPU #0: "')[1].split('"\n')[0] cache_size = '' #_get_field(False, output, None, None, 'machdep.cpu.cache.size') stepping = int(output.split(', stepping ')[1].split(',')[0].strip()) model = int(output.split(', model ')[1].split(',')[0].strip()) family = int(output.split(', family ')[1].split(',')[0].strip()) # Flags flags = [] for line in output.split('\n'): if line.startswith('\t\t'): for flag in line.strip().lower().split(): flags.append(flag) flags.sort() # Convert from GHz/MHz string to Hz scale, hz_advertised = _get_hz_string_from_brand(processor_brand) hz_actual = hz_advertised info = { 'vendor_id' : vendor_id, 'brand' : processor_brand, 'hz_advertised' : _to_friendly_hz(hz_advertised, scale), 'hz_actual' : _to_friendly_hz(hz_actual, scale), 'hz_advertised_raw' : _to_raw_hz(hz_advertised, scale), 'hz_actual_raw' : _to_raw_hz(hz_actual, scale), 'l2_cache_size' : _to_friendly_bytes(cache_size), 'stepping' : stepping, 'model' : model, 'family' : family, 'flags' : flags } info = {k: v for k, v in info.items() if v} return info except: return {} def _get_cpu_info_from_sysinfo_v2(): ''' Returns the CPU info gathered from sysinfo. Returns {} if sysinfo is not found. ''' try: # Just return {} if there is no sysinfo if not DataSource.has_sysinfo(): return {} # If sysinfo fails return {} returncode, output = DataSource.sysinfo_cpu() if output == None or returncode != 0: return {} # Various fields vendor_id = '' #_get_field(False, output, None, None, 'CPU #0: ') processor_brand = output.split('CPU #0: "')[1].split('"\n')[0] cache_size = '' #_get_field(False, output, None, None, 'machdep.cpu.cache.size') signature = output.split('Signature:')[1].split('\n')[0].strip() # stepping = int(signature.split('stepping ')[1].split(',')[0].strip()) model = int(signature.split('model ')[1].split(',')[0].strip()) family = int(signature.split('family ')[1].split(',')[0].strip()) # Flags def get_subsection_flags(output): retval = [] for line in output.split('\n')[1:]: if not line.startswith(' '): break for entry in line.strip().lower().split(' '): retval.append(entry) return retval flags = get_subsection_flags(output.split('Features: ')[1]) + \ get_subsection_flags(output.split('Extended Features (0x00000001): ')[1]) + \ get_subsection_flags(output.split('Extended Features (0x80000001): ')[1]) flags.sort() # Convert from GHz/MHz string to Hz scale, hz_advertised = _get_hz_string_from_brand(processor_brand) hz_actual = hz_advertised info = { 'vendor_id' : vendor_id, 'brand' : processor_brand, 'hz_advertised' : _to_friendly_hz(hz_advertised, scale), 'hz_actual' : _to_friendly_hz(hz_actual, scale), 'hz_advertised_raw' : _to_raw_hz(hz_advertised, scale), 'hz_actual_raw' : _to_raw_hz(hz_actual, scale), 'l2_cache_size' : _to_friendly_bytes(cache_size), 'stepping' : stepping, 'model' : model, 'family' : family, 'flags' : flags } info = {k: v for k, v in info.items() if v} return info except: return {} def _get_cpu_info_from_wmic(): ''' Returns the CPU info gathered from WMI. Returns {} if not on Windows, or wmic is not installed. ''' try: # Just return {} if not Windows or there is no wmic if not DataSource.is_windows or not DataSource.has_wmic(): return {} returncode, output = DataSource.wmic_cpu() if output == None or returncode != 0: return {} # Break the list into key values pairs value = output.split("\n") value = [s.rstrip().split('=') for s in value if '=' in s] value = {k: v for k, v in value if v} # Get the advertised MHz processor_brand = value.get('Name') scale_advertised, hz_advertised = _get_hz_string_from_brand(processor_brand) # Get the actual MHz hz_actual = value.get('CurrentClockSpeed') scale_actual = 6 if hz_actual: hz_actual = _to_hz_string(hz_actual) # Get cache sizes l2_cache_size = value.get('L2CacheSize') if l2_cache_size: l2_cache_size = l2_cache_size + ' KB' l3_cache_size = value.get('L3CacheSize') if l3_cache_size: l3_cache_size = l3_cache_size + ' KB' # Get family, model, and stepping family, model, stepping = '', '', '' description = value.get('Description') or value.get('Caption') entries = description.split(' ') if 'Family' in entries and entries.index('Family') < len(entries)-1: i = entries.index('Family') family = int(entries[i + 1]) if 'Model' in entries and entries.index('Model') < len(entries)-1: i = entries.index('Model') model = int(entries[i + 1]) if 'Stepping' in entries and entries.index('Stepping') < len(entries)-1: i = entries.index('Stepping') stepping = int(entries[i + 1]) info = { 'vendor_id' : value.get('Manufacturer'), 'brand' : processor_brand, 'hz_advertised' : _to_friendly_hz(hz_advertised, scale_advertised), 'hz_actual' : _to_friendly_hz(hz_actual, scale_actual), 'hz_advertised_raw' : _to_raw_hz(hz_advertised, scale_advertised), 'hz_actual_raw' : _to_raw_hz(hz_actual, scale_actual), 'l2_cache_size' : l2_cache_size, 'l3_cache_size' : l3_cache_size, 'stepping' : stepping, 'model' : model, 'family' : family, } info = {k: v for k, v in info.items() if v} return info except: #raise # NOTE: To have this throw on error, uncomment this line return {} def _get_cpu_info_from_registry(): ''' FIXME: Is missing many of the newer CPU flags like sse3 Returns the CPU info gathered from the Windows Registry. Returns {} if not on Windows. ''' try: # Just return {} if not on Windows if not DataSource.is_windows: return {} # Get the CPU name processor_brand = DataSource.winreg_processor_brand() # Get the CPU vendor id vendor_id = DataSource.winreg_vendor_id() # Get the CPU arch and bits raw_arch_string = DataSource.winreg_raw_arch_string() arch, bits = _parse_arch(raw_arch_string) # Get the actual CPU Hz hz_actual = DataSource.winreg_hz_actual() hz_actual = _to_hz_string(hz_actual) # Get the advertised CPU Hz scale, hz_advertised = _get_hz_string_from_brand(processor_brand) # Get the CPU features feature_bits = DataSource.winreg_feature_bits() def is_set(bit): mask = 0x80000000 >> bit retval = mask & feature_bits > 0 return retval # http://en.wikipedia.org/wiki/CPUID # http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean # http://www.lohninger.com/helpcsuite/public_constants_cpuid.htm flags = { 'fpu' : is_set(0), # Floating Point Unit 'vme' : is_set(1), # V86 Mode Extensions 'de' : is_set(2), # Debug Extensions - I/O breakpoints supported 'pse' : is_set(3), # Page Size Extensions (4 MB pages supported) 'tsc' : is_set(4), # Time Stamp Counter and RDTSC instruction are available 'msr' : is_set(5), # Model Specific Registers 'pae' : is_set(6), # Physical Address Extensions (36 bit address, 2MB pages) 'mce' : is_set(7), # Machine Check Exception supported 'cx8' : is_set(8), # Compare Exchange Eight Byte instruction available 'apic' : is_set(9), # Local APIC present (multiprocessor operation support) 'sepamd' : is_set(10), # Fast system calls (AMD only) 'sep' : is_set(11), # Fast system calls 'mtrr' : is_set(12), # Memory Type Range Registers 'pge' : is_set(13), # Page Global Enable 'mca' : is_set(14), # Machine Check Architecture 'cmov' : is_set(15), # Conditional MOVe instructions 'pat' : is_set(16), # Page Attribute Table 'pse36' : is_set(17), # 36 bit Page Size Extensions 'serial' : is_set(18), # Processor Serial Number 'clflush' : is_set(19), # Cache Flush #'reserved1' : is_set(20), # reserved 'dts' : is_set(21), # Debug Trace Store 'acpi' : is_set(22), # ACPI support 'mmx' : is_set(23), # MultiMedia Extensions 'fxsr' : is_set(24), # FXSAVE and FXRSTOR instructions 'sse' : is_set(25), # SSE instructions 'sse2' : is_set(26), # SSE2 (WNI) instructions 'ss' : is_set(27), # self snoop #'reserved2' : is_set(28), # reserved 'tm' : is_set(29), # Automatic clock control 'ia64' : is_set(30), # IA64 instructions '3dnow' : is_set(31) # 3DNow! instructions available } # Get a list of only the flags that are true flags = [k for k, v in flags.items() if v] flags.sort() info = { 'vendor_id' : vendor_id, 'brand' : processor_brand, 'hz_advertised' : _to_friendly_hz(hz_advertised, scale), 'hz_actual' : _to_friendly_hz(hz_actual, 6), 'hz_advertised_raw' : _to_raw_hz(hz_advertised, scale), 'hz_actual_raw' : _to_raw_hz(hz_actual, 6), 'flags' : flags } info = {k: v for k, v in info.items() if v} return info except: return {} def _get_cpu_info_from_kstat(): ''' Returns the CPU info gathered from isainfo and kstat. Returns {} if isainfo or kstat are not found. ''' try: # Just return {} if there is no isainfo or kstat if not DataSource.has_isainfo() or not DataSource.has_kstat(): return {} # If isainfo fails return {} returncode, flag_output = DataSource.isainfo_vb() if flag_output == None or returncode != 0: return {} # If kstat fails return {} returncode, kstat = DataSource.kstat_m_cpu_info() if kstat == None or returncode != 0: return {} # Various fields vendor_id = kstat.split('\tvendor_id ')[1].split('\n')[0].strip() processor_brand = kstat.split('\tbrand ')[1].split('\n')[0].strip() stepping = int(kstat.split('\tstepping ')[1].split('\n')[0].strip()) model = int(kstat.split('\tmodel ')[1].split('\n')[0].strip()) family = int(kstat.split('\tfamily ')[1].split('\n')[0].strip()) # Flags flags = flag_output.strip().split('\n')[-1].strip().lower().split() flags.sort() # Convert from GHz/MHz string to Hz scale = 6 hz_advertised = kstat.split('\tclock_MHz ')[1].split('\n')[0].strip() hz_advertised = _to_hz_string(hz_advertised) # Convert from GHz/MHz string to Hz hz_actual = kstat.split('\tcurrent_clock_Hz ')[1].split('\n')[0].strip() hz_actual = _to_hz_string(hz_actual) info = { 'vendor_id' : vendor_id, 'brand' : processor_brand, 'hz_advertised' : _to_friendly_hz(hz_advertised, scale), 'hz_actual' : _to_friendly_hz(hz_actual, 0), 'hz_advertised_raw' : _to_raw_hz(hz_advertised, scale), 'hz_actual_raw' : _to_raw_hz(hz_actual, 0), 'stepping' : stepping, 'model' : model, 'family' : family, 'flags' : flags } info = {k: v for k, v in info.items() if v} return info except: return {} def _get_cpu_info_internal(): ''' Returns the CPU info by using the best sources of information for your OS. Returns {} if nothing is found. ''' # Get the CPU arch and bits arch, bits = _parse_arch(DataSource.raw_arch_string) friendly_maxsize = { 2**31-1: '32 bit', 2**63-1: '64 bit' }.get(sys.maxsize) or 'unknown bits' friendly_version = "{0}.{1}.{2}.{3}.{4}".format(*sys.version_info) PYTHON_VERSION = "{0} ({1})".format(friendly_version, friendly_maxsize) info = { 'python_version' : PYTHON_VERSION, 'cpuinfo_version' : CPUINFO_VERSION, 'arch' : arch, 'bits' : bits, 'count' : DataSource.cpu_count, 'raw_arch_string' : DataSource.raw_arch_string, } # Try the Windows wmic _copy_new_fields(info, _get_cpu_info_from_wmic()) # Try the Windows registry _copy_new_fields(info, _get_cpu_info_from_registry()) # Try /proc/cpuinfo _copy_new_fields(info, _get_cpu_info_from_proc_cpuinfo()) # Try cpufreq-info _copy_new_fields(info, _get_cpu_info_from_cpufreq_info()) # Try LSCPU _copy_new_fields(info, _get_cpu_info_from_lscpu()) # Try sysctl _copy_new_fields(info, _get_cpu_info_from_sysctl()) # Try kstat _copy_new_fields(info, _get_cpu_info_from_kstat()) # Try dmesg _copy_new_fields(info, _get_cpu_info_from_dmesg()) # Try /var/run/dmesg.boot _copy_new_fields(info, _get_cpu_info_from_cat_var_run_dmesg_boot()) # Try lsprop ibm,pa-features _copy_new_fields(info, _get_cpu_info_from_ibm_pa_features()) # Try sysinfo _copy_new_fields(info, _get_cpu_info_from_sysinfo()) # Try querying the CPU cpuid register _copy_new_fields(info, _get_cpu_info_from_cpuid()) return info def get_cpu_info_json(): ''' Returns the CPU info by using the best sources of information for your OS. Returns the result in a json string ''' import json output = None # If running under pyinstaller, run normally if getattr(sys, 'frozen', False): info = _get_cpu_info_internal() output = json.dumps(info) output = "{0}".format(output) # if not running under pyinstaller, run in another process. # This is done because multiprocesing has a design flaw that # causes non main programs to run multiple times on Windows. else: from subprocess import Popen, PIPE command = [sys.executable, __file__, '--json'] p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) output = p1.communicate()[0] if p1.returncode != 0: return "{}" if not IS_PY2: output = output.decode(encoding='UTF-8') return output def get_cpu_info(): ''' Returns the CPU info by using the best sources of information for your OS. Returns the result in a dict ''' import json output = get_cpu_info_json() # Convert JSON to Python with non unicode strings output = json.loads(output, object_hook = _utf_to_str) return output def main(): from argparse import ArgumentParser import json # Parse args parser = ArgumentParser(description='Gets CPU info with pure Python 2 & 3') parser.add_argument('--json', action='store_true', help='Return the info in JSON format') args = parser.parse_args() try: _check_arch() except Exception as err: sys.stderr.write(str(err) + "\n") sys.exit(1) info = _get_cpu_info_internal() if not info: sys.stderr.write("Failed to find cpu info\n") sys.exit(1) if args.json: print(json.dumps(info)) else: print('Python Version: {0}'.format(info.get('python_version', ''))) print('Cpuinfo Version: {0}'.format(info.get('cpuinfo_version', ''))) print('Vendor ID: {0}'.format(info.get('vendor_id', ''))) print('Hardware Raw: {0}'.format(info.get('hardware', ''))) print('Brand: {0}'.format(info.get('brand', ''))) print('Hz Advertised: {0}'.format(info.get('hz_advertised', ''))) print('Hz Actual: {0}'.format(info.get('hz_actual', ''))) print('Hz Advertised Raw: {0}'.format(info.get('hz_advertised_raw', ''))) print('Hz Actual Raw: {0}'.format(info.get('hz_actual_raw', ''))) print('Arch: {0}'.format(info.get('arch', ''))) print('Bits: {0}'.format(info.get('bits', ''))) print('Count: {0}'.format(info.get('count', ''))) print('Raw Arch String: {0}'.format(info.get('raw_arch_string', ''))) print('L1 Data Cache Size: {0}'.format(info.get('l1_data_cache_size', ''))) print('L1 Instruction Cache Size: {0}'.format(info.get('l1_instruction_cache_size', ''))) print('L2 Cache Size: {0}'.format(info.get('l2_cache_size', ''))) print('L2 Cache Line Size: {0}'.format(info.get('l2_cache_line_size', ''))) print('L2 Cache Associativity: {0}'.format(info.get('l2_cache_associativity', ''))) print('L3 Cache Size: {0}'.format(info.get('l3_cache_size', ''))) print('Stepping: {0}'.format(info.get('stepping', ''))) print('Model: {0}'.format(info.get('model', ''))) print('Family: {0}'.format(info.get('family', ''))) print('Processor Type: {0}'.format(info.get('processor_type', ''))) print('Extended Model: {0}'.format(info.get('extended_model', ''))) print('Extended Family: {0}'.format(info.get('extended_family', ''))) print('Flags: {0}'.format(', '.join(info.get('flags', '')))) if __name__ == '__main__': main() else: _check_arch()