init: raw cpuid/rdtsc access via ctypes
This commit is contained in:
commit
fa82965ab5
15 changed files with 437 additions and 0 deletions
32
tests/test_rawcpu.py
Normal file
32
tests/test_rawcpu.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import rawcpu
|
||||
|
||||
|
||||
def test_vendor_not_empty():
|
||||
assert len(rawcpu.vendor()) > 0
|
||||
|
||||
|
||||
def test_brand_not_empty():
|
||||
assert len(rawcpu.brand()) > 0
|
||||
|
||||
|
||||
def test_rdtsc_moves_forward():
|
||||
a = rawcpu.rdtsc()
|
||||
b = rawcpu.rdtsc()
|
||||
assert b >= a
|
||||
|
||||
|
||||
def test_cpuid_leaf_zero_reports_max_leaf():
|
||||
eax, _ebx, _ecx, _edx = rawcpu.cpuid(0)
|
||||
assert eax >= 1
|
||||
|
||||
|
||||
def test_has_feature_sse2_true_on_any_modern_x86():
|
||||
assert rawcpu.has_feature("sse2") is True
|
||||
|
||||
|
||||
def test_has_feature_unknown_raises():
|
||||
try:
|
||||
rawcpu.has_feature("not-a-real-feature")
|
||||
assert False, "expected ValueError"
|
||||
except ValueError:
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue