diff mbox

[i-g-t,1/2] lib: add some defines to help spatch parsing

Message ID 1427730818-29044-1-git-send-email-thomas.wood@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Wood March 30, 2015, 3:53 p.m. UTC
Add simple definitions for various macros to help spatch parse the
special igt control flow blocks and other macros correctly.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 lib/igt-spatch.h | 41 +++++++++++++++++++++++++++++++++++++++++
 lib/igt.cocci    |  6 +++---
 2 files changed, 44 insertions(+), 3 deletions(-)
 create mode 100644 lib/igt-spatch.h
diff mbox

Patch

diff --git a/lib/igt-spatch.h b/lib/igt-spatch.h
new file mode 100644
index 0000000..f9d53ea
--- /dev/null
+++ b/lib/igt-spatch.h
@@ -0,0 +1,41 @@ 
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+/* various macros to help spatch parsing */
+
+#error This header should only be used with spatch
+
+/* define igt control flow blocks as ordinary code blocks */
+#define igt_fixture
+#define igt_subtest(name)
+#define igt_subtest_f(f...)
+#define igt_fork(child, num_children)
+#define igt_fork_helper(proc)
+
+#define igt_main int main(int argc, char *argv)
+#define igt_simple_main int main(int argc, char *argv)
+
+/* the third parameter of timercmp is an operator, so needs to be defined as a
+ * macro to be parsed correctly */
+#define timercmp(a, b, CMP) (1)
diff --git a/lib/igt.cocci b/lib/igt.cocci
index 156f0cf..e7bef8d 100644
--- a/lib/igt.cocci
+++ b/lib/igt.cocci
@@ -1,7 +1,7 @@ 
-// Semantic patch for common patters and their replacement by igt infrastructure
-// and macros. Please run with
+// Semantic patch for common patterns and their replacement by igt
+// infrastructure and macros. Please run with
 //
-// spatch --sp-file lib/igt.cocci --in-place tests/*.c
+// spatch --sp-file lib/igt.cocci --macro-file lib/igt-spatch.h --in-place tests/*.c
 //
 // on your new testcase.