summaryrefslogtreecommitdiff
path: root/lib/igt_core.c
AgeCommit message (Collapse)Author
2022-05-25lib/igt_core: use print_backtrace() on internal_assert()Mauro Carvalho Chehab
When internal_assert() hits, it is desired to know what part of the code actually hit the issue. Reviewed-by: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-05-18lib/igt_core: export kill_children() functionMauro Carvalho Chehab
This function is needed outside igt_core. So, make it exportable, and allow passing different signs to the children. Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-05-16lib: Add missing newline in igt_fopen_data's loggingPetri Latvala
Also drive-by, change %s strerror(errno) to the equivalent %m. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
2022-03-11lib/i915/gem_create: Introduce gem-pool bo cacheZbigniew Kempczyński
Handling batchbuffers with softpin requires tracking its state otherwise we can write to inflight batchbuffer and encounter gpu hang. Gem pool adds such tracking (similar to libdrm bo cache) and provides free and ready to use bo. If pool has no free bo new one is created what means pool can be growing during test execution. When test completes freeing buffers and memory is called from igt_core so no additional cleanup is necessary. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
2022-02-22lib: Use safe wrappers around libpciaccess initialization functionsJanusz Krzysztofik
Multiple calls to igt functions using pci_system_init() provided by libpciaccess result in memory leaking if not followed by its counterpart pci_system_cleanup() before next use. On the other hand, calling pci_system_cleanup() can affect other users which still depend on global data initialized by pci_system_init(). Introduce safe IGT wrappers around those libpciaccess functions and use those wrappers in IGT library and tests. Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> [jkrzyszt: shorten excessive long name of hidden variable (Chris)] Reviewed-by: Chris Wilson <chris.p.wilson@intel.com>
2022-02-02lib/intel_batchbuffer: add tracking and reset for allocatorKamil Konieczny
After subtest ends, due to normal flow or after fail by igt_assert, igt_core inits intel_allocator before next subtest, and this makes allocator handle keeped in intel_batchbuffer invalid. Moreover any call to intel_allocator can result in fail as there are no allocators until first allocator_open. Add tracking intel_butchbuffer if it is using allocator and recreate its allocator handle and offsets from igt_core before next subtest. Add flag for turn on tracking and a helper function for it with default value off. It will not change behaviour of already used tests. Use case is for standalone runs with many subtests like gem_concurrent_blit. v2: add tracking flag with default off (Zbigniew) v3: add and correct functions descriptions (Zbigniew) Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com> Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
2021-12-16lib/igt_core: Ensure subtest result is skip if all dynamic subtests skipPetri Latvala
Even though the best practices for dynamic subtests is to not execute the dynamic subtest at all instead of skipping, there are a couple of tests that to the opposite, without an easy way to construct them along best practices. Accomodate this with fixing the handling of skipping dynamic subtests so that the result of the containing subtest becomes a skip also if all dynamic subtests skip, not just when there are no dynamic subtests. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arek@hiler.eu> Cc: Jari Tahvanainen <jari.tahvanainen@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
2021-04-19lib: Fix option parsingVille Syrjälä
--skip-crc-compare and --trace-on-oops mistakenly abort further option parsing. So depending on where you have them in your command line you get some very confusing behaviour where some of the options get totally ignored. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2021-04-19lib: Document that we have --trace-on-oopsVille Syrjälä
Include --trace-on-oops in the help text. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2021-04-13lib/intel_allocator: Add intel_allocator coreZbigniew Kempczyński
For discrete gens we have to cease of using relocations when batch buffers are submitted to GPU. On cards which have ppgtt we can use softpin establishing addresses on our own. We added simple allocator (taken from Mesa; works on lists) and random allocator to exercise batches with different addresses. All of that works for single VM (context) so we have to add additional layer (intel_allocator) to support multiprocessing / multithreading. For main IGT process (also for threads created in it) intel_allocator resolves addresses "locally", just by mutexing access to global allocator data (ctx/vm map). When fork() is in use children cannot establish addresses on they own and have to contact to the thread spawned within main IGT process. Currently SysV IPC message queue was chosen as a communication channel between children and allocator thread. Child calls same functions as main IGT process, only communication path will be chosen instead of acquiring addresses locally. v2: Add intel_allocator_open_full() to allow user pass vm range. Add strategy: NONE, LOW_TO_HIGH, HIGH_TO_LOW passed to allocator backend. v3: Child is now able to use allocator directly as standalone. It only need to call intel_allocator_init() to reinitialize appropriate structures. v4: Add pseudo allocator - INTEL_ALLOCATOR_RELOC which just increments offsets to avoid unnecessary conditional code. v5: Alter allocator core according to igt_map changes. v6: Add internal version __intel_allocator_alloc() to return ALLOC_INVALID_ADDRESS without assertion. v7: Add libatomic for linking libigt library. It is required on some archs, like mips. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Petri Latvala <petri.latvala@intel.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Petri Latvala <petri.latvala@intel.com>
2021-04-13lib/igt_core: Track child process pid and tidZbigniew Kempczyński
Introduce variables which can decrease number of getpid()/gettid() calls, especially for allocator which must be aware of method acquiring addresses. When child is spawned using igt_fork() we can control its initialization and prepare child_pid implicitly. Tracking child_tid requires our intervention in the code and do something like this: if (child_tid == -1) child_tid = gettid() Variable was created for using in TLS so each thread is created with variable set to -1. This will give each thread it's own "copy" and there's no risk to use other thread tid. For each forked child we reassign -1 to child_tid to avoid using already set variable. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Petri Latvala <petri.latvala@intel.com> Acked-by: Arjun Melkaveri <arjun.melkaveri@intel.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Petri Latvala <petri.latvala@intel.com>
2021-01-30meson: Turn on -WerrorAshutosh Dixit
We can choose which compile warnings to enable, but once they are enabled treat all warnings as error. This enforces stricter checks against compile warnings creeping in. v2: Fix redefinition warning errors from i915/gem_userptr_blits v3: Fix the even more pedantic clang compilation v4: Do not alter whitespace in lib/tests/igt_describe! Note: clang does not build assembler/ Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2021-01-01lib: Avoid freeing an uninitialised variableChris Wilson
../lib/igt_core.c:2759:6: warning: variable 'line' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!thread_id) ^~~~~~~~~~ ../lib/igt_core.c:2824:7: note: uninitialized use occurs here free(line); Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
2020-11-04lib/igt_core: Don't return too early in common_init_configPetri Latvala
common_init_config is responsible for adding the device filters supplied through the environment to the filter list. If the .igtrc file cannot be opened, make sure the filter is added still. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arek@hiler.eu> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
2020-10-02lib/igt_core: Reinitialize print mutex in child processZbigniew Kempczyński
IGT are prone to deadlock in igt_log() in following scenario: 1. Parent process creates additional thread which for example is doing endless loop. 2. Thread sometimes is logging to console using igt_info(). This locks and unlocks print_mutex. 3. If in the meantime parent process will spawn child process it can be created having print_mutex locked (thread entered igt_vlog() function and entered critical section). When child will try to log it will deadlock. We should reinitialize print_mutex in child process to avoid use inherited value. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-06-22igt/core: Disallow igt_require/skip in non-main threadsArkadiusz Hiler
Handling magic control blocks and longjmp() out of them in threads is hard. The test should state the requirements before it starts spinning threads. Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-06-22lib/core: Handle asserts in threadsArkadiusz Hiler
Since IGT is using magic control blocks (igt_subtest et al.) asserts jump out the them using longjmp() causing a bunch of confusing messages and occasionally crashing the whole process. This is not the behavior we want :-) With this patch: 1. simple_main, dynamic and subtest each clears the thread failure state at the start 2. each of those blocks also asserts no thread failures at the end 3. igt_assert() in non-main thread prints out the error + stacktrace and marks that we have failed thread Issue: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/55 Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-06-22lib/core: Print thread:tid with igt_log for non-main threadsArkadiusz Hiler
So that we know what's the source of messages. igt_thread.c is created to facilitate more threading-related functionality that will come in the following patch. Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-06-04lib/igt_core: Don't kill the world after a failed forkArkadiusz Hiler
If we fail to fork (e.g. due to restrictive limits) -1 gets written as PID of our child and we assert out. The cleanup that happens afterwards tries to kill all our children, which ends up in kill(-1, SIGKILL) which is not good. This patch makes sure of two things: * -1 doesn't get written down as our child * when we are killing children we make sure that pid > 0 Reported-by: Fei Yang <fei.yang@intel.com> Cc: Michael Hebenstreit <michael.hebenstreit@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Tested-by: Michael Hebenstreit <michael.hebenstreit@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-05-05lib/igt_core: Disallow nesting of igt_dynamic inside igt_dynamicArkadiusz Hiler
igt_dynamic is allowed only inside igt_subtest_with_dynamic Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-05-05lib/igt_core: Make assert on invalid magic blocks nesting more verboseArkadiusz Hiler
Instead of ending the execution with cryptic assert let's actually print a message explaining the reason and point towards igt_core's documentation. I am sticking with assert() instead of abort() because of the semi-useful stacktraces it produces. Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-05-05lib: Support multiple filtersArkadiusz Hiler
This patch brings back support for multiple filters that was in the original series by Zbyszek. We can now take multiple, semicolon separated filters. Right now the tests are using only the first filter. v2: drop unnecessary check before for-loop (Petri) Cc: Petri Latvala <petri.latvala@intel.com> Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-04-17igt_core: Add --versionPetri Latvala
To help verify correct deployment, add a --version flag that just prints the IGT-Version text. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2020-03-23lib: Make it possible to abort the whole execution from inside of a testArkadiusz Hiler
igt_abort_on_f() is introduced which does very little cleanup and causes a hard exit() of the test binary with a unique exit code (IGT_EXIT_ABORT). The exit code informs the monitoring process that there is a critical issue with the testing environment which may have an impact on the results if testing continues. v2: Add a meta_test Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-03-17lib/igt_core: Make igt_subtest_jmpbuf/igt_dynamic_jmpbuf externLyude Paul
Since gcc 10, -fno-common has become the default (vs. -fcommon). As a result, gcc is much stricter about missing extern and static keywords and causes our build to fail in anything including igt_core.h: /usr/bin/ld: lib/libigt-i915_gem_context_c.a(i915_gem_context.c.o):lib/igt_core.h:149: multiple definition of `igt_dynamic_jmpbuf'; lib/libigt-drmtest_c.a(drmtest.c.o):lib/igt_core.h:149: first defined here /usr/bin/ld: lib/libigt-i915_gem_context_c.a(i915_gem_context.c.o):lib/igt_core.h:148: multiple definition of `igt_subtest_jmpbuf'; lib/libigt-drmtest_c.a(drmtest.c.o):lib/igt_core.h:148: first defined here So, fix this by marking these as extern and declaring them in lib/igt_core.c. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Lyude Paul <lyude@redhat.com>
2020-02-05lib: Kill residual children at the end of a subtestChris Wilson
Ensure that we tidy up all the excess children left behind by a failing subtest, we do not want them loitering into the next! v2: Behead the undead plague, and throw in a bonus lib/tests Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2020-01-28lib: Report wait() failuresChris Wilson
Check the error status from a wait() failure and propagate if not SIGINT -- to avoid falling into a trap of an infinite error loop. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
2020-01-27lib/igt_core: Detect gdb harderVille Syrjälä
The current gdb detection only works for the parent igt process, but none of its children will see the gdb and so won't trap properly in igt_fail_assert(). Also we will not detect gdb if it was attached after the fact. Fix all of that by looking for the "TracerPid" information in /proc/<pid>/status. We'll leave the current "assume parent may be gdb" approach as a fallback. Also annoyingly by default gdb will only track a single process. To make it track all of them, and let them all run simultanously one needs the following incantations: set detach-on-fork off set schedule-multiple on Maybe that will save someone from having to trawl as many docs/gogole hits as I did. v2: s/1024/32/ bytes (should be more than enough to find the TracePid line) Put the multi-process gdb instructions into a comment (Chris) Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2020-01-16lib: Don't dump log buffer when dynamic subtest failure is inheritedPetri Latvala
A subtest with dynamic subparts will automatically fail if any dynamic subparts fail. Failing a subtest will dump our log buffer, which is useful in normal cases, but when it's just the actual subtest inheriting the failure from a dynamic subtest, nothing in the log buffer is of any use for the failure. Dynamic subtest parsing will stuff all output after the last dynamic subtest into that last dynamic subtest's output, and in the case of that last dynamic subtest itself being a 'SUCCESS', that extra output from dumping the log buffer will cause an innocent dynamic subtest to be incorrectly marked as a 'WARN' result. Issue: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/66 Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2019-12-04Add device selection in IGTZbigniew Kempczyński
New IGT command line argument --device, IGT_DEVICE enviroment and .igtrc Common::Device were added to allow selecting device using device selection API. See generated docs for device selection and lsgpu for more details on filters. NOTE: IGT_FORCE_DRIVER still works if no filter is selected. We may want to deprecate it later. NOTE2: This does not work with tests that open 2 or more devices (e.g. kms_prime). The core is capable of doing multiple filtering passes but we need to figure out how we want *open*() functions to expose this capability. v2 (Arek): * remove functions acting on igt_device_card * use only a single filter v3 (Arek): * typos, misspellings (Petri) * add notes on IGT_FORCE_DRIVER and opening 2 or more devices Cc: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-11-19Rename dynamic subtest blocksPetri Latvala
The final naming for the magic block identifiers is: igt_subtest_with_dynamic("do-stuff-on-things") { for_each_thing(x) { igt_dynamic_f("%s", x->name) { do_stuff(x); } } } Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Katarzyna Dec <katarzyna.dec@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2019-11-18igt: Stop requesting ftrace dumps on oops by defaultChris Wilson
They have lived past their usefulness as now we frequently lose vital debug information because we are spamming unrelated GEM traces. We can add the spam directly to GEM_BUG_ON(), and enable it ourselves if we truly need the trace-on-oops. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Martin Peres <martin.peres@linux.intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Acked-by: Petri Latvala <petri.latvala@intel.com>
2019-11-15lib: Introduce dynamic subsubtestsPetri Latvala
Dynamic subsubtests, or subtests of subtests, are individual pieces of tests that are not statically available all the time. A good example of a need for a dynamic subsubtest is i915 engine listing: A normal subtest for each engine class ("bsd"), and a dynamic subsubtest for each instance ("bsd0", "bsd2", etc). Or a normal subtest for an operation with a dynamic subsubtest for every engine there is. Another example is dynamic subsubtests for pipes: Instead of using foreach_pipe_static, make one subtest and use foreach_pipe with dynamic subsubtests for each pipe. v2: Rebase and adapt to igt_describe changes v3: Rename to igt_subtest_with_dynamic_subsubtests & igt_dynamic_subsubtest, better docs, make igt_describe fail loudly if it's used in an impossible context. v4: Mention dynamic blocks in the warning for longjmp in core docs. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2019-11-12lib/igt_list: Update, clean-up and document igt_listArkadiusz Hiler
Our list was something between Wayland and Linux Kernel list implementations, right in the uncanny valley. On top of that it falsely claimed that it's a straight copy from the Wayland project. Let's make our impl more akin to the kernel one to ease the cognitive dissonance for the developers working on all those projects. This patch: * mimics the current kernel list interface * separates IGT helpers in the source files * adds brief explanation and code example for igt-doc * introduces igt_list.c as static inlines are not visible in the docs v2: mimic the kernel instead of wayland (Chris) - _head suffix for the sentinel/link struct - _entry_ in iterator names that go over the elements v3: I forgot to merge this in time and there was another call site that had to be converted in gem_spin_batch.c Cc: Petri Latvala <petri.latvala@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Acked-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-10-18lib: Add igt_trace()Ville Syrjälä
Add igt_trace() which can be used to inject messages into the kernel ftrace buffer via the trace_marker file. Quite useful when trying to correlate test case activity with kernel tracepoints. v2: Use igt_debugfs_mount() (Chris) Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-17lib: Export a function for loading igtrcPetri Latvala
Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2019-07-08lib/igt_core: Add support for subtest descriptionsArkadiusz Hiler
This patch adds igt_description() which attaches a description to the following igt_subtest or igt_subtest_group block. Descriptions are accessible via './test --describe[=pattern]' Subtest description is its own igt_describe as well as igt_describes of all the parenting igt_subtest_groups, starting from the outermost scope. Examples of code and produced outputs are included in lib/test/igt_describe.c and as a documentation comment on igt_describe() macro. v2: address Simon's review Cc: Simon Ser <simon.ser@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Acked-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Simon Ser <simon.ser@intel.com>
2019-07-03lib: Add --skip-crc-compare optionMatt Roper
When using --interactive-debug, it's sometimes desirable to ignore CRC mismatches and let the test proceed as if they passed so that the on-screen outcome can be inspected. Let's add a debug option to allow this. Cc: igt-dev@lists.freedesktop.org Signed-off-by: Matt Roper <matthew.d.roper@intel.com> [vsyrjala: pimp the debug message to indicate the skip] Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2019-06-06lib/igt_core: add -h to usageLucas De Marchi
We also accept the short option -h. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-06-06lib/igt_core: 0 is a valid val for long optionsLucas De Marchi
This is usually used by long options when working with enum to set long option values. So replace the strchr() with a memchr() to take that into account. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-06-06lib/igt_core: reserve long options for individual testsLucas De Marchi
Start the core options from 500 so the individual tests can have their own options starting from 0. This makes it easier to set the long options without conflicting. 500 is just a magic number, higher than any ascii char that could be used in the individual test. While at it, fix the coding style to use tab rather than space. v2: also fix the test for conflicting args Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-05-27lib: Document igt_opt_handler_t semanticsPetri Latvala
Best practices for the help string formatting, along with explicit symbols for the possible return values for the callback. Also documented: Do not call the _parse_opts functions yourself, use igt_main_args or igt_simple_main_args. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2019-05-23i915/gem_exec_fence: Replace open-coded recursive batch with igt_spin_tChris Wilson
The only detail of note here was that we were creating a fence from the recursive batch, now supported by igt_spin_t (thanks Tvrtko). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com>
2019-05-23lib/igt_core: Rework extra options conflicts handlingArkadiusz Hiler
This started simple, as a fixup for a warning: In file included from ../lib/drmtest.h:39, from ../lib/igt_core.c:60: ../lib/igt_core.c: In function ‘common_init’: ../lib/igt_core.h:891:24: warning: ‘%s’ directive argument is null [-Wformat-overflow=] 891 | #define igt_warn(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_WARN, f) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/igt_core.c:704:4: note: in expansion of macro ‘igt_warn’ 704 | igt_warn("Conflicting long and short option values between --%s and -%s\n", | ^~~~~~~~ ../lib/igt_core.c:704:73: note: format string is defined here 704 | igt_warn("Conflicting long and short option values between --%s and -%s\n", | ^~ But it ended up doing the following things: 1. Promote all igt_warns to _critical and assert afterwards. 2. Use for loop instead of a while-doing-for's-job. 3. Streamline calculation of the option list sizes. 4. Add checks for long option names. 5. Log about "'val' representation" instead of confusing "value". 6. Log correct things so we won't %s on a NULL. 7. Write tests to confirm that it works. Cc: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-05-07lib/igt_core: Just use igt_can_fail() in __igt_run_subtest()Lyude Paul
That's what it's there for. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Lyude Paul <lyude@redhat.com>
2019-05-07Use gettid() wrapper everywhereLyude Paul
Currently we have multiple different parts of IGT that define their own wrapper around the gettid() syscall (or just call it directly with no wrapper). Additionally, add the appropriate #includes for igt_aux.h to make sure syscall() is available. Reviewed-by: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Lyude Paul <lyude@redhat.com>
2019-04-18lib/igt_dummyload: Get rid of 'batch' on spinner accessorsMika Kuoppala
There is no guarantee that spinners are and will be implemented using batches. As we have igt_spin_t, manipulate it through igt_spin_* functions consistently and hide the batch nature. Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-04-10lib: Reset errno to 0 after isattyArkadiusz Hiler
Since igt_assert family of functions logs last errno we get a lot of those: "Last errno: 25, Inappropriate ioctl for device" isatty() seems to be the biggest offender in that area, so this patch should limit amount of confusing messages significantly. Cc: Martin Peres <martin.peres@linux.intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-02-21lib: disallow fixtures/subtest groups in simple testsDaniel Vetter
They don't work, see igt_can_fail(). We already check for test_with_subtests in igt_subtest. Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2019-02-15lib: Drop IGT_EXIT_TIMEOUTDaniel Vetter
We use the timeout status for when the runner had to kill a testcase, which indicates a more sever issue than an operation failing that we expected to complete within seconds. Since it's unused, drop it. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>