summaryrefslogtreecommitdiff
path: root/runner/runner_tests.c
AgeCommit message (Collapse)Author
2019-05-10runner_tests: Operate within defined behaviorArkadiusz Hiler
Quoting lib/igt_core.c: * - Code blocks with magic control flow are implemented with setjmp() and * longjmp(). This applies to #igt_fixture and #igt_subtest blocks and all the * three variants to finish test: igt_success(), igt_skip() and igt_fail(). * Mostly this is of no concern, except when such a control block changes * stack variables defined in the same function as the control block resides. * Any store/load behaviour after a longjmp() is ill-defined for these * variables. Avoid such code. * * Quoting the man page for longjmp(): * * "The values of automatic variables are unspecified after a call to * longjmp() if they meet all the following criteria:" * - "they are local to the function that made the corresponding setjmp() call; * - "their values are changed between the calls to setjmp() and longjmp(); and * - "they are not declared as volatile." We have quite a few igt_subtest_group that define local variables to share the state between subtest and fixture (e.g. set open() in subtest, close() in the following fixture), causing the contents to be undefined. We can allocate some of them using malloc and make the others volatile to be back on the defined grounds. 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-04-01runner: Add --dmesg-warn-level switchArkadiusz Hiler
This switch allows users to select which dmesg log level is treated as warning resulting in overriding the test results to dmesg-fail/dmesg-warn. Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-04-01runner: Refactor metadata parsingArkadiusz Hiler
To aid testing function parsing metadata.txt is split into outer helper that operates on dirfd and inner function that operates on FILE*. This allows us to test the parsing using fmemopen(), limiting the amount of necessary boilerplate. Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-02-21runner: Exit with 0 on dry-runPetri Latvala
v2: Adjust tests accordingly Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2019-01-22runner: Implement --dry-runPetri Latvala
Actually implement --dry-run to not execute tests. With dry-run active, attempting to execute will figure out the list of things to execute, serialize them along with settings, and stop. This will be useful for CI that wants to post-mortem on failed test rounds to generate a list of tests that should have been executed and produce json result files (full of 'notrun') for proper statistics. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Andi Shyti <andi.shyti@intel.com> Cc: Martin Peres <martin.peres@linux.intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
2018-11-15runner: Implement --abort-on-monitored-errorPetri Latvala
Deviating a bit from the piglit command line flag, igt_runner takes an optional comma-separated list as an argument to --abort-on-monitored-error for the list of conditions to abort on. Without a list all possible conditions will be checked. Two conditions implemented: - "taint" checks the kernel taint level for TAINT_PAGE, TAINT_DIE and TAINT_OOPS - "lockdep" checks the kernel lockdep status Checking is done after every test binary execution, and if an abort condition is met, the reason is printed to stderr (unless log level is quiet) and the runner doesn't execute any further tests. Aborting between subtests (when running in --multiple-mode) is not done. v2: - Remember to fclose - Taints are unsigned long (Chris) - Use getline instead of fgets (Chris) v3: - Fix brainfart with lockdep v4: - Rebase - Refactor the abort condition checking to pass down strings - Present the abort result in results.json as a pseudo test result - Unit tests for the pseudo result v5: - Refactors (Chris) - Don't claim lockdep was triggered if debug_locks is not on anymore. Just say it's not active. - Dump lockdep_stats when aborting due to lockdep (Chris) - Use igt@runner@aborted instead for the pseudo result (Martin) v6: - If aborting after a test, generate results.json. Like was already done for aborting at startup. - Print the test that would be executed next as well when aborting, as requested by Tomi. v7: - Remove the resolved TODO item from commit message Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Cc: Martin Peres <martin.peres@linux.intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-11-05runner: const-correct the unit testsPetri Latvala
const where possible, and cast away const when passing argv to parse_options, which expects non-const strings, because it passes them to getopt_long, which expects non-const strings... getopt and getopt_long take the argv array as char * const *, or in other words, as pointer-to-const-pointer-to-char. In C, pointer-to-T implicitly converts to pointer-to-const-T and for a char **, the T is char* and "const T" is char * const, ergo char ** converts to char * const *, not const char **. The only const-correctness getopt and getopt_long can really do is char * const * or they lose the ability to directly pass in main()'s arguments, which are an array of non-const pointers to non-const char for legacy reasons. For testing the argument handling, it's very convenient to use an array of string literals, which are of type const char[N], convertible to const char *. To get such an array into getopt, the choices are: 1) Cast away the const in the pointer-to-pointer 2) Cast away the const in the string literal 3) Don't cast anything and eat the compiler warning Option 1 looked cleanest out of all those. tl;dr: Choices made in 1972 force our hand. v2: - Augment commit message Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-10-19runner: Add --overall-timeoutPetri Latvala
With --overall-timeout $foo, the runner will stop executing new tests when $foo seconds have already been used. A resumed run will start over with no time used, using the same timeout. This allows for executing a long list of tests piecemeal, in about $foo length executions. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106127 Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Cc: Martin Peres <martin.peres@linux.intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-10-04runner: Add unit test for resume when enough subtests are already runPetri 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>
2018-10-03runner: Add a unit test that checks for fd leaksPetri Latvala
Pretty much needed, as proven. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-10-03runner: Plug more fd leaksPetri 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>
2018-09-21runner: Support -t and -x with a --test-listPetri Latvala
Actually implement what was already commented to work. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Acked-by: Tomi Sarvela <tomi.p.sarvela@intel.com> #irc
2018-08-31runner: Introduce --piglit-style-dmesgPetri Latvala
With the flag, dmesg handling is done exactly as piglit does it: Level 5 (info) and higher dmesg lines, if they match a regexp, cause test result to change to dmesg-*. The default is false (use new method). Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Martin Peres <martin.peres@linux.intel.com> Acked-by: Martin Peres <martin.peres@linux.intel.com>
2018-08-16runner: Match the piglit name with -t and -x optionsPetri Latvala
Instead of just matching the binary/subtest name. Originally not implemented to get the runner landed faster. Turned out to be simple enough. 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>
2018-08-13runner: Fix path handlingArkadiusz Hiler
absolute_path() tends to return NULL if more than the last element of the path is nonexistent. That behavior is confusing the callers, which use NULL as a convention for something not being set at all. Let's fix that by sprinkling a little bit of recursion onto absolute_path() and wrapping POSIX in some sanity. Cc: Petri Latvala <petri.latvala@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2018-08-09runner: Unit tests for the runnerPetri Latvala
TODO: Unit tests for the results.json file contents. v2: - Avoid writing the nul character to mock files - Properly set up tmpdirs v3: - Restore the resume-related changes that were lost in rebase v4: - Better teardown for temporary directories - Build with autotools Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>