[PATCH] string: Improve memchr random test

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Jun 18 19:29:08 GMT 2026



On 18/06/26 16:09, Wilco Dijkstra wrote:
> 
> Add matches before the start to ensure the memchr test checks they do not
> result in false matches or missed matches.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 
> ---
> 
> diff --git a/string/test-memchr.c b/string/test-memchr.c
> index df9ce0f22c04c73472b134e89585c7557cd00dfc..42d18a596f850a5871dcbb2903153b59a8153d72 100644
> --- a/string/test-memchr.c
> +++ b/string/test-memchr.c
> @@ -177,6 +177,11 @@ do_random_tests (void)
>  	    }
>  	}
>  
> +      /* Add matching chars before the start to improve test coverage.  */
> +      i = random () & 31;
> +      if (i < align)
> +	p[i] = seek_char;
> +
>        if (pos < len)
>  	{
>  	  size_t r = random ();
> 



More information about the Libc-alpha mailing list