[PATCH i-g-t 1/1] tests/intel/xe_sysfs_scheduler: Add invalid string test for engine sysfs properties
Kamil Konieczny
kamil.konieczny at linux.intel.com
Tue Apr 1 13:21:16 UTC 2025
Hi replace_with,
On 2025-03-31 at 14:27:49 +0000, replace_with Sobin Thomas wrote:
> From: Sobin Thomas <sobin.thomas at intel.com>
one nit about configuring your mailer, please remove 'replace_with'
from it, now in a header there is From: with:
replace_with Sobin Thomas <sobin.thomas at intel.com>
and this should be just:
Sobin Thomas <sobin.thomas at intel.com>
Few more nits in addition to what Dominik Karol already wrote.
>
> 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.
>
> 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 at intel.com>
> ---
> tests/intel/xe_sysfs_scheduler.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/tests/intel/xe_sysfs_scheduler.c b/tests/intel/xe_sysfs_scheduler.c
> index 4fc764f82..594c51d44 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,29 @@ 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";
If we start to test it, why not allocate more than one page here
and fill it with gargabe from rand() ? I mean letters from a....zA...Z
That big overflow attempt could be a separate subtest, also with all
letters and/or digits.
> +
> + 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]);
> + continue;
Better to assert here, did you run this on real hardware?
Please test it yourself with igt_runner and as standalone run with
sudo ./xe_sysfs_scheduler.c --r invalid-string
> + }
> +
> + igt_assert(igt_sysfs_scanf(engine, property[i], "%u", &set) == 0);
> +
> + //Check if the values are unchanged.
Please use rather C-style comments or remove this line:
/* Check if the values are unchanged */
> + igt_assert_eq(set, saved);
> + }
> +}
> +
> +
> #define MAX_GTS 8
> igt_main
> {
> @@ -130,6 +158,7 @@ igt_main
> } tests[] = {
> { "invalid", test_invalid },
> { "min-max", test_min_max },
> + { "invalid-string", test_invalid_string },
This should be in alphabetical order, so before 'min-max'.
Regards,
Kamil
> { }
> };
>
> --
> 2.34.1
>
More information about the igt-dev
mailing list