From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Josh Triplett <josh@joshtriplett.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
"Jason J. Herne" <jjherne@linux.vnet.ibm.com>,
Linux-Sparse <linux-sparse@vger.kernel.org>,
Sam Ravnborg <sam@ravnborg.org>
Subject: [PATCH 2/3] test-suite: allow filename expansion of the input sections
Date: Wed, 4 Feb 2015 04:11:45 +0100 [thread overview]
Message-ID: <20150204031144.GA8049@macpro.local> (raw)
In-Reply-To: <CANeU7Qn9ORJ=uH6szkW2FpTT8hFhdNETjxndBYa8347Z1iON0Q@mail.gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Suggested-by: Josh Triplett <josh@joshtriplett.org>
---
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
prev parent reply other threads:[~2015-02-04 3:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-22 20:31 sparse: new feature " multiple initializers" has false positives on MODULE_ALIAS Christian Borntraeger
2015-01-23 16:40 ` Christopher Li
2015-01-23 22:23 ` [PATCH] Teach sparse about the __COUNTER__ predefined macro Luc Van Oostenryck
2015-01-23 22:28 ` Sam Ravnborg
2015-01-23 22:38 ` josh
2015-01-23 23:59 ` Luc Van Oostenryck
2015-01-24 1:29 ` Josh Triplett
2015-01-24 11:27 ` Luc Van Oostenryck
2015-01-24 20:19 ` Josh Triplett
2015-01-24 20:39 ` Luc Van Oostenryck
2015-01-25 20:12 ` Christian Borntraeger
2015-01-28 10:08 ` Christian Borntraeger
2015-02-02 5:17 ` Christopher Li
2015-02-04 2:38 ` Luc Van Oostenryck
2015-02-12 20:16 ` Christopher Li
2015-02-04 2:46 ` [PATCH 1/3] test-suite: add support for tests case involving several input files Luc Van Oostenryck
2015-02-06 15:02 ` Christopher Li
2015-02-04 2:49 ` [PATCH 2/3] test-suite: allow filename expansion of the input sections Luc Van Oostenryck
2015-02-04 2:51 ` [PATCH 3/3] test-suite: consolidate tests that require include files into single test files Luc Van Oostenryck
2015-02-04 3:11 ` Luc Van Oostenryck [this message]
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=20150204031144.GA8049@macpro.local \
--to=luc.vanoostenryck@gmail.com \
--cc=borntraeger@de.ibm.com \
--cc=jjherne@linux.vnet.ibm.com \
--cc=josh@joshtriplett.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sam@ravnborg.org \
--cc=sparse@chrisli.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.