From e08ed8a272fda96b8f7224985177f313c3b2ddf6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 24 Mar 2017 20:52:44 +0000 Subject: lib/debugfs: Phase out igt_debugfs_fopen() Wrapping fdopen() proved dangerous, the underlying fd is not refcounted, and we must close it in the library or else we easily leak and exhaust all fd. Since we can't provide igt_debugfs_fopen(), move the burden onto the caller for those that require a stream FILE*. Signed-off-by: Chris Wilson --- tests/kms_pipe_crc_basic.c | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'tests/kms_pipe_crc_basic.c') diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c index f3c58390..a6996d43 100644 --- a/tests/kms_pipe_crc_basic.c +++ b/tests/kms_pipe_crc_basic.c @@ -23,6 +23,7 @@ */ #include "igt.h" +#include "igt_sysfs.h" #include #include #include @@ -45,42 +46,18 @@ static struct { static void test_bad_command(data_t *data, const char *cmd) { - FILE *ctl; - size_t written; + int dir = igt_debugfs_dir(data->drm_fd); - ctl = igt_debugfs_fopen(data->drm_fd, "i915_display_crc_ctl", "r+"); - igt_require(ctl); - - written = fwrite(cmd, 1, strlen(cmd), ctl); - fflush(ctl); - igt_assert_eq(written, strlen(cmd)); - igt_assert(ferror(ctl)); - igt_assert_eq(errno, EINVAL); - - fclose(ctl); + igt_require(igt_sysfs_set(dir, "i915_display_crc_ctl", cmd)); + close(dir); } static void test_bad_source(data_t *data) { - FILE *f; - size_t written; - const char *source = "foo"; - - f = igt_debugfs_fopen(data->drm_fd, "crtc-0/crc/control", "w"); - if (!f) { - test_bad_command(data, "pipe A foo"); - return; - } - - written = fwrite(source, 1, strlen(source), f); - fflush(f); - igt_assert_eq(written, strlen(source)); - igt_assert(!ferror(f)); - fclose(f); + int dir = igt_debugfs_dir(data->drm_fd); - f = igt_debugfs_fopen(data->drm_fd, "crtc-0/crc/data", "w"); - igt_assert(!f); - igt_assert_eq(errno, EINVAL); + igt_require(igt_sysfs_set(dir, "crtc-0/crc/control", "foo")); + close(dir); } #define N_CRCS 3 -- cgit v1.2.3