18 Commits

Author SHA1 Message Date
Daniel Stone
668c053e6a lib/igt.cocci: De-opencode ioctls
Use do_ioctl and do_ioctl_err where possible.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2015-10-07 17:57:26 +01:00
Daniel Stone
31821fce59 lib/igt.cocci: Add greater-than to igt_assert_lt*
Change m >= n patterns to igt_assert_lte(n, m), and ditto for strict
greater-than.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2015-10-07 17:57:26 +01:00
Thomas Wood
aa6c63463f igt.cocci: don't use igt_assert_neq to compare pointers
igt_assert_neq can only compare integers, not pointers.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-05-14 17:01:57 +01:00
Thomas Wood
b47032e191 lib: add a define for test failure exit status
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-04-14 17:43:05 +01:00
Thomas Wood
47f6b1305c igt.cocci: check the return values of various functions
Add rules to fix unused-result warnings when compiling with
_FORTIFY_SOURCE defined and apply them to the library and tests.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-03-26 15:50:59 +00:00
Matt Roper
07be8fec15 igt.cocci: Replace igt_assert() with igt_assert_CMP() where possible
The integer comparison macros give us better error output by including
the actual values that failed the comparison.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-03-06 18:06:10 +01:00
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
Thomas Wood
032f30cb38 lib: remove unnecessary checks on the drm_open_any return value
drm_open_any always returns a valid file descriptor, so there is no need
to check the return value.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-01-15 12:23:04 +00:00
Ville Syrjälä
e1bdab9973 lib/igt.cocci: Deal with min/max/swap
Replace open coded min/max/swap with the macro invocation.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2014-12-08 19:26:39 +02:00
Daniel Vetter
428060c555 lib/igt.cocci: Add s/assert/igt_assert/
People use it way too often, and it upsets the test library. The only
valid places to use this is of igt infrastructure self-tests where you
need to check something _without_ all the other abi use checks
igt_fail and friends do. For those tests just #define an internal
assert to hide it.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-07-15 10:23:20 +02:00
Daniel Vetter
8bf115ed99 lib/igt.cocci: Add stanza for for_each_pipe
Damien dodged this ...

Also run the script while at it.

v2: Don't just capture identifiers for pipe, but also expressions.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-07-11 17:43:22 +02:00
Daniel Vetter
87042d671f NEWS: Mention igt.cocci
And also pimp the spatch file itself with usage hints.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-06-13 18:14:13 +02:00
Daniel Vetter
2347e6d21e lib: Introduce igt_fail_on/_f
I've yet again totally screwed things up (this time automated with
cocci even, but not yet pushed luckily). So finally add a new version
for easier conversion and adjust the cocci script.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-06-13 18:14:13 +02:00
Daniel Vetter
46811c849a lib/igt.cocci: Also add rule to use igt_warn_on_f
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-06-13 18:12:42 +02:00
Daniel Vetter
9eb9345f99 lib/igt.cocci: Convert abort() to igt_fail
abort should only be used for internal library checks - using
abort() we get a "crash" result, using igt_fail we get "fail"
in piglit.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-06-13 18:12:42 +02:00
Daniel Vetter
bde52d1a08 lib/igt.cocci: Conversion to igt logging
Also update old hunks to match on igt logging instead of fprintf.

v2: Don't forget about perror.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-06-13 18:12:36 +02:00
Daniel Vetter
6b73a9a288 tests: Don't use stderr for informational messages
These should go to stdout instead. The next patch will clean this up
with cocci, so no change from fprintf(stdout, to printf( here.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-06-13 18:09:05 +02:00
Daniel Vetter
66b31b6e19 lib: add igt.cocci
Small start but useful to collect refactorings/simplifications for
common igt patterns. Please add more if you stumble over some so that
we can occasionally run this to clean up the tests.

I haven't figured out yet how to do the assert_cmpint->assert_eq
transformation.

Run this with

spatch --sp-file lib/igt.cocci --in-place tests/*.c

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-06-13 11:17:22 +02:00