From patchwork Fri Nov 28 16:22:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5404921 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3CF1EBEEA8 for ; Fri, 28 Nov 2014 16:22:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48A9F2013A for ; Fri, 28 Nov 2014 16:22:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 282042016C for ; Fri, 28 Nov 2014 16:22:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96F286EF09; Fri, 28 Nov 2014 08:22:30 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 9175A6EF08 for ; Fri, 28 Nov 2014 08:22:28 -0800 (PST) Received: by mail-wg0-f42.google.com with SMTP id z12so9294295wgg.15 for ; Fri, 28 Nov 2014 08:22:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vY4uvpU3UV2FDHC62ThllSUp6KuU3DX1g32lFTQLEGI=; b=lAQm1+L4AINe0yBbroGBAPZNFAm8uw2cidX66bHTf0Y/oURpf5MIjlOaOBwqpimpQb sUAfxA1NqZlZ+E3Tmkiq9i1NZv/So3TKwHRWqZlV1qdgUaqedXjp+bEx0MaVaSRcETAc 5hwVsepuEZ4BQLEPZRtZR7rkQq2A5kcJJ5Ll4FRdVok3scgjr3s7HLzfYE4l1hLk+s6x zIi34dZOxAKhXNeUXyo2aKdnJZBJlgqyelPOA/rnG8PuDdHJvB5WJxsU+21KZQpiOjl0 b/PvCpS8B77Sj+IIMbVDI0D79CVLUEL7NWUDF7c0lsLieh8EWIugn2s5mCobFqD4x/46 RHog== X-Gm-Message-State: ALoCoQnjzmUlCzBuKNoKSb5W83XTJKbCtM7vqtNGtPw0/JRpJJ1EtYKim91pu/TxOH7osV7wcha/ X-Received: by 10.194.48.109 with SMTP id k13mr13446249wjn.7.1417191747981; Fri, 28 Nov 2014 08:22:27 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id gy8sm30170135wib.3.2014.11.28.08.22.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Nov 2014 08:22:27 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Fri, 28 Nov 2014 16:22:22 +0000 Message-Id: <1417191744-5767-2-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1417191744-5767-1-git-send-email-thomas.wood@intel.com> References: <1417191744-5767-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/4] tests/kms_force_connect: split into subtests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Thomas Wood --- tests/kms_force_connector.c | 167 +++++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 78 deletions(-) diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c index 34c33b0..d446eaa 100644 --- a/tests/kms_force_connector.c +++ b/tests/kms_force_connector.c @@ -27,98 +27,109 @@ #include "drmtest.h" #include "igt_edid.h" -int -main (int argc, char **argv) +igt_main { /* force the VGA output and test that it worked */ - int drm_fd; + int drm_fd = 0; drmModeRes *res; - drmModeConnector *vga_connector, *temp; + drmModeConnector *vga_connector = NULL, *temp; igt_display_t display; int start_n_modes; - igt_simple_init(argc, argv); + igt_fixture { + drm_fd = drm_open_any_master(); + res = drmModeGetResources(drm_fd); - drm_fd = drm_open_any_master(); - res = drmModeGetResources(drm_fd); + /* find the vga connector */ + for (int i = 0; i < res->count_connectors; i++) { - /* find the vga connector */ - for (int i = 0; i < res->count_connectors; i++) { + vga_connector = drmModeGetConnector(drm_fd, res->connectors[i]); - vga_connector = drmModeGetConnector(drm_fd, res->connectors[i]); + if (vga_connector->connector_type == DRM_MODE_CONNECTOR_VGA) + break; - if (vga_connector->connector_type == DRM_MODE_CONNECTOR_VGA) - break; + drmModeFreeConnector(vga_connector); - drmModeFreeConnector(vga_connector); + vga_connector = NULL; + } + + igt_require(vga_connector); + } - vga_connector = NULL; + igt_subtest("force-connector-state") { + /* force the connector on and check the reported values */ + kmstest_force_connector(drm_fd, vga_connector, FORCE_CONNECTOR_ON); + temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); + igt_assert(temp->connection == DRM_MODE_CONNECTED); + igt_assert(temp->count_modes > 0); + start_n_modes = temp->count_modes; + drmModeFreeConnector(temp); + + /* attempt to use the display */ + kmstest_set_vt_graphics_mode(); + igt_display_init(&display, drm_fd); + igt_display_commit(&display); + + + /* force the connector off */ + kmstest_force_connector(drm_fd, vga_connector, + FORCE_CONNECTOR_OFF); + temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); + igt_assert(temp->connection == DRM_MODE_DISCONNECTED); + igt_assert(temp->count_modes == 0); + drmModeFreeConnector(temp); + + /* check that the previous state is restored */ + kmstest_force_connector(drm_fd, vga_connector, + FORCE_CONNECTOR_UNSPECIFIED); + temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); + igt_assert(temp->connection == vga_connector->connection); + drmModeFreeConnector(temp); } - igt_require(vga_connector); - - /* force the connector on and check the reported values */ - kmstest_force_connector(drm_fd, vga_connector, FORCE_CONNECTOR_ON); - temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); - igt_assert(temp->connection == DRM_MODE_CONNECTED); - igt_assert(temp->count_modes > 0); - start_n_modes = temp->count_modes; - drmModeFreeConnector(temp); - - /* attempt to use the display */ - kmstest_set_vt_graphics_mode(); - - igt_display_init(&display, drm_fd); - igt_display_commit(&display); - - /* test edid forcing */ - kmstest_force_edid(drm_fd, vga_connector, generic_edid[EDID_FHD], - EDID_LENGTH); - temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); - - igt_assert(temp->count_modes == 1); - igt_assert(temp->modes[0].vrefresh == 60 - && temp->modes[0].hdisplay == 1920 - && temp->modes[0].vdisplay == 1080); - - drmModeFreeConnector(temp); - - /* custom edid */ - kmstest_force_edid(drm_fd, vga_connector, generic_edid[EDID_WSXGA], - EDID_LENGTH); - temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); - - igt_assert(temp->count_modes == 1); - igt_assert(temp->modes[0].vrefresh == 60 - && temp->modes[0].hdisplay == 1680 - && temp->modes[0].vdisplay == 1050); - - drmModeFreeConnector(temp); - - /* remove edid */ - kmstest_force_edid(drm_fd, vga_connector, NULL, 0); - temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); - /* the connector should now have the same number of modes that it - * started with */ - igt_assert(temp->count_modes == start_n_modes); - drmModeFreeConnector(temp); - - /* force the connector off */ - kmstest_force_connector(drm_fd, vga_connector, FORCE_CONNECTOR_OFF); - temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); - igt_assert(temp->connection == DRM_MODE_DISCONNECTED); - igt_assert(temp->count_modes == 0); - drmModeFreeConnector(temp); - - - /* check that the previous state is restored */ - kmstest_force_connector(drm_fd, vga_connector, - FORCE_CONNECTOR_UNSPECIFIED); - temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); - igt_assert(temp->connection == vga_connector->connection); - drmModeFreeConnector(temp); - - drmModeFreeConnector(vga_connector); + igt_subtest("force-edid") { + kmstest_force_connector(drm_fd, vga_connector, + FORCE_CONNECTOR_ON); + + /* test edid forcing */ + kmstest_force_edid(drm_fd, vga_connector, + generic_edid[EDID_FHD], EDID_LENGTH); + temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); + + igt_assert(temp->count_modes == 1); + igt_assert(temp->modes[0].vrefresh == 60 + && temp->modes[0].hdisplay == 1920 + && temp->modes[0].vdisplay == 1080); + + drmModeFreeConnector(temp); + + /* custom edid */ + kmstest_force_edid(drm_fd, vga_connector, + generic_edid[EDID_WSXGA], EDID_LENGTH); + temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); + + igt_assert(temp->count_modes == 1); + igt_assert(temp->modes[0].vrefresh == 60 + && temp->modes[0].hdisplay == 1680 + && temp->modes[0].vdisplay == 1050); + + drmModeFreeConnector(temp); + + /* remove edid */ + kmstest_force_edid(drm_fd, vga_connector, NULL, 0); + temp = drmModeGetConnector(drm_fd, vga_connector->connector_id); + /* the connector should now have the same number of modes that + * it started with */ + igt_assert(temp->count_modes == start_n_modes); + drmModeFreeConnector(temp); + + kmstest_force_connector(drm_fd, vga_connector, + FORCE_CONNECTOR_UNSPECIFIED); + } + + igt_fixture { + drmModeFreeConnector(vga_connector); + } igt_exit(); }