tests/kms_flip: use igt_assert more

I've left the time delta checks as-is since those are tricky math and
my mind is feeble.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter 2013-10-04 18:42:26 +02:00
parent 54b5f7251a
commit 37e5b318c5

View File

@ -602,12 +602,11 @@ static void set_y_tiling(struct test_output *o, int fb_idx)
} }
static int exec_nop(int fd, uint32_t handle) static void exec_nop(int fd, uint32_t handle)
{ {
struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_execbuffer2 execbuf;
struct drm_i915_gem_exec_object2 gem_exec[1]; struct drm_i915_gem_exec_object2 gem_exec[1];
uint32_t b[2] = {MI_BATCH_BUFFER_END}; uint32_t b[2] = {MI_BATCH_BUFFER_END};
int r;
gem_write(fd, handle, 0, b, sizeof(b)); gem_write(fd, handle, 0, b, sizeof(b));
@ -632,13 +631,9 @@ static int exec_nop(int fd, uint32_t handle)
i915_execbuffer2_set_context_id(execbuf, 0); i915_execbuffer2_set_context_id(execbuf, 0);
execbuf.rsvd2 = 0; execbuf.rsvd2 = 0;
r = drmIoctl(fd, igt_assert(drmIoctl(fd,
DRM_IOCTL_I915_GEM_EXECBUFFER2, DRM_IOCTL_I915_GEM_EXECBUFFER2,
&execbuf); &execbuf) == 0);
if (r)
fprintf(stderr, "failed to exec: %s\n",
strerror(errno));
return r;
} }
static void eat_error_state(struct test_output *o) static void eat_error_state(struct test_output *o)
@ -651,7 +646,6 @@ static void eat_error_state(struct test_output *o)
char fname[FILENAME_MAX]; char fname[FILENAME_MAX];
int card_index = drm_get_card(); int card_index = drm_get_card();
int fd; int fd;
ssize_t r;
igt_assert(card_index != -1); igt_assert(card_index != -1);
@ -660,16 +654,9 @@ static void eat_error_state(struct test_output *o)
dfs_base, card_index, dfs_entry_error); dfs_base, card_index, dfs_entry_error);
fd = open(fname, O_WRONLY); fd = open(fname, O_WRONLY);
if (fd < 0) { igt_assert(fd >= 0);
fprintf(stderr, "failed to open '%s': %s\n",
fname, strerror(errno));
return;
}
r = write(fd, data, sizeof data); igt_assert(write(fd, data, sizeof(data)) == sizeof(data));
if (r < 0)
fprintf(stderr, "failed to write '%s': %s\n",
fname, strerror(errno));
close(fd); close(fd);
/* and check whether stop_rings is not reset, i.e. the hang has indeed /* and check whether stop_rings is not reset, i.e. the hang has indeed
@ -678,21 +665,12 @@ static void eat_error_state(struct test_output *o)
dfs_base, card_index, dfs_entry_stop); dfs_base, card_index, dfs_entry_stop);
fd = open(fname, O_RDONLY); fd = open(fname, O_RDONLY);
if (fd < 0) { igt_assert(fd >= 0);
fprintf(stderr, "failed to open '%s': %s\n",
fname, strerror(errno));
return;
}
r = read(fd, tmp, sizeof tmp); igt_assert(read(fd, tmp, sizeof tmp) > 0);
if (r < 0)
fprintf(stderr, "failed to read '%s': %s\n",
fname, strerror(errno));
if (atoi(tmp) != 0) { igt_assert_f(atoi(tmp) == 0,
fprintf(stderr, "no gpu hang detected, stop_rings is still %s\n", tmp); "no gpu hang detected, stop_rings is still %s\n", tmp);
igt_fail(20);
}
close(fd); close(fd);
} }
@ -705,22 +683,14 @@ static void hang_gpu(struct test_output *o)
char fname[FILENAME_MAX]; char fname[FILENAME_MAX];
int card_index = drm_get_card(); int card_index = drm_get_card();
int fd; int fd;
ssize_t r;
snprintf(fname, FILENAME_MAX, "%s/%i/%s", snprintf(fname, FILENAME_MAX, "%s/%i/%s",
dfs_base, card_index, dfs_entry); dfs_base, card_index, dfs_entry);
fd = open(fname, O_WRONLY); fd = open(fname, O_WRONLY);
if (fd < 0) { igt_assert(fd >= 0);
fprintf(stderr, "failed to open '%s': %s\n",
fname, strerror(errno));
return;
}
r = write(fd, data, sizeof data); igt_assert(write(fd, data, sizeof(data)) == sizeof(data));
if (r < 0)
fprintf(stderr, "failed to write '%s': %s\n",
fname, strerror(errno));
close(fd); close(fd);
} }
@ -820,13 +790,8 @@ static unsigned int run_test_step(struct test_output *o)
if (o->flags & TEST_DPMS_OFF) if (o->flags & TEST_DPMS_OFF)
set_dpms(o, DRM_MODE_DPMS_OFF); set_dpms(o, DRM_MODE_DPMS_OFF);
if (o->flags & TEST_MODESET) { if (o->flags & TEST_MODESET)
if (set_mode(o, o->fb_ids[o->current_fb_id], 0, 0)) { igt_assert(set_mode(o, o->fb_ids[o->current_fb_id], 0, 0) == 0);
fprintf(stderr, "failed to restore output mode: %s\n",
strerror(errno));
igt_fail(7);
}
}
if (o->flags & TEST_DPMS) if (o->flags & TEST_DPMS)
set_dpms(o, DRM_MODE_DPMS_ON); set_dpms(o, DRM_MODE_DPMS_ON);
@ -865,28 +830,23 @@ static unsigned int run_test_step(struct test_output *o)
o->flip_state.count : o->vblank_state.count; o->flip_state.count : o->vblank_state.count;
int x_ofs = count * 10 > o->fb_width - o->kmode[0].hdisplay ? o->fb_width - o->kmode[0].hdisplay : count * 10; int x_ofs = count * 10 > o->fb_width - o->kmode[0].hdisplay ? o->fb_width - o->kmode[0].hdisplay : count * 10;
if (set_mode(o, o->fb_ids[o->current_fb_id], x_ofs, 0)){ igt_assert_f(set_mode(o, o->fb_ids[o->current_fb_id], x_ofs, 0) == 0,
fprintf(stderr, "failed to pan (%dx%d@%dHz)+%d: %s\n", "failed to pan (%dx%d@%dHz)+%d: %s\n",
o->kmode[0].hdisplay, o->kmode[0].vdisplay, o->kmode[0].vrefresh, o->kmode[0].hdisplay, o->kmode[0].vdisplay, o->kmode[0].vrefresh,
x_ofs, strerror(errno)); x_ofs, strerror(errno));
igt_fail(7);
}
} }
if (o->flags & TEST_DPMS) if (o->flags & TEST_DPMS)
set_dpms(o, DRM_MODE_DPMS_OFF); set_dpms(o, DRM_MODE_DPMS_OFF);
if (o->flags & TEST_MODESET && !(o->flags & TEST_RMFB)) { if (o->flags & TEST_MODESET && !(o->flags & TEST_RMFB))
if (set_mode(o, 0 /* no fb */, 0, 0)) { igt_assert_f(set_mode(o, 0 /* no fb */, 0, 0),
fprintf(stderr, "failed to disable output: %s\n", "failed to disable output: %s\n",
strerror(errno)); strerror(errno));
igt_fail(7);
}
}
if (do_vblank && (o->flags & TEST_EINVAL) && o->vblank_state.count > 0) if (do_vblank && (o->flags & TEST_EINVAL) && o->vblank_state.count > 0)
igt_assert(do_wait_for_vblank(o, o->pipe, target_seq, &vbl_reply) igt_assert(do_wait_for_vblank(o, o->pipe, target_seq, &vbl_reply)
== -EINVAL); == -EINVAL);
if (do_flip && (o->flags & TEST_EINVAL) && !(o->flags & TEST_FB_BAD_TILING)) if (do_flip && (o->flags & TEST_EINVAL) && !(o->flags & TEST_FB_BAD_TILING))
igt_assert(do_page_flip(o, new_fb_id, true) == expected_einval); igt_assert(do_page_flip(o, new_fb_id, true) == expected_einval);
@ -1046,10 +1006,8 @@ fb_is_bound(struct test_output *o, int fb)
static void check_final_state(struct test_output *o, struct event_state *es, static void check_final_state(struct test_output *o, struct event_state *es,
unsigned int elapsed) unsigned int elapsed)
{ {
if (es->count == 0) { igt_assert_f(es->count > 0,
fprintf(stderr, "no %s event received\n", es->name); "no %s event received\n", es->name);
igt_fail(12);
}
/* Verify we drop no frames, but only if it's not a TV encoder, since /* Verify we drop no frames, but only if it's not a TV encoder, since
* those use some funny fake timings behind userspace's back. */ * those use some funny fake timings behind userspace's back. */
@ -1096,14 +1054,10 @@ static unsigned int wait_for_events(struct test_output *o)
ret = select(drm_fd + 1, &fds, NULL, NULL, &timeout); ret = select(drm_fd + 1, &fds, NULL, NULL, &timeout);
} while (ret < 0 && errno == EINTR); } while (ret < 0 && errno == EINTR);
if (ret <= 0) { igt_assert_f(ret > 0,
fprintf(stderr, "select timed out or error (ret %d)\n", "select timed out or error (ret %d)\n", ret);
ret); igt_assert_f(!FD_ISSET(0, &fds),
igt_fail(1); "no fds active, breaking\n");
} else if (FD_ISSET(0, &fds)) {
fprintf(stderr, "no fds active, breaking\n");
igt_fail(2);
}
do_or_die(drmHandleEvent(drm_fd, &evctx)); do_or_die(drmHandleEvent(drm_fd, &evctx));
} while (o->pending_events); } while (o->pending_events);
@ -1189,10 +1143,7 @@ static void run_test_on_crtc(struct test_output *o, int crtc_idx, int duration_m
if (o->flags & TEST_CHECK_TS) if (o->flags & TEST_CHECK_TS)
sleep(1); sleep(1);
if (do_page_flip(o, o->fb_ids[1], true)) { igt_assert(do_page_flip(o, o->fb_ids[1], true) == 0);
fprintf(stderr, "failed to page flip: %s\n", strerror(errno));
igt_fail(4);
}
wait_for_events(o); wait_for_events(o);
o->current_fb_id = 1; o->current_fb_id = 1;
@ -1276,10 +1227,7 @@ static void run_test_on_crtc_pair(struct test_output *o,
if (o->flags & TEST_CHECK_TS) if (o->flags & TEST_CHECK_TS)
sleep(1); sleep(1);
if (do_page_flip(o, o->fb_ids[1], true)) { igt_assert(do_page_flip(o, o->fb_ids[1], true) == 0);
fprintf(stderr, "failed to page flip: %s\n", strerror(errno));
igt_fail(4);
}
wait_for_events(o); wait_for_events(o);
o->current_fb_id = 1; o->current_fb_id = 1;