| 1 |
|
| 2 |
|
| 3 |
import unittest |
| 4 |
from cpuinfo import * |
| 5 |
import helpers |
| 6 |
|
| 7 |
|
| 8 |
class MockDataSource: |
| 9 |
bits = '64bit' |
| 10 |
cpu_count = 8 |
| 11 |
is_windows = False |
| 12 |
arch_string_raw = 'x86_64' |
| 13 |
uname_string_raw = 'x86_64' |
| 14 |
can_cpuid = False |
| 15 |
|
| 16 |
@staticmethod |
| 17 |
def has_proc_cpuinfo(): |
| 18 |
return True |
| 19 |
|
| 20 |
@staticmethod |
| 21 |
def has_lscpu(): |
| 22 |
return True |
| 23 |
|
| 24 |
@staticmethod |
| 25 |
def has_sestatus(): |
| 26 |
return True |
| 27 |
|
| 28 |
@staticmethod |
| 29 |
def cat_proc_cpuinfo(): |
| 30 |
returncode = 0 |
| 31 |
output = r''' |
| 32 |
processor : 0 |
| 33 |
vendor_id : AuthenticAMD |
| 34 |
cpu family : 23 |
| 35 |
model : 8 |
| 36 |
model name : AMD Ryzen 7 2700X Eight-Core Processor |
| 37 |
stepping : 2 |
| 38 |
microcode : 0x6000626 |
| 39 |
cpu MHz : 3693.060 |
| 40 |
cache size : 512 KB |
| 41 |
physical id : 0 |
| 42 |
siblings : 8 |
| 43 |
core id : 0 |
| 44 |
cpu cores : 8 |
| 45 |
apicid : 0 |
| 46 |
initial apicid : 0 |
| 47 |
fpu : yes |
| 48 |
fpu_exception : yes |
| 49 |
cpuid level : 13 |
| 50 |
wp : yes |
| 51 |
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 mmxext fxsr_opt rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch cpb ssbd vmmcall fsgsbase avx2 rdseed clflushopt arat |
| 52 |
bugs : fxsave_leak sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass |
| 53 |
bogomips : 7386.12 |
| 54 |
TLB size : 2560 4K pages |
| 55 |
clflush size : 64 |
| 56 |
cache_alignment : 64 |
| 57 |
address sizes : 48 bits physical, 48 bits virtual |
| 58 |
power management: |
| 59 |
|
| 60 |
|
| 61 |
''' |
| 62 |
return returncode, output |
| 63 |
|
| 64 |
@staticmethod |
| 65 |
def lscpu(): |
| 66 |
returncode = 0 |
| 67 |
output = r''' |
| 68 |
Architecture: x86_64 |
| 69 |
CPU op-mode(s): 32-bit, 64-bit |
| 70 |
Byte Order: Little Endian |
| 71 |
CPU(s): 8 |
| 72 |
On-line CPU(s) list: 0-7 |
| 73 |
Thread(s) per core: 1 |
| 74 |
Core(s) per socket: 8 |
| 75 |
Socket(s): 1 |
| 76 |
NUMA node(s): 1 |
| 77 |
Vendor ID: AuthenticAMD |
| 78 |
CPU family: 23 |
| 79 |
Model: 8 |
| 80 |
Model name: AMD Ryzen 7 2700X Eight-Core Processor |
| 81 |
Stepping: 2 |
| 82 |
CPU MHz: 3693.060 |
| 83 |
BogoMIPS: 7386.12 |
| 84 |
Hypervisor vendor: KVM |
| 85 |
Virtualization type: full |
| 86 |
L1d cache: 32K |
| 87 |
L1i cache: 64K |
| 88 |
L2 cache: 512K |
| 89 |
L3 cache: 16384K |
| 90 |
NUMA node0 CPU(s): 0-7 |
| 91 |
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 mmxext fxsr_opt rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch cpb ssbd vmmcall fsgsbase avx2 rdseed clflushopt arat |
| 92 |
|
| 93 |
|
| 94 |
''' |
| 95 |
return returncode, output |
| 96 |
|
| 97 |
@staticmethod |
| 98 |
def sestatus_b(): |
| 99 |
returncode = 0 |
| 100 |
output = r''' |
| 101 |
SELinux status: enabled |
| 102 |
SELinuxfs mount: /sys/fs/selinux |
| 103 |
SELinux root directory: /etc/selinux |
| 104 |
Loaded policy name: targeted |
| 105 |
Current mode: enforcing |
| 106 |
Mode from config file: enforcing |
| 107 |
Policy MLS status: enabled |
| 108 |
Policy deny_unknown status: allowed |
| 109 |
Memory protection checking: actual (secure) |
| 110 |
Max kernel policy version: 31 |
| 111 |
|
| 112 |
Policy booleans: |
| 113 |
abrt_anon_write off |
| 114 |
abrt_handle_event off |
| 115 |
abrt_upload_watch_anon_write on |
| 116 |
antivirus_can_scan_system off |
| 117 |
antivirus_use_jit off |
| 118 |
auditadm_exec_content on |
| 119 |
authlogin_nsswitch_use_ldap off |
| 120 |
authlogin_radius off |
| 121 |
authlogin_yubikey off |
| 122 |
awstats_purge_apache_log_files off |
| 123 |
boinc_execmem on |
| 124 |
cdrecord_read_content off |
| 125 |
cluster_can_network_connect off |
| 126 |
cluster_manage_all_files off |
| 127 |
cluster_use_execmem off |
| 128 |
cobbler_anon_write off |
| 129 |
cobbler_can_network_connect off |
| 130 |
cobbler_use_cifs off |
| 131 |
cobbler_use_nfs off |
| 132 |
collectd_tcp_network_connect off |
| 133 |
colord_use_nfs off |
| 134 |
condor_tcp_network_connect off |
| 135 |
conman_can_network off |
| 136 |
conman_use_nfs off |
| 137 |
cron_can_relabel off |
| 138 |
cron_system_cronjob_use_shares off |
| 139 |
cron_userdomain_transition on |
| 140 |
cups_execmem off |
| 141 |
cvs_read_shadow off |
| 142 |
daemons_dump_core off |
| 143 |
daemons_enable_cluster_mode off |
| 144 |
daemons_use_tcp_wrapper off |
| 145 |
daemons_use_tty off |
| 146 |
dbadm_exec_content on |
| 147 |
dbadm_manage_user_files off |
| 148 |
dbadm_read_user_files off |
| 149 |
deny_execmem off |
| 150 |
deny_ptrace off |
| 151 |
dhcpc_exec_iptables off |
| 152 |
dhcpd_use_ldap off |
| 153 |
domain_can_mmap_files off |
| 154 |
domain_can_write_kmsg off |
| 155 |
domain_fd_use on |
| 156 |
domain_kernel_load_modules off |
| 157 |
entropyd_use_audio on |
| 158 |
exim_can_connect_db off |
| 159 |
exim_manage_user_files off |
| 160 |
exim_read_user_files off |
| 161 |
fcron_crond off |
| 162 |
fenced_can_network_connect off |
| 163 |
fenced_can_ssh off |
| 164 |
fips_mode on |
| 165 |
ftpd_anon_write off |
| 166 |
ftpd_connect_all_unreserved off |
| 167 |
ftpd_connect_db off |
| 168 |
ftpd_full_access off |
| 169 |
ftpd_use_cifs off |
| 170 |
ftpd_use_fusefs off |
| 171 |
ftpd_use_nfs off |
| 172 |
ftpd_use_passive_mode off |
| 173 |
git_cgi_enable_homedirs off |
| 174 |
git_cgi_use_cifs off |
| 175 |
git_cgi_use_nfs off |
| 176 |
git_session_bind_all_unreserved_ports off |
| 177 |
git_session_users off |
| 178 |
git_system_enable_homedirs off |
| 179 |
git_system_use_cifs off |
| 180 |
git_system_use_nfs off |
| 181 |
gitosis_can_sendmail off |
| 182 |
glance_api_can_network off |
| 183 |
glance_use_execmem off |
| 184 |
glance_use_fusefs off |
| 185 |
global_ssp off |
| 186 |
gluster_anon_write off |
| 187 |
gluster_export_all_ro off |
| 188 |
gluster_export_all_rw on |
| 189 |
gluster_use_execmem off |
| 190 |
gpg_web_anon_write off |
| 191 |
gssd_read_tmp on |
| 192 |
guest_exec_content on |
| 193 |
haproxy_connect_any off |
| 194 |
httpd_anon_write off |
| 195 |
httpd_builtin_scripting on |
| 196 |
httpd_can_check_spam off |
| 197 |
httpd_can_connect_ftp off |
| 198 |
httpd_can_connect_ldap off |
| 199 |
httpd_can_connect_mythtv off |
| 200 |
httpd_can_connect_zabbix off |
| 201 |
httpd_can_network_connect off |
| 202 |
httpd_can_network_connect_cobbler off |
| 203 |
httpd_can_network_connect_db off |
| 204 |
httpd_can_network_memcache off |
| 205 |
httpd_can_network_relay off |
| 206 |
httpd_can_sendmail off |
| 207 |
httpd_dbus_avahi off |
| 208 |
httpd_dbus_sssd off |
| 209 |
httpd_dontaudit_search_dirs off |
| 210 |
httpd_enable_cgi on |
| 211 |
httpd_enable_ftp_server off |
| 212 |
httpd_enable_homedirs off |
| 213 |
httpd_execmem off |
| 214 |
httpd_graceful_shutdown off |
| 215 |
httpd_manage_ipa off |
| 216 |
httpd_mod_auth_ntlm_winbind off |
| 217 |
httpd_mod_auth_pam off |
| 218 |
httpd_read_user_content off |
| 219 |
httpd_run_ipa off |
| 220 |
httpd_run_preupgrade off |
| 221 |
httpd_run_stickshift off |
| 222 |
httpd_serve_cobbler_files off |
| 223 |
httpd_setrlimit off |
| 224 |
httpd_ssi_exec off |
| 225 |
httpd_sys_script_anon_write off |
| 226 |
httpd_tmp_exec off |
| 227 |
httpd_tty_comm off |
| 228 |
httpd_unified off |
| 229 |
httpd_use_cifs off |
| 230 |
httpd_use_fusefs off |
| 231 |
httpd_use_gpg off |
| 232 |
httpd_use_nfs off |
| 233 |
httpd_use_openstack off |
| 234 |
httpd_use_sasl off |
| 235 |
httpd_verify_dns off |
| 236 |
icecast_use_any_tcp_ports off |
| 237 |
irc_use_any_tcp_ports off |
| 238 |
irssi_use_full_network off |
| 239 |
kdumpgui_run_bootloader off |
| 240 |
keepalived_connect_any off |
| 241 |
kerberos_enabled on |
| 242 |
ksmtuned_use_cifs off |
| 243 |
ksmtuned_use_nfs off |
| 244 |
logadm_exec_content on |
| 245 |
logging_syslogd_can_sendmail off |
| 246 |
logging_syslogd_run_nagios_plugins off |
| 247 |
logging_syslogd_use_tty on |
| 248 |
login_console_enabled on |
| 249 |
logrotate_read_inside_containers off |
| 250 |
logrotate_use_nfs off |
| 251 |
logwatch_can_network_connect_mail off |
| 252 |
lsmd_plugin_connect_any off |
| 253 |
mailman_use_fusefs off |
| 254 |
mcelog_client off |
| 255 |
mcelog_exec_scripts on |
| 256 |
mcelog_foreground off |
| 257 |
mcelog_server off |
| 258 |
minidlna_read_generic_user_content off |
| 259 |
mmap_low_allowed off |
| 260 |
mock_enable_homedirs off |
| 261 |
mount_anyfile on |
| 262 |
mozilla_plugin_bind_unreserved_ports off |
| 263 |
mozilla_plugin_can_network_connect on |
| 264 |
mozilla_plugin_use_bluejeans off |
| 265 |
mozilla_plugin_use_gps off |
| 266 |
mozilla_plugin_use_spice off |
| 267 |
mozilla_read_content off |
| 268 |
mpd_enable_homedirs off |
| 269 |
mpd_use_cifs off |
| 270 |
mpd_use_nfs off |
| 271 |
mplayer_execstack off |
| 272 |
mysql_connect_any off |
| 273 |
mysql_connect_http off |
| 274 |
nagios_run_pnp4nagios off |
| 275 |
nagios_run_sudo off |
| 276 |
nagios_use_nfs off |
| 277 |
named_tcp_bind_http_port off |
| 278 |
named_write_master_zones off |
| 279 |
neutron_can_network off |
| 280 |
nfs_export_all_ro on |
| 281 |
nfs_export_all_rw on |
| 282 |
nfsd_anon_write off |
| 283 |
nis_enabled off |
| 284 |
nscd_use_shm on |
| 285 |
openshift_use_nfs off |
| 286 |
openvpn_can_network_connect on |
| 287 |
openvpn_enable_homedirs on |
| 288 |
openvpn_run_unconfined off |
| 289 |
pcp_bind_all_unreserved_ports off |
| 290 |
pcp_read_generic_logs off |
| 291 |
pdns_can_network_connect_db off |
| 292 |
piranha_lvs_can_network_connect off |
| 293 |
polipo_connect_all_unreserved off |
| 294 |
polipo_session_bind_all_unreserved_ports off |
| 295 |
polipo_session_users off |
| 296 |
polipo_use_cifs off |
| 297 |
polipo_use_nfs off |
| 298 |
polyinstantiation_enabled off |
| 299 |
postfix_local_write_mail_spool on |
| 300 |
postgresql_can_rsync off |
| 301 |
postgresql_selinux_transmit_client_label off |
| 302 |
postgresql_selinux_unconfined_dbadm on |
| 303 |
postgresql_selinux_users_ddl on |
| 304 |
pppd_can_insmod off |
| 305 |
pppd_for_user off |
| 306 |
privoxy_connect_any on |
| 307 |
prosody_bind_http_port off |
| 308 |
puppetagent_manage_all_files off |
| 309 |
puppetmaster_use_db off |
| 310 |
racoon_read_shadow off |
| 311 |
radius_use_jit off |
| 312 |
redis_enable_notify off |
| 313 |
rpcd_use_fusefs off |
| 314 |
rsync_anon_write off |
| 315 |
rsync_client off |
| 316 |
rsync_export_all_ro off |
| 317 |
rsync_full_access off |
| 318 |
samba_create_home_dirs off |
| 319 |
samba_domain_controller off |
| 320 |
samba_enable_home_dirs off |
| 321 |
samba_export_all_ro off |
| 322 |
samba_export_all_rw off |
| 323 |
samba_load_libgfapi off |
| 324 |
samba_portmapper off |
| 325 |
samba_run_unconfined off |
| 326 |
samba_share_fusefs off |
| 327 |
samba_share_nfs off |
| 328 |
sanlock_enable_home_dirs off |
| 329 |
sanlock_use_fusefs off |
| 330 |
sanlock_use_nfs off |
| 331 |
sanlock_use_samba off |
| 332 |
saslauthd_read_shadow off |
| 333 |
secadm_exec_content on |
| 334 |
secure_mode off |
| 335 |
secure_mode_insmod off |
| 336 |
secure_mode_policyload off |
| 337 |
selinuxuser_direct_dri_enabled on |
| 338 |
selinuxuser_execheap off |
| 339 |
selinuxuser_execmod on |
| 340 |
selinuxuser_execstack on |
| 341 |
selinuxuser_mysql_connect_enabled off |
| 342 |
selinuxuser_ping on |
| 343 |
selinuxuser_postgresql_connect_enabled off |
| 344 |
selinuxuser_rw_noexattrfile on |
| 345 |
selinuxuser_share_music off |
| 346 |
selinuxuser_tcp_server off |
| 347 |
selinuxuser_udp_server off |
| 348 |
selinuxuser_use_ssh_chroot off |
| 349 |
sge_domain_can_network_connect off |
| 350 |
sge_use_nfs off |
| 351 |
smartmon_3ware off |
| 352 |
smbd_anon_write off |
| 353 |
spamassassin_can_network off |
| 354 |
spamd_enable_home_dirs on |
| 355 |
spamd_update_can_network off |
| 356 |
squid_connect_any on |
| 357 |
squid_use_tproxy off |
| 358 |
ssh_chroot_rw_homedirs off |
| 359 |
ssh_keysign off |
| 360 |
ssh_sysadm_login off |
| 361 |
ssh_use_tcpd off |
| 362 |
sslh_can_bind_any_port off |
| 363 |
sslh_can_connect_any_port off |
| 364 |
staff_exec_content on |
| 365 |
staff_use_svirt off |
| 366 |
swift_can_network off |
| 367 |
sysadm_exec_content on |
| 368 |
telepathy_connect_all_ports off |
| 369 |
telepathy_tcp_connect_generic_network_ports on |
| 370 |
tftp_anon_write off |
| 371 |
tftp_home_dir off |
| 372 |
tmpreaper_use_cifs off |
| 373 |
tmpreaper_use_nfs off |
| 374 |
tmpreaper_use_samba off |
| 375 |
tomcat_can_network_connect_db off |
| 376 |
tomcat_read_rpm_db off |
| 377 |
tomcat_use_execmem off |
| 378 |
tor_bind_all_unreserved_ports off |
| 379 |
tor_can_network_relay off |
| 380 |
tor_can_onion_services off |
| 381 |
unconfined_chrome_sandbox_transition on |
| 382 |
unconfined_login on |
| 383 |
unconfined_mozilla_plugin_transition on |
| 384 |
unprivuser_use_svirt off |
| 385 |
use_ecryptfs_home_dirs off |
| 386 |
use_fusefs_home_dirs off |
| 387 |
use_lpd_server off |
| 388 |
use_nfs_home_dirs off |
| 389 |
use_samba_home_dirs off |
| 390 |
use_virtualbox off |
| 391 |
user_exec_content on |
| 392 |
varnishd_connect_any off |
| 393 |
virt_read_qemu_ga_data off |
| 394 |
virt_rw_qemu_ga_data off |
| 395 |
virt_sandbox_share_apache_content off |
| 396 |
virt_sandbox_use_all_caps on |
| 397 |
virt_sandbox_use_audit on |
| 398 |
virt_sandbox_use_fusefs off |
| 399 |
virt_sandbox_use_mknod off |
| 400 |
virt_sandbox_use_netlink off |
| 401 |
virt_sandbox_use_sys_admin off |
| 402 |
virt_transition_userdomain off |
| 403 |
virt_use_comm off |
| 404 |
virt_use_execmem off |
| 405 |
virt_use_fusefs off |
| 406 |
virt_use_glusterd off |
| 407 |
virt_use_nfs off |
| 408 |
virt_use_pcscd off |
| 409 |
virt_use_rawip off |
| 410 |
virt_use_samba off |
| 411 |
virt_use_sanlock off |
| 412 |
virt_use_usb on |
| 413 |
virt_use_xserver off |
| 414 |
webadm_manage_user_files off |
| 415 |
webadm_read_user_files off |
| 416 |
wine_mmap_zero_ignore off |
| 417 |
xdm_bind_vnc_tcp_port off |
| 418 |
xdm_exec_bootloader off |
| 419 |
xdm_sysadm_login off |
| 420 |
xdm_write_home off |
| 421 |
xen_use_nfs off |
| 422 |
xend_run_blktap on |
| 423 |
xend_run_qemu on |
| 424 |
xguest_connect_network on |
| 425 |
xguest_exec_content on |
| 426 |
xguest_mount_media on |
| 427 |
xguest_use_bluetooth on |
| 428 |
xserver_clients_write_xshm off |
| 429 |
xserver_execmem off |
| 430 |
xserver_object_manager off |
| 431 |
zabbix_can_network off |
| 432 |
zabbix_run_sudo off |
| 433 |
zarafa_setrlimit off |
| 434 |
zebra_write_config off |
| 435 |
zoneminder_anon_write off |
| 436 |
zoneminder_run_sudo off |
| 437 |
''' |
| 438 |
return returncode, output |
| 439 |
|
| 440 |
|
| 441 |
class Test_Linux_Fedora_29_X86_64_Ryzen_7(unittest.TestCase): |
| 442 |
def setUp(self): |
| 443 |
helpers.backup_data_source(cpuinfo) |
| 444 |
helpers.monkey_patch_data_source(cpuinfo, MockDataSource) |
| 445 |
|
| 446 |
def tearDown(self): |
| 447 |
helpers.restore_data_source(cpuinfo) |
| 448 |
|
| 449 |
''' |
| 450 |
Make sure calls return the expected number of fields. |
| 451 |
''' |
| 452 |
def test_returns(self): |
| 453 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry())) |
| 454 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpufreq_info())) |
| 455 |
self.assertEqual(14, len(cpuinfo._get_cpu_info_from_lscpu())) |
| 456 |
self.assertEqual(11, len(cpuinfo._get_cpu_info_from_proc_cpuinfo())) |
| 457 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl())) |
| 458 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat())) |
| 459 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg())) |
| 460 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())) |
| 461 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features())) |
| 462 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo())) |
| 463 |
self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid())) |
| 464 |
self.assertEqual(21, len(cpuinfo._get_cpu_info_internal())) |
| 465 |
|
| 466 |
def test_get_cpu_info_from_lscpu(self): |
| 467 |
info = cpuinfo._get_cpu_info_from_lscpu() |
| 468 |
|
| 469 |
self.assertEqual('AuthenticAMD', info['vendor_id_raw']) |
| 470 |
self.assertEqual('AMD Ryzen 7 2700X Eight-Core Processor', info['brand_raw']) |
| 471 |
self.assertEqual('3.6931 GHz', info['hz_advertised_friendly']) |
| 472 |
self.assertEqual('3.6931 GHz', info['hz_actual_friendly']) |
| 473 |
self.assertEqual((3693060000, 0), info['hz_advertised']) |
| 474 |
self.assertEqual((3693060000, 0), info['hz_actual']) |
| 475 |
|
| 476 |
self.assertEqual(2, info['stepping']) |
| 477 |
self.assertEqual(8, info['model']) |
| 478 |
self.assertEqual(23, info['family']) |
| 479 |
|
| 480 |
self.assertEqual(64 * 1024, info['l1_instruction_cache_size']) |
| 481 |
self.assertEqual(32 * 1024, info['l1_data_cache_size']) |
| 482 |
self.assertEqual(512 * 1024, info['l2_cache_size']) |
| 483 |
self.assertEqual(16384 * 1024, info['l3_cache_size']) |
| 484 |
|
| 485 |
self.assertEqual( |
| 486 |
['3dnowprefetch', 'abm', 'aes', 'apic', 'arat', 'avx', 'avx2', |
| 487 |
'clflush', 'clflushopt', 'cmov', 'cmp_legacy', 'constant_tsc', |
| 488 |
'cpb', 'cpuid', 'cr8_legacy', 'cx16', 'cx8', 'de', 'extd_apicid', |
| 489 |
'fpu', 'fsgsbase', 'fxsr', 'fxsr_opt', 'ht', 'hypervisor', |
| 490 |
'lahf_lm', 'lm', 'mca', 'mce', 'misalignsse', 'mmx', 'mmxext', |
| 491 |
'movbe', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', |
| 492 |
'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdrand', |
| 493 |
'rdseed', 'rdtscp', 'rep_good', 'sep', 'ssbd', 'sse', 'sse2', |
| 494 |
'sse4_1', 'sse4_2', 'sse4a', 'ssse3', 'syscall', 'tsc', |
| 495 |
'tsc_known_freq', 'vme', 'vmmcall', 'x2apic', 'xsave'] |
| 496 |
, |
| 497 |
info['flags'] |
| 498 |
) |
| 499 |
|
| 500 |
def test_get_cpu_info_from_proc_cpuinfo(self): |
| 501 |
info = cpuinfo._get_cpu_info_from_proc_cpuinfo() |
| 502 |
|
| 503 |
self.assertEqual('AuthenticAMD', info['vendor_id_raw']) |
| 504 |
self.assertEqual('AMD Ryzen 7 2700X Eight-Core Processor', info['brand_raw']) |
| 505 |
self.assertEqual('3.6931 GHz', info['hz_advertised_friendly']) |
| 506 |
self.assertEqual('3.6931 GHz', info['hz_actual_friendly']) |
| 507 |
self.assertEqual((3693060000, 0), info['hz_advertised']) |
| 508 |
self.assertEqual((3693060000, 0), info['hz_actual']) |
| 509 |
|
| 510 |
# FIXME: This is l2 cache size not l3 cache size |
| 511 |
self.assertEqual(512 * 1024, info['l3_cache_size']) |
| 512 |
|
| 513 |
self.assertEqual(2, info['stepping']) |
| 514 |
self.assertEqual(8, info['model']) |
| 515 |
self.assertEqual(23, info['family']) |
| 516 |
self.assertEqual( |
| 517 |
['3dnowprefetch', 'abm', 'aes', 'apic', 'arat', 'avx', 'avx2', |
| 518 |
'clflush', 'clflushopt', 'cmov', 'cmp_legacy', 'constant_tsc', |
| 519 |
'cpb', 'cpuid', 'cr8_legacy', 'cx16', 'cx8', 'de', 'extd_apicid', |
| 520 |
'fpu', 'fsgsbase', 'fxsr', 'fxsr_opt', 'ht', 'hypervisor', |
| 521 |
'lahf_lm', 'lm', 'mca', 'mce', 'misalignsse', 'mmx', 'mmxext', |
| 522 |
'movbe', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', |
| 523 |
'pat', 'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', |
| 524 |
'rdrand', 'rdseed', 'rdtscp', 'rep_good', 'sep', 'ssbd', 'sse', |
| 525 |
'sse2', 'sse4_1', 'sse4_2', 'sse4a', 'ssse3', 'syscall', 'tsc', |
| 526 |
'tsc_known_freq', 'vme', 'vmmcall', 'x2apic', 'xsave'] |
| 527 |
, |
| 528 |
info['flags'] |
| 529 |
) |
| 530 |
|
| 531 |
def test_all(self): |
| 532 |
info = cpuinfo._get_cpu_info_internal() |
| 533 |
|
| 534 |
self.assertEqual('AuthenticAMD', info['vendor_id_raw']) |
| 535 |
self.assertEqual('AMD Ryzen 7 2700X Eight-Core Processor', info['brand_raw']) |
| 536 |
self.assertEqual('3.6931 GHz', info['hz_advertised_friendly']) |
| 537 |
self.assertEqual('3.6931 GHz', info['hz_actual_friendly']) |
| 538 |
self.assertEqual((3693060000, 0), info['hz_advertised']) |
| 539 |
self.assertEqual((3693060000, 0), info['hz_actual']) |
| 540 |
self.assertEqual('X86_64', info['arch']) |
| 541 |
self.assertEqual(64, info['bits']) |
| 542 |
self.assertEqual(8, info['count']) |
| 543 |
|
| 544 |
self.assertEqual('x86_64', info['arch_string_raw']) |
| 545 |
|
| 546 |
self.assertEqual(64 * 1024, info['l1_instruction_cache_size']) |
| 547 |
self.assertEqual(32 * 1024, info['l1_data_cache_size']) |
| 548 |
|
| 549 |
self.assertEqual(512 * 1024, info['l2_cache_size']) |
| 550 |
# FIXME: This is l2 cache size not l3 cache size |
| 551 |
# it is wrong in /proc/cpuinfo |
| 552 |
self.assertEqual(512 * 1024, info['l3_cache_size']) |
| 553 |
|
| 554 |
self.assertEqual(2, info['stepping']) |
| 555 |
self.assertEqual(8, info['model']) |
| 556 |
self.assertEqual(23, info['family']) |
| 557 |
self.assertEqual( |
| 558 |
['3dnowprefetch', 'abm', 'aes', 'apic', 'arat', 'avx', 'avx2', |
| 559 |
'clflush', 'clflushopt', 'cmov', 'cmp_legacy', 'constant_tsc', |
| 560 |
'cpb', 'cpuid', 'cr8_legacy', 'cx16', 'cx8', 'de', 'extd_apicid', |
| 561 |
'fpu', 'fsgsbase', 'fxsr', 'fxsr_opt', 'ht', 'hypervisor', |
| 562 |
'lahf_lm', 'lm', 'mca', 'mce', 'misalignsse', 'mmx', 'mmxext', |
| 563 |
'movbe', 'msr', 'mtrr', 'nonstop_tsc', 'nopl', 'nx', 'pae', 'pat', |
| 564 |
'pclmulqdq', 'pge', 'pni', 'popcnt', 'pse', 'pse36', 'rdrand', |
| 565 |
'rdseed', 'rdtscp', 'rep_good', 'sep', 'ssbd', 'sse', 'sse2', |
| 566 |
'sse4_1', 'sse4_2', 'sse4a', 'ssse3', 'syscall', 'tsc', |
| 567 |
'tsc_known_freq', 'vme', 'vmmcall', 'x2apic', 'xsave'] |
| 568 |
, |
| 569 |
info['flags'] |
| 570 |
) |