[PATCH i-g-t 1/1] tests/intel/xe_sysfs_scheduler: Add invalid string test for engine sysfs properties

Piatkowski, Dominik Karol dominik.karol.piatkowski at intel.com
Tue Apr 1 09:44:19 UTC 2025


Hi Sobin,

For future submissions, please don't change cover letter's patch number from 0 to not confuse patchwork.

> -----Original Message-----
> From: Thomas, Sobin <sobin.thomas at intel.com>
> Sent: Monday, March 31, 2025 4:28 PM
> To: igt-dev at lists.freedesktop.org
> Cc: Konieczny, Kamil <kamil.konieczny at intel.com>; Piatkowski, Dominik Karol
> <dominik.karol.piatkowski at intel.com>
> Subject: [PATCH i-g-t 1/1] tests/intel/xe_sysfs_scheduler: Add invalid string

Missing v2 after PATCH.

> test for engine sysfs properties
> 
> From: Sobin Thomas <sobin.thomas at 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.
> 
> 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.

Please align this line in a similar way to other subtests in this file.

> + * 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";
> +
> +	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;

I see a flaw in the test flow. In case of igt_sysfs_printf not failing as expected, we print message with IGT_LOG_CRITICAL level and just continue the loop, not hitting asserts below. The thing is, the igt_critical does not make the test fail, despite the fact that we found a bug. Please fix it.

Thanks,
Dominik Karol

> +		}
> +
> +		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 +158,7 @@ igt_main
>  	} tests[] = {
>  		{ "invalid", test_invalid },
>  		{ "min-max", test_min_max },
> +		{ "invalid-string", test_invalid_string },
>  		{ }
>  	};
> 
> --
> 2.34.1



More information about the igt-dev mailing list