ntel-gpu-tools/lib/igt.cocci
Daniel Vetter 2eca38eab9 lib/igt_aux: s/swap/igt_swap/
It collides with the subtest naming convention glossary entry for swap.
Which makes the docbook xml stuff unhappy.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-13 09:35:36 +01:00

144 lines
1.9 KiB
Plaintext

// 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);
// Replace open-coded igt_swap()
@@
type T;
T a, b, tmp;
@@
- tmp = a;
- a = b;
- b = tmp;
+ igt_swap(a, b);
// Replace open-coded min()
@@
expression a;
expression b;
@@
(
- ((a) < (b) ? (a) : (b))
+ min(a, b)
|
- ((a) <= (b) ? (a) : (b))
+ min(a, b)
)
// Replace open-coded max()
@@
expression a;
expression b;
@@
(
- ((a) > (b) ? (a) : (b))
+ max(a, b)
|
- ((a) >= (b) ? (a) : (b))
+ max(a, b)
)
// drm_open_any always returns a valid file descriptor
@@
expression a;
@@
a = drm_open_any();
(
- igt_assert(a >= 0);
|
- if (a < 0) {
- ...
- return ...;
- }
)