From patchwork Mon Sep 28 23:54:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rafael Antognolli X-Patchwork-Id: 7281571 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83894BEEA4 for ; Mon, 28 Sep 2015 23:52:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DD6B2070F for ; Mon, 28 Sep 2015 23:52:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2641E20705 for ; Mon, 28 Sep 2015 23:52:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B0356EA72; Mon, 28 Sep 2015 16:52:40 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 4F2706EA6E; Mon, 28 Sep 2015 16:52:36 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 28 Sep 2015 16:52:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,605,1437462000"; d="scan'208";a="653979456" Received: from di-604.jf.intel.com (HELO apicaltest.jf.intel.com) ([10.7.199.92]) by orsmga003.jf.intel.com with ESMTP; 28 Sep 2015 16:52:21 -0700 From: Rafael Antognolli To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Mon, 28 Sep 2015 16:54:15 -0700 Message-Id: <1443484455-2516-1-git-send-email-rafael.antognolli@intel.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] tests: Adding kms_dp_aux_dev test. 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: , 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 This new test makes some basic testing on the proposed drm_dp_aux_dev interface. If the feature is enabled and the drm_dp_aux_dev class is present, it will check for available DP aux channels and test them for: - basic seek to 0 and read 1 byte - seek to the last address and read, to confirm 0 is returned - seek one more byte and confirm that EINVAL is returned - try to read 64 bytes when at 8 bytes from the end of the address space - try to read 64 bytes at the address 0. So far, no write checks are done. Signed-off-by: Rafael Antognolli --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_dp_aux_dev.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 tests/kms_dp_aux_dev.c diff --git a/tests/.gitignore b/tests/.gitignore index dc8bb53..efdad75 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -127,6 +127,7 @@ kms_3d kms_addfb_basic kms_crtc_background_color kms_cursor_crc +kms_dp_aux_dev kms_draw_crc kms_fbc_crc kms_fbcon_fbt diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 2e2e088..dc07737 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -64,6 +64,7 @@ TESTS_progs_M = \ gem_write_read_ring_switch \ kms_addfb_basic \ kms_cursor_crc \ + kms_dp_aux_dev \ kms_draw_crc \ kms_fbc_crc \ kms_fbcon_fbt \ diff --git a/tests/kms_dp_aux_dev.c b/tests/kms_dp_aux_dev.c new file mode 100644 index 0000000..aab8c95 --- /dev/null +++ b/tests/kms_dp_aux_dev.c @@ -0,0 +1,134 @@ +/* + * Copyright © 2015 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. + */ + +/** @file kms_dp_aux_dev.c + * + * This is a test of functionality of drm_dp_aux_dev. + */ + +#include "igt.h" +#include +#include +#include +#include +#include +#include + +#include + +#define DRM_DP_AUX_SYSFS_PATH "/sys/class/drm_dp_aux_dev" + +IGT_TEST_DESCRIPTION("Test of drm_aux_dev nodes."); + +static void drm_dp_aux_test(const char *devname) +{ + char basedir[] = "/dev/"; + char name[256 + sizeof(basedir)]; + off_t address; + uint8_t buf; + uint8_t bigbuf[64]; + int fd; + + ssize_t res; + + snprintf(name, sizeof(name), "%s%s", basedir, devname); + igt_info("Running test on %s\n", name); + + /* Check if this DP aux channel is connected before continuing tests */ + fd = open(name, O_RDONLY); + igt_assert_lte(0, fd); + address = lseek(fd, 0x0, SEEK_SET); + igt_assert_eq(address, 0x0); + res = read(fd, &buf, sizeof(buf)); + igt_skip_on(res < 0 && errno == ETIMEDOUT); + + + /* Channel is connected, start tests */ + igt_assert_eq(res, sizeof(buf)); + + /* Test reads on the end of address space */ + address = lseek(fd, 0, SEEK_END); + igt_assert_eq(address, 1 << 20); + res = read(fd, &buf, sizeof(buf)); + igt_assert_eq(res, 0); + + address = lseek(fd, 1, SEEK_CUR); + igt_assert_eq(address, -1); + igt_assert_eq(errno, EINVAL); + + address = lseek(fd, -8, SEEK_END); + res = read(fd, bigbuf, sizeof(bigbuf)); + igt_assert_eq(res, 8); + + /* Test reading more than 16 bytes at once */ + address = lseek(fd, 0, SEEK_SET); + res = read(fd, bigbuf, sizeof(bigbuf)); + igt_assert_eq(res, sizeof(bigbuf)); +} + +static void for_each_dp_aux(DIR *dir) +{ + int count = 0; + struct dirent *dirent; + + if (!dir) + return; + + rewinddir(dir); + while ((dirent = readdir(dir))) { + if (dirent->d_name[0] == '.') + continue; + + count++; + igt_subtest(dirent->d_name) + drm_dp_aux_test(dirent->d_name); + } + + closedir(dir); +} + +igt_main +{ + struct stat st; + DIR *dir = NULL; + + igt_fixture { + int count = 0; + struct dirent *dirent; + + igt_require(stat(DRM_DP_AUX_SYSFS_PATH, &st) == 0); + igt_require(S_ISDIR(st.st_mode)); + + dir = opendir(DRM_DP_AUX_SYSFS_PATH); + igt_require(dir); + + while ((dirent = readdir(dir))) { + if (dirent->d_name[0] != '.') + count++; + } + + igt_require(count > 0); + } + + for_each_dp_aux(dir); +}