203 Commits

Author SHA1 Message Date
Mika Kuoppala
2f2c491cf3 lib/drmtest: don't dup quiescent fd
If we dup the fd, we are in mercy of the context banning
of the test application. Better to have our own to guarantee
that gem_quiescent_gpu won't find itself banned on exit.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
2014-04-10 17:50:49 +03:00
Mika Kuoppala
bfa6fa9a4b lib: add igt_get_stop_rings and igt_set_stop_rings
Multiple tests are introducing hangs by fidding with i915_ring_stop
debugfs entry.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
2014-04-10 17:40:48 +03:00
Daniel Vetter
c6c2b2bb70 lib/igt_kms/bf: doc skeleton
igt_kms docs are just skeleton and also added igt_fb to make sure the
linking works correctly.

Next up: Actually documenting igt_fb.

Also fix that depency spelling fumble I've copied around to a few too
many places.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-26 18:50:28 +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
c03c6ceb29 lib: rename intel_gpu_tools.h to intel_io.h
With the header cleanup we can now give this header a suitable name,
since it now really only contains register access and other I/O
functions and assorted definitions.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22 21:34:29 +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
6cfcd71589 lib: remove uncessary #includes from headers
Only include what the header itself needs. The big fish here is
intel-gpu-tools.h. More will follow.

One ugly thing removed here is the duplicated GEN6_TD_CTL #define, one
of which was broken.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22 20:08:13 +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
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
Daniel Vetter
0d1084fe3f lib: install exit handler only on success for prefault control
Otherwise we'll hit an igt_skip in the exit handler, which upsets
the new in_fixture||in_subtests checks.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-02-12 00:07:19 +01:00
Damien Lespiau
3386b4b286 lib: Don't wait in igt_wait_for_keypress() if stdin is not a tty
When running in a non interactive terminal, there's little point in
trying to wait for some input on stdin.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-02-11 13:54:10 +00: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
Daniel Vetter
333a5c6f07 lib/drmtest: Fix up skip_henceforth checks
We need to first check whether we'll even run the testcase before
deciding to print a premature SKIP/FAIL. Without this and global
skipped resulted in superflous output when running only one testcase.

References: https://bugs.freedesktop.org/show_bug.cgi?id=74100
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-02-11 12:14:09 +01: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
Imre Deak
2423b6c04e lib/drmtest: fix hang in quiescent_gpu_at_exit due to signal-unsafe asprintf
I got kms_flip in hung state with the backtrace below, while the parent process
waiting for the signal helper to exit. It was quite easy to reproduce the bug
by running

kms_flip --run-subtest=flip-vs-dpms-off-vs-modeset

With the change I couldn't reproduce it.

TODO: audit/fix other signal handlers with signal-unsafe functions

0  0x00007f9a1362018b in ?? () from /lib/x86_64-linux-gnu/libc.so.6
1  0x00007f9a1359df81 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
2  0x00007f9a1359b6cf in ?? () from /lib/x86_64-linux-gnu/libc.so.6
3  0x00007f9a13628eb6 in __vasprintf_chk () from /lib/x86_64-linux-gnu/libc.so.6
4  0x00007f9a13628e72 in __asprintf_chk () from /lib/x86_64-linux-gnu/libc.so.6
5  0x000000000040a4a2 in asprintf (__fmt=0x417441 "/dev/dri/card%u", __ptr=0x7fff1a972c08)
    at /usr/include/x86_64-linux-gnu/bits/stdio2.h:178
6  drm_get_card () at drmtest.c:190
7  0x000000000040a54a in __drm_open_any () at drmtest.c:229
8  0x000000000040a846 in quiescent_gpu_at_exit (sig=<optimized out>) at drmtest.c:281
9  0x0000000000408759 in call_exit_handlers (sig=3) at drmtest.c:1519
10 fatal_sig_handler (sig=3) at drmtest.c:1543
11 <signal handler called>
12 0x00007f9a13596770 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
13 0x00007f9a135d8f3f in fork () from /lib/x86_64-linux-gnu/libc.so.6
14 0x000000000040b3af in __igt_fork_helper (proc=0x61d8cc <signal_helper>) at drmtest.c:1199
15 0x000000000040b4ce in igt_fork_signal_helper () at drmtest.c:751
16 0x0000000000404167 in main (argc=<optimized out>, argv=<optimized out>) at kms_flip.c:1533

v2:
- can't use snprintf as that's also signal-unsafe, so just use a dup'ed fd (Chris,Daniel)

Signed-off-by: Imre Deak <imre.deak@intel.com>
2014-02-05 15:28:45 +02:00
Chris Wilson
48ad03ca0c lib: Capture errno on entry
When printing the errno, it is important that we capture the user errno
before we make any library calls - as they may alter the value.

References: https://bugs.freedesktop.org/show_bug.cgi?id=74007
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-01-31 16:57:17 +00: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
Paulo Zanoni
329faeccf7 drmtest: don't leak memory when parsing the arguments
Found this while investigating memory leaks on kms_flip. Detected by
Valgrind.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2014-01-07 09:57:03 -02: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
f1c4ec936c lib: print uname information in the version string
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-10 09:26:08 +01:00
Daniel Vetter
831a47196d lib: Add host platform to version string
This is import on systems where we compile 32bit tests that run on
64bit platforms.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-10 09:23:44 +01:00
Ben Widawsky
8c33e9ad11 intel-gpu-tools: Version information
Provide two arguments version, and verbose, which allow printing from an
arbitrary igt test. It will show system information (from build time,
not runtime), as well as the git SHA being used.

This will help reduce errors when people try to reproduce problems.

As an example if I want to verify someone is running the correct version
of a test, I could ask them to do:
bwidawsk@ironside ~/intel-gfx/intel-gpu-tools (master)$ sudo ./tests/gem_exec_nop --verbose
gem_exec_nop-git-3c5423b (Linux ironside 3.12.0-1-ARCH #1 SMP PREEMPT
Wed Nov 6 09:06:27 CET 2013 x86_64 GNU/Linux)
Time to exec x 1:		 35.000µs (ring=render)
Time to exec x 2:		 28.000µs (ring=render)
Time to exec x 4:		 20.000µs (ring=render)
Time to exec x 8:		 14.625µs (ring=render)
Time to exec x 16:		 11.188µs (ring=render)
Time to exec x 32:		 11.125µs (ring=render)
Time to exec x 64:		 10.328µs (ring=render)
Time to exec x 128:		 10.172µs (ring=render)
Time to exec x 256:		 10.234µs (ring=render)
Time to exec x 512:		 10.232µs (ring=render)
Time to exec x 1024:		 10.121µs (ring=render)
Time to exec x 2048:		 10.151µs (ring=render)
Time to exec x 4096:		 11.474µs (ring=render)
Time to exec x 8192:		  9.432µs (ring=render)
Time to exec x 16384:		  6.003µs (ring=render)
Time to exec x 32768:		  5.029µs (ring=render)
Time to exec x 65536:		  4.206µs (ring=render)
Time to exec x 131072:		  3.630µs (ring=render)
Subtest render: SUCCESS

--verbose is provided for completeness, but doesn't seem too useful at
the moement.

bwidawsk@ironside ~/intel-gfx/intel-gpu-tools (master)$ sudo ./tests/gem_exec_nop --version
gem_exec_nop-git-3c5423b (Linux ironside 3.12.0-1-ARCH #1 SMP PREEMPT
Wed Nov 6 09:06:27 CET 2013 x86_64 GNU/Linux)

I've put version.h in the root directory so that any subdir can access
it. I've added the tests usage since it's immediately useful, and done
easily via Daniels igt infrastructure work.

v2:
- Always print the version number.
- We want to print uname at runtime.
- Also prefix the i-g-t release version.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net> (v1)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-10 09:23:40 +01:00
Daniel Vetter
ea8c086919 lib: Always print errno in igt assert/require macros
Useful to figure out why things have failed.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-10 08:07:11 +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
Mika Kuoppala
fb03ea7737 lib/drmtest: Fix filedesc leak on gem_quiescent_gpu
to not run out of filedescs as some tests call gem_quiescent_gpu
directly.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-04 13:23:01 +01:00
Tvrtko Ursulin
ab7cbf9737 Revert "lib/drmtest: ducttape over fork race"
This reverts commit a031a1bf93b828585e7147f06145fc5030814547.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Conflicts:
	lib/drmtest.c
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-03 17:57:27 +01:00
Daniel Vetter
b34322fd15 Revert "test/gem_concurrent_blt"
This reverts commit aee0dcb1ec2075991d310dd6f3fb5e50160847d1.

Oops, accidentally commit a bit of wip changes.
2013-12-03 17:57:06 +01:00
Tvrtko Ursulin
139c72f38a drmtest: Avoid wrong PID/TID after clone races
Various C library implementations have various races with regards
to caching getpid() or TID inside pthread_kill() implementations.

For example see clone(2) glibc man page and pthread_kill
Bionic C library source.

Work around that by making sure correct PID/TGID and TID values
are retrieved from the kernel when re-raising the signal. It
can be delivered immediately after the clone system call while C
library cached copies have not yet been updated.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-03 17:55:56 +01:00
Daniel Vetter
aee0dcb1ec test/gem_concurrent_blt
Limit working set size also with available ram.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72255
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-03 16:32:52 +01:00
Daniel Vetter
26b336f811 lib: Don't put functional code into asserts
Android apparently compiles with NDEBUG. Which is strongly advised
against, since the big pile of asserts mostly check correct usage of
the helper code in testcases.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-12-03 13:07:28 +01:00
Chris Wilson
38354ec4d8 drmtest: Fix weird signage on errno
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-12-03 10:13:43 +00: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
Daniel Vetter
2d1119dfc0 lib: adjust oom_score
This way the igt test will always be killed first (hopefully),
preventing mayhem when one of the memory thrashing tests treatens to
take down the entire system.

To avoid any burden on test writers we adjust the oom score on
drm_open, any of the fork helpers and subtest init. That should cover
everything.

v2: Fix it up.

Cc: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-14 18:14:38 +01:00
Oscar Mateo
235ff9cf34 lib/drmtest: Get the correct basename() under Android
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-12 12:16:03 +01: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
Oscar Mateo
aa252d0e00 lib/drmtest: Retire requests via drop caches after gem_quiescent_gpu
This helps make sure that the GPU is really quiescent by getting
rid of any residual stuff.

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-05 16:45:16 +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
Daniel Vetter
e14596a6d0 lib: fix igt_exit assert when only listing subtests.
Ooops. Reported by Paulo. Also add a new testcase for make check to
make sure this actually works.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-11-01 18:30:22 +01:00