public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Marius Vlad <marius.c.vlad@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 3/3] tests/kms_sysfs_edid_timing: Convert sh script to C version.
Date: Thu, 20 Oct 2016 22:36:49 +0300	[thread overview]
Message-ID: <20161020193649.11701-4-marius.c.vlad@intel.com> (raw)
In-Reply-To: <20161020193649.11701-1-marius.c.vlad@intel.com>

While at it, make available time macros to other users.

Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
---
 benchmarks/gem_syslatency.c   |  4 ---
 lib/igt_core.c                |  3 --
 lib/igt_core.h                |  3 ++
 tests/Makefile.sources        |  2 +-
 tests/drv_hangman.c           |  1 -
 tests/gem_wait.c              |  4 ---
 tests/kms_flip.c              |  3 --
 tests/kms_sysfs_edid_timing   | 25 -------------
 tests/kms_sysfs_edid_timing.c | 82 +++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 86 insertions(+), 41 deletions(-)
 delete mode 100755 tests/kms_sysfs_edid_timing
 create mode 100644 tests/kms_sysfs_edid_timing.c

diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 6cad3a0..83bfac7 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -133,10 +133,6 @@ static void *gem_busyspin(void *arg)
 	return NULL;
 }
 
-#define MSEC_PER_SEC (1000)
-#define USEC_PER_SEC (1000 * MSEC_PER_SEC)
-#define NSEC_PER_SEC (1000 * USEC_PER_SEC)
-
 static double elapsed(const struct timespec *a, const struct timespec *b)
 {
 	return 1e9*(b->tv_sec - a->tv_sec) + (b->tv_nsec - a ->tv_nsec);
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 9cd5f98..f64c809 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -398,9 +398,6 @@ error:
 	return -errno;
 }
 
-#define MSEC_PER_SEC (1000)
-#define USEC_PER_SEC (1000*MSEC_PER_SEC)
-#define NSEC_PER_SEC (1000*USEC_PER_SEC)
 uint64_t igt_nsec_elapsed(struct timespec *start)
 {
 	struct timespec now;
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 03be757..a45e334 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -847,6 +847,9 @@ extern enum igt_log_level igt_log_level;
 void igt_set_timeout(unsigned int seconds,
 		     const char *op);
 
+#define MSEC_PER_SEC (1000)
+#define USEC_PER_SEC (1000*MSEC_PER_SEC)
+#define NSEC_PER_SEC (1000*USEC_PER_SEC)
 /**
  * igt_nsec_elapsed:
  * @start: measure from this point in time
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c35ea11..969ef0b 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -210,6 +210,7 @@ TESTS_progs = \
 	kms_mmap_write_crc \
 	kms_pwrite_crc \
 	kms_sink_crc_basic \
+	kms_sysfs_edid_timing \
 	prime_udl \
 	drv_module_reload_basic \
 	$(NULL)
@@ -222,7 +223,6 @@ TESTS_scripts_M = \
 TESTS_scripts = \
 	debugfs_emon_crash \
 	drv_debugfs_reader \
-	kms_sysfs_edid_timing \
 	sysfs_l3_parity \
 	test_rte_check \
 	tools_test \
diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
index 953a4c6..19d809c 100644
--- a/tests/drv_hangman.c
+++ b/tests/drv_hangman.c
@@ -282,7 +282,6 @@ static void test_error_state_capture(unsigned ring_id,
  * case and it takes a lot more time to wrap, so the acthd can potentially keep
  * increasing for a long time
  */
-#define NSEC_PER_SEC	1000000000LL
 static void hangcheck_unterminated(void)
 {
 	int fd;
diff --git a/tests/gem_wait.c b/tests/gem_wait.c
index b4127de..db04958 100644
--- a/tests/gem_wait.c
+++ b/tests/gem_wait.c
@@ -83,10 +83,6 @@ static void sigiter(int sig, siginfo_t *info, void *arg)
 	__sync_synchronize();
 }
 
-#define MSEC_PER_SEC (1000)
-#define USEC_PER_SEC (1000 * MSEC_PER_SEC)
-#define NSEC_PER_SEC (1000 * USEC_PER_SEC)
-
 #define BUSY 1
 #define HANG 2
 static void basic(int fd, unsigned engine, unsigned flags)
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 7646aaf..842bc3a 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -83,9 +83,6 @@
 #define DRM_CAP_TIMESTAMP_MONOTONIC 6
 #endif
 
-#define USEC_PER_SEC 1000000L
-#define NSEC_PER_SEC 1000000000L
-
 drmModeRes *resources;
 int drm_fd;
 static drm_intel_bufmgr *bufmgr;
diff --git a/tests/kms_sysfs_edid_timing b/tests/kms_sysfs_edid_timing
deleted file mode 100755
index 46ea540..0000000
--- a/tests/kms_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 $IGT_EXIT_FAILURE
-fi
-
-exit $IGT_EXIT_SUCCESS
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
new file mode 100644
index 0000000..8de4b78
--- /dev/null
+++ b/tests/kms_sysfs_edid_timing.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2016 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 "igt.h"
+#include "igt_debugfs.h"
+#include "igt_sysfs.h"
+#include "igt_core.h"
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <time.h>
+
+#define MSEC_PER_SEC (1000)
+#define USEC_PER_SEC (1000*MSEC_PER_SEC)
+#define NSEC_PER_SEC (1000*USEC_PER_SEC)
+
+IGT_TEST_DESCRIPTION("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");
+
+igt_simple_main
+{
+	int dir = igt_sysfs_open(-1, NULL);
+	DIR *dirp = fdopendir(dir);
+	struct dirent *de;
+
+	int i, fd = 0;
+	int fds[32];
+	uint64_t elapsed;
+
+	struct stat st;
+	struct timespec start = {};
+
+	memset(fds, -1, sizeof(fds));
+	while ((de = readdir(dirp))) {
+
+		if (*de->d_name == '.')
+			continue;
+
+		if (fstatat(dir, de->d_name, &st, 0))
+			continue;
+
+		if (S_ISDIR(st.st_mode) &&
+		    strncmp(de->d_name, "card0-", 6) == 0) {
+			int dfd = openat(dir, de->d_name, O_RDONLY);
+			igt_assert(dfd > 0);
+			fds[fd++] = dfd;
+		}
+	}
+	closedir(dirp);
+
+	elapsed = igt_nsec_elapsed(&start);
+	for (i = 0; i < fd - 1; i++) {
+		igt_assert(igt_sysfs_get(fds[i], "status") != NULL);
+		close(fds[i]);
+	}
+	elapsed = igt_nsec_elapsed(&start);
+
+	igt_fail_on(elapsed > 600 * USEC_PER_SEC);
+}
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-10-20 19:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 19:36 [PATCH i-g-t 0/3] Convert sh scripts to C variants Marius Vlad
2016-10-20 19:36 ` [PATCH i-g-t 1/3] lib/{igt_sysfs, igt_aux}: Make available to other users kick_fbcon() (unbind_fbcon()), and added helpers to igt_aux Marius Vlad
2016-10-20 20:09   ` Chris Wilson
2016-10-24 18:08     ` Marius Vlad
2016-10-24  8:40   ` Daniel Vetter
2016-10-26 21:02     ` Marius Vlad
2016-10-27  6:40       ` Daniel Vetter
2016-10-20 19:36 ` [PATCH i-g-t 2/3] tests/drv_module_reload_basic: Convert sh script to C version Marius Vlad
2016-10-20 19:52   ` Chris Wilson
2016-10-24 18:05     ` Marius Vlad
2016-10-24 20:34       ` Chris Wilson
2016-10-21  9:39   ` Petri Latvala
2016-10-24 18:06     ` Marius Vlad
2016-10-20 19:36 ` Marius Vlad [this message]
2016-10-20 19:58   ` [PATCH i-g-t 3/3] tests/kms_sysfs_edid_timing: " Chris Wilson
2016-10-20 21:00 ` [PATCH i-g-t 0/3] Convert sh scripts to C variants Jani Nikula
2016-10-21  7:38   ` Joonas Lahtinen
2016-10-24  8:46     ` Daniel Vetter
2016-10-24  8:49       ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161020193649.11701-4-marius.c.vlad@intel.com \
    --to=marius.c.vlad@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox