mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2026-08-22 22:02:57 +00:00
lib: add igt_debugfs_read()
A helpful function for when you want to read a whole debugfs file to a string and don't want to worry about opening and closing file descriptors and asserting buffer sizes. We've been using this already for kms_frontbuffer_tracking and kms_fbcon_fbt, so the only test with new code here is kms_fbc_crc. Also notice that for kms_fbc_crc we had to increase the buffer size since the file can sometimes be bigger than 64 bytes - depending on the reason why FBC is disabled. Of course, there are probably many other programs we can patch, but I'm not doing this now. v2: Add the macro to wrap sizeof() (Daniel). v3: Add documentation for the macro too (Daniel). Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
This commit is contained in:
+4
-14
@@ -215,14 +215,9 @@ static void fill_mmap_gtt(data_t *data, uint32_t handle, unsigned char color)
|
||||
|
||||
static bool fbc_enabled(data_t *data)
|
||||
{
|
||||
FILE *status;
|
||||
char str[64] = {};
|
||||
char str[128] = {};
|
||||
|
||||
status = igt_debugfs_fopen("i915_fbc_status", "r");
|
||||
igt_assert(status);
|
||||
|
||||
igt_assert(fread(str, 1, sizeof(str) - 1, status) > 0);
|
||||
fclose(status);
|
||||
igt_debugfs_read("i915_fbc_status", str);
|
||||
return strstr(str, "FBC enabled") != NULL;
|
||||
}
|
||||
|
||||
@@ -544,8 +539,7 @@ igt_main
|
||||
igt_skip_on_simulation();
|
||||
|
||||
igt_fixture {
|
||||
char buf[64];
|
||||
FILE *status;
|
||||
char buf[128];
|
||||
|
||||
data.drm_fd = drm_open_any_master();
|
||||
kmstest_set_vt_graphics_mode();
|
||||
@@ -554,11 +548,7 @@ igt_main
|
||||
|
||||
igt_require_pipe_crc();
|
||||
|
||||
status = igt_debugfs_fopen("i915_fbc_status", "r");
|
||||
igt_require_f(status, "No i915_fbc_status found\n");
|
||||
igt_assert_lt(0, fread(buf, 1, sizeof(buf), status));
|
||||
fclose(status);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
igt_debugfs_read("i915_fbc_status", buf);
|
||||
igt_require_f(!strstr(buf, "unsupported on this chipset"),
|
||||
"FBC not supported\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user