diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-13 13:20:58 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-13 15:15:18 +0200 |
commit | 8f5387eb99b640771812d28a0b949aca729bf296 (patch) | |
tree | 4ccb29a62ff7c4f055cf18fe31c9482ad16ae698 /tests/gem_reg_read.c | |
parent | 5e25fcc285240353ab15bd4c3a0d0e02d970f45b (diff) |
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>
Diffstat (limited to 'tests/gem_reg_read.c')
-rw-r--r-- | tests/gem_reg_read.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/gem_reg_read.c b/tests/gem_reg_read.c index 39ebfd81..67c1d91b 100644 --- a/tests/gem_reg_read.c +++ b/tests/gem_reg_read.c @@ -66,16 +66,14 @@ static uint64_t timer_query(int fd) int main(int argc, char *argv[]) { struct local_drm_i915_reg_read reg_read; - int fd; + int fd, ret; fd = drm_open_any(); reg_read.offset = 0x2358; - if (drmIoctl(fd, REG_READ_IOCTL, ®_read)) { - if (errno == EINVAL) - igt_skip(); - igt_fail(1); - } + ret = drmIoctl(fd, REG_READ_IOCTL, ®_read); + igt_assert(ret == 0 || errno == EINVAL); + igt_require(ret == 0); reg_read.val = timer_query(fd); sleep(1); |