[Intel-gfx] [PATCH 4/5] tests: Use kms_ prefix a bit more

Daniel Vetter daniel.vetter at ffwll.ch
Sat Nov 2 13:04:35 CET 2013


I was a bit on the fence about the basic pipe CRC test since that
doesn't really test kms, but debug infrastructure in debugfs.

Otoh running this one for a full kms testrun is always good, to make
sure that all the other (real) CRC based tests work sanely.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 tests/.gitignore            |   8 +-
 tests/Makefile.am           |   4 +-
 tests/debugfs_pipe_crc.c    | 262 --------------------------------------------
 tests/kms_pipe_crc_basic.c  | 262 ++++++++++++++++++++++++++++++++++++++++++++
 tests/kms_sysfs_edid_timing |  25 +++++
 tests/sysfs_edid_timing     |  25 -----
 6 files changed, 293 insertions(+), 293 deletions(-)
 delete mode 100644 tests/debugfs_pipe_crc.c
 create mode 100644 tests/kms_pipe_crc_basic.c
 create mode 100755 tests/kms_sysfs_edid_timing
 delete mode 100755 tests/sysfs_edid_timing

diff --git a/tests/.gitignore b/tests/.gitignore
index e99b2da04c20..09ea074f4d2c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,8 @@
 # Please keep sorted alphabetically
+core_getclient
+core_getstats
+core_getversion
 ddi_compute_wrpll
-debugfs_pipe_crc
 drv_suspend
 drm_get_client_auth
 drm_vma_limiter
@@ -93,9 +95,6 @@ gen3_render_linear_blits
 gen3_render_mixed_blits
 gen3_render_tiledx_blits
 gen3_render_tiledy_blits
-getclient
-getstats
-getversion
 igt_fork_helper
 igt_list_only
 igt_no_exit
@@ -104,6 +103,7 @@ igt_no_subtest
 kms_addfb
 kms_cursor_crc
 kms_flip
+kms_pipe_crc_basic
 kms_render
 kms_setmode
 pm_pc8
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4e2813fffc4c..807a67c09a45 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,7 +17,6 @@ NOUVEAU_TESTS_M = \
 endif
 
 TESTS_progs_M = \
-	debugfs_pipe_crc \
 	drv_suspend \
 	gem_basic \
 	gem_caching \
@@ -54,6 +53,7 @@ TESTS_progs_M = \
 	kms_addfb \
 	kms_cursor_crc \
 	kms_flip \
+	kms_pipe_crc_basic \
 	kms_render \
 	kms_setmode \
 	$(NOUVEAU_TESTS_M) \
@@ -135,7 +135,7 @@ TESTS_scripts = \
 	drv_hangman \
 	drv_missed_irq_hang \
 	drv_module_reload \
-	sysfs_edid_timing \
+	kms_sysfs_edid_timing \
 	sysfs_l3_parity \
 	test_rte_check \
 	tools_test \
diff --git a/tests/debugfs_pipe_crc.c b/tests/debugfs_pipe_crc.c
deleted file mode 100644
index 2545233187cc..000000000000
--- a/tests/debugfs_pipe_crc.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright © 2013 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- */
-
-#include <errno.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include "drmtest.h"
-#include "igt_debugfs.h"
-
-typedef struct {
-	struct kmstest_connector_config config;
-	struct kmstest_fb fb;
-	bool valid;
-} connector_t;
-
-typedef struct {
-	int drm_fd;
-	igt_debugfs_t debugfs;
-	drmModeRes *resources;
-	int n_connectors;
-	connector_t *connectors;
-	FILE *ctl;
-} data_t;
-
-static void test_bad_command(data_t *data, const char *cmd)
-{
-	size_t written;
-
-	written = fwrite(cmd, 1, strlen(cmd), data->ctl);
-	fflush(data->ctl);
-	igt_assert_cmpint(written, ==, (strlen(cmd)));
-	igt_assert(ferror(data->ctl));
-	igt_assert_cmpint(errno, ==, EINVAL);
-}
-
-static void connector_init(data_t *data, connector_t *connector,
-			   uint32_t id, uint32_t crtc_id_mask)
-{
-	int ret;
-
-	ret = kmstest_get_connector_config(data->drm_fd, id, crtc_id_mask,
-					   &connector->config);
-	if (ret == 0)
-		connector->valid = true;
-	else
-		connector->valid = false;
-
-}
-
-static void connector_fini(connector_t *connector)
-{
-	kmstest_free_connector_config(&connector->config);
-}
-
-static bool
-connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode)
-{
-	struct kmstest_connector_config *config = &connector->config;
-	unsigned int fb_id;
-	cairo_t *cr;
-	int ret;
-
-	fb_id = kmstest_create_fb(data->drm_fd,
-				  mode->hdisplay, mode->vdisplay,
-				  32 /* bpp */, 24 /* depth */,
-				  false /* tiling */,
-				  &connector->fb);
-	igt_assert(fb_id);
-
-	cr = kmstest_get_cairo_ctx(data->drm_fd, &connector->fb);
-	kmstest_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
-			    0.0, 1.0, 0.0);
-	igt_assert(cairo_status(cr) == 0);
-
-#if 0
-	fprintf(stdout, "Using pipe %c, %dx%d\n", pipe_name(config->pipe),
-		mode->hdisplay, mode->vdisplay);
-#endif
-
-	ret = drmModeSetCrtc(data->drm_fd,
-			     config->crtc->crtc_id,
-			     connector->fb.fb_id,
-			     0, 0, /* x, y */
-			     &config->connector->connector_id,
-			     1,
-			     mode);
-	igt_assert(ret == 0);
-
-	return 0;
-}
-
-static void display_init(data_t *data)
-{
-	data->resources = drmModeGetResources(data->drm_fd);
-	igt_assert(data->resources);
-
-	data->n_connectors = data->resources->count_connectors;
-	data->connectors = calloc(data->n_connectors, sizeof(connector_t));
-	igt_assert(data->connectors);
-}
-
-static void connectors_init(data_t *data, uint32_t crtc_id_mask)
-{
-	int i;
-
-	for (i = 0; i < data->n_connectors; i++) {
-		uint32_t id = data->resources->connectors[i];
-
-		connector_init(data, &data->connectors[i], id, crtc_id_mask);
-	}
-}
-
-static void display_fini(data_t *data)
-{
-	int i;
-
-	for (i = 0; i < data->n_connectors; i++)
-		connector_fini(&data->connectors[i]);
-	free(data->connectors);
-
-	drmModeFreeResources(data->resources);
-}
-
-#define TEST_SEQUENCE (1<<0)
-
-static void test_read_crc(data_t *data, int pipe, unsigned flags)
-{
-	connector_t *connector;
-	igt_pipe_crc_t *pipe_crc;
-	igt_crc_t *crcs = NULL;
-	int valid_connectors = 0, i;
-
-	connectors_init(data, 1 << pipe);
-
-	for (i = 0;  i < data->n_connectors; i++) {
-		connector = &data->connectors[i];
-
-		if (!connector->valid)
-			continue;
-
-		fprintf(stdout, "%s: Testing connector %u\n",
-			igt_subtest_name(), connector->config.connector->connector_id);
-
-		connector_set_mode(data, connector, &connector->config.default_mode);
-
-		pipe_crc = igt_pipe_crc_new(&data->debugfs, data->drm_fd,
-					    connector->config.pipe,
-					    INTEL_PIPE_CRC_SOURCE_AUTO);
-
-		if (!pipe_crc)
-			continue;
-		valid_connectors++;
-
-		igt_assert(igt_pipe_crc_start(pipe_crc));
-
-		/* wait for 3 vblanks and the corresponding 3 CRCs */
-		igt_pipe_crc_get_crcs(pipe_crc, 3, &crcs);
-
-		igt_pipe_crc_stop(pipe_crc);
-
-		/* ensure the CRCs are not all 0s */
-		igt_assert(!igt_crc_is_null(&crcs[0]));
-		igt_assert(!igt_crc_is_null(&crcs[1]));
-		igt_assert(!igt_crc_is_null(&crcs[2]));
-
-		/* and ensure that they'are all equal, we haven't changed the fb */
-		igt_assert(igt_crc_equal(&crcs[0], &crcs[1]));
-		igt_assert(igt_crc_equal(&crcs[1], &crcs[2]));
-
-		if (flags & TEST_SEQUENCE) {
-			igt_assert(crcs[0].frame + 1 == crcs[1].frame);
-			igt_assert(crcs[1].frame + 1 == crcs[2].frame);
-		}
-
-		free(crcs);
-		igt_pipe_crc_free(pipe_crc);
-		kmstest_remove_fb(data->drm_fd, &connector->fb);
-	}
-
-	igt_require_f(valid_connectors, "No connector found for pipe %i\n", pipe);
-
-}
-
-igt_main
-{
-	data_t data = {0, };
-
-	igt_skip_on_simulation();
-
-	igt_fixture {
-		size_t written;
-		int ret;
-		const char *cmd = "pipe A none";
-
-		data.drm_fd = drm_open_any();
-		igt_require(data.drm_fd >= 0);
-
-		igt_set_vt_graphics_mode();
-
-		display_init(&data);
-
-		igt_debugfs_init(&data.debugfs);
-		data.ctl = igt_debugfs_fopen(&data.debugfs,
-					     "i915_display_crc_ctl", "r+");
-		igt_require_f(data.ctl,
-			      "No display_crc_ctl found, kernel too old\n");
-		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
-		ret = fflush(data.ctl);
-		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
-			      "CRCs not supported on this platform\n");
-	}
-
-	igt_subtest("bad-pipe")
-		test_bad_command(&data, "pipe D none");
-
-	igt_subtest("bad-source")
-		test_bad_command(&data, "pipe A foo");
-
-	igt_subtest("bad-nb-words-1")
-		test_bad_command(&data, "pipe foo");
-
-	igt_subtest("bad-nb-words-3")
-		test_bad_command(&data, "pipe A none option");
-
-	for (int i = 0; i < 3; i++) {
-		igt_subtest_f("read-crc-pipe-%c", 'A'+i)
-			test_read_crc(&data, i, 0);
-
-		igt_subtest_f("read-crc-pipe-%c-frame-sequence", 'A'+i)
-			test_read_crc(&data, i, TEST_SEQUENCE);
-	}
-
-	igt_fixture {
-		display_fini(&data);
-		fclose(data.ctl);
-	}
-}
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
new file mode 100644
index 000000000000..2545233187cc
--- /dev/null
+++ b/tests/kms_pipe_crc_basic.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "drmtest.h"
+#include "igt_debugfs.h"
+
+typedef struct {
+	struct kmstest_connector_config config;
+	struct kmstest_fb fb;
+	bool valid;
+} connector_t;
+
+typedef struct {
+	int drm_fd;
+	igt_debugfs_t debugfs;
+	drmModeRes *resources;
+	int n_connectors;
+	connector_t *connectors;
+	FILE *ctl;
+} data_t;
+
+static void test_bad_command(data_t *data, const char *cmd)
+{
+	size_t written;
+
+	written = fwrite(cmd, 1, strlen(cmd), data->ctl);
+	fflush(data->ctl);
+	igt_assert_cmpint(written, ==, (strlen(cmd)));
+	igt_assert(ferror(data->ctl));
+	igt_assert_cmpint(errno, ==, EINVAL);
+}
+
+static void connector_init(data_t *data, connector_t *connector,
+			   uint32_t id, uint32_t crtc_id_mask)
+{
+	int ret;
+
+	ret = kmstest_get_connector_config(data->drm_fd, id, crtc_id_mask,
+					   &connector->config);
+	if (ret == 0)
+		connector->valid = true;
+	else
+		connector->valid = false;
+
+}
+
+static void connector_fini(connector_t *connector)
+{
+	kmstest_free_connector_config(&connector->config);
+}
+
+static bool
+connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode)
+{
+	struct kmstest_connector_config *config = &connector->config;
+	unsigned int fb_id;
+	cairo_t *cr;
+	int ret;
+
+	fb_id = kmstest_create_fb(data->drm_fd,
+				  mode->hdisplay, mode->vdisplay,
+				  32 /* bpp */, 24 /* depth */,
+				  false /* tiling */,
+				  &connector->fb);
+	igt_assert(fb_id);
+
+	cr = kmstest_get_cairo_ctx(data->drm_fd, &connector->fb);
+	kmstest_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
+			    0.0, 1.0, 0.0);
+	igt_assert(cairo_status(cr) == 0);
+
+#if 0
+	fprintf(stdout, "Using pipe %c, %dx%d\n", pipe_name(config->pipe),
+		mode->hdisplay, mode->vdisplay);
+#endif
+
+	ret = drmModeSetCrtc(data->drm_fd,
+			     config->crtc->crtc_id,
+			     connector->fb.fb_id,
+			     0, 0, /* x, y */
+			     &config->connector->connector_id,
+			     1,
+			     mode);
+	igt_assert(ret == 0);
+
+	return 0;
+}
+
+static void display_init(data_t *data)
+{
+	data->resources = drmModeGetResources(data->drm_fd);
+	igt_assert(data->resources);
+
+	data->n_connectors = data->resources->count_connectors;
+	data->connectors = calloc(data->n_connectors, sizeof(connector_t));
+	igt_assert(data->connectors);
+}
+
+static void connectors_init(data_t *data, uint32_t crtc_id_mask)
+{
+	int i;
+
+	for (i = 0; i < data->n_connectors; i++) {
+		uint32_t id = data->resources->connectors[i];
+
+		connector_init(data, &data->connectors[i], id, crtc_id_mask);
+	}
+}
+
+static void display_fini(data_t *data)
+{
+	int i;
+
+	for (i = 0; i < data->n_connectors; i++)
+		connector_fini(&data->connectors[i]);
+	free(data->connectors);
+
+	drmModeFreeResources(data->resources);
+}
+
+#define TEST_SEQUENCE (1<<0)
+
+static void test_read_crc(data_t *data, int pipe, unsigned flags)
+{
+	connector_t *connector;
+	igt_pipe_crc_t *pipe_crc;
+	igt_crc_t *crcs = NULL;
+	int valid_connectors = 0, i;
+
+	connectors_init(data, 1 << pipe);
+
+	for (i = 0;  i < data->n_connectors; i++) {
+		connector = &data->connectors[i];
+
+		if (!connector->valid)
+			continue;
+
+		fprintf(stdout, "%s: Testing connector %u\n",
+			igt_subtest_name(), connector->config.connector->connector_id);
+
+		connector_set_mode(data, connector, &connector->config.default_mode);
+
+		pipe_crc = igt_pipe_crc_new(&data->debugfs, data->drm_fd,
+					    connector->config.pipe,
+					    INTEL_PIPE_CRC_SOURCE_AUTO);
+
+		if (!pipe_crc)
+			continue;
+		valid_connectors++;
+
+		igt_assert(igt_pipe_crc_start(pipe_crc));
+
+		/* wait for 3 vblanks and the corresponding 3 CRCs */
+		igt_pipe_crc_get_crcs(pipe_crc, 3, &crcs);
+
+		igt_pipe_crc_stop(pipe_crc);
+
+		/* ensure the CRCs are not all 0s */
+		igt_assert(!igt_crc_is_null(&crcs[0]));
+		igt_assert(!igt_crc_is_null(&crcs[1]));
+		igt_assert(!igt_crc_is_null(&crcs[2]));
+
+		/* and ensure that they'are all equal, we haven't changed the fb */
+		igt_assert(igt_crc_equal(&crcs[0], &crcs[1]));
+		igt_assert(igt_crc_equal(&crcs[1], &crcs[2]));
+
+		if (flags & TEST_SEQUENCE) {
+			igt_assert(crcs[0].frame + 1 == crcs[1].frame);
+			igt_assert(crcs[1].frame + 1 == crcs[2].frame);
+		}
+
+		free(crcs);
+		igt_pipe_crc_free(pipe_crc);
+		kmstest_remove_fb(data->drm_fd, &connector->fb);
+	}
+
+	igt_require_f(valid_connectors, "No connector found for pipe %i\n", pipe);
+
+}
+
+igt_main
+{
+	data_t data = {0, };
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		size_t written;
+		int ret;
+		const char *cmd = "pipe A none";
+
+		data.drm_fd = drm_open_any();
+		igt_require(data.drm_fd >= 0);
+
+		igt_set_vt_graphics_mode();
+
+		display_init(&data);
+
+		igt_debugfs_init(&data.debugfs);
+		data.ctl = igt_debugfs_fopen(&data.debugfs,
+					     "i915_display_crc_ctl", "r+");
+		igt_require_f(data.ctl,
+			      "No display_crc_ctl found, kernel too old\n");
+		written = fwrite(cmd, 1, strlen(cmd), data.ctl);
+		ret = fflush(data.ctl);
+		igt_require_f((written == strlen(cmd) && ret == 0) || errno != ENODEV,
+			      "CRCs not supported on this platform\n");
+	}
+
+	igt_subtest("bad-pipe")
+		test_bad_command(&data, "pipe D none");
+
+	igt_subtest("bad-source")
+		test_bad_command(&data, "pipe A foo");
+
+	igt_subtest("bad-nb-words-1")
+		test_bad_command(&data, "pipe foo");
+
+	igt_subtest("bad-nb-words-3")
+		test_bad_command(&data, "pipe A none option");
+
+	for (int i = 0; i < 3; i++) {
+		igt_subtest_f("read-crc-pipe-%c", 'A'+i)
+			test_read_crc(&data, i, 0);
+
+		igt_subtest_f("read-crc-pipe-%c-frame-sequence", 'A'+i)
+			test_read_crc(&data, i, TEST_SEQUENCE);
+	}
+
+	igt_fixture {
+		display_fini(&data);
+		fclose(data.ctl);
+	}
+}
diff --git a/tests/kms_sysfs_edid_timing b/tests/kms_sysfs_edid_timing
new file mode 100755
index 000000000000..ec704f6725b7
--- /dev/null
+++ b/tests/kms_sysfs_edid_timing
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# This check the time we take to read the content of all the possible connectors.
+# Without the edid -ENXIO patch (http://permalink.gmane.org/gmane.comp.video.dri.devel/62083),
+# we sometimes take a *really* long time. So let's just check for some reasonable timing here
+#
+
+DRM_LIB_ALLOW_NO_MASTER=1
+
+SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
+. $SOURCE_DIR/drm_lib.sh
+
+TIME1=$(date +%s%N)
+cat $(find /sys/devices/|grep drm | grep /status) > /dev/null
+TIME2=$(date +%s%N)
+
+# time in ms
+RES=$(((TIME2 - TIME1) / 1000000))
+
+if [ $RES -gt 600 ]; then
+	echo "Talking to outputs took ${RES}ms, something is wrong"
+	exit 1
+fi
+
+exit 0
diff --git a/tests/sysfs_edid_timing b/tests/sysfs_edid_timing
deleted file mode 100755
index ec704f6725b7..000000000000
--- a/tests/sysfs_edid_timing
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-#
-# This check the time we take to read the content of all the possible connectors.
-# Without the edid -ENXIO patch (http://permalink.gmane.org/gmane.comp.video.dri.devel/62083),
-# we sometimes take a *really* long time. So let's just check for some reasonable timing here
-#
-
-DRM_LIB_ALLOW_NO_MASTER=1
-
-SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
-. $SOURCE_DIR/drm_lib.sh
-
-TIME1=$(date +%s%N)
-cat $(find /sys/devices/|grep drm | grep /status) > /dev/null
-TIME2=$(date +%s%N)
-
-# time in ms
-RES=$(((TIME2 - TIME1) / 1000000))
-
-if [ $RES -gt 600 ]; then
-	echo "Talking to outputs took ${RES}ms, something is wrong"
-	exit 1
-fi
-
-exit 0
-- 
1.8.4.rc3




More information about the Intel-gfx mailing list