diff options
-rw-r--r-- | psutil/__init__.py | 2 | ||||
-rw-r--r-- | psutil/arch/freebsd/cpu.c | 7 | ||||
-rwxr-xr-x | psutil/tests/test_bsd.py | 12 |
3 files changed, 17 insertions, 4 deletions
diff --git a/psutil/__init__.py b/psutil/__init__.py index eef32c97..a0c8c844 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -1915,7 +1915,7 @@ if hasattr(_psplatform, "cpu_info"): * "l1_cache": Windows * "l2_cache": Linux, macOS, Windows * "l3_cache": Linux, macOS, Windows - * "flags": Linux, macOS, Windows + * "flags": Linux, macOS, Windows, FreeBSD """ ret = _psplatform.cpu_info() if 'arch' not in ret and POSIX: diff --git a/psutil/arch/freebsd/cpu.c b/psutil/arch/freebsd/cpu.c index 2dd23e53..383681be 100644 --- a/psutil/arch/freebsd/cpu.c +++ b/psutil/arch/freebsd/cpu.c @@ -24,6 +24,7 @@ For reference, here's the git history with original(ish) implementations: #include "../../_psutil_posix.h" +// Reference: `cpuid` command, see https://www.freshports.org/misc/cpuid #define cpuid(in,a,b,c,d) \ asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in)); #define EBX_INTEL 0x756e6547 @@ -269,7 +270,7 @@ error: } -// Reference: `cpuid` command, see: https://www.freshports.org/misc/cpuid +// Reference: `cpuid` command, see https://www.freshports.org/misc/cpuid PyObject * psutil_cpu_vendor(PyObject *self, PyObject *args) { int i; @@ -296,7 +297,7 @@ psutil_cpu_vendor(PyObject *self, PyObject *args) { } -// Reference: `cpuid` command, see: https://www.freshports.org/misc/cpuid +// Reference: `cpuid` command, see https://www.freshports.org/misc/cpuid PyObject * psutil_cpu_flags(PyObject *self, PyObject *args) { int i, feature_flags; @@ -329,7 +330,7 @@ psutil_cpu_flags(PyObject *self, PyObject *args) { ;; } else if (ebx == EBX_CYRIX) { - ;; + ;; } else { ;; // unknown vendor diff --git a/psutil/tests/test_bsd.py b/psutil/tests/test_bsd.py index 1ae810f1..2057c378 100755 --- a/psutil/tests/test_bsd.py +++ b/psutil/tests/test_bsd.py @@ -475,6 +475,18 @@ class FreeBSDSystemTestCase(PsutilTestCase): psutil.sensors_temperatures()["coretemp"][cpu].high, sysctl_result) + # --- CPU info + + @unittest.skipIf(not which('cpuid'), "cpuid cmd not available") + def test_cpu_info_vendor(self): + out = sh("cpuid") + for line in out.splitlines(): + if "vendor" in line.lower(): + self.assertIn(psutil.cpu_info()["vendor"], line) + break + else: + raise self.skipTest("line not found") + # ===================================================================== # --- OpenBSD |