From: Karthik Poosa <karthik.poosa@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: rodrigo.vivi@intel.com, anshuman.gupta@intel.com,
badal.nilawar@intel.com, raag.jadav@intel.com,
riana.tauro@intel.com, sk.anirban@intel.com,
mallesh.koujalagi@intel.com, soham.purkait@intel.com,
Karthik Poosa <karthik.poosa@intel.com>
Subject: [PATCH i-g-t] tests/intel/intel_hwmon: Warn on zero-valued numeric attributes
Date: Wed, 5 Aug 2026 19:28:42 +0530 [thread overview]
Message-ID: <20260805135842.34736-1-karthik.poosa@intel.com> (raw)
Add a check for numeric hwmon attribute values and emit a warning when a
valid numeric attribute reports 0.
This acts as a sanity check for valid telemetry data reported via hwmon.
Exclude *_label attributes from this validation to avoid false warnings on
non-numeric label entries.
Also include the necessary headers required for numeric parsing helpers.
Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
Assisted-by: GitHub-Copilot:GPT-5.3-Codex
---
tests/intel/intel_hwmon.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/tests/intel/intel_hwmon.c b/tests/intel/intel_hwmon.c
index f185c1ca3..6fe57a334 100644
--- a/tests/intel/intel_hwmon.c
+++ b/tests/intel/intel_hwmon.c
@@ -4,6 +4,8 @@
*/
#include <dirent.h>
+#include <errno.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include "igt.h"
#include "igt_hwmon.h"
@@ -26,6 +28,31 @@
IGT_TEST_DESCRIPTION("Tests for intel hwmon");
+static bool value_is_numeric_zero(const char *val)
+{
+ char *end;
+ long long num;
+
+ errno = 0;
+ num = strtoll(val, &end, 10);
+ if (errno || *val == '\0' || *end != '\0')
+ return false;
+
+ return num == 0;
+}
+
+static bool is_hmwon_label(const char *name)
+{
+ const char *suffix = "_label";
+ size_t name_len = strlen(name);
+ size_t suffix_len = strlen(suffix);
+
+ if (name_len < suffix_len)
+ return false;
+
+ return !strcmp(name + name_len - suffix_len, suffix);
+}
+
static void check_if_temp_valid(int hwm, char *sysfs_name)
{
int32_t cur_temp = 0, limit = 0;
@@ -64,9 +91,11 @@ static void hwmon_read(int hwm)
igt_assert(igt_sysfs_scanf(hwm, de->d_name, "%127s", val) == 1);
igt_debug("'%s': %s\n", de->d_name, val);
+ if (!is_hmwon_label(de->d_name) && value_is_numeric_zero(val))
+ igt_warn("hwmon sysfs entry '%s' has zero value\n", de->d_name);
+
if (!strncmp(de->d_name, "temp", 4))
check_if_temp_valid(hwm, de->d_name);
-
}
closedir(dir);
}
--
2.25.1
next reply other threads:[~2026-08-05 13:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 13:58 Karthik Poosa [this message]
2026-08-06 2:49 ` ✗ Xe.CI.BAT: failure for tests/intel/intel_hwmon: Warn on zero-valued numeric attributes Patchwork
2026-08-06 3:15 ` ✗ i915.CI.BAT: " Patchwork
2026-08-06 13:19 ` ✗ Xe.CI.FULL: " Patchwork
2026-08-19 4:31 ` [PATCH i-g-t] " Purkait, Soham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805135842.34736-1-karthik.poosa@intel.com \
--to=karthik.poosa@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=mallesh.koujalagi@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=sk.anirban@intel.com \
--cc=soham.purkait@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox