From mboxrd@z Thu Jan 1 00:00:00 1970 From: Luc Van Oostenryck Subject: [PATCH 2/3] test-suite: allow filename expansion of the input sections Date: Wed, 4 Feb 2015 03:49:16 +0100 Message-ID: <20150204024916.GC7731@macpro.local> References: <54C15E0E.4000008@de.ibm.com> <20150123222332.GB42179@macpro.local> <20150123223856.GB1489@cloud> <20150123235934.GA42931@macpro.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail-wi0-f176.google.com ([209.85.212.176]:45841 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750944AbbBDCtV (ORCPT ); Tue, 3 Feb 2015 21:49:21 -0500 Received: by mail-wi0-f176.google.com with SMTP id bs8so28832748wib.3 for ; Tue, 03 Feb 2015 18:49:20 -0800 (PST) Content-Disposition: inline In-Reply-To: Sender: linux-sparse-owner@vger.kernel.org List-Id: linux-sparse@vger.kernel.org To: Christopher Li Cc: Josh Triplett , Christian Borntraeger , Linus Torvalds , "Jason J. Herne" , Linux-Sparse , Sam Ravnborg Signed-off-by: Luc Van Oostenryck Suggested-by: Josh Triplett --- Documentation/test-suite | 4 ++++ validation/test-suite | 2 ++ validation/test-suite-file-expansion.c | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 validation/test-suite-file-expansion.c diff --git a/Documentation/test-suite b/Documentation/test-suite index e2ce7003..86bee335 100644 --- a/Documentation/test-suite +++ b/Documentation/test-suite @@ -35,6 +35,10 @@ check-known-to-fail (optional) input-file-1-start / input-file-1-end, / input-file-2-start/ ... (optional) The input files of check-command lies between those two tags. It's only needed when a test requires several files. + The '$file1', '$file2', ... strings are special. They will be expanded + at run time to the name of each of these files. These strings can be used + inside these input sections themselves, the check-command or the + check-output section. Using test-suite diff --git a/validation/test-suite b/validation/test-suite index 97d4dd40..8b0cd5e4 100755 --- a/validation/test-suite +++ b/validation/test-suite @@ -106,6 +106,7 @@ do_test() input_nr=1 while grep -q "input-file-$input_nr-start" "$file"; do sed -n "/input-file-$input_nr-start/,/input-file-$input_nr-end/p" "$file" \ + | sed "s:\\\$file\\([1-9]\\):$(basename $file).input\\1:" \ | grep -v input-file > "$file".input$input_nr eval "file$input_nr=$file.input$input_nr" input_nr=$(($input_nr + 1)) @@ -136,6 +137,7 @@ do_test() # grab the expected output sed -n '/check-output-start/,/check-output-end/p' $file \ + | sed "s:\\\$file\\([1-9]\\):$file.input\\1:" \ | grep -v check-output > "$file".output.expected sed -n '/check-error-start/,/check-error-end/p' $file \ | grep -v check-error > "$file".error.expected diff --git a/validation/test-suite-file-expansion.c b/validation/test-suite-file-expansion.c new file mode 100644 index 00000000..fc4ff8d5 --- /dev/null +++ b/validation/test-suite-file-expansion.c @@ -0,0 +1,22 @@ +/* input-file-1-start */ +const char file = __FILE__; +/* input-file-1-end */ + +/* input-file-2-start */ +int val = 0; +#include "$file1" +const char file = __FILE__; +/* input-file-2-end */ + +/* + * check-name: test-suite $file* expansion + * check-command: sparse -E $file1 $file2 + * + * check-output-start + +const char file = "$file1"; +int val = 0; +const char file = "$file1"; +const char file = "$file2"; + * check-output-end + */ -- 2.2.0