[igt-dev] [for trybot 2/7] kms_vblank: Reorganize subtests by pipe, v2.
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Thu Jan 18 11:14:01 UTC 2018
Changes since v1:
- Move per-pipe subtests to its own function and fix indent.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
tests/kms_vblank.c | 111 +++++++++++++++++++++++++++++------------------------
1 file changed, 60 insertions(+), 51 deletions(-)
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index 342e4ef23b97..d5f5aa0b6189 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -113,54 +113,47 @@ static int wait_vblank(int fd, union drm_wait_vblank *vbl)
return err;
}
-static void run_test(data_t *data, int fd, void (*testfunc)(data_t *, int, int))
+static void run_test(data_t *data, void (*testfunc)(data_t *, int, int))
{
int nchildren =
data->flags & FORKED ? sysconf(_SC_NPROCESSORS_ONLN) : 1;
igt_display_t *display = &data->display;
- igt_output_t *output;
- enum pipe p;
-
- for_each_pipe_with_valid_output(display, p, output) {
- data->pipe = p;
- prepare_crtc(data, fd, output);
+ igt_output_t *output = data->output;
+ int fd = display->drm_fd;
- igt_info("Beginning %s on pipe %s, connector %s (%d threads)\n",
- igt_subtest_name(),
- kmstest_pipe_name(data->pipe),
- igt_output_name(output),
- nchildren);
-
- if (data->flags & BUSY) {
- union drm_wait_vblank vbl;
-
- memset(&vbl, 0, sizeof(vbl));
- vbl.request.type =
- DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT;
- vbl.request.type |= kmstest_get_vbl_flag(data->pipe);
- vbl.request.sequence = 120 + 12;
- igt_assert_eq(wait_vblank(fd, &vbl), 0);
- }
+ prepare_crtc(data, fd, output);
- igt_fork(child, nchildren)
- testfunc(data, fd, nchildren);
- igt_waitchildren();
+ igt_info("Beginning %s on pipe %s, connector %s (%d threads)\n",
+ igt_subtest_name(), kmstest_pipe_name(data->pipe),
+ igt_output_name(output), nchildren);
- if (data->flags & BUSY) {
- struct drm_event_vblank buf;
- igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf));
- }
+ if (data->flags & BUSY) {
+ union drm_wait_vblank vbl;
- igt_assert(poll(&(struct pollfd){fd, POLLIN}, 1, 0) == 0);
+ memset(&vbl, 0, sizeof(vbl));
+ vbl.request.type =
+ DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT;
+ vbl.request.type |= kmstest_get_vbl_flag(data->pipe);
+ vbl.request.sequence = 120 + 12;
+ igt_assert_eq(wait_vblank(fd, &vbl), 0);
+ }
- igt_info("\n%s on pipe %s, connector %s: PASSED\n\n",
- igt_subtest_name(),
- kmstest_pipe_name(data->pipe),
- igt_output_name(output));
+ igt_fork(child, nchildren)
+ testfunc(data, fd, nchildren);
+ igt_waitchildren();
- /* cleanup what prepare_crtc() has done */
- cleanup_crtc(data, fd, output);
+ if (data->flags & BUSY) {
+ struct drm_event_vblank buf;
+ igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf));
}
+
+ igt_assert(poll(&(struct pollfd){fd, POLLIN}, 1, 0) == 0);
+
+ igt_info("\n%s on pipe %s, connector %s: PASSED\n\n",
+ igt_subtest_name(), kmstest_pipe_name(data->pipe), igt_output_name(output));
+
+ /* cleanup what prepare_crtc() has done */
+ cleanup_crtc(data, fd, output);
}
static void crtc_id_subtest(data_t *data, int fd)
@@ -315,10 +308,8 @@ static void vblank_wait(data_t *data, int fd, int nchildren)
elapsed(&start, &end, count));
}
-igt_main
+static void run_subtests_for_pipe(data_t *data)
{
- int fd;
- data_t data;
const struct {
const char *name;
void (*func)(data_t *, int, int);
@@ -329,6 +320,7 @@ igt_main
{ "wait", vblank_wait, IDLE | FORKED | BUSY },
{ }
}, *f;
+
const struct {
const char *name;
unsigned int flags;
@@ -340,6 +332,31 @@ igt_main
{ }
}, *m;
+ igt_fixture
+ igt_display_require_output_on_pipe(&data->display, data->pipe);
+
+ for (f = funcs; f->name; f++) {
+ for (m = modes; m->name; m++) {
+ if (m->flags & ~f->valid)
+ continue;
+
+ igt_subtest_f("pipe-%s-%s-%s",
+ kmstest_pipe_name(data->pipe),
+ f->name, m->name) {
+ for_each_valid_output_on_pipe(&data->display, data->pipe, data->output) {
+ data->flags = m->flags;
+ run_test(data, f->func);
+ }
+ }
+ }
+ }
+}
+
+igt_main
+{
+ int fd;
+ data_t data;
+
igt_skip_on_simulation();
igt_fixture {
@@ -352,15 +369,7 @@ igt_main
igt_subtest("crtc-id")
crtc_id_subtest(&data, fd);
- for (f = funcs; f->name; f++) {
- for (m = modes; m->name; m++) {
- if (m->flags & ~f->valid)
- continue;
-
- igt_subtest_f("%s-%s", f->name, m->name) {
- data.flags = m->flags;
- run_test(&data, fd, f->func);
- }
- }
- }
+ for_each_pipe_static(data.pipe)
+ igt_subtest_group
+ run_subtests_for_pipe(&data);
}
--
2.15.1
More information about the igt-dev
mailing list