[Linux-kernel-mentees] [PATCH 30/30] tests: Add test case to detect a macrodecl attribute

Jaskaran Singh jaskaransingh7654321 at gmail.com
Sun May 24 17:19:35 UTC 2020


Macrodecl attributes are added to the SmPL and C ASTs. Add a test case
to detect a macrodecl attribute.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321 at gmail.com>
---
 tests/detect_macrodecl_attr.c     |  5 +++++
 tests/detect_macrodecl_attr.cocci | 12 ++++++++++++
 tests/detect_macrodecl_attr.res   |  5 +++++
 3 files changed, 22 insertions(+)
 create mode 100644 tests/detect_macrodecl_attr.c
 create mode 100644 tests/detect_macrodecl_attr.cocci
 create mode 100644 tests/detect_macrodecl_attr.res

diff --git a/tests/detect_macrodecl_attr.c b/tests/detect_macrodecl_attr.c
new file mode 100644
index 00000000..3dd89410
--- /dev/null
+++ b/tests/detect_macrodecl_attr.c
@@ -0,0 +1,5 @@
+#define __macro_attr MACROANNOTATION
+
+DECLARER(a, b) __macro_attr;
+
+DECLARER(a, b);
diff --git a/tests/detect_macrodecl_attr.cocci b/tests/detect_macrodecl_attr.cocci
new file mode 100644
index 00000000..70182f49
--- /dev/null
+++ b/tests/detect_macrodecl_attr.cocci
@@ -0,0 +1,12 @@
+ at r0@
+declarer name DECLARER;
+attribute name __macro_attr;
+@@
+
+DECLARER(
+	...,
+-	a
++	c
+	,
+	...
+  ) __macro_attr;
diff --git a/tests/detect_macrodecl_attr.res b/tests/detect_macrodecl_attr.res
new file mode 100644
index 00000000..6574a7ea
--- /dev/null
+++ b/tests/detect_macrodecl_attr.res
@@ -0,0 +1,5 @@
+#define __macro_attr MACROANNOTATION
+
+DECLARER(c, b) __macro_attr;
+
+DECLARER(a, b);
-- 
2.21.1



More information about the Linux-kernel-mentees mailing list