109 Commits

Author SHA1 Message Date
Joonas Lahtinen
d84e62478b lib/igt_core: Prefer CLOCK_MONOTONIC_RAW
CLOCK_MONOTONIC_RAW is not affected by NTP, so it should be THE clock
used for timing execution of tests.

When fetching either the starting or ending time of a test, show the
time as -1.000s.

v6:
- Whitespace corrections (Chris)

v5:
- Do not use C99 style comments (Chris)

v4:
- Introduce time_valid macro (Chris)
- Reduce amount of boilerplate code for calculating elapsed time

v3:
- Do not exit directly from handler (Chris)
- Show elapsed time as -1 if it is not calculable

v2:
- Cache the used clock (Chris)
- Do not change the clock during execution
- Spit out and error if monotonic time can not be read

Cc: Thomas Wood <thomas.wood@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-11-24 16:36:54 +00:00
Thomas Wood
790f1f804b lib: add a environment variable to control output
Disable output of terminal control characters and progress meters when
IGT_PLAIN_OUTPUT is set in the environment.

Cc: Derek Morton <derek.j.morton@intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-11-11 14:52:47 +00:00
Thomas Wood
fca7b1b5fd lib: highlight subtest results on terminals
Make subtest results easier to identify by making them bold when the output
is a terminal.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-11-11 14:52:47 +00:00
Thomas Wood
36b8143c22 Add missing noreturn attribute to various functions
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-11-11 14:20:55 +00:00
Thomas Wood
982934625a lib: allow wildcard matching when specifying subtests
This allows multiple subtests to be specified using standard wildcard
characters when using the --run-subtest command line option.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-09-17 12:41:35 +01:00
Thomas Wood
f0381d1abe lib: various documentation fixes
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-09-08 16:15:16 +01:00
Daniel Vetter
5b0a8433fd lib/core: Add igt_reset_timeout
Convenience wrapper suggested by Chris for igt_set_timeout(0, NULL).

v2: While at it add an empty line in kms_flip to make
set/reset_timeout a visual block.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-08-12 14:46:46 +02:00
Daniel Vetter
370c989723 lib/core: Add optional reason for timeout failure
"Timed out" isn't a terribly informative message, allow users to set
something more informative. Inspired by a request from Jesse.

Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-08-12 14:46:40 +02:00
Thomas Wood
e65c69b995 lib: exit immediately if igt_fail is called in an exit handler
Exit immediately if the test is already exiting and igt_fail is called.
This can happen if an igt_assert fails in an exit handler.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91349
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-07-20 18:13:37 +01:00
Thomas Wood
d01ebbd97d docs: various documentation fixes
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-07-02 08:17:17 +01:00
Damien Lespiau
6ebd8c2dc3 doc: Remove i-g-t/intel prefixes and capitalize section titles
Looks better!

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Paulo Zanoni
6cc553adf2 lib/igt_core: fflush stdout after printing subtest results
I often run "sudo ./test 2>&1 | tee output.txt", and when we're
succeeding - never printing to stderr - the output gets buffered and
is never flushed (because it doesn't point to a terminal), so I never
know which test is running. With this fflush, I'm able to know when
each test finishes.

v2: Add blank line too (Chris)

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2015-06-26 17:35:39 -03:00
Chris Wilson
453792c501 lib: Enable locale dependent output to a terminal
If we are in an interactive session, enable the locale. This allows for
features like setting thousand separators for printing large values. By
only enabling it for interactive terminals, we avoid changing outputs
for the test scripts (leaving them as the "C" locale).

Note this mainly affects the testcases, or binaries built using libigt.
Other binaries need to be localised separately.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Michel Thierry <michel.thierry@intel.com>
2015-06-24 17:03:04 +01:00
Derek Morton
f49723872b lib/igt_core.c: Flag the test as failing after a segfault
fatal_signal_handler() was trapping fatal errors but not
flagging the test as failing or setting an exit code.
The result was that the test would return Ok or Skipped
depending on what the other subtests did even though one
of the subtests had segfaulted.

Signed-off-by: Derek Morton <derek.j.morton@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-05-28 13:37:11 +02:00
Damien Lespiau
fd6846c99f lib: Add a user data pointer to the argument parsing functions
It can be useful to have one of those to carry state between the handler
parsing the options and the rest of the test. Right now the only thing
we can do is to use global variables for that.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-05-15 12:22:14 +01:00
Chris Wilson
9b0a32dc80 lib/core: Limit fatal signal CRASH reporting to the fatal signals
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-05-10 09:12:16 +01:00
Chris Wilson
578795ff95 lib: Teach igt to handle signal failures gracefully
If we see a fatal signal in a subtest, fail.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-05-08 14:42:27 +01:00
Tim Gore
48a27bcaf6 lib/igt_core.c : only disable low mem killer once
The call to low_mem_killer_disable(true) was being done
from within function oom_adjust_for_doom. However,
oom_adjust_for_doom gets called from 3 places. We only
want the call to low_mem_killer_disable(true) to happen
during common_init, so call it from here instead of from
oom_adjust_for_doom.

v2:Thomas Wood pointed out that the initial call to disable
the low_mem_killer does not get made when we are just
listing subtests; so I have qualified the call from the
exit handler, which re-enables the low_mem_killer, with
if (!igt_only_list_subtests()).
For belt and braces I have also made low_mem_killer_disable
idempotent, so multiple calls to disable or re-enable are
safe.

Signed-off-by: Tim Gore <tim.gore@intel.com>
[Thomas: small coding style fix]
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-05-01 17:13:56 +01:00
Thomas Wood
5b7edb9cb0 docs: avoid escaping characters in documentation comments
Avoid having to escape certain characters in documentation comments by
not allowing docbook markup tags. Markdown formatting in documentation
comments is still supported.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-04-21 10:52:14 +01:00
Thomas Wood
90dadcd0da lib: use a critical warning when unable to open a data file
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-04-14 17:44:35 +01:00
Thomas Wood
cff102ebb2 lib: use test failure status for igt_set_timeout
Use a failure status code for timeout to avoid confusion between tests
that take too long to execute versus a failure due to an operation
taking longer than expected.

v2: Add a "timed out" message before exiting. (Daniel Vetter)
    Fix the timeout library check by disabling hard errors in xfail
    tests, since these share the same exit status as test failure.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-04-14 17:43:05 +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
Joonas Lahtinen
a95033fdbc tests: install test programs to libexec
Install the test programs by default so that they can be packaged.

Tested with the testdisplay test so that it still runs after the
modifications as it depends on a data file to be present. Need to
pass -r option to enable QR code display on success (PNG data file).

Packaging is useful when building a complete software stack for a
DUT from scratch. This should bring us closer to achieving a
built-from-scratch testing workflow.

Package maintainers can always decide to ignore the installed files.

v2:
- Install more tests including scripts and their data

v3:
- Add clarification to commit message about why we do this.
  (Chris Wilson & Thomas Wood)
- Change libexec into pkglibexec to comply to standard
  (Thomas Wood)
- Do not install $(common_files). (Thomas Wood)
- Make it really obvious the installed files are tests by using
  tests directory name to avoid any confusion with packagers.

v4:
- Fixed commit message.

v5:
- Add file locator helper to retain backwards compatibility.
  (Thomas Wood)
- Test with testdisplay -r option that draws the .png file.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Thomas Wood <thomas.wood@intel.com>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-04-02 16:32:47 +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
Thomas Wood
277ca2b992 lib: print a stack trace when a test assertion fails
Add an optional dependency on libunwind to print stack traces when a
test assertion fails.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-03-26 15:50:05 +00:00
Chris Wilson
7763349a9a igt/gem_concurrent_blit: Separate out the combinatorial explosion
Apparently nobody else likes testing and debugging GEM coherency issues.
However, this also means that QA is skipping these vital tests. Split
out a set of canaries into igt/gem_concurrent_blit and keep the rest in
igt/gem_concurrent_all.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89497
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-03-26 08:15:19 +00:00
Chris Wilson
2fa35c7316 lib/core: Silence internally used signals
We use SIGTERM to kill off child processes. We use it a lot. Reporting
everytime we use it is just spam. Treat the similar user signals
(SIGINT, SIGQUIT and the should-never-have-been SIGPIPE) similarly to
reduce noise.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Thomas Wood <thomas.wood@intel.com>
2015-03-26 08:15:18 +00:00
Daniel Vetter
4fec18e5e0 lib/core: add interactive debug point to igt_fail
Useful for inspecting the screen state in kms tests when they fail.

Also move the screen clearing in kms_cursor_crc to the bottom.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-03-23 11:02:28 +01:00
Thomas Wood
a6c40c7665 lib: move igt_interactive_debug into igt_core.c
igt_interactive_debug should be defined in igt_core.c, rather than the
header, to avoid it being defined more than once.

Reported-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-03-12 15:11:11 +00:00
Chris Wilson
b8db5d60e0 lib/core: Make the start of the debug output more clear
I missed the quiet "Log start" between the test failure and the debug
output (and so was very confused by the repetition). You have to shout
at me!

v2: Thomas suggested I make the end of the logging clear as well. Since
I completely missed that there was a end marker, he must be right!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Thomas Wood <thomas.wood@intel.com>
2015-03-06 15:43:03 +00:00
Daniel Vetter
f45698df8b lib/igt_core: don't add newlines in logging functions
igt_kms extensively uses line continuation when dumping state updates
at the debug level. They got badly mangled with the recent changes to
for the log handling functions. Two separate fixes:
- Don't prepend domain and other metainformation when it's just a
  continuation line.
- Dont add newlines when dumping the log recorder.

If someone interleaves different log level messages this will go awry,
but really just don't do that.

Cc: Thomas Wood <thomas.wood@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-27 19:34:38 +01:00
Thomas Wood
4ff4ea601a lib: print the signal name to stderr when handling a signal
Print the received signal name to stderr when handling a signal. This
uses an array of handled signal names since strsignal() only provides
descriptions.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-25 16:50:13 +00:00
Thomas Wood
8fb19782f8 lib: remove handled option arguments from argv
Remove options from argv that have been handled by getopt to allow
additional non-option parameters to be processed in the test application.

This fixes issues when using options such as --debug with tests that accept
additional non-option parameters.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-25 16:48:25 +00:00
Thomas Wood
55cc132b32 lib: use defines for igt_simple_init and igt_subtest_init
Using defines removes an extra function call and prepares for changes
to the command line argument handling.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-25 16:48:25 +00:00
Thomas Wood
f8fd4c977a lib: print recent log messages to stderr when a test or subtest fails
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-17 11:24:04 +00:00
Thomas Wood
a5f21726cd lib: add a ring buffer for log entries
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-17 11:24:04 +00:00
Thomas Wood
16cfa37a50 lib: add exit status message to simple tests
Add an exit status message to simple tests, similar to the one printed
for subtests. This includes the test outcome and the time taken to run
the test.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-09 14:39:41 +00:00
Thomas Wood
9942a40437 lib: add subtest start and exit status code messages to debug output
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-09 14:39:41 +00:00
Thomas Wood
2b05ecfb06 lib: validate subtest names
Subtest names should only contain '-', '_' and alphanumeric characters.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-09 14:39:41 +00:00
Thomas Wood
61737903ad lib: print warning and critical messages when listing subtests
These messages are sent to stderr and could indicate an issue when
enumerating subtests.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-09 14:39:41 +00:00
Thomas Wood
a228223ffa lib: warning messages should be sent to stderr
This is a regression from commit df11a0f (lib: add a critical warning
level).

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-09 14:39:41 +00:00
Rodrigo Vivi
3d65ff780d lib: s/IGT_DEBUG_INTERACTIVE/--interactive-debug=var
Use cmdline variable for interactive debug instead of env var.

v2: Make interactive-debug domain optional and use "all" when not set.

Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-20 11:36:10 +01:00
Thomas Wood
0167619bbc lib: use critical log level for assertion failure messages
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-01-16 11:11:10 +00:00
Thomas Wood
df11a0f4a8 lib: add a critical warning level
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-01-16 11:11:10 +00:00
Alan Coopersmith
843beb152b Don't try to use CLOCK_MONOTONIC_COARSE on OS'es that don't support it
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-06 09:29:45 +01:00
Alan Coopersmith
95ea5d5c0b Provide sighandler_t fallback for non-GNU-libc platforms
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-06 09:29:45 +01:00
Alan Coopersmith
f04b9dfba0 Need to #include <libgen.h> for basename() on Solaris
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-06 09:29:45 +01:00
Alan Coopersmith
99e6defbe7 Use pthread calls instead of raw syscalls on non-Linux systems
Raw system calls aren't portable to other kernels.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-06 09:29:45 +01:00
Chris Wilson
c49a7e9163 lib/core: Fix compile error from rebasing
s/KMSG_INFO/KERN_INFO/

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-01-05 14:34:58 +00:00
Chris Wilson
d8bf7e17cb lib/core: Show the exitcode in kmsg as well
This provides symmetry with logging the start of the test via kmsg.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-01-05 14:12:02 +00:00