[20/33] cocci: Split out assert() rules

Submitted by Lyude Paul on June 10, 2019, 3:03 p.m.

Details

Message ID 20190610150321.512-20-lyude@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in IGT - Trybot

Not browsing as part of any series.

Commit Message

Lyude Paul June 10, 2019, 3:03 p.m.
From: Lyude Paul <lyude@redhat.com>

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 scripts/cocci/igt.cocci           | 17 -----------------
 scripts/cocci/igt_no_assert.cocci | 20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 17 deletions(-)
 create mode 100644 scripts/cocci/igt_no_assert.cocci

Patch hide | download patch | download mbox

diff --git a/scripts/cocci/igt.cocci b/scripts/cocci/igt.cocci
index 4628e3ab..84df03ca 100644
--- a/scripts/cocci/igt.cocci
+++ b/scripts/cocci/igt.cocci
@@ -31,23 +31,6 @@  def warn_cmp_macro(p, type_prefix, op, e1, e2):
     msg = 'WARNING: igt_assert_%s%s(%s, %s) should be used instead' % args
     coccilib.report.print_report(p[0], msg)
 
-// Tests and test libraries really shouldn't use plain assert!
-@depends on report && file in "tests/"@
-expression E;
-@@
-- assert(E);
-+ igt_assert(E);
-
-@no_assert_report depends on report && file in "tests/"@
-position p;
-@@
-assert@p(...);
-
-@script:python depends on report@
-p << no_assert_report.p;
-@@
-coccilib.report.print_report(p[0], "ERROR: plain assert() calls are not allowed")
-
 // Replace open-coded igt_swap()
 @depends on patch@
 type T;
diff --git a/scripts/cocci/igt_no_assert.cocci b/scripts/cocci/igt_no_assert.cocci
new file mode 100644
index 00000000..6f4f876a
--- /dev/null
+++ b/scripts/cocci/igt_no_assert.cocci
@@ -0,0 +1,20 @@ 
+// Tests and test libraries really shouldn't use plain assert!
+
+virtual patch
+virtual report
+
+@depends on report && file in "tests/"@
+expression E;
+@@
+- assert(E);
++ igt_assert(E);
+
+@no_assert_report depends on report && file in "tests/"@
+position p;
+@@
+assert@p(...);
+
+@script:python depends on report@
+p << no_assert_report.p;
+@@
+coccilib.report.print_report(p[0], "ERROR: plain assert() calls are not allowed")