[Linux-kernel-mentees] [PATCH 26/27] tests: Add test case to detect a struct end attribute

Jaskaran Singh jaskaransingh7654321 at gmail.com
Sun May 31 15:26:20 UTC 2020


Struct end attributes are added to the SmPL and C ASTs. Add a test case
to detect a struct end attribute.

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

diff --git a/tests/detect_struct_endattr.c b/tests/detect_struct_endattr.c
new file mode 100644
index 00000000..240fcde9
--- /dev/null
+++ b/tests/detect_struct_endattr.c
@@ -0,0 +1,13 @@
+#define __struct_endattr MACROANNOTATION
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+} __struct_endattr;
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+};
diff --git a/tests/detect_struct_endattr.cocci b/tests/detect_struct_endattr.cocci
new file mode 100644
index 00000000..8b6ba797
--- /dev/null
+++ b/tests/detect_struct_endattr.cocci
@@ -0,0 +1,9 @@
+@@
+attribute name __struct_endattr;
+@@
+
+struct abcd {
+	...
+-	int b;
+	...
+} __struct_endattr;
diff --git a/tests/detect_struct_endattr.res b/tests/detect_struct_endattr.res
new file mode 100644
index 00000000..71002542
--- /dev/null
+++ b/tests/detect_struct_endattr.res
@@ -0,0 +1,12 @@
+#define __struct_endattr MACROANNOTATION
+
+struct abcd {
+	int a;
+	int c;
+} __struct_endattr;
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+};
-- 
2.21.1



More information about the Linux-kernel-mentees mailing list