Re: [PATCH 1/5] replace test for c99 for-loop initializers

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

 




On 18/02/17 20:30, Luc Van Oostenryck wrote:
> The existing test is an indirect test, using a warning
> about context imbalance to show that some part of code
> was discarded.
> 
> Now that we have the minimal tools to test the output of
> test-linearize, use them to replace the test by a direct one.

Hmm, it may be a more direct test, but it is not clear
just what is being tested (or indeed how it is being tested).

> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  validation/c99-for-loop.c | 36 ++++++++++++------------------------
>  1 file changed, 12 insertions(+), 24 deletions(-)
> 
> diff --git a/validation/c99-for-loop.c b/validation/c99-for-loop.c
> index 42246c513..427fde268 100644
> --- a/validation/c99-for-loop.c
> +++ b/validation/c99-for-loop.c
> @@ -1,33 +1,21 @@
> -int op(int);
> -
> -static int good(void)
> +int c99(void);
> +int c99(void)
>  {
> -	__context__(1);
> -	for (int i = 0; i < 10; i++) {
> -		if (!op(i)) {
> -			__context__(-1);
> -			return 0;
> -		}
> -	}
> -	__context__(-1);
> -	return 1;
> -}
> +	int r = -1;
>  
> -static int bad(void)
> -{
> -	__context__(1);
>  	for (int i = 0; i < 10; i++) {
> -		if (!op(i)) {
> -			__context__(-1);
> -			return 0;
> -		}
> +		r = i;
>  	}
> -	return 1;
> +
> +	return r;
>  }
> +
>  /*
>   * check-name: C99 for loop variable declaration
> + * check-command: test-linearize $file
>   *
> - * check-error-start
> -c99-for-loop.c:16:12: warning: context imbalance in 'bad' - different lock contexts for basic block
> - * check-error-end
> + * check-output-ignore
> + * check-output-contains: phisrc\\.
> + * check-output-contains: phi\\.
> + * check-output-contains: add\\.
>   */
> 

After applying this patch, I edited validation/c99-for-loop.c
like so:

    $ git diff
    diff --git a/validation/c99-for-loop.c b/validation/c99-for-loop.c
    index 427fde2..6b24fa8 100644
    --- a/validation/c99-for-loop.c
    +++ b/validation/c99-for-loop.c
    @@ -2,8 +2,9 @@ int c99(void);
     int c99(void)
     {
            int r = -1;
    +       int i;
 
    -       for (int i = 0; i < 10; i++) {
    +       for (i = 0; i < 10; i++) {
                    r = i;
            }
 
    $ 

This modified test still passes (indeed the output is identical).
:-P

ATB,
Ramsay Jones


--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux