linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Triplett <josh@freedesktop.org>
To: Pavel Roskin <proski@gnu.org>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 6/6] Add a simple test script,	embed expected results into test files
Date: Thu, 28 Jun 2007 00:20:09 -0700	[thread overview]
Message-ID: <46836129.7050407@freedesktop.org> (raw)
In-Reply-To: <20070628054019.30704.64375.stgit@dv.roinet.com>

[-- Attachment #1: Type: text/plain, Size: 3715 bytes --]

Awesome!  I plan to merge this tomorrow.

I did notice a few issues.  If you get to them before tomorrow then please
submit an updated patch, but otherwise I will go ahead and fix them myself and
apply the patch; I really want to see this go into Sparse as soon as possible.

* The files starting with "preprocessor" shouldn't run through all of Sparse,
  just the preprocessor (sparse -E).  I've moved them to a
  validation/preprocessor/ subdirectory to keep them separated.

* Ideally, the test suite should support a SPARSE_FLAGS comment, so you can
  specify different -Wfoo options and the corresponding output.  This would
  also handle the preprocessor tests.

Pavel Roskin wrote:
> diff --git a/validation/preprocessor1.c b/validation/preprocessor1.c
> index 5ae20aa..5e9f234 100644
> --- a/validation/preprocessor1.c
> +++ b/validation/preprocessor1.c
> @@ -12,3 +12,8 @@
>  #define bar func(
>  #define foo bar foo
>  foo )
> +
> +/* SPARSE
> +builtin:0:0: error: Expected ; at end of declaration
> +builtin:0:0: error: got end-of-input
> +   SPARSE */

Errors in builtin seem strange and probably broken.

> diff --git a/validation/preprocessor10.c b/validation/preprocessor10.c
> index 7fcac36..137bafd 100644
> --- a/validation/preprocessor10.c
> +++ b/validation/preprocessor10.c
> @@ -11,3 +11,8 @@ defined
>  #else
>  undefined
>  #endif
> +
> +/* SPARSE
> +builtin:0:0: error: Expected ; at end of declaration
> +builtin:0:0: error: got end-of-input
> +   SPARSE */

Ditto.

> diff --git a/validation/preprocessor4.c b/validation/preprocessor4.c
> index 8b8c4da..1620a8b 100644
> --- a/validation/preprocessor4.c
> +++ b/validation/preprocessor4.c
> @@ -8,3 +8,8 @@
>  
>  mac(foo)
>  
> +
> +/* SPARSE
> +builtin:0:0: error: Expected ; at end of declaration
> +builtin:0:0: error: got end-of-input
> +   SPARSE */

Ditto

> diff --git a/validation/run-tests b/validation/run-tests
> new file mode 100755
> index 0000000..ebe8ffc
> --- /dev/null
> +++ b/validation/run-tests
> @@ -0,0 +1,58 @@
> +#!/bin/sh
> +
> +: ${SPARSE=../sparse}
> +: ${SPARSE_FLAGS=}
> +
> +# Use "--update" to update test files with the actual output
> +update=
> +if test "$1" = "--update"; then
> +	update=1
> +	shift
> +fi
> +
> +if test -n "$1"; then
> +	tests="$@"
> +else
> +	tests=`echo *.c`
> +fi
> +
> +bad=
> +for test in $tests; do
> +	base="`basename $test .c`"
> +	exp="$base.exp"
> +	res="$base.res"
> +	diff="$base.diff"
> +	$SPARSE $SPARSE_FLAGS "$test" 2>"$res"
> +	if test "$?" != 0; then
> +		echo "FATAL: $test"
> +		bad="$bad $test"
> +		continue
> +	fi
> +
> +	if test -n "$update"; then
> +		sed -i '/SPARSE/,/SPARSE/d' "$test"
> +		if test -s "$res"; then
> +			echo "/* SPARSE" >>"$test"
> +			cat "$res" >>"$test"
> +			echo "   SPARSE */" >>"$test"
> +		fi
> +	fi

Rather than treating the absence of a SPARSE comment as meaning that the test
has no output, I think I'd rather explicitly include an empty SPARSE comment
in such tests, and then make the absence of a SPARSE comment an error.

> +	sed -n '/SPARSE/,/SPARSE/p' "$test" |grep -v SPARSE >"$exp"
> +	diff -u "$exp" "$res" >"$diff"
> +	if test -s "$diff"; then
> +		echo "FAIL: $test"
> +		bad="$bad $test"
> +		continue
> +	fi
> +
> +	rm -f "$exp" "$res" "$diff"
> +done
> +
> +if test -n "$bad"; then
> +	echo "Failed tests:$bad"
> +	exit 1
> +fi

How about a --verbose that prints the diffs?  I'd prefer that with automated
build systems, for example, so that I can immediately see the test suite
failure in the logs.  Also, --verbose --update should print the diffs it
applies.

- Josh Triplett


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

  reply	other threads:[~2007-06-28  7:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-28  5:39 [PATCH 1/6] Bitfield without explicit sign should be a warning, not an error Pavel Roskin
2007-06-28  5:39 ` [PATCH 2/6] Hardcode actual type sizes, add -m32 support Pavel Roskin
2007-06-28  5:58   ` Al Viro
2007-06-28  6:05     ` Josh Triplett
2007-06-28  6:23       ` Al Viro
2007-06-28  6:27         ` Jeff Garzik
2007-06-28  6:46         ` Josh Triplett
2007-06-28  6:25       ` Jeff Garzik
2007-06-28  6:44         ` Pavel Roskin
2007-06-28  6:47           ` Jeff Garzik
2007-06-28  6:55             ` Josh Triplett
2007-06-28  6:54         ` Josh Triplett
2007-06-28  7:01           ` Jeff Garzik
2007-06-28  7:38             ` Josh Triplett
2007-06-28  6:27       ` Pavel Roskin
2007-06-28  5:40 ` [PATCH 3/6] cgcc: preserve sparse exit code if -no-compile is used Pavel Roskin
2007-06-28  6:12   ` Josh Triplett
2007-06-28  5:40 ` [PATCH 4/6] Avoid use of libc headers in the validation suite Pavel Roskin
2007-06-28  6:14   ` Josh Triplett
2007-06-28  5:40 ` [PATCH 5/6] Fix warnings about undeclared globals, they are irrelevant to the test Pavel Roskin
2007-06-28  6:18   ` Josh Triplett
2007-06-28  5:40 ` [PATCH 6/6] Add a simple test script, embed expected results into test files Pavel Roskin
2007-06-28  7:20   ` Josh Triplett [this message]
2007-06-28 18:59     ` Damien Lespiau
2007-06-28 21:21       ` Pavel Roskin
2007-06-28 21:38       ` Josh Triplett
2007-06-29  0:13         ` Damien Lespiau
2007-06-29  0:29           ` Josh Triplett
2007-07-02  4:59             ` Damien Lespiau
2007-07-02  5:19               ` Josh Triplett
2007-07-08 21:52               ` Josh Triplett
2007-07-09  2:15                 ` Josh Triplett
2007-07-09 21:27                   ` Damien Lespiau
2007-07-11  0:48                     ` Anderson Lizardo
2007-06-28  6:09 ` [PATCH 1/6] Bitfield without explicit sign should be a warning, not an error Josh Triplett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46836129.7050407@freedesktop.org \
    --to=josh@freedesktop.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=proski@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).