@@ -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
@@ -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
new file mode 100644
@@ -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
+ */
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