tests: introduce igt_require

Since igt_skip has funny control flow we can abuse it and make it work
like a special kind of assert which automatically skips tests if a
requirement fails.

Note that in places where we have a less strict test which should
always succeed (e.g. ioctl works or isn't available) the igt_assert
should be place before the igt_require with the more strict
requirements. Otherwise we'll skip a test instead of properly failing
it.

Convert a few users of igt_skip over to igt_require to showcase its
use.

v2: s/gem_check_/gem_require_/ so that we consistently use "require"
to indicate magic check that can call igt_skip. Imo hiding the
igt_require for feature checks is ok, but for more traditional assert
like use cases an explicit igt_require might be better.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter
2013-08-13 13:20:58 +02:00
parent 5e25fcc285
commit 8f5387eb99
8 changed files with 83 additions and 91 deletions
+5 -6
View File
@@ -101,6 +101,8 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)
char buf[100];
int i;
gem_require_ring(fd, ring_id);
sprintf(buf, "testing %s cs tlb coherency: ", ring_name);
/* Shut up gcc, too stupid. */
@@ -163,16 +165,13 @@ int main(int argc, char **argv)
run_on_ring(fd, I915_EXEC_RENDER, "render");
igt_subtest("bsd")
if (gem_check_bsd(fd))
run_on_ring(fd, I915_EXEC_BSD, "bsd");
run_on_ring(fd, I915_EXEC_BSD, "bsd");
igt_subtest("blt")
if (gem_check_blt(fd))
run_on_ring(fd, I915_EXEC_BLT, "blt");
run_on_ring(fd, I915_EXEC_BLT, "blt");
igt_subtest("vebox")
if (gem_check_vebox(fd))
run_on_ring(fd, LOCAL_I915_EXEC_VEBOX, "vebox");
run_on_ring(fd, LOCAL_I915_EXEC_VEBOX, "vebox");
close(fd);