Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: replace_with Sobin Thomas <sobin.thomas@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: dominik.karol.piatkowski@intel.com
Subject: [PATCH v3 i-g-t 1/1] tests/intel/xe_sysfs_scheduler: Add invalid string test for engine sysfs properties
Date: Tue,  1 Apr 2025 11:45:29 +0000	[thread overview]
Message-ID: <20250401114529.1828868-2-sobin.thomas@intel.com> (raw)
In-Reply-To: <20250401114529.1828868-1-sobin.thomas@intel.com>

From: Sobin Thomas <sobin.thomas@intel.com>

This test validates that invalid string inputs are correctly rejected
by engine sysfs write. It ensures that the property values remain
unchanged when invalid inputs are provided.

v3: Fixed the test logic. Fixed the tabs

v2: Added error check for return values for igt_sysfs_scanf and
igt_sysfs_printf. Removed the changes for fault injection in
tests/intel/xe_fault_injection.c

v1: Initial changes for checking error string.

Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
 tests/intel/xe_sysfs_scheduler.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tests/intel/xe_sysfs_scheduler.c b/tests/intel/xe_sysfs_scheduler.c
index 4fc764f82..eb95d0d6e 100644
--- a/tests/intel/xe_sysfs_scheduler.c
+++ b/tests/intel/xe_sysfs_scheduler.c
@@ -10,6 +10,11 @@
  * Sub-category: SysMan tests
  * Functionality: scheduler control interface
  *
+ * SUBTEST: %s-invalid-string
+ * Description: Test to check if %s arg[1] schedule parameter checks for
+ *		min max values.
+ * Test category: Negative string test
+ *
  * SUBTEST: %s-invalid
  * Description: Test to check if %s arg[1] schedule parameter rejects any
  *		unrepresentable intervals.
@@ -121,6 +126,28 @@ static void test_min_max(int xe, int engine, const char **property,
 	igt_assert_eq(set, default_max);
 }
 
+static void test_invalid_string(int xe, int engine, const char **property,
+			uint16_t class, int gt)
+{
+	unsigned int saved, set;
+	char invalid_input[] = "999abc";
+
+	for (int i = 0; i < 3; i++) {
+		igt_assert(igt_sysfs_scanf(engine, property[i], "%u", &saved) == 1);
+		igt_info("Initial %s: %u\n", property[i], saved);
+		if (igt_sysfs_printf(engine, property[i], "%s", invalid_input) > 0) {
+			igt_critical("invalid value %s can be set to property %s\n",
+					invalid_input, property[i]);
+		}
+
+		igt_assert(igt_sysfs_scanf(engine, property[i], "%u", &set) == 0);
+
+		//Check if the values are unchanged.
+		igt_assert_eq(set, saved);
+	}
+}
+
+
 #define MAX_GTS 8
 igt_main
 {
@@ -130,6 +157,7 @@ igt_main
 	} tests[] = {
 		{ "invalid", test_invalid },
 		{ "min-max", test_min_max },
+		{ "invalid-string", test_invalid_string },
 		{ }
 	};
 
-- 
2.34.1


  reply	other threads:[~2025-04-01 11:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 11:45 [PATCH v3 i-g-t 0/1] tests/intel/xe_sysfs_scheduler: Add invalid string test for engine sysfs properties replace_with Sobin Thomas
2025-04-01 11:45 ` replace_with Sobin Thomas [this message]
2025-04-01 12:59   ` [PATCH v3 i-g-t 1/1] " Piatkowski, Dominik Karol
2025-04-07 10:43     ` Kamil Konieczny
2025-04-01 13:51 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-04-01 13:55 ` ✓ i915.CI.BAT: " Patchwork
2025-04-01 16:10 ` ✗ Xe.CI.Full: failure " Patchwork
2025-04-01 17:38 ` ✗ i915.CI.Full: " Patchwork
2025-04-06 22:43 ` ✗ Xe.CI.Full: " Patchwork

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=20250401114529.1828868-2-sobin.thomas@intel.com \
    --to=sobin.thomas@intel.com \
    --cc=dominik.karol.piatkowski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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