[Linux-kernel-mentees] [PATCH 2/2] tests: Add test case for user comments attached to ident

Jaskaran Singh jaskaransingh7654321 at gmail.com
Fri Jan 10 17:11:50 UTC 2020


When comments were appended to an identifier passed from python to cocci or
ocaml to cocci, two cases showed pretty printing errors. Add a test case
for both of the erroneous cases.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321 at gmail.com>
---
 tests/id_comments.c     |  4 ++++
 tests/id_comments.cocci | 19 +++++++++++++++++++
 tests/id_comments.res   |  6 ++++++
 3 files changed, 29 insertions(+)
 create mode 100644 tests/id_comments.c
 create mode 100644 tests/id_comments.cocci
 create mode 100644 tests/id_comments.res

diff --git a/tests/id_comments.c b/tests/id_comments.c
new file mode 100644
index 00000000..b92f346b
--- /dev/null
+++ b/tests/id_comments.c
@@ -0,0 +1,4 @@
+foo () {
+	const void * const id;
+	pgd_t *__meminit id;
+}
diff --git a/tests/id_comments.cocci b/tests/id_comments.cocci
new file mode 100644
index 00000000..971616a5
--- /dev/null
+++ b/tests/id_comments.cocci
@@ -0,0 +1,19 @@
+@ r0 @
+type t;
+position p;
+@@
+t at p
+
+@ script:python r1 @
+id;
+@@
+coccinelle.id = "id/* user comment */"
+
+@ r2 @
+identifier r1.id;
+type r0.t;
+@@
+foo() {
+...
+++ t id;
+}
diff --git a/tests/id_comments.res b/tests/id_comments.res
new file mode 100644
index 00000000..b29ac113
--- /dev/null
+++ b/tests/id_comments.res
@@ -0,0 +1,6 @@
+foo() {
+	const void * const id;
+	pgd_t *__meminit id;
+	const void *const id/* user comment */;
+	pgd_t *__meminit id/* user comment */;
+}
-- 
2.21.1



More information about the Linux-kernel-mentees mailing list