[PATCH] test-suite: integrate unhandled proprocessor tests

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

 



Instrument validate/preprocessor/preproprocessor*.c to be integrated
into the test-suite where missing and add an additional test case.

Signed-off-by: Hannes Eder <hannes@xxxxxxxxxxxxxx>
---

It's a little bit unclear to me how to deal with preprocessor14.c.
Sparse and cpp disagree on the output to produce.

$ sparse -E preprocessor14.c > preprocessor14.sparse
$ cpp -P preprocessor14.c > preprocessor14.cpp
$ diff -u preprocessor14.cpp preprocessor14.sparse
|> --- preprocessor14.cpp	2009-03-11 01:08:34.000000000 +0100
|> +++ preprocessor14.sparse	2009-03-11 01:05:39.000000000 +0100
|> @@ -1,9 +1,2 @@
|>
|> -
|> -
|> -
|> -
|> -
|> -
|> -
|> -
|> +,

Ok there is a difference in the number of empty lines, who cares, but
spares outputs a "," and cpp does not.

Could somebody with more insight comment on this?  Al? :)

Meanwhile I marked this test as "check-known-to-fail".

 validation/preprocessor/preprocessor11.c |   21 ++++++++++++++++++
 validation/preprocessor/preprocessor12.c |   11 +++++++++
 validation/preprocessor/preprocessor13.c |   16 ++++++++++++++
 validation/preprocessor/preprocessor14.c |   10 +++++++++
 validation/preprocessor/preprocessor15.c |    9 ++++++++
 validation/preprocessor/preprocessor16.c |    9 ++++++++
 validation/preprocessor/preprocessor22.c |   35 ++++++++++++++++++++++++++++++
 validation/preprocessor/preprocessor7.c  |    9 ++++++++
 validation/preprocessor/preprocessor8.c  |   22 +++++++++++++++++++
 9 files changed, 142 insertions(+), 0 deletions(-)
 create mode 100644 validation/preprocessor/preprocessor22.c

diff --git a/validation/preprocessor/preprocessor11.c b/validation/preprocessor/preprocessor11.c
index 4c6c1c0..4b37664 100644
--- a/validation/preprocessor/preprocessor11.c
+++ b/validation/preprocessor/preprocessor11.c
@@ -8,3 +8,24 @@
 #define H(x...,y)
 #define I(...+
 #define J(x,y)
+/*
+ * check-name: Preprocessor #11
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/preprocessor11.c:1:11: error: "1" may not appear in macro parameter list
+preprocessor/preprocessor11.c:2:11: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:3:12: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:4:11: error: parameter name missing
+preprocessor/preprocessor11.c:5:11: error: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro
+preprocessor/preprocessor11.c:6:12: error: "+" may not appear in macro parameter list
+preprocessor/preprocessor11.c:7:12: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:8:12: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:9:11: error: missing ')' in macro parameter list
+ * check-error-end
+ */
diff --git a/validation/preprocessor/preprocessor12.c b/validation/preprocessor/preprocessor12.c
index 385c1a7..e23e53b 100644
--- a/validation/preprocessor/preprocessor12.c
+++ b/validation/preprocessor/preprocessor12.c
@@ -5,3 +5,14 @@
 A(1)
 A(1,2)
 A(1,2,3)
+/*
+ * check-name: Preprocessor #12
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+1
+1,2
+1,2,3
+ * check-output-end
+ */
diff --git a/validation/preprocessor/preprocessor13.c b/validation/preprocessor/preprocessor13.c
index 96c813e..b1af855 100644
--- a/validation/preprocessor/preprocessor13.c
+++ b/validation/preprocessor/preprocessor13.c
@@ -5,3 +5,19 @@
 A(1)
 A(1,2)
 A(1,2,3)
+/*
+ * check-name: Preprocessor #13
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+1
+1,2
+1,2,3
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/preprocessor13.c:6:1: error: '##' failed: concatenation is not a valid token
+preprocessor/preprocessor13.c:7:1: error: '##' failed: concatenation is not a valid token
+ * check-error-end
+ */
diff --git a/validation/preprocessor/preprocessor14.c b/validation/preprocessor/preprocessor14.c
index 001f1f2..05fc248 100644
--- a/validation/preprocessor/preprocessor14.c
+++ b/validation/preprocessor/preprocessor14.c
@@ -5,3 +5,13 @@
 A(,1)
 #define B(x,y,...) x##,##__VA_ARGS__
 B(,1)
+/*
+ * check-name: Preprocessor #14
+ * check-known-to-fail
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ */
diff --git a/validation/preprocessor/preprocessor15.c b/validation/preprocessor/preprocessor15.c
index 0a2dfd7..df87751 100644
--- a/validation/preprocessor/preprocessor15.c
+++ b/validation/preprocessor/preprocessor15.c
@@ -5,3 +5,12 @@
 #if D(A,B) B
 D(1,2)
 #endif
+/*
+ * check-name: Preprocessor #15
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+12
+ * check-output-end
+ */
diff --git a/validation/preprocessor/preprocessor16.c b/validation/preprocessor/preprocessor16.c
index e3bd0d9..75a4a0b 100644
--- a/validation/preprocessor/preprocessor16.c
+++ b/validation/preprocessor/preprocessor16.c
@@ -19,3 +19,12 @@ they hit before we get to the level of groups.
 #bullshit
 
 #endif
+/*
+ * check-name: Preprocessor #16
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ */
diff --git a/validation/preprocessor/preprocessor22.c b/validation/preprocessor/preprocessor22.c
new file mode 100644
index 0000000..af5bcb3
--- /dev/null
+++ b/validation/preprocessor/preprocessor22.c
@@ -0,0 +1,35 @@
+#define CONFIG_FOO 1
+
+#define define_struct(name, fields...) struct fields name;
+
+define_struct(a, {
+#ifdef CONFIG_FOO
+  int b;
+#elif defined(CONFIG_BAR)
+  int c;
+#else
+  int d;
+#endif
+});
+/*
+ * check-name: Preprocessor #22
+ *
+ * check-description: Directives are not allowed within a macro argument list,
+ * although cpp deals with it to treat macro more like C functions.
+ *
+ * check-command: sparse -E $file
+ *
+ * check-error-start
+preprocessor/preprocessor22.c:6:1: error: directive in argument list
+preprocessor/preprocessor22.c:8:1: error: directive in argument list
+preprocessor/preprocessor22.c:10:1: error: directive in argument list
+preprocessor/preprocessor22.c:12:1: error: directive in argument list
+ * check-error-end
+ *
+ * check-output-start
+
+struct {
+int b;
+} a;;
+ * check-output-end
+ */
diff --git a/validation/preprocessor/preprocessor7.c b/validation/preprocessor/preprocessor7.c
index e7e1d37..07fce8c 100644
--- a/validation/preprocessor/preprocessor7.c
+++ b/validation/preprocessor/preprocessor7.c
@@ -3,3 +3,12 @@
 #define C(x,y) E(y)
 #define E(y) #y
 A(2))
+/*
+ * check-name: Preprocessor #7
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+"\"D\""
+ * check-output-end
+ */
diff --git a/validation/preprocessor/preprocessor8.c b/validation/preprocessor/preprocessor8.c
index 861dfe5..524825c 100644
--- a/validation/preprocessor/preprocessor8.c
+++ b/validation/preprocessor/preprocessor8.c
@@ -14,3 +14,25 @@
 "x#y"			: E
 "ab GH \"G\" 12"	: F(G,H)
 "a ## b"		: I(a,##,b)
+/*
+ * check-name: Preprocessor #8
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+"A(x)" : A(x)
+"B(x)" : B(x)
+"C(x)" : C(x)
+"D(x)" : D(x)
+"x#y" : x#y
+"ab GH \"G\" 12" : ab GH "G" 12
+"a ## b" : a ## b
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/preprocessor8.c:1:14: error: '##' cannot appear at the ends of macro expansion
+preprocessor/preprocessor8.c:2:16: error: '##' cannot appear at the ends of macro expansion
+preprocessor/preprocessor8.c:3:22: error: '##' cannot appear at the ends of macro expansion
+preprocessor/preprocessor8.c:4:15: error: '#' is not followed by a macro parameter
+ * check-error-end
+ */

--
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