diff options
author | Thomas Wood <thomas.wood@intel.com> | 2015-09-23 16:52:24 +0100 |
---|---|---|
committer | Thomas Wood <thomas.wood@intel.com> | 2015-09-24 14:24:18 +0100 |
commit | 6c89204da77a721c9f6c2c77908ca9502a246df8 (patch) | |
tree | b189c79537dc5376639c94ae5cdade48c314963d /tests/gem_ppgtt.c | |
parent | 1ea96af776a853303240fe6ec414aeed3316c24b (diff) |
lib: add igt_debugfs_search
Add igt_debugfs_search to search each line in a debugfs file for a
specified substring.
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'tests/gem_ppgtt.c')
-rw-r--r-- | tests/gem_ppgtt.c | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/tests/gem_ppgtt.c b/tests/gem_ppgtt.c index f891411a..1cc69eda 100644 --- a/tests/gem_ppgtt.c +++ b/tests/gem_ppgtt.c @@ -266,37 +266,6 @@ static void flink_and_close(void) close(fd2); } -static bool grep_name(const char *fname, const char *match) -{ - int fd; - FILE *fh; - size_t n = 0; - char *line = NULL; - char *matched = NULL; - - fd = igt_debugfs_open(fname, O_RDONLY); - igt_assert(fd >= 0); - - fh = fdopen(fd, "r"); - igt_assert(fh); - - while (getline(&line, &n, fh) >= 0) { - matched = strstr(line, match); - if (line) { - free(line); - line = NULL; - } - if (matched) - break; - } - - if (line) - free(line); - fclose(fh); - - return matched != NULL; -} - static void flink_and_exit(void) { uint32_t fd, fd2; @@ -323,7 +292,7 @@ static void flink_and_exit(void) gem_sync(fd2, flinked_bo); /* Verify looking for string works OK. */ - matched = grep_name("i915_gem_gtt", match); + matched = igt_debugfs_search("i915_gem_gtt", match); igt_assert_eq(matched, true); gem_close(fd2, flinked_bo); @@ -338,7 +307,7 @@ retry: /* The flinked bo VMA should have been cleared now, so list of VMAs * in debugfs should not contain the one for the imported object. */ - matched = grep_name("i915_gem_gtt", match); + matched = igt_debugfs_search("i915_gem_gtt", match); if (matched && retry++ < retries) goto retry; |