From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 3/3] lib/igt_kms: Remove fragile display_info debugfs parsing
Date: Fri, 8 Nov 2019 17:57:04 +0200 [thread overview]
Message-ID: <20191108155704.31802-3-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20191108155704.31802-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Relying on the specific layout of the display_info debugfs
file is fragile. Any change in the file layout will likely
result in test failure. Let's just get rid of it.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_kms.c | 141 --------------------------------------------------
lib/igt_kms.h | 1 -
2 files changed, 142 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e9b80b9bcb81..7095d8252262 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1520,147 +1520,6 @@ void kmstest_wait_for_pageflip(int fd)
igt_assert(drmHandleEvent(fd, &evctx) == 0);
}
-static void get_plane(char *str, int type, struct kmstest_plane *plane)
-{
- int ret;
- char buf[256];
-
- plane->type = type;
- ret = sscanf(str + 12, "%d%*c %*s %[^n]s",
- &plane->id,
- buf);
- igt_assert_eq(ret, 2);
-
- ret = sscanf(buf + 9, "%4d%*c%4d%*c", &plane->pos_x, &plane->pos_y);
- igt_assert_eq(ret, 2);
-
- ret = sscanf(buf + 30, "%4d%*c%4d%*c", &plane->width, &plane->height);
- igt_assert_eq(ret, 2);
-}
-
-static int parse_planes(FILE *fid, struct kmstest_plane *planes)
-{
- char tmp[256];
- int n_planes;
-
- n_planes = 0;
- while (fgets(tmp, 256, fid) != NULL) {
- if (strstr(tmp, "type=PRI") != NULL) {
- if (planes) {
- get_plane(tmp, DRM_PLANE_TYPE_PRIMARY, &planes[n_planes]);
- planes[n_planes].index = n_planes;
- }
- n_planes++;
- } else if (strstr(tmp, "type=OVL") != NULL) {
- if (planes) {
- get_plane(tmp, DRM_PLANE_TYPE_OVERLAY, &planes[n_planes]);
- planes[n_planes].index = n_planes;
- }
- n_planes++;
- } else if (strstr(tmp, "type=CUR") != NULL) {
- if (planes) {
- get_plane(tmp, DRM_PLANE_TYPE_CURSOR, &planes[n_planes]);
- planes[n_planes].index = n_planes;
- }
- n_planes++;
- break;
- }
- }
-
- return n_planes;
-}
-
-static void parse_crtc(char *info, struct kmstest_crtc *crtc)
-{
- char buf[256];
- int ret;
- char pipe;
-
- ret = sscanf(info + 4, "%d%*c %*s %c%*c %*s %s%*c",
- &crtc->id, &pipe, buf);
- igt_assert_eq(ret, 3);
-
- crtc->pipe = kmstest_pipe_to_index(pipe);
- igt_assert(crtc->pipe >= 0);
-
- ret = sscanf(buf + 6, "%d%*c%d%*c",
- &crtc->width, &crtc->height);
- igt_assert_eq(ret, 2);
-}
-
-static void kmstest_get_crtc(int device, enum pipe pipe, struct kmstest_crtc *crtc)
-{
- char tmp[256];
- FILE *file;
- int ncrtc;
- int line;
- long int n;
- int fd;
-
- fd = igt_debugfs_open(device, "i915_display_info", O_RDONLY);
- file = fdopen(fd, "r");
- igt_skip_on(file == NULL);
-
- ncrtc = 0;
- line = 0;
- while (fgets(tmp, 256, file) != NULL) {
- if ((strstr(tmp, "CRTC") != NULL) && (line > 0)) {
- if (strstr(tmp, "active=yes") != NULL) {
- crtc->active = true;
- parse_crtc(tmp, crtc);
-
- n = ftell(file);
- crtc->n_planes = parse_planes(file, NULL);
- igt_assert_lt(0, crtc->n_planes);
- crtc->planes = calloc(crtc->n_planes, sizeof(*crtc->planes));
- igt_assert_f(crtc->planes, "Failed to allocate memory for %d planes\n", crtc->n_planes);
-
- fseek(file, n, SEEK_SET);
- parse_planes(file, crtc->planes);
-
- if (crtc->pipe != pipe) {
- free(crtc->planes);
- } else {
- ncrtc++;
- break;
- }
- }
- }
-
- line++;
- }
-
- fclose(file);
- close(fd);
-
- igt_assert(ncrtc == 1);
-}
-
-/**
- * igt_assert_plane_visible:
- * @fd: Opened file descriptor
- * @pipe: Display pipe
- * @visibility: Boolean parameter to test against the plane's current visibility state
- *
- * Asserts only if the plane's visibility state matches the status being passed by @visibility
- */
-void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility)
-{
- struct kmstest_crtc crtc;
- bool visible = true;
-
- kmstest_get_crtc(fd, pipe, &crtc);
-
- igt_assert(plane_index < crtc.n_planes);
-
- if (crtc.planes[plane_index].pos_x > crtc.width ||
- crtc.planes[plane_index].pos_y > crtc.height)
- visible = false;
-
- free(crtc.planes);
- igt_assert_eq(visible, visibility);
-}
-
/**
* kms_has_vblank:
* @fd: DRM fd
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 7193f9a50ea2..3f798392f8a0 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -228,7 +228,6 @@ void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
void kmstest_dumb_destroy(int fd, uint32_t handle);
void kmstest_wait_for_pageflip(int fd);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
-void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility);
bool kms_has_vblank(int fd);
--
2.23.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-11-08 15:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 15:57 [igt-dev] [PATCH i-g-t 1/3] tests/kms_plane_lowres: Nuke unused defines Ville Syrjala
2019-11-08 15:57 ` [igt-dev] [PATCH i-g-t 2/3] tests/kms_plane_lowres: Stop relying in debugfs display_info Ville Syrjala
2019-11-19 10:42 ` Kahola, Mika
2019-11-08 15:57 ` Ville Syrjala [this message]
2019-11-19 10:43 ` [igt-dev] [PATCH i-g-t 3/3] lib/igt_kms: Remove fragile display_info debugfs parsing Kahola, Mika
2019-11-08 16:29 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] tests/kms_plane_lowres: Nuke unused defines Patchwork
2019-11-10 8:19 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-11-19 10:35 ` [igt-dev] [PATCH i-g-t 1/3] " Kahola, Mika
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=20191108155704.31802-3-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@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