tests/kms_cursor_crc: rework to auto-skip connectors
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 31 Oct 2013 15:06:40 +0000 (16:06 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 1 Nov 2013 19:43:16 +0000 (20:43 +0100)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/kms_cursor_crc.c

index 55b9b7c..cddfe10 100644 (file)
@@ -116,25 +116,14 @@ static igt_pipe_crc_t *create_crc(data_t *data, int crtc_idx)
 
 static void display_init(data_t *data)
 {
-       int i;
-
        data->resources = drmModeGetResources(data->drm_fd);
        igt_assert(data->resources);
 
        data->pipe_crc = calloc(data->resources->count_crtcs, sizeof(data->pipe_crc[0]));
-       for (i = 0; i < data->resources->count_crtcs; i++) {
-               data->pipe_crc[i] = create_crc(data, i);
-               igt_require_f(data->pipe_crc[i],
-                             "pipe/pf crc not supported\n");
-       }
 }
 
 static void display_fini(data_t *data)
 {
-       int i;
-
-       for (i = 0; i < data->resources->count_crtcs; i++)
-               igt_pipe_crc_free(data->pipe_crc[i]);
        free(data->pipe_crc);
 
        drmModeFreeResources(data->resources);
@@ -236,7 +225,7 @@ static bool prepare_crtc(test_data_t *test_data, uint32_t connector_id)
        connector_t connector;
        igt_crc_t *crcs = NULL;
        data_t *data = test_data->data;
-       igt_pipe_crc_t *pipe_crc = data->pipe_crc[test_data->crtc_idx];
+       igt_pipe_crc_t *pipe_crc;
        int ret;
 
        ret = kmstest_get_connector_config(data->drm_fd,
@@ -248,6 +237,15 @@ static bool prepare_crtc(test_data_t *test_data, uint32_t connector_id)
 
        connector_set_mode(data, &connector, &connector.config.default_mode);
 
+       pipe_crc = create_crc(data, test_data->crtc_idx);
+       if (!pipe_crc) {
+               printf("auto crc not supported on this connector with crtc %i\n",
+                      test_data->crtc_idx);
+               return false;
+       }
+
+       data->pipe_crc[test_data->crtc_idx] = pipe_crc;
+
        /* x/y position where the cursor is still fully visible */
        test_data->left = 0;
        test_data->right = connector.config.default_mode.hdisplay - 64;
@@ -276,6 +274,7 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen)
                .data = data,
        };
        int i, n;
+       int valid_tests = 0;
 
        for (i = 0; i < data->resources->count_connectors; i++) {
                uint32_t connector_id = data->resources->connectors[i];
@@ -287,6 +286,8 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen)
                        if (!prepare_crtc(&test_data, connector_id))
                                continue;
 
+                       valid_tests++;
+
                        fprintf(stdout, "Beginning %s on crtc %d, connector %d\n",
                                igt_subtest_name(), test_data.crtc_id, connector_id);
 
@@ -295,8 +296,12 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen)
 
                        fprintf(stdout, "\n%s on crtc %d, connector %d: PASSED\n\n",
                                igt_subtest_name(), test_data.crtc_id, connector_id);
+
+                       igt_pipe_crc_free(data->pipe_crc[test_data.crtc_idx]);
                }
        }
+
+       igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 }
 
 static void exit_handler(int sig)