summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-13 13:20:58 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-13 15:15:18 +0200
commit8f5387eb99b640771812d28a0b949aca729bf296 (patch)
tree4ccb29a62ff7c4f055cf18fe31c9482ad16ae698 /tests
parent5e25fcc285240353ab15bd4c3a0d0e02d970f45b (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')
-rw-r--r--tests/gem_caching.c2
-rw-r--r--tests/gem_cs_tlb.c11
-rw-r--r--tests/gem_dummy_reloc_loop.c33
-rw-r--r--tests/gem_exec_nop.c13
-rw-r--r--tests/gem_reg_read.c10
-rw-r--r--tests/gem_write_read_ring_switch.c21
6 files changed, 36 insertions, 54 deletions
diff --git a/tests/gem_caching.c b/tests/gem_caching.c
index 52931c57..6af76fa2 100644
--- a/tests/gem_caching.c
+++ b/tests/gem_caching.c
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
fd = drm_open_any();
- gem_check_caching(fd);
+ gem_require_caching(fd);
devid = intel_get_drm_devid(fd);
if (IS_GEN2(devid)) /* chipset only handles cached -> uncached */
diff --git a/tests/gem_cs_tlb.c b/tests/gem_cs_tlb.c
index 2f8037ac..d4fbabc3 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -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);
diff --git a/tests/gem_dummy_reloc_loop.c b/tests/gem_dummy_reloc_loop.c
index de292c7c..bccd791b 100644
--- a/tests/gem_dummy_reloc_loop.c
+++ b/tests/gem_dummy_reloc_loop.c
@@ -166,30 +166,27 @@ int main(int argc, char **argv)
}
igt_subtest("bsd") {
- if (gem_check_bsd(fd)) {
- sleep(2);
- printf("running dummy loop on bsd\n");
- dummy_reloc_loop(I915_EXEC_BSD);
- printf("dummy loop run on bsd completed\n");
- }
+ gem_require_ring(fd, I915_EXEC_BSD);
+ sleep(2);
+ printf("running dummy loop on bsd\n");
+ dummy_reloc_loop(I915_EXEC_BSD);
+ printf("dummy loop run on bsd completed\n");
}
igt_subtest("blt") {
- if (gem_check_blt(fd)) {
- sleep(2);
- printf("running dummy loop on blt\n");
- dummy_reloc_loop(I915_EXEC_BLT);
- printf("dummy loop run on blt completed\n");
- }
+ gem_require_ring(fd, I915_EXEC_BLT);
+ sleep(2);
+ printf("running dummy loop on blt\n");
+ dummy_reloc_loop(I915_EXEC_BLT);
+ printf("dummy loop run on blt completed\n");
}
igt_subtest("vebox") {
- if (gem_check_vebox(fd)) {
- sleep(2);
- printf("running dummy loop on vebox\n");
- dummy_reloc_loop(LOCAL_I915_EXEC_VEBOX);
- printf("dummy loop run on vebox completed\n");
- }
+ gem_require_ring(fd, I915_EXEC_VEBOX);
+ sleep(2);
+ printf("running dummy loop on vebox\n");
+ dummy_reloc_loop(LOCAL_I915_EXEC_VEBOX);
+ printf("dummy loop run on vebox completed\n");
}
igt_subtest("mixed") {
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 4cb157ca..47bcf108 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -92,6 +92,8 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_nam
{
int count;
+ gem_require_ring(fd, ring_id);
+
for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) {
struct timeval start, end;
@@ -103,8 +105,8 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_nam
count, elapsed(&start, &end, count), ring_name);
fflush(stdout);
}
-
}
+
int main(int argc, char **argv)
{
uint32_t batch[2] = {MI_BATCH_BUFFER_END};
@@ -122,16 +124,13 @@ int main(int argc, char **argv)
loop(fd, handle, I915_EXEC_RENDER, "render");
igt_subtest("bsd")
- if (gem_check_blt(fd))
- loop(fd, handle, I915_EXEC_BSD, "bsd");
+ loop(fd, handle, I915_EXEC_BSD, "bsd");
igt_subtest("blt")
- if (gem_check_blt(fd))
- loop(fd, handle, I915_EXEC_BLT, "blt");
+ loop(fd, handle, I915_EXEC_BLT, "blt");
igt_subtest("vebox")
- if (gem_check_vebox(fd))
- loop(fd, handle, LOCAL_I915_EXEC_VEBOX, "vebox");
+ loop(fd, handle, LOCAL_I915_EXEC_VEBOX, "vebox");
gem_close(fd, handle);
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, &reg_read)) {
- if (errno == EINVAL)
- igt_skip();
- igt_fail(1);
- }
+ ret = drmIoctl(fd, REG_READ_IOCTL, &reg_read);
+ igt_assert(ret == 0 || errno == EINVAL);
+ igt_require(ret == 0);
reg_read.val = timer_query(fd);
sleep(1);
diff --git a/tests/gem_write_read_ring_switch.c b/tests/gem_write_read_ring_switch.c
index d8b67023..b9db8f24 100644
--- a/tests/gem_write_read_ring_switch.c
+++ b/tests/gem_write_read_ring_switch.c
@@ -146,20 +146,6 @@ static void run_test(int ring, const char *testname)
drm_intel_bo_unreference(target_bo);
}
-static int has_ring(int ring)
-{
- switch (ring) {
- case I915_EXEC_RENDER: /* test only makes sense with separate blitter */
- return gem_check_blt(fd);
- case I915_EXEC_BSD:
- return gem_check_bsd(fd);
- case LOCAL_I915_EXEC_VEBOX:
- return gem_check_vebox(fd);
- default:
- return 0;
- }
-}
-
int main(int argc, char **argv)
{
static const struct {
@@ -206,8 +192,11 @@ int main(int argc, char **argv)
for (i = 0; i < ARRAY_SIZE(tests); i++) {
igt_subtest(tests[i].name) {
- if (has_ring(tests[i].ring))
- run_test(tests[i].ring, tests[i].name);
+ gem_require_ring(fd, tests[i].ring);
+ /* Testing render only makes sense with separate blt. */
+ if (tests[i].ring == I915_EXEC_RENDER)
+ gem_require_ring(fd, I915_EXEC_BLT);
+ run_test(tests[i].ring, tests[i].name);
}
}