summaryrefslogtreecommitdiff
path: root/lib/igt_core.c
AgeCommit message (Collapse)Author
2014-10-01lib/igt_core.c: disable lowmemorykiller during testsTim Gore
Several IGT tests cycle through a lot of GEM memory and when running these tests on Android they tend to get killed by the lowmemorykiller. The lowmemorykiller really is not usefull in this context and is just preventing the test from doing its job. This commit adds a function to disable the lowmemorykiller by writing "9999" to its oom adj parameter, which means it will never "select" any process to kill. The normal linux oom killer is still there to protect the kernel. The low memory killer is disabled during the common init function and then re-enabled by the exit handler. To make this work for single tests the exit handler is now installed in the common init function also so that it is invoked for all tests. This is just a hack to get round the fact that the i915 driver uses the concept of purgeable memory which is not understood by the lowmemorykiller. If this ever gets fixed then this patch can be removed. Signed-off-by: Tim Gore <tim.gore@intel.com> [danvet: A bit of polish (coding style, static and rename check_igt_exit to common_exit_handler, drop the is_disabled check since we only call this once now).] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-09-30lib: ensure any buffers are flushed before forkThomas Wood
Flush any buffers before forking to prevent duplicated output. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-09-30doc: various spelling and typo fixesThomas Wood
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-09-29lib/igt_core: make single/simple tests use igt_exitTim Gore
Currently tests that use igt_simple_main will simply call "exit()" if they pass, making it difficult to ensure that any required cleanup is done. At present this is not an issue, but it will be when I submit a patch to turn off the lowmemorykiller for all tests. Signed-off-by: Tim Gore <tim.gore@intel.com> [danvet: Also update api docs.] Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2014-09-06core: Display subtest walltimeChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-09-04igt_core: zero exit_handler_count before forkingPaulo Zanoni
If we don't reset exit_handler_count before forking, we may have a case where the forked process is killed before it even does "exit_handler_count = 0": in that case, it is still finishing forking. When that happens, we may end up calling our exit handlers. On the specific bug I'm investigating, we call igt_reset_connnectors(), which ends up in a deadlock inside malloc_atfork. If we attach gdb to the forked process and get a backtrace, we have: (gdb) bt 0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 1 0x00007f15634d36bf in _L_lock_10524 () from /lib/x86_64-linux-gnu/libc.so.6 2 0x00007f15634d12ef in malloc_atfork (sz=139729840351352, caller=<optimized out>) at arena.c:181 3 0x00007f15640466a1 in drmMalloc () from /usr/lib/x86_64-linux-gnu/libdrm.so.2 4 0x00007f1564049ad7 in drmModeGetResources () from /usr/lib/x86_64-linux-gnu/libdrm.so.2 5 0x0000000000408f84 in igt_reset_connectors () at igt_kms.c:1656 6 0x00000000004092dc in call_exit_handlers (sig=15) at igt_core.c:1130 7 fatal_sig_handler (sig=15) at igt_core.c:1154 8 <signal handler called> 9 0x00007f15634cce60 in ptmalloc_unlock_all2 () at arena.c:298 10 0x00007f156350ca3f in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/x86_64/../fork.c:188 11 0x000000000040a029 in __igt_fork_helper (proc=proc@entry=0x610fc4 <signal_helper>) at igt_core.c:910 12 0x000000000040459d in igt_fork_signal_helper () at igt_aux.c:110 13 0x0000000000402ab7 in __real_main63 () at bug.c:76 14 0x000000000040296e in main (argc=<optimized out>, argv=<optimized out>) at bug.c:63 After doing some searches for "stuck at malloc_atfork", it seems to me we probably shouldn't be doing any malloc calls at this point of the code, so the best way to do that is to make sure we can't really run the exit handlers. So on this patch, instead of resetting the exit handlers after forking, we reset them before forking, and then restore the original value on the parent process. I can reproduce this problem by running "./kms_flip --run-subtest 2x-flip-vs-modeset" under an infinite loop. Usually after a few hundred calls, we end up stuck on the deadlock mentioned above. QA says this problem happens every time, but I'm not sure what is the difference between our environments that makes the race condition so much easier for them. The kms_flip.c problem can be considered a regression introduced by: commit eef768f283466b6d7cb3f08381f72ccf3951dc99 Author: Thomas Wood <thomas.wood@intel.com> Date: Wed Jun 18 14:28:43 2014 +0100 tests: enable extra connectors in kms_flip and kms_pipe_crc_basic even though this commit is not the one that introduced the real problem. It is also possible to reproduce this problem with a few modifications to template.c: - Add a call to igt_enable_connectors() inside the first fixture. - Add igt_fork_signal_helper() and igt_stop_signal_helper() calls around subtest B. Note that the crucial piece is that the parent actively kills helper children, and if we skip tests this can happen _really_ fast. See e.g. commit a031a1bf93b828585e7147f06145fc5030814547 Author: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Fri Sep 13 16:43:22 2013 +0200 lib/drmtest: ducttape over fork race for past hilarity in this area. Cc: Thomas Wood <thomas.wood@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81367 Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-07-30core: Add all kernel log levelsChris Wilson
And notice that INFO is 6 not 5. This is because I had intended to use KERN_NOTICE anyway... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-30lib: check test options for conflictsThomas Wood
Check any test specific options for conflicts with the standard set of options. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-30lib: avoid getopt value conflicts with testsThomas Wood
Most tests use a printable character as the value for getopt to return, so avoid conflicts by using non-printing values for the standard options. v2: fix "-h" short option Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-25core: Inject program name into dmesgChris Wilson
Write the program name if !list_only so that we associate oops with simple tests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-25core: Improve phrasing for test requirementsChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-24core: Inject subtest message into dmesgChris Wilson
One of the side-effects we test for are kernel oops and knowing the guilty subtest can help speed up debugging. We can write to /dev/kmsg to inject messages into dmesg, so let's do so before the start of every test. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-24igt_core: Read manpages more carefully for WNOHANGChris Wilson
/me hides I thought it said it would not return for a signal and stopped thinking. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-24igt_core: Refactor igt_stop_helper() to use igt_wait_helper()Chris Wilson
Reduce code duplication as the igt_stop_helper can reuse igt_wait_helper() to replace its own waiting routine. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-24core: Only use signalsafe functions inside signal handlersChris Wilson
The atexit() and signal() callbacks both need to only use signalsafe functions - that excludes the use of assert. So simplify fork_helper_exit_handler() and children_exit_handler(). __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 0x00007fd630883d2b in _L_lock_13840 () from /lib/x86_64-linux-gnu/libc.so.6 0x00007fd630881df8 in __GI___libc_realloc (oldmem=0xfcb010, bytes=88) at malloc.c:3025 0x00007fd63087111b in _IO_vasprintf (result_ptr=0x7fff35dc4780, format=<optimised out>, args=args@entry=0x7fff35dc4658) at vasprintf.c:84 0x00007fd630852907 in ___asprintf (string_ptr=string_ptr@entry=0x7fff35dc4780, format=format@entry=0x7fd63097f718 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n") at asprintf.c:35 0x00007fd63082dd92 in __assert_fail_base (fmt=0x7fd63097f718 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x40cff5 "ret == 0", file=file@entry=0x4108d1 "igt_core.c", line=line@entry=872, function=function@entry=0x410ea0 <__PRETTY_FUNCTION__.8052> "children_exit_handler") at assert.c:57 0x00007fd63082dee2 in __GI___assert_fail (assertion=assertion@entry=0x40cff5 "ret == 0", file=file@entry=0x4108d1 "igt_core.c", line=line@entry=872, function=function@entry=0x410ea0 <__PRETTY_FUNCTION__.8052> "children_exit_handler") at assert.c:101 0x000000000040b03f in children_exit_handler (sig=<optimised out>) at igt_core.c:872 0x000000000040b089 in call_exit_handlers (sig=2) at igt_core.c:1029 fatal_sig_handler (sig=2) at igt_core.c:1053 <signal handler called> 0x00007fd6308bfe63 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/x86_64/../fork.c:130 0x00007fd630bd6045 in __fork () at ../nptl/sysdeps/unix/sysv/linux/pt-fork.c:25 0x000000000040c51a in __igt_fork () at igt_core.c:900 0x00000000004036c2 in forking_evictions (ops=0x614360 <fault_ops>, surface_size=1048576, flags=5, trash_surfaces=<optimised out>, working_surfaces=338, fd=4) at eviction_common.c:203 test_forking_evictions (size=1048576, flags=5, count=338, fd=4) at gem_userptr_blits.c:1086 main (argc=1, argv=0x7fff35dc5328) at gem_userptr_blits.c:1478 Reported-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-23lib: add an exit code to use when invalid options are specifiedThomas Wood
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-23lib: add a command line option to enable debug output in testsThomas Wood
Add --debug as a common command line option for all tests to enable debug output. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-23lib: always warn about unknown optionsThomas Wood
All tests can now register extra options, so there should not be any unknown options. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-23lib: don't ignore unknown options in multi-testsThomas Wood
None of the current tests have additional options that might make use of any unknown options and igt_subtest_init_parse_opts is available that integrates additional option parsing. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-23lib: add igt_simple_init_parse_optsThomas Wood
This function allows simple tests to register additional command line options. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-23lib: move option parsing into common_initThomas Wood
Move option parsing into common_init so it can be shared between simple tests and tests with subtests. This allows for more common command line behaviour across all tests. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-23lib: warn when attempting to run an unknown subtestThomas Wood
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-21Use SIGTERM in replace of SIGQUITChris Wilson
SIGTERM is the normal signal to use when instructing a process to exit. The only difference is that an unhandled SIGQUIT is meant to generate a coredump, which is not what we want, but in practice I encountered an issue where SIGTERM seemed to be deliverable more reliably than SIGQUIT (in tests using multiple signal helpers). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-17core: increase the exit handler limitThomas Wood
Increase the maximum number of exit handlers since some tests now require more that the previous limit. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81320 Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-07-14lib: Add argc/argv to igt_simple_initDaniel Vetter
There's a pile of ideas around to add generally useful options like --debug to all igt tests. Or unify the runtime behaviour between simple and subtest tests a bit more. The first step to get there is to add argc/argv to igt_simple_init so that we can get at the argument list. Cc: Tim Gore <tim.gore@intel.com> Cc: Thomas Wood <thomas.wood@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-07-11lib/igt_core: Don't log when listing subtestsDaniel Vetter
I've noticed some spam in the userptr list ... Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-07-11Wait for any pid in order to reap failure quickerChris Wilson
When waiting for the forked tests, we can respond quicker to a failure (such as oom) by waiting for any child to exit rather than waiting for each child in order. Then when we see that a test failed, we can kill all other children before aborting. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-10core: Apply the same treatment to the in errno message in __igt_fail_assert()Damien Lespiau
Just like the it was done for the requirement message, display the errno message only if errno is set, and display it at the end of the assert message. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-07-10core: Only display the errno message if errno is setDamien Lespiau
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-07-10core: Put the requirement failure messages togetherDamien Lespiau
The errno message was a bit in the middle here, it makes more sense to group the messages about why the test requirement wasn't met together. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-06-12lib: various documentation fixesThomas Wood
Fix some documentation comments and mark some struct members private. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-06-09Fix make distclean by fixing includes of version.hRodrigo Vivi
Actually only the igt_core was breaking the make distcheck, but let's make it consistent and let the code cleaner. Credits-to: Reviewed-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
2014-05-14lib/igt_core: Fixup docs with symbolic exit codesDaniel Vetter
Conflict between me and Thomas pushing patches in parallel. Cc: Thomas Wood <thomas.wood@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-05-14lib: add exit status definesThomas Wood
Add defines for success, skip and timeout exit statuses. Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-05-14lib: add igt_set_timeoutThomas Wood
Add a function to stop and fail a test after the specified number of seconds have elapsed. Signed-off-by: Thomas Wood <thomas.wood@intel.com> Acked-by: Damien Lespiau <damien.lespiau@intel.com>
2014-05-13lib/igt_core: Fix type on igt_log docDaniel Vetter
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-05-13lib/igt_core: Document testrunner interface a bitDaniel Vetter
Also fix up one gtkdoc fumble in igt_fb. We should use symbolic defines if possible instead of just listening the magic 0, 77, 78 values for exit codes, but that's a separate patch. Cc: tim.gore@intel.com Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-26lib/igt_core: fix igt_skip_on_simulation regressionDaniel Vetter
I've forgotten that we might want to call this from within specific subtests (or special helpers like the autoresume one). Also props for being competent enough to write a testcase, but incompetent enough to botch the job up. Fix both things and remove a leftover debug printf while at it. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-23lib: Use @include tag for include filesDaniel Vetter
Occasionally useful to read documentation ... Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-23lib: s/igt_env_set/igt_check_boolean_env_varDaniel Vetter
So I wasn't really happy with env_set since it's way too close to setenv(), whic actually _sets_ and environment variable. So use check instead of set as the verb (well adjective for env_set). Also sprinkle in some hints that we talk about a boolean setting here. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-23lib: extract igt_aux.[hc]Daniel Vetter
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-22lib: rename intel_gpu_tools.h to intel_io.hDaniel Vetter
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-22lib: unnecessary header removal for drmtest.h, part 2Daniel Vetter
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-22lib: add #include "foo.h" lines like in manpagesDaniel Vetter
Should help in alleviating the header mess we have atm. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22tests|lib: remove assert.h includesDaniel Vetter
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-22lib: allow igt_skip_on_simulation outside of fixtures.Daniel Vetter
Thomas noticed that in simulation mode a lot of the tests fall over instead of skipping properly. This is due to recently added self-checks which ensure that any call to igt_skip happens either within a fixture or subtest block (or it's a simple test without subtests). This is to catch bugs since pretty much always not wrapping up hardware setup and checks into these blocks is a bug. Bug simulation skipping is a bit different, so allow that exception. Otherwise we'd need to fix up piles of tests (and likely need to play a game of whack-a-mole). Also add a library testcase for all the different variants to make sure it really works. Cc: Thomas Wood <thomas.wood@intel.com> Cc: Ben Widawsky <benjamin.widawsky@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-17lib/igt_core: Document library design best practicesDaniel Vetter
This is what I've been doing in the past few months when refactoring i-g-t code. More ideas and also patterns to add highly welcome. v2: Some minor polish on the text and add another bullet to reference the kernel's coding style. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-17lib/igt_core: Small api doc fixDaniel Vetter
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-14lib/igt_core: document the caveats of magic code blocksDaniel Vetter
v2: Polish the wording a bit. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-13lib: add igt_vlog to print varargsDaniel Vetter
... and put it to immediate use in igt_display_log. To make this all add up also drop the return value of igt_display_log, no one really cared anyway. Aside: I've noticed that every time another subtest runs (at least with kms_pipe_crc_basic) the log indent level moves one up ... Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>