diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-03-24 20:52:44 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-03-24 21:35:25 +0000 |
commit | e08ed8a272fda96b8f7224985177f313c3b2ddf6 (patch) | |
tree | 5fdba2e2cade4db9f64582e6414c3372a5681180 /tests/kms_pipe_crc_basic.c | |
parent | 58de785468782f29e6eb1d32d47b55b3d234dfcf (diff) |
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 <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/kms_pipe_crc_basic.c')
-rw-r--r-- | tests/kms_pipe_crc_basic.c | 37 |
1 files changed, 7 insertions, 30 deletions
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 <errno.h> #include <stdbool.h> #include <stdio.h> @@ -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 |