summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2022-01-17 14:54:15 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2022-01-17 14:54:15 +0000
commitba1ff52a36d95ca7a9b456f98c9658661d9f76fc (patch)
tree9997b48b3fd1fa6a3434787c71ba1163b56d3cea
parent70c0d62ba06b00f3d38a6a679f825ade1c53e0a6 (diff)
downloadpsutil-ba1ff52a36d95ca7a9b456f98c9658661d9f76fc.tar.gz
add test case for CPU vendor on FreeBSD
-rw-r--r--psutil/__init__.py2
-rw-r--r--psutil/arch/freebsd/cpu.c7
-rwxr-xr-xpsutil/tests/test_bsd.py12
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