130 Commits

Author SHA1 Message Date
Daniel Stone
c8cec6b885 lib/drmtest: Add do_ioctl_err to expect failure
do_ioctl demands that the ioctl returns success; add a variant named
do_ioctl_err, which expects the ioctl to fail, and demands a particular
result.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2015-10-07 17:57:26 +01:00
Micah Fedke
f91e93fa40 lib: remove support for deprecated drm_open_any*() calls
Signed-off-by: Micah Fedke <micah.fedke@collabora.co.uk>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-09-11 14:39:43 +01:00
Micah Fedke
e2241805a4 lib: adding drm_open_driver() interface
The drm_open_driver*() functions replace the drm_open_any*() functions and
provide the same utility, but in a way that is platform agnostic, not
intel-specific.  This opens the path for adopting intel-gpu-tools to non-intel
platforms.

This commit renames the calls and adds the chipset parameter which can be used
to restrict the opening to a specific hardware family.  For example,
drm_open_driver(DRIVER_INTEL) will only return a valid fd if an intel GPU is
found on the system, along with performing intel-specific initialization stuff
like gem_quiescent_gpu(), et al.  If OPEN_ANY_GPU is specified, the first
available drm device of any type will be opened.

Other hardware type flags may be added in the future.

The drm_open_any*() calls are retained as aliases of
drm_open_driver*(OPEN_ANY_GPU) but will be removed in a subsequent patch.

Signed-off-by: Micah Fedke <micah.fedke@collabora.co.uk>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-09-11 14:39:43 +01:00
Tim Gore
52888df084 lib/drmtest.h : fix mmap64 again
In android mmap64 was redirected to mmap2 because mmap64
was not alway available. But now mmap2 has been removed
from 64 bit android builds (and mmap64 is available), so
update preprocessor conditional to check for __x86_64__.

Signed-off-by: Tim Gore <tim.gore@intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-04-22 18:00:42 +01:00
Chris Wilson
a29f28eba9 igt/drv_module_reload: Check more carefully for a live driver
As drm_open_any() now quietly fails if there is no driver, this
nullifies the effectiviness of using gem_exec_nop as the test for a good
reload. Combine with gem_alive (and guarantee that gem_alive can detect
a dead driver, putting lie to

commit 032f30cb38bb03562ee7fde19cd278b1d8ac31a9
Author: Thomas Wood <thomas.wood@intel.com>
Date:   Tue Jan 13 13:33:57 2015 +0000

    lib: remove unnecessary checks on the drm_open_any return value

) first.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88573
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-01-19 09:47:03 +00:00
Imre Deak
bfda78cd33 tests/pm_rpm: factor out drm_open_any_master
Signed-off-by: Imre Deak <imre.deak@intel.com>
2014-09-30 16:44:50 +03:00
Chris Wilson
b918a3ba15 Reset errno to 0 after success
errno is only valid after a syscall wrapper (e.g. ioctl()) reports an
error. However, we report the last errno value as a part of the
igt_assert() output and so we display spurious values such as:

Test requirement not met in function gem_require_ring, file ioctl_wrappers.c:802:
Last errno: 11, Resource temporarily unavailable
Test requirement: (!((((intel_get_drm_devid(fd)) == 0x0102 || ...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-04-25 07:45:56 +01:00
Tvrtko Ursulin
dc14bf455d tests: Extract ALIGN macro into a common header
Makes for a little bit less code duplication, especially since
it will be used from more callers in the future.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Brad Volkin <bradley.d.volkin@intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-04-24 13:49:19 +01:00
tgore
a96c634076 intel-gpu-tools: fix problem with redefinition of mmap64
In android builds there is no reliable way to determine if mmap64 is defined
or not, and this sometimes leads to a compile error due to its re-defnition.
So this commit avoids its use altogether in intel-gpu-tools for Android builds,
unless the HAVE_MMAP64 macro is defined.

Signed-off-by: Tim Gore <tim.gore@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-28 17:50:41 +01:00
Daniel Vetter
187b66da09 lib/drmtest: api documentation
Also rename the arguments of do_ioctl a bit for better clarity.

I haven't figured out a way to reference other section headers, hence
the links to igt_core and intel_batchbuffer are a bit fragile
unfortunately. It gets the job done though.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-23 15:03:50 +01:00
Daniel Vetter
f5daeec724 lib: extract igt_aux.[hc]
And shovel all the various helpers in there.

Also move igt_set_vt_graphics_mode to igt_kms.h since the function is
implemented in igt_kms.c. And it fits better. I kinda missed this in
the prep work.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-23 13:47:09 +01:00
Daniel Vetter
018f8c3c45 lib: s/drmtest_dumb_aub/igt_aub_dump_enabled/
This is prep work to extract a new igt aux library with all kinds
of random stuff. Also give it a bit a more suitable name to
indicate that this is just a flag and doesn't do the aub dumping
itself.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22 22:42:35 +01:00
Daniel Vetter
254f19ba8d lib: unnecessary header removal for drmtest.h, part 2
I've left unistd.h in it - it's not strictly required but most users
of drmtest.h want it for the open helpers, and then you kinda need to
close that file descriptor again ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22 21:29:01 +01:00
Daniel Vetter
e49ceb8690 lib: unnecessary header removal for drmtest.h, part 1
Brought a few missing headers to light in ioctl_wrappers.h, too.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22 21:07:37 +01:00
Daniel Vetter
0e22f14ed6 tests|lib: remove assert.h includes
Only the igt core and non-test tools should have asserts to catch
internal errors, tests and helper libraries should all user igt_asert
instead.

Fix things up where assert instead of igt_assert was used.

One tiny step towards header sanity.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22 19:39:46 +01:00
Daniel Vetter
bff22f7317 lib: Move non-register things out of intel-gpu-tools.h
Right now almost everything in there concerns itself with register
access. Move everything else out (into drmtest.h for lack of better
place) to prepare for api documentation.

Also rename intel_drm.c to intel_os.c since it contains OS, not
drm abstractions.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22 19:39:37 +01:00
Daniel Vetter
adb28fd71d lib: move prefault helpers to igt_debugfs.c
This way all debugfs library code is in one place, ready for some api
documentation care.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-12 21:22:31 +01:00
Daniel Vetter
d63fe1519d lib: extract igt_core.c
Same game as with ioctl_wrappers.c.

To split was rather clean except for the static function
oom_adjust_for_doom. But that was a bug, the calls to it in the
various open helpers should simply be done at init and fork time.
Which was already the case, except for simple testcase.  So fix it up.

While at it also start with a small section header for the
documentation.

v2: Don't forget to update the xml template ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-12 16:39:39 +01:00
Daniel Vetter
556c49f20b lib/ioctl_wrappers: api doc
Also some tiny polish to function interface:
- @caching in gem_set_tiling should be uint32_t to match the ioctl
  struct.
- s/size/length/ for gem_write/read.
- move gem_get_num_rings to the other ring feature helpers.

v2: Also demote gem_require_ring from static inline and move it, too.

v3: Also move gem_handle_to_libdrm_bo.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-12 16:39:39 +01:00
Daniel Vetter
766c5bc6ae lib: extract ioctl_wrappers.c
I want to group the ioctl wrappers and related functions into their
own documentation section.

Apparently gtkdoc refuses to obey this wish without a corespdonding
header. So appease it. Also gtkdoc seems to struggle with rebuilding a
bit ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-11 22:58:07 +01:00
Thomas Wood
2d4438605e drmtest: reformat the API documentation
Make the existing documentation compatible with gtk-doc.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-11 17:19:47 +01:00
Daniel Vetter
eebdf7f920 lib: (somewhat) structured logging support
Apparently there's a bit a need for more verbose output in testcases,
mostly for debugging purposes. At least gem_reset_stats and pm_rps
have a verbose mode.

On top of that we're currently not taking advantage of piglit's "warn"
state all that much. But I think it might be useful for testcases which
are notorious for some kinds of spurious failures, like e.g. the really
nasty timing checks in kms_flip. If we demote some of them to just
warnings we could run the overall tests more often.

Hence this patchs adds a new igt_log function with the three levels DEBUG,
INFO and WARN. Plus a bunch of convenience helpers to keep the test
code tidy.

The level can be set through an enviroment vairable IGT_LOG_LEVEL with
info being the default. Also tests can look at the selected log level in
case they want to run costly debug functions only when needed.

Comments highly welcome, I plan to roll this out over tests which can
use it (not all, imo that's too much churn) once we've settled on the
interfaces/semantics.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-02-13 14:41:40 +01:00
Daniel Vetter
a036959f3e lib: Make igt_skip noreturn
This is a remnant from the subtest code before we had proper
fixture blocks. With those there's no no reason to have igt_skip
calls outside of fixtures or subtests, so we can assert this and
hence always jump out.

Suggested by Thomas Wood since static analyzers got confused about
this.

To check for fallout I've run all tests as non-root so that they'll
all skip. Only very little fallout resulted.

Cc: Thomas Wood <thomas.wood@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-02-12 00:07:19 +01:00
Damien Lespiau
377f48afe6 lib: Add a helper to wait for a keypress
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-02-11 13:50:16 +00:00
Jeff McGee
fd3fcbd3b3 lib/drmtest: Add igt_wait_helper
igt_wait_helper compliments igt_stop_helper and is used when helper
processes are expected to exit naturally.

Signed-off-by: Jeff McGee <jeff.mcgee@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-02-06 07:45:53 +01:00
Daniel Vetter
7d2ba073ad lib: add __gem_create
Useful for when a gem_create ioctl is expected to fail.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-01-19 22:13:36 +01:00
Daniel Vetter
862de5636f lib: extract igt_drop_root
Useful in other tests.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-01-19 22:06:48 +01:00
Daniel Vetter
ef9745b7fa lib: igt_simple_main/init for subtest-less tests
Atm only used to print the version information.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-10 09:41:48 +01:00
Daniel Vetter
1a95c710f9 lib: add gem_available_aperture_size helper
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-05 15:50:43 +01:00
Ville Syrjälä
49f4860d5c lib: Add gem_bo_busy
Move gem_bo_busy() from gem_wait_render_timeout.c to lib.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2013-11-27 16:21:28 +02:00
Ville Syrjälä
525788a736 lib: Add gem_sw_finish()
Wrap DRM_IOCTL_I915_GEM_SW_FINISH into gem_sw_finish()

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2013-11-27 16:21:28 +02:00
Oscar Mateo
5032e7bbdd build: Fix assorted compilation warnings
As these files are compiled for every test, the warnings cluttered
the Android build completely.

v2: As suggested by Daniel Vetter, drop some of the fixes and fix
the compilation flags instead.

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-12 12:05:55 +01:00
Oscar Mateo
37f26d17b1 lib: Move kms stuff from drmtest.c over to igt_kms.c
This makes cairo dependencies easier to handle. Otherwise, we
would have to litter drmtest all over with "#ifndef ANDROID"

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
[danvet: Add missing _GNU_SOURCE to igt_kms.c and missing include to
intel_sprite_on.c]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-12 12:04:12 +01:00
Daniel Vetter
071e9ca1ca lib: add igt_main macro
In the past new testcases with subtest often forgot to add the call to
igt_exit at the end of their main() function. That is now caught with
a bit more obnoxious asserts, but it's still a nuissance.

This little igt_main macro takes care of that (and also of calling the
subtest machinery initialization code correctly).

If no one objects I'll roll this out for all the simple cases (i.e.
those tests that don't have additional argv parsing on top of the
subtest machinery).

v2: Roll it out across the board.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-01 21:10:59 +01:00
Daniel Vetter
223a61e12e lib: make igt_install_exit_handler never fail
Most callers didn't bother checking, so just move the asserts into
the function itself.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-01 21:10:59 +01:00
Daniel Vetter
1f0cf2df85 lib: make igt_set_vt_graphics_mode never fail
All tests agree that this is a letal failure, so no point
to pass it back to callers.

Also add some igt_require calls for the drm_fd where I've
noticed that it's missing.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-01 21:10:59 +01:00
Damien Lespiau
69c200b0bb lib: Add a drm_open_any_render() that will try to use render nodes
I was fedup with having to run my tests as root and not being able to
use my usual setup for tests that only exercise the GT part of the GPU.

Render nodes to the rescue!

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-10-28 11:00:07 +00:00
Ville Syrjälä
471ec64de8 lib/drmtest: Add kmstest_paint_color_alpha()
kmstest_paint_color_alpha() just like kmstest_paint_color() except you
also get to specify the alpha channel.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2013-10-21 20:00:32 +03:00
Damien Lespiau
09e9f0b216 rendercopy: Add a way to dump an .aub file with the rendercopy bos
v2 (by Ben): Remove libdrm dependency since intel-gpu-tools now requires
a higher version anyway. Remove associated #ifdef ENABLE_AUB_DUMP

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Ben Widawsky <benjamin.widawsky@intel.com>
2013-10-18 09:49:41 -07:00
Damien Lespiau
252dca1c7b lib: Add kmstest_paint_color()
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-10-15 19:32:09 +01:00
Damien Lespiau
5a97ea91e1 lib: Add a igt_assert_cmpint()
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-10-15 19:02:08 +01:00
Daniel Vetter
ffdece38e2 tests/gem_suspend: test debugfs/sysfs reads while s/r
Just a very quick hack cobbled together with /bin/sh and exec. We
can't use system since that does stupid things with singals ... Still
we need to whack the child process pretty hard to get rid of it.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-10-10 14:20:43 +02:00
Daniel Vetter
590f610140 lib/drmtest: extract rawer __gem_set_tiling
For tests that expect failures. Also apply the existing gem_set_tiling
helper a bit wider.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-10-09 20:50:50 +02:00
Damien Lespiau
a7d1937cd7 testdisplay: Use DRM_MODE_FLAG_3D_MASK
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-09-30 18:04:22 +01:00
Damien Lespiau
79f4cfedbf lib: Add a helper to write a png from a struct kmstest_fb
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-09-30 18:04:21 +01:00
Damien Lespiau
bde7060e3c lib: Add a helper to paint a PNG using cairo
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-09-30 18:04:21 +01:00
Damien Lespiau
30e0710ca3 lib: Dump information about the supported 3D stereo formats
When dumping the details of a mode, let's add the 3D formats the mode
supports.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-09-30 18:04:21 +01:00
Daniel Vetter
e5cdd62624 lib/drmtest: igt_assert|require with format strings
v2: Add a comment about the pitfalls around va_list handling.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-19 19:40:32 +02:00
Daniel Vetter
e73c1a07f3 lib/drmtest: consolidate the helper process killing in one exit handler
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-10 18:22:17 +02:00
Daniel Vetter
edd723457c lib/drmtest: create helpers for forking helper threads
The upshot is that we can share the logic to make sure the helpers
are all properly stoved again in a 2nd step.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-10 17:40:06 +02:00