summaryrefslogtreecommitdiff
path: root/lib/igt.cocci
blob: adebb31c0277cfe02f7440f1c3ce2427a27571fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Semantic patch for common patters and their replacement by igt infrastructure
// and macros. Please run with
//
// spatch --sp-file lib/igt.cocci --in-place tests/*.c
//
// on your new testcase.


// Replace open-coded augmented igt_assert/skip/require with macro versions
@@
expression Ec;
expression list[n] Ep;
@@
- if (Ec) {
(
- igt_warn( Ep );
|
- igt_info( Ep );
|
- igt_debug( Ep );
)
- igt_fail(...);
- }
+ igt_fail_on_f(Ec, Ep);
@@
expression Ec;
@@
- if (Ec) {
- igt_fail(...);
- }
+ igt_fail_on(Ec);
@@
expression Ec;
expression list[n] Ep;
@@
- if (Ec) {
- igt_skip(Ep);
- }
+ igt_skip_on_f(Ec, Ep);
@@
expression Ec;
expression list[n] Ep;
@@
- if (Ec) {
- igt_warn(Ep);
- }
+ igt_warn_on_f(Ec, Ep);

// Enforce use of logging functions
@@
expression list[n] Ep;
@@
-fprintf(stderr, Ep);
+igt_warn(Ep);
@@
expression E;
@@
-perror(E);
+igt_warn(E);
@@
expression list[n] Ep;
@@
-fprintf(stdout, Ep);
+igt_info(Ep);
@@
expression list[n] Ep;
@@
-printf(Ep);
+igt_info(Ep);

// No abort for tests, really. Should only be used for internal library checks
// in lib/*
@@
@@
-abort();
+igt_fail(1);

@@
iterator name for_each_pipe;
igt_display_t *display;
expression pipe;
@@
- for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++) {
+ for_each_pipe (display, pipe) {
...
}

// Tests really shouldn't use plain assert!
@@
expression E;
@@
- assert(E);
+ igt_assert(E);