Re: [PATCH i-g-t] igt/drv_hangman: Fix clear_error_state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 22, 2017 at 05:26:29PM -0800, Michel Thierry wrote:
> clear_error_state was not doing anything (igt_sysfs_set was not writing to
> the error file).
> 
> Also fix assert_entry to catch this issue; strcasecmp returns 0 when
> there's a match, or an integer in a mismatch.
> 
> Finally, only print part of the error string when the assert fails.
> 
> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Fixes: 79c6a84ca85b ("igt/drv_hangman: Migrate to sysfs")
> Signed-off-by: Michel Thierry <michel.thierry@xxxxxxxxx>
> ---
>  tests/drv_hangman.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
> index cafdf4c1..43f73661 100644
> --- a/tests/drv_hangman.c
> +++ b/tests/drv_hangman.c
> @@ -58,9 +58,15 @@ static void assert_entry(const char *s, bool expect)
>  	error = igt_sysfs_get(sysfs, "error");
>  	igt_assert(error);
>  
> -	igt_assert_f(strcasecmp(error, s) != expect,
!!strcasecmp != expect
or (bool)strcasecmp != expect, type promotion working in the opposite
direction.

> -		     "contents of error: '%s' (expected %s '%s')\n",
> -		     error, expect ? "": "not", s);
> +	if (expect) {
> +		igt_assert_f(strcasecmp(error, s) == 0,
> +			     "contents of error: '%.24s' (expected %s '%s')\n",
> +			     error, expect ? "": "not", s);

Keep the full error state, it can be very informative. 24 characters
isn't enough to determine what.

> +	} else {
> +		igt_assert_f(strcasecmp(error, s) != 0,
> +			     "contents of error: '%.24s' (expected %s '%s')\n",
> +			     error, expect ? "": "not", s);
> +	}
>  
>  	free(error);
>  }
> @@ -77,7 +83,7 @@ static void assert_error_state_collected(void)
>  
>  static void clear_error_state(void)
>  {
> -	igt_sysfs_set(sysfs, "error", "");
> +	igt_sysfs_set(sysfs, "error", " ");

My bad, I was expecting it write the nul character. "\0" would be my
preference
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux